aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2009-02-02 00:15:57 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2009-02-02 00:15:57 +0000
commit512c8ae0537ad2ffcb70db03ca50b532781ae799 (patch)
tree3658be19324bd2f6c26eaa90a1369de77a4dacda
parent4eff8efa591ae4b91e2f453ec63b4ca36a17c256 (diff)
downloadbusybox-w32-512c8ae0537ad2ffcb70db03ca50b532781ae799.tar.gz
busybox-w32-512c8ae0537ad2ffcb70db03ca50b532781ae799.tar.bz2
busybox-w32-512c8ae0537ad2ffcb70db03ca50b532781ae799.zip
login: small simplification by Walter Harms. -10 bytes
-rw-r--r--loginutils/login.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/loginutils/login.c b/loginutils/login.c
index d9e9b532b..cdc38fbaf 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -284,7 +284,7 @@ int login_main(int argc UNUSED_PARAM, char **argv)
284 struct passwd *pw; 284 struct passwd *pw;
285 char *opt_host = opt_host; /* for compiler */ 285 char *opt_host = opt_host; /* for compiler */
286 char *opt_user = opt_user; /* for compiler */ 286 char *opt_user = opt_user; /* for compiler */
287 char full_tty[TTYNAME_SIZE]; 287 char *full_tty;
288 USE_SELINUX(security_context_t user_sid = NULL;) 288 USE_SELINUX(security_context_t user_sid = NULL;)
289 USE_FEATURE_UTMP(struct utmp utent;) 289 USE_FEATURE_UTMP(struct utmp utent;)
290#if ENABLE_PAM 290#if ENABLE_PAM
@@ -296,7 +296,6 @@ int login_main(int argc UNUSED_PARAM, char **argv)
296 char pwdbuf[256]; 296 char pwdbuf[256];
297#endif 297#endif
298 298
299 short_tty = full_tty;
300 username[0] = '\0'; 299 username[0] = '\0';
301 signal(SIGALRM, alarm_handler); 300 signal(SIGALRM, alarm_handler);
302 alarm(TIMEOUT); 301 alarm(TIMEOUT);
@@ -322,15 +321,14 @@ int login_main(int argc UNUSED_PARAM, char **argv)
322 safe_strncpy(username, argv[0], sizeof(username)); 321 safe_strncpy(username, argv[0], sizeof(username));
323 322
324 /* Let's find out and memorize our tty */ 323 /* Let's find out and memorize our tty */
325 if (!isatty(0) || !isatty(1) || !isatty(2)) 324 if (!isatty(STDIN_FILENO) || !isatty(STDOUT_FILENO) || !isatty(STDERR_FILENO))
326 return EXIT_FAILURE; /* Must be a terminal */ 325 return EXIT_FAILURE; /* Must be a terminal */
327 safe_strncpy(full_tty, "UNKNOWN", sizeof(full_tty)); 326 full_tty = xmalloc_ttyname(STDIN_FILENO);
328 tmp = xmalloc_ttyname(STDIN_FILENO); 327 if (!full_tty)
329 if (tmp) { 328 full_tty = xstrdup("UNKNOWN");
330 safe_strncpy(full_tty, tmp, sizeof(full_tty)); 329 short_tty = full_tty;
331 if (strncmp(full_tty, "/dev/", 5) == 0) 330 if (strncmp(full_tty, "/dev/", 5) == 0)
332 short_tty = full_tty + 5; 331 short_tty += 5;
333 }
334 332
335 read_or_build_utent(&utent, run_by_root); 333 read_or_build_utent(&utent, run_by_root);
336 334