Skip to content

Commit 0d08fbc

Browse files
!nshlib: Remove fixed login; require FSUTILS_PASSWD
Remove CONFIG_NSH_LOGIN_FIXED and CONFIG_NSH_LOGIN_PASSWORD. Console and telnet login now depend on CONFIG_FSUTILS_PASSWD and verify credentials against the passwd file (PBKDF2-HMAC-SHA256). Signed-off-by: Abhishek Mishra <mishra.abhishek2808@gmail.com>
1 parent e807938 commit 0d08fbc

5 files changed

Lines changed: 9 additions & 32 deletions

File tree

nshlib/Kconfig

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,32 +1230,30 @@ config NSH_LOGIN
12301230
config NSH_CONSOLE_LOGIN
12311231
bool "Console Login"
12321232
default n
1233+
depends on FSUTILS_PASSWD
12331234
select NSH_LOGIN
12341235
---help---
12351236
If defined, then the console user will be required to provide a
1236-
username and password to start the NSH shell.
1237+
username and password to start the NSH shell. Requires
1238+
CONFIG_FSUTILS_PASSWD so credentials are verified against the
1239+
encrypted password file (for example ROMFS /etc/passwd).
12371240

12381241
config NSH_TELNET_LOGIN
12391242
bool "Telnet Login"
12401243
default n
1241-
depends on NSH_TELNET
1244+
depends on NSH_TELNET && FSUTILS_PASSWD
12421245
select NSH_LOGIN
12431246
---help---
12441247
If defined, then the Telnet user will be required to provide a
1245-
username and password to start the NSH shell.
1248+
username and password to start the NSH shell. Requires
1249+
CONFIG_FSUTILS_PASSWD so credentials are verified against the
1250+
encrypted password file (for example ROMFS /etc/passwd).
12461251

12471252
if NSH_LOGIN
12481253

12491254
choice
12501255
prompt "Verification method"
1251-
default NSH_LOGIN_PASSWD if FSUTILS_PASSWD
1252-
default NSH_LOGIN_FIXED if !FSUTILS_PASSWD
1253-
1254-
config NSH_LOGIN_FIXED
1255-
bool "Fixed username/password"
1256-
---help---
1257-
Verify user credentials by matching to fixed username and password
1258-
strings
1256+
default NSH_LOGIN_PASSWD
12591257

12601258
config NSH_LOGIN_PLATFORM
12611259
bool "Platform username/password"
@@ -1292,16 +1290,6 @@ config NSH_LOGIN_USERNAME
12921290
---help---
12931291
Login user name. Default: "root"
12941292

1295-
config NSH_LOGIN_PASSWORD
1296-
string "Login password"
1297-
depends on NSH_LOGIN_FIXED
1298-
---help---
1299-
The plaintext login password used when fixed username/password
1300-
verification is selected (CONFIG_NSH_LOGIN_FIXED). There is no
1301-
default; set CONFIG_NSH_LOGIN_PASSWORD in the board defconfig,
1302-
via menuconfig, or enter it when prompted during an interactive
1303-
build.
1304-
13051293
config NSH_LOGIN_FAILDELAY
13061294
int "Login failure delay"
13071295
default 0

nshlib/nsh.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,6 @@
267267
* options may be specified:
268268
*
269269
* CONFIG_NSH_LOGIN_USERNAME - Login user name. Default: "root"
270-
* CONFIG_NSH_LOGIN_PASSWORD - Login password (required when using fixed
271-
* credentials; no default is provided).
272270
* CONFIG_NSH_LOGIN_FAILCOUNT - Number of login retry attempts.
273271
* Default 3.
274272
*/

nshlib/nsh_identity.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,6 @@ static bool nsh_verify_credentials(FAR const char *username,
165165
return PASSWORD_VERIFY_MATCH(passwd_verify(username, password));
166166
#elif defined(CONFIG_NSH_LOGIN_PLATFORM)
167167
return PASSWORD_VERIFY_MATCH(platform_user_verify(username, password));
168-
#elif defined(CONFIG_NSH_LOGIN_FIXED)
169-
return strcmp(password, CONFIG_NSH_LOGIN_PASSWORD) == 0 &&
170-
strcmp(username, CONFIG_NSH_LOGIN_USERNAME) == 0;
171168
#else
172169
UNUSED(username);
173170
UNUSED(password);

nshlib/nsh_login.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,6 @@ int nsh_login(FAR struct console_stdio_s *pstate)
243243
#endif
244244
if (PASSWORD_VERIFY_MATCH(ret))
245245

246-
#elif defined(CONFIG_NSH_LOGIN_FIXED)
247-
if (strcmp(password, CONFIG_NSH_LOGIN_PASSWORD) == 0 &&
248-
strcmp(username, CONFIG_NSH_LOGIN_USERNAME) == 0)
249246
#else
250247
# error No user verification method selected
251248
#endif

nshlib/nsh_telnetlogin.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,9 +248,6 @@ int nsh_telnetlogin(FAR struct console_stdio_s *pstate)
248248
if (PASSWORD_VERIFY_MATCH(platform_user_verify(username,
249249
password)))
250250
# endif
251-
#elif defined(CONFIG_NSH_LOGIN_FIXED)
252-
if (strcmp(password, CONFIG_NSH_LOGIN_PASSWORD) == 0 &&
253-
strcmp(username, CONFIG_NSH_LOGIN_USERNAME) == 0)
254251
#else
255252
# error No user verification method selected
256253
#endif

0 commit comments

Comments
 (0)