diff options
-rw-r--r-- | loginutils/login.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/loginutils/login.c b/loginutils/login.c index 0157bace8..1b13fa0cc 100644 --- a/loginutils/login.c +++ b/loginutils/login.c | |||
@@ -235,13 +235,13 @@ int login_main(int argc, char **argv) | |||
235 | alarm(TIMEOUT); | 235 | alarm(TIMEOUT); |
236 | 236 | ||
237 | opt = bb_getopt_ulflags(argc, argv, "f:h:p", &opt_user, &opt_host); | 237 | opt = bb_getopt_ulflags(argc, argv, "f:h:p", &opt_user, &opt_host); |
238 | |||
239 | if (opt & LOGIN_OPT_f) { | 238 | if (opt & LOGIN_OPT_f) { |
240 | if (!amroot) | 239 | if (!amroot) |
241 | bb_error_msg_and_die("-f is for root only"); | 240 | bb_error_msg_and_die("-f is for root only"); |
242 | safe_strncpy(username, opt_user, strlen(opt_user)); | 241 | safe_strncpy(username, opt_user, sizeof(username)); |
243 | } | 242 | } |
244 | username[USERNAME_SIZE] = 0; | 243 | if (optind < argc) /* user from command line (getty) */ |
244 | safe_strncpy(username, argv[optind], sizeof(username)); | ||
245 | 245 | ||
246 | /* Let's find out and memorize our tty */ | 246 | /* Let's find out and memorize our tty */ |
247 | if (!isatty(0) || !isatty(1) || !isatty(2)) | 247 | if (!isatty(0) || !isatty(1) || !isatty(2)) |