aboutsummaryrefslogtreecommitdiff
path: root/loginutils/login.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-03-15 08:29:22 +0000
committerEric Andersen <andersen@codepoet.org>2004-03-15 08:29:22 +0000
commitc7bda1ce659294d6e22c06e087f6f265983c7578 (patch)
tree4c6d2217f4d8306c59cf1096f8664e1cfd167213 /loginutils/login.c
parent8854004b41065b3d081af7f3df13a100b0c8bfbe (diff)
downloadbusybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.tar.gz
busybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.tar.bz2
busybox-w32-c7bda1ce659294d6e22c06e087f6f265983c7578.zip
Remove trailing whitespace. Update copyright to include 2004.
Diffstat (limited to 'loginutils/login.c')
-rw-r--r--loginutils/login.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/loginutils/login.c b/loginutils/login.c
index ee50a175a..99f66b53b 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -77,7 +77,7 @@ extern int login_main(int argc, char **argv)
77 int opt_preserve = 0; 77 int opt_preserve = 0;
78 int opt_fflag = 0; 78 int opt_fflag = 0;
79 char *opt_host = 0; 79 char *opt_host = 0;
80 int alarmstarted = 0; 80 int alarmstarted = 0;
81#ifdef CONFIG_SELINUX 81#ifdef CONFIG_SELINUX
82 int flask_enabled = is_flask_enabled(); 82 int flask_enabled = is_flask_enabled();
83 security_id_t sid = 0, old_tty_sid, new_tty_sid; 83 security_id_t sid = 0, old_tty_sid, new_tty_sid;
@@ -88,7 +88,7 @@ extern int login_main(int argc, char **argv)
88 signal ( SIGALRM, alarm_handler ); 88 signal ( SIGALRM, alarm_handler );
89 alarm ( TIMEOUT ); 89 alarm ( TIMEOUT );
90 alarmstarted = 1; 90 alarmstarted = 1;
91 91
92 while (( flag = getopt(argc, argv, "f:h:p")) != EOF ) { 92 while (( flag = getopt(argc, argv, "f:h:p")) != EOF ) {
93 switch ( flag ) { 93 switch ( flag ) {
94 case 'p': 94 case 'p':
@@ -104,7 +104,7 @@ extern int login_main(int argc, char **argv)
104 104
105 if ( !amroot ) /* Auth bypass only if real UID is zero */ 105 if ( !amroot ) /* Auth bypass only if real UID is zero */
106 bb_error_msg_and_die ( "-f permission denied" ); 106 bb_error_msg_and_die ( "-f permission denied" );
107 107
108 safe_strncpy(username, optarg, USERNAME_SIZE); 108 safe_strncpy(username, optarg, USERNAME_SIZE);
109 opt_fflag = 1; 109 opt_fflag = 1;
110 break; 110 break;
@@ -119,7 +119,7 @@ extern int login_main(int argc, char **argv)
119 if (optind < argc) // user from command line (getty) 119 if (optind < argc) // user from command line (getty)
120 safe_strncpy(username, argv[optind], USERNAME_SIZE); 120 safe_strncpy(username, argv[optind], USERNAME_SIZE);
121 121
122 if ( !isatty ( 0 ) || !isatty ( 1 ) || !isatty ( 2 )) 122 if ( !isatty ( 0 ) || !isatty ( 1 ) || !isatty ( 2 ))
123 return EXIT_FAILURE; /* Must be a terminal */ 123 return EXIT_FAILURE; /* Must be a terminal */
124 124
125#ifdef CONFIG_FEATURE_U_W_TMP 125#ifdef CONFIG_FEATURE_U_W_TMP
@@ -136,7 +136,7 @@ extern int login_main(int argc, char **argv)
136 if ( amroot ) 136 if ( amroot )
137 memset ( utent.ut_host, 0, sizeof utent.ut_host ); 137 memset ( utent.ut_host, 0, sizeof utent.ut_host );
138#endif 138#endif
139 139
140 if ( opt_host ) { 140 if ( opt_host ) {
141#ifdef CONFIG_FEATURE_U_W_TMP 141#ifdef CONFIG_FEATURE_U_W_TMP
142 safe_strncpy ( utent.ut_host, opt_host, sizeof( utent. ut_host )); 142 safe_strncpy ( utent.ut_host, opt_host, sizeof( utent. ut_host ));
@@ -145,7 +145,7 @@ extern int login_main(int argc, char **argv)
145 } 145 }
146 else 146 else
147 snprintf ( fromhost, sizeof( fromhost ) - 1, " on `%.100s'", tty ); 147 snprintf ( fromhost, sizeof( fromhost ) - 1, " on `%.100s'", tty );
148 148
149 setpgrp(); 149 setpgrp();
150 150
151 openlog ( "login", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH ); 151 openlog ( "login", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH );
@@ -167,14 +167,14 @@ extern int login_main(int argc, char **argv)
167 pw_copy.pw_passwd = "!"; 167 pw_copy.pw_passwd = "!";
168 opt_fflag = 0; 168 opt_fflag = 0;
169 failed = 1; 169 failed = 1;
170 } else 170 } else
171 pw_copy = *pw; 171 pw_copy = *pw;
172 172
173 pw = &pw_copy; 173 pw = &pw_copy;
174 174
175 if (( pw-> pw_passwd [0] == '!' ) || ( pw-> pw_passwd[0] == '*' )) 175 if (( pw-> pw_passwd [0] == '!' ) || ( pw-> pw_passwd[0] == '*' ))
176 failed = 1; 176 failed = 1;
177 177
178 if ( opt_fflag ) { 178 if ( opt_fflag ) {
179 opt_fflag = 0; 179 opt_fflag = 0;
180 goto auth_ok; 180 goto auth_ok;
@@ -192,14 +192,14 @@ extern int login_main(int argc, char **argv)
192 goto auth_ok; 192 goto auth_ok;
193 193
194 failed = 1; 194 failed = 1;
195 195
196auth_ok: 196auth_ok:
197 if ( !failed) 197 if ( !failed)
198 break; 198 break;
199 199
200 { // delay next try 200 { // delay next try
201 time_t start, now; 201 time_t start, now;
202 202
203 time ( &start ); 203 time ( &start );
204 now = start; 204 now = start;
205 while ( difftime ( now, start ) < FAIL_DELAY) { 205 while ( difftime ( now, start ) < FAIL_DELAY) {
@@ -215,7 +215,7 @@ auth_ok:
215 return EXIT_FAILURE; 215 return EXIT_FAILURE;
216 } 216 }
217 } 217 }
218 218
219 alarm ( 0 ); 219 alarm ( 0 );
220 if ( check_nologin ( pw-> pw_uid == 0 )) 220 if ( check_nologin ( pw-> pw_uid == 0 ))
221 return EXIT_FAILURE; 221 return EXIT_FAILURE;
@@ -253,15 +253,15 @@ auth_ok:
253 sid = 0; 253 sid = 0;
254#endif 254#endif
255 255
256 if ( *tty != '/' ) 256 if ( *tty != '/' )
257 snprintf ( full_tty, sizeof( full_tty ) - 1, "/dev/%s", tty); 257 snprintf ( full_tty, sizeof( full_tty ) - 1, "/dev/%s", tty);
258 else 258 else
259 safe_strncpy ( full_tty, tty, sizeof( full_tty ) - 1 ); 259 safe_strncpy ( full_tty, tty, sizeof( full_tty ) - 1 );
260 260
261 if ( !is_my_tty ( full_tty )) 261 if ( !is_my_tty ( full_tty ))
262 syslog ( LOG_ERR, "unable to determine TTY name, got %s\n", full_tty ); 262 syslog ( LOG_ERR, "unable to determine TTY name, got %s\n", full_tty );
263 263
264 /* Try these, but don't complain if they fail 264 /* Try these, but don't complain if they fail
265 * (for example when the root fs is read only) */ 265 * (for example when the root fs is read only) */
266 chown ( full_tty, pw-> pw_uid, pw-> pw_gid ); 266 chown ( full_tty, pw-> pw_uid, pw-> pw_gid );
267 chmod ( full_tty, 0600 ); 267 chmod ( full_tty, 0600 );
@@ -275,14 +275,14 @@ auth_ok:
275 motd ( ); 275 motd ( );
276 signal ( SIGALRM, SIG_DFL ); /* default alarm signal */ 276 signal ( SIGALRM, SIG_DFL ); /* default alarm signal */
277 277
278 if ( pw-> pw_uid == 0 ) 278 if ( pw-> pw_uid == 0 )
279 syslog ( LOG_INFO, "root login %s\n", fromhost ); 279 syslog ( LOG_INFO, "root login %s\n", fromhost );
280 run_shell ( tmp, 1, 0, 0 280 run_shell ( tmp, 1, 0, 0
281#ifdef CONFIG_SELINUX 281#ifdef CONFIG_SELINUX
282 , sid 282 , sid
283#endif 283#endif
284 ); /* exec the shell finally. */ 284 ); /* exec the shell finally. */
285 285
286 return EXIT_FAILURE; 286 return EXIT_FAILURE;
287} 287}
288 288
@@ -306,7 +306,7 @@ static int login_prompt ( char *buf_name )
306 for ( sp = buf; isspace ( *sp ); sp++ ) { } 306 for ( sp = buf; isspace ( *sp ); sp++ ) { }
307 for ( ep = sp; isgraph ( *ep ); ep++ ) { } 307 for ( ep = sp; isgraph ( *ep ); ep++ ) { }
308 308
309 *ep = 0; 309 *ep = 0;
310 safe_strncpy(buf_name, sp, USERNAME_SIZE); 310 safe_strncpy(buf_name, sp, USERNAME_SIZE);
311 if(buf_name[0]) 311 if(buf_name[0])
312 return 1; 312 return 1;
@@ -332,7 +332,7 @@ static int check_nologin ( int amroot )
332 } 332 }
333 if ( !amroot ) 333 if ( !amroot )
334 return 1; 334 return 1;
335 335
336 puts ( "\r\n[Disconnect bypassed -- root login allowed.]\r" ); 336 puts ( "\r\n[Disconnect bypassed -- root login allowed.]\r" );
337 } 337 }
338 return 0; 338 return 0;
@@ -377,7 +377,7 @@ static int is_my_tty ( const char *tty )
377 377
378 if ( stat ( tty, &by_name ) || fstat ( 0, &by_fd )) 378 if ( stat ( tty, &by_name ) || fstat ( 0, &by_fd ))
379 return 0; 379 return 0;
380 380
381 if ( by_name. st_rdev != by_fd. st_rdev ) 381 if ( by_name. st_rdev != by_fd. st_rdev )
382 return 0; 382 return 0;
383 else 383 else
@@ -391,8 +391,8 @@ static void motd ( )
391 register int c; 391 register int c;
392 392
393 if (( fp = fopen ( bb_path_motd_file, "r" ))) { 393 if (( fp = fopen ( bb_path_motd_file, "r" ))) {
394 while (( c = getc ( fp )) != EOF ) 394 while (( c = getc ( fp )) != EOF )
395 putchar ( c ); 395 putchar ( c );
396 fclose ( fp ); 396 fclose ( fp );
397 } 397 }
398} 398}