aboutsummaryrefslogtreecommitdiff
path: root/loginutils/login.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2005-07-01 01:04:32 +0000
committerMike Frysinger <vapier@gentoo.org>2005-07-01 01:04:32 +0000
commit8deb686d2e07ab812887a1a43a00ce5035c2b590 (patch)
tree132237fb52e98c8d72570d7ee2728f3e299383de /loginutils/login.c
parenta87bb6080925177b0c09416a6b4e213bd9450042 (diff)
downloadbusybox-w32-8deb686d2e07ab812887a1a43a00ce5035c2b590.tar.gz
busybox-w32-8deb686d2e07ab812887a1a43a00ce5035c2b590.tar.bz2
busybox-w32-8deb686d2e07ab812887a1a43a00ce5035c2b590.zip
Patch by jonlar in Bug 312 to split the U_W_TMP feature into sep UTMP and WTMP options
Diffstat (limited to 'loginutils/login.c')
-rw-r--r--loginutils/login.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/loginutils/login.c b/loginutils/login.c
index 5186e2369..6632a7665 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -23,7 +23,7 @@
23#include <errno.h> 23#include <errno.h>
24#endif 24#endif
25 25
26#ifdef CONFIG_FEATURE_U_W_TMP 26#ifdef CONFIG_FEATURE_UTMP
27// import from utmp.c 27// import from utmp.c
28static void checkutmp(int picky); 28static void checkutmp(int picky);
29static void setutmp(const char *name, const char *line); 29static void setutmp(const char *name, const char *line);
@@ -121,7 +121,7 @@ extern int login_main(int argc, char **argv)
121 if ( !isatty ( 0 ) || !isatty ( 1 ) || !isatty ( 2 )) 121 if ( !isatty ( 0 ) || !isatty ( 1 ) || !isatty ( 2 ))
122 return EXIT_FAILURE; /* Must be a terminal */ 122 return EXIT_FAILURE; /* Must be a terminal */
123 123
124#ifdef CONFIG_FEATURE_U_W_TMP 124#ifdef CONFIG_FEATURE_UTMP
125 checkutmp ( !amroot ); 125 checkutmp ( !amroot );
126#endif 126#endif
127 127
@@ -133,13 +133,13 @@ extern int login_main(int argc, char **argv)
133 else 133 else
134 safe_strncpy ( tty, "UNKNOWN", sizeof( tty )); 134 safe_strncpy ( tty, "UNKNOWN", sizeof( tty ));
135 135
136#ifdef CONFIG_FEATURE_U_W_TMP 136#ifdef CONFIG_FEATURE_UTMP
137 if ( amroot ) 137 if ( amroot )
138 memset ( utent.ut_host, 0, sizeof utent.ut_host ); 138 memset ( utent.ut_host, 0, sizeof utent.ut_host );
139#endif 139#endif
140 140
141 if ( opt_host ) { 141 if ( opt_host ) {
142#ifdef CONFIG_FEATURE_U_W_TMP 142#ifdef CONFIG_FEATURE_UTMP
143 safe_strncpy ( utent.ut_host, opt_host, sizeof( utent. ut_host )); 143 safe_strncpy ( utent.ut_host, opt_host, sizeof( utent. ut_host ));
144#endif 144#endif
145 snprintf ( fromhost, sizeof( fromhost ) - 1, " on `%.100s' from `%.200s'", tty, opt_host ); 145 snprintf ( fromhost, sizeof( fromhost ) - 1, " on `%.100s' from `%.200s'", tty, opt_host );
@@ -221,7 +221,7 @@ auth_ok:
221 if ( check_nologin ( pw-> pw_uid == 0 )) 221 if ( check_nologin ( pw-> pw_uid == 0 ))
222 return EXIT_FAILURE; 222 return EXIT_FAILURE;
223 223
224#ifdef CONFIG_FEATURE_U_W_TMP 224#ifdef CONFIG_FEATURE_UTMP
225 setutmp ( username, tty ); 225 setutmp ( username, tty );
226#endif 226#endif
227 227
@@ -402,7 +402,7 @@ static void motd (void)
402} 402}
403 403
404 404
405#ifdef CONFIG_FEATURE_U_W_TMP 405#ifdef CONFIG_FEATURE_UTMP
406// vv Taken from tinylogin utmp.c vv 406// vv Taken from tinylogin utmp.c vv
407 407
408#define NO_UTENT \ 408#define NO_UTENT \
@@ -480,9 +480,11 @@ static void setutmp(const char *name, const char *line)
480 setutent(); 480 setutent();
481 pututline(&utent); 481 pututline(&utent);
482 endutent(); 482 endutent();
483#ifdef CONFIG_FEATURE_WTMP
483 if (access(_PATH_WTMP, R_OK|W_OK) == -1) { 484 if (access(_PATH_WTMP, R_OK|W_OK) == -1) {
484 close(creat(_PATH_WTMP, 0664)); 485 close(creat(_PATH_WTMP, 0664));
485 } 486 }
486 updwtmp(_PATH_WTMP, &utent); 487 updwtmp(_PATH_WTMP, &utent);
488#endif
487} 489}
488#endif /* CONFIG_FEATURE_U_W_TMP */ 490#endif /* CONFIG_FEATURE_UTMP */