aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-09-08 17:25:04 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-09-08 17:25:04 +0000
commit1a0604a37251c07fe45efd2cfc3d189faad739ce (patch)
tree818a4ed8752c02f54f5beaa09ebea9c8d3fbd7bc
parent3a0dceb3d000e9f45a216b8ef5ce61cc3c1d0342 (diff)
downloadbusybox-w32-1a0604a37251c07fe45efd2cfc3d189faad739ce.tar.gz
busybox-w32-1a0604a37251c07fe45efd2cfc3d189faad739ce.tar.bz2
busybox-w32-1a0604a37251c07fe45efd2cfc3d189faad739ce.zip
login: previous commit comment was wrong :)
That commit added login script support. Now _this commit_ is a style fix. Sorry.... git-svn-id: svn://busybox.net/trunk/busybox@16073 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r--loginutils/login.c264
1 files changed, 133 insertions, 131 deletions
diff --git a/loginutils/login.c b/loginutils/login.c
index 39d980fa8..82be87eb3 100644
--- a/loginutils/login.c
+++ b/loginutils/login.c
@@ -35,31 +35,31 @@ static void setutmp(const char *name, const char *line);
35static struct utmp utent; 35static struct utmp utent;
36#endif 36#endif
37 37
38// login defines 38enum {
39#define TIMEOUT 60 39 TIMEOUT = 60,
40#define EMPTY_USERNAME_COUNT 10 40 EMPTY_USERNAME_COUNT = 10,
41#define USERNAME_SIZE 32 41 USERNAME_SIZE = 32,
42};
42 43
43 44static int check_nologin(int amroot);
44static int check_nologin ( int amroot );
45 45
46#if defined CONFIG_FEATURE_SECURETTY 46#if defined CONFIG_FEATURE_SECURETTY
47static int check_tty ( const char *tty ); 47static int check_tty(const char *tty);
48 48
49#else 49#else
50static inline int check_tty ( const char *tty ) { return 1; } 50static inline int check_tty(const char *tty) { return 1; }
51 51
52#endif 52#endif
53 53
54static int is_my_tty ( const char *tty ); 54static int is_my_tty(const char *tty);
55static int login_prompt ( char *buf_name ); 55static int login_prompt(char *buf_name);
56static void motd ( void ); 56static void motd(void);
57 57
58 58
59static void alarm_handler ( int sig ATTRIBUTE_UNUSED) 59static void alarm_handler(int sig ATTRIBUTE_UNUSED)
60{ 60{
61 fprintf (stderr, "\nLogin timed out after %d seconds.\n", TIMEOUT ); 61 fprintf(stderr, "\nLogin timed out after %d seconds.\n", TIMEOUT);
62 exit ( EXIT_SUCCESS ); 62 exit(EXIT_SUCCESS);
63} 63}
64 64
65 65
@@ -73,7 +73,7 @@ int login_main(int argc, char **argv)
73 int amroot; 73 int amroot;
74 int flag; 74 int flag;
75 int failed; 75 int failed;
76 int count=0; 76 int count = 0;
77 struct passwd *pw, pw_copy; 77 struct passwd *pw, pw_copy;
78#ifdef CONFIG_WHEEL_GROUP 78#ifdef CONFIG_WHEEL_GROUP
79 struct group *grp; 79 struct group *grp;
@@ -86,14 +86,14 @@ int login_main(int argc, char **argv)
86 security_context_t user_sid = NULL; 86 security_context_t user_sid = NULL;
87#endif 87#endif
88 88
89 username[0]=0; 89 username[0] = '\0';
90 amroot = ( getuid ( ) == 0 ); 90 amroot = (getuid() == 0);
91 signal ( SIGALRM, alarm_handler ); 91 signal(SIGALRM, alarm_handler);
92 alarm ( TIMEOUT ); 92 alarm(TIMEOUT);
93 alarmstarted = 1; 93 alarmstarted = 1;
94 94
95 while (( flag = getopt(argc, argv, "f:h:p")) != EOF ) { 95 while ((flag = getopt(argc, argv, "f:h:p")) != EOF) {
96 switch ( flag ) { 96 switch (flag) {
97 case 'p': 97 case 'p':
98 opt_preserve = 1; 98 opt_preserve = 1;
99 break; 99 break;
@@ -102,11 +102,11 @@ int login_main(int argc, char **argv)
102 * username must be a separate token 102 * username must be a separate token
103 * (-f root, *NOT* -froot). --marekm 103 * (-f root, *NOT* -froot). --marekm
104 */ 104 */
105 if ( optarg != argv[optind-1] ) 105 if (optarg != argv[optind-1])
106 bb_show_usage( ); 106 bb_show_usage();
107 107
108 if ( !amroot ) /* Auth bypass only if real UID is zero */ 108 if (!amroot) /* Auth bypass only if real UID is zero */
109 bb_error_msg_and_die ( "-f permission denied" ); 109 bb_error_msg_and_die("-f permission denied");
110 110
111 safe_strncpy(username, optarg, USERNAME_SIZE); 111 safe_strncpy(username, optarg, USERNAME_SIZE);
112 opt_fflag = 1; 112 opt_fflag = 1;
@@ -115,59 +115,60 @@ int login_main(int argc, char **argv)
115 opt_host = optarg; 115 opt_host = optarg;
116 break; 116 break;
117 default: 117 default:
118 bb_show_usage( ); 118 bb_show_usage();
119 } 119 }
120 } 120 }
121 121
122 if (optind < argc) // user from command line (getty) 122 if (optind < argc) /* user from command line (getty) */
123 safe_strncpy(username, argv[optind], USERNAME_SIZE); 123 safe_strncpy(username, argv[optind], USERNAME_SIZE);
124 124
125 if ( !isatty ( 0 ) || !isatty ( 1 ) || !isatty ( 2 )) 125 if (!isatty(0) || !isatty(1) || !isatty(2))
126 return EXIT_FAILURE; /* Must be a terminal */ 126 return EXIT_FAILURE; /* Must be a terminal */
127 127
128#ifdef CONFIG_FEATURE_UTMP 128#ifdef CONFIG_FEATURE_UTMP
129 checkutmp ( !amroot ); 129 checkutmp(!amroot);
130#endif 130#endif
131 131
132 tmp = ttyname ( 0 ); 132 tmp = ttyname(0);
133 if ( tmp && ( strncmp ( tmp, "/dev/", 5 ) == 0 )) 133 if (tmp && (strncmp(tmp, "/dev/", 5) == 0))
134 safe_strncpy ( tty, tmp + 5, sizeof( tty )); 134 safe_strncpy(tty, tmp + 5, sizeof(tty));
135 else if ( tmp && *tmp == '/' ) 135 else if (tmp && *tmp == '/')
136 safe_strncpy ( tty, tmp, sizeof( tty )); 136 safe_strncpy(tty, tmp, sizeof(tty));
137 else 137 else
138 safe_strncpy ( tty, "UNKNOWN", sizeof( tty )); 138 safe_strncpy(tty, "UNKNOWN", sizeof(tty));
139 139
140#ifdef CONFIG_FEATURE_UTMP 140#ifdef CONFIG_FEATURE_UTMP
141 if ( amroot ) 141 if (amroot)
142 memset ( utent.ut_host, 0, sizeof utent.ut_host ); 142 memset(utent.ut_host, 0, sizeof(utent.ut_host));
143#endif 143#endif
144 144
145 if ( opt_host ) { 145 if (opt_host) {
146#ifdef CONFIG_FEATURE_UTMP 146#ifdef CONFIG_FEATURE_UTMP
147 safe_strncpy ( utent.ut_host, opt_host, sizeof( utent. ut_host )); 147 safe_strncpy(utent.ut_host, opt_host, sizeof(utent.ut_host));
148#endif 148#endif
149 snprintf ( fromhost, sizeof( fromhost ) - 1, " on `%.100s' from `%.200s'", tty, opt_host ); 149 snprintf(fromhost, sizeof(fromhost)-1, " on `%.100s' from `%.200s'", tty, opt_host);
150 } 150 }
151 else 151 else
152 snprintf ( fromhost, sizeof( fromhost ) - 1, " on `%.100s'", tty ); 152 snprintf(fromhost, sizeof(fromhost)-1, " on `%.100s'", tty);
153 153
154 bb_setpgrp; 154 bb_setpgrp;
155 155
156 openlog ( "login", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH ); 156 openlog("login", LOG_PID | LOG_CONS | LOG_NOWAIT, LOG_AUTH);
157 157
158 while ( 1 ) { 158 while (1) {
159 failed = 0; 159 failed = 0;
160 160
161 if ( !username[0] ) 161 if (!username[0])
162 if(!login_prompt ( username )) 162 if (!login_prompt(username))
163 return EXIT_FAILURE; 163 return EXIT_FAILURE;
164 164
165 if ( !alarmstarted && ( TIMEOUT > 0 )) { 165 if (!alarmstarted && (TIMEOUT > 0)) {
166 alarm ( TIMEOUT ); 166 alarm(TIMEOUT);
167 alarmstarted = 1; 167 alarmstarted = 1;
168 } 168 }
169 169
170 if (!( pw = getpwnam ( username ))) { 170 pw = getpwnam(username);
171 if (!pw) {
171 pw_copy.pw_name = "UNKNOWN"; 172 pw_copy.pw_name = "UNKNOWN";
172 pw_copy.pw_passwd = "!"; 173 pw_copy.pw_passwd = "!";
173 opt_fflag = 0; 174 opt_fflag = 0;
@@ -177,93 +178,92 @@ int login_main(int argc, char **argv)
177 178
178 pw = &pw_copy; 179 pw = &pw_copy;
179 180
180 if (( pw-> pw_passwd [0] == '!' ) || ( pw-> pw_passwd[0] == '*' )) 181 if ((pw->pw_passwd[0] == '!') || (pw->pw_passwd[0] == '*'))
181 failed = 1; 182 failed = 1;
182 183
183 if ( opt_fflag ) { 184 if (opt_fflag) {
184 opt_fflag = 0; 185 opt_fflag = 0;
185 goto auth_ok; 186 goto auth_ok;
186 } 187 }
187 188
188 if (!failed && ( pw-> pw_uid == 0 ) && ( !check_tty ( tty ))) 189 if (!failed && (pw->pw_uid == 0) && (!check_tty(tty)))
189 failed = 1; 190 failed = 1;
190 191
191 /* Don't check the password if password entry is empty (!) */ 192 /* Don't check the password if password entry is empty (!) */
192 if ( !pw-> pw_passwd[0] ) 193 if (!pw->pw_passwd[0])
193 goto auth_ok; 194 goto auth_ok;
194 195
195 /* authorization takes place here */ 196 /* authorization takes place here */
196 if ( correct_password ( pw )) 197 if (correct_password(pw))
197 goto auth_ok; 198 goto auth_ok;
198 199
199 failed = 1; 200 failed = 1;
200 201
201auth_ok: 202auth_ok:
202 if ( !failed) 203 if (!failed)
203 break; 204 break;
204 205
205 bb_do_delay(FAIL_DELAY); 206 bb_do_delay(FAIL_DELAY);
206 puts("Login incorrect"); 207 puts("Login incorrect");
207 username[0] = 0; 208 username[0] = 0;
208 if ( ++count == 3 ) { 209 if (++count == 3) {
209 syslog ( LOG_WARNING, "invalid password for `%s'%s\n", pw->pw_name, fromhost); 210 syslog(LOG_WARNING, "invalid password for `%s'%s'\n", pw->pw_name, fromhost);
210 return EXIT_FAILURE; 211 return EXIT_FAILURE;
211 } 212 }
212 } 213 }
213 214
214 alarm ( 0 ); 215 alarm(0);
215 if ( check_nologin ( pw-> pw_uid == 0 )) 216 if (check_nologin(pw->pw_uid == 0))
216 return EXIT_FAILURE; 217 return EXIT_FAILURE;
217 218
218#ifdef CONFIG_FEATURE_UTMP 219#ifdef CONFIG_FEATURE_UTMP
219 setutmp ( username, tty ); 220 setutmp(username, tty);
220#endif 221#endif
221 222
222 if ( *tty != '/' ) 223 if (*tty != '/')
223 snprintf ( full_tty, sizeof( full_tty ) - 1, "/dev/%s", tty); 224 snprintf(full_tty, sizeof(full_tty)-1, "/dev/%s", tty);
224 else 225 else
225 safe_strncpy ( full_tty, tty, sizeof( full_tty ) - 1 ); 226 safe_strncpy(full_tty, tty, sizeof(full_tty)-1);
226 227
227#ifdef CONFIG_SELINUX 228#ifdef CONFIG_SELINUX
228 if (is_selinux_enabled()) 229 if (is_selinux_enabled()) {
229 {
230 security_context_t old_tty_sid, new_tty_sid; 230 security_context_t old_tty_sid, new_tty_sid;
231 231
232 if (get_default_context(username, NULL, &user_sid)) 232 if (get_default_context(username, NULL, &user_sid)) {
233 {
234 fprintf(stderr, "Unable to get SID for %s\n", username); 233 fprintf(stderr, "Unable to get SID for %s\n", username);
235 exit(1); 234 exit(1);
236 } 235 }
237 if (getfilecon(full_tty, &old_tty_sid) < 0) 236 if (getfilecon(full_tty, &old_tty_sid) < 0) {
238 { 237 fprintf(stderr, "getfilecon(%.100s) failed: "
239 fprintf(stderr, "getfilecon(%.100s) failed: %.100s\n", full_tty, strerror(errno)); 238 "%.100s\n", full_tty, strerror(errno));
240 return EXIT_FAILURE; 239 return EXIT_FAILURE;
241 } 240 }
242 if (security_compute_relabel(user_sid, old_tty_sid, SECCLASS_CHR_FILE, &new_tty_sid) != 0) 241 if (security_compute_relabel(user_sid, old_tty_sid, SECCLASS_CHR_FILE,
243 { 242 &new_tty_sid) != 0) {
244 fprintf(stderr, "security_change_sid(%.100s) failed: %.100s\n", full_tty, strerror(errno)); 243 fprintf(stderr, "security_change_sid(%.100s) failed: "
244 "%.100s\n", full_tty, strerror(errno));
245 return EXIT_FAILURE; 245 return EXIT_FAILURE;
246 } 246 }
247 if(setfilecon(full_tty, new_tty_sid) != 0) 247 if (setfilecon(full_tty, new_tty_sid) != 0) {
248 { 248 fprintf(stderr, "chsid(%.100s, %s) failed: "
249 fprintf(stderr, "chsid(%.100s, %s) failed: %.100s\n", full_tty, new_tty_sid, strerror(errno)); 249 "%.100s\n", full_tty, new_tty_sid, strerror(errno));
250 return EXIT_FAILURE; 250 return EXIT_FAILURE;
251 } 251 }
252 } 252 }
253#endif 253#endif
254 if ( !is_my_tty ( full_tty )) 254 if (!is_my_tty(full_tty))
255 syslog ( LOG_ERR, "unable to determine TTY name, got %s\n", full_tty ); 255 syslog(LOG_ERR, "unable to determine TTY name, got %s\n", full_tty);
256 256
257 /* Try these, but don't complain if they fail 257 /* Try these, but don't complain if they fail
258 * (for example when the root fs is read only) */ 258 * (for example when the root fs is read only) */
259 chown ( full_tty, pw-> pw_uid, pw-> pw_gid ); 259 chown(full_tty, pw->pw_uid, pw->pw_gid);
260 chmod ( full_tty, 0600 ); 260 chmod(full_tty, 0600);
261 261
262 if (ENABLE_LOGIN_SCRIPTS) { 262 if (ENABLE_LOGIN_SCRIPTS) {
263 char *script = getenv("LOGIN_PRE_SUID_SCRIPT"); 263 char *script = getenv("LOGIN_PRE_SUID_SCRIPT");
264 if (script) { 264 if (script) {
265 char *t_argv[2] = { script, NULL }; 265 char *t_argv[2] = { script, NULL };
266 switch(fork()) { 266 switch (fork()) {
267 case -1: break; 267 case -1: break;
268 case 0: /* child */ 268 case 0: /* child */
269 xchdir("/"); 269 xchdir("/");
@@ -280,99 +280,100 @@ auth_ok:
280 } 280 }
281 } 281 }
282 282
283 change_identity ( pw ); 283 change_identity(pw);
284 tmp = pw-> pw_shell; 284 tmp = pw->pw_shell;
285 if(!tmp || !*tmp) 285 if (!tmp || !*tmp)
286 tmp = DEFAULT_SHELL; 286 tmp = DEFAULT_SHELL;
287 setup_environment ( tmp, 1, !opt_preserve, pw ); 287 setup_environment(tmp, 1, !opt_preserve, pw);
288 288
289 motd ( ); 289 motd();
290 signal ( SIGALRM, SIG_DFL ); /* default alarm signal */ 290 signal(SIGALRM, SIG_DFL); /* default alarm signal */
291 291
292 if ( pw-> pw_uid == 0 ) 292 if (pw->pw_uid == 0)
293 syslog ( LOG_INFO, "root login %s\n", fromhost ); 293 syslog(LOG_INFO, "root login %s\n", fromhost);
294#ifdef CONFIG_SELINUX 294#ifdef CONFIG_SELINUX
295 /* well, a simple setexeccon() here would do the job as well, 295 /* well, a simple setexeccon() here would do the job as well,
296 * but let's play the game for now */ 296 * but let's play the game for now */
297 set_current_security_context(user_sid); 297 set_current_security_context(user_sid);
298#endif 298#endif
299 run_shell ( tmp, 1, 0, 0); /* exec the shell finally. */ 299 run_shell(tmp, 1, 0, 0); /* exec the shell finally. */
300 300
301 return EXIT_FAILURE; 301 return EXIT_FAILURE;
302} 302}
303 303
304 304
305 305static int login_prompt(char *buf_name)
306static int login_prompt ( char *buf_name )
307{ 306{
308 char buf [1024]; 307 char buf[1024];
309 char *sp, *ep; 308 char *sp, *ep;
310 int i; 309 int i;
311 310
312 for(i=0; i<EMPTY_USERNAME_COUNT; i++) { 311 for (i=0; i<EMPTY_USERNAME_COUNT; i++) {
313 print_login_prompt(); 312 print_login_prompt();
314 313
315 if ( !fgets ( buf, sizeof( buf ) - 1, stdin )) 314 if (!fgets(buf, sizeof(buf)-1, stdin))
316 return 0; 315 return 0;
317 316
318 if ( !strchr ( buf, '\n' )) 317 if (!strchr(buf, '\n'))
319 return 0; 318 return 0;
320 319
321 for ( sp = buf; isspace ( *sp ); sp++ ) { } 320 for (sp = buf; isspace(*sp); sp++) { }
322 for ( ep = sp; isgraph ( *ep ); ep++ ) { } 321 for (ep = sp; isgraph(*ep); ep++) { }
323 322
324 *ep = 0; 323 *ep = '\0';
325 safe_strncpy(buf_name, sp, USERNAME_SIZE); 324 safe_strncpy(buf_name, sp, USERNAME_SIZE);
326 if(buf_name[0]) 325 if (buf_name[0])
327 return 1; 326 return 1;
328 } 327 }
329 return 0; 328 return 0;
330} 329}
331 330
332 331
333static int check_nologin ( int amroot ) 332static int check_nologin(int amroot)
334{ 333{
335 if ( access ( bb_path_nologin_file, F_OK ) == 0 ) { 334 if (access(bb_path_nologin_file, F_OK) == 0) {
336 FILE *fp; 335 FILE *fp;
337 int c; 336 int c;
338 337
339 if (( fp = fopen ( bb_path_nologin_file, "r" ))) { 338 fp = fopen(bb_path_nologin_file, "r");
340 while (( c = getc ( fp )) != EOF ) 339 if (fp) {
341 putchar (( c == '\n' ) ? '\r' : c ); 340 while ((c = getc(fp)) != EOF)
341 putchar((c=='\n') ? '\r' : c);
342 342
343 fflush ( stdout ); 343 fflush(stdout);
344 fclose ( fp ); 344 fclose(fp);
345 } else { 345 } else {
346 puts ( "\r\nSystem closed for routine maintenance.\r" ); 346 puts("\r\nSystem closed for routine maintenance.\r");
347 } 347 }
348 if ( !amroot ) 348 if (!amroot)
349 return 1; 349 return 1;
350 350
351 puts ( "\r\n[Disconnect bypassed -- root login allowed.]\r" ); 351 puts("\r\n[Disconnect bypassed -- root login allowed.]\r");
352 } 352 }
353 return 0; 353 return 0;
354} 354}
355 355
356#ifdef CONFIG_FEATURE_SECURETTY 356#ifdef CONFIG_FEATURE_SECURETTY
357 357
358static int check_tty ( const char *tty ) 358static int check_tty(const char *tty)
359{ 359{
360 FILE *fp; 360 FILE *fp;
361 int i; 361 int i;
362 char buf[BUFSIZ]; 362 char buf[BUFSIZ];
363 363
364 if (( fp = fopen ( bb_path_securetty_file, "r" ))) { 364 fp = fopen(bb_path_securetty_file, "r");
365 while ( fgets ( buf, sizeof( buf ) - 1, fp )) { 365 if (fp) {
366 for ( i = strlen( buf ) - 1; i >= 0; --i ) { 366 while (fgets(buf, sizeof(buf)-1, fp)) {
367 if ( !isspace ( buf[i] )) 367 for(i = strlen(buf)-1; i>=0; --i) {
368 if (!isspace(buf[i]))
368 break; 369 break;
369 } 370 }
370 buf[++i] = '\0'; 371 buf[++i] = '\0';
371 if (( buf [0] == '\0' ) || ( buf [0] == '#' )) 372 if ((buf[0]=='\0') || (buf[0]=='#'))
372 continue; 373 continue;
373 374
374 if ( strcmp ( buf, tty ) == 0 ) { 375 if (strcmp(buf, tty)== 0) {
375 fclose ( fp ); 376 fclose(fp);
376 return 1; 377 return 1;
377 } 378 }
378 } 379 }
@@ -386,29 +387,30 @@ static int check_tty ( const char *tty )
386#endif 387#endif
387 388
388/* returns 1 if true */ 389/* returns 1 if true */
389static int is_my_tty ( const char *tty ) 390static int is_my_tty(const char *tty)
390{ 391{
391 struct stat by_name, by_fd; 392 struct stat by_name, by_fd;
392 393
393 if ( stat ( tty, &by_name ) || fstat ( 0, &by_fd )) 394 if (stat(tty, &by_name) || fstat(0, &by_fd))
394 return 0; 395 return 0;
395 396
396 if ( by_name. st_rdev != by_fd. st_rdev ) 397 if (by_name.st_rdev != by_fd.st_rdev)
397 return 0; 398 return 0;
398 else 399 else
399 return 1; 400 return 1;
400} 401}
401 402
402 403
403static void motd (void) 404static void motd(void)
404{ 405{
405 FILE *fp; 406 FILE *fp;
406 int c; 407 int c;
407 408
408 if (( fp = fopen ( bb_path_motd_file, "r" ))) { 409 fp = fopen(bb_path_motd_file, "r");
409 while (( c = getc ( fp )) != EOF ) 410 if (fp) {
410 putchar ( c ); 411 while ((c = getc(fp)) != EOF)
411 fclose ( fp ); 412 putchar(c);
413 fclose(fp);
412 } 414 }
413} 415}
414 416
@@ -466,13 +468,13 @@ static void checkutmp(int picky)
466 } 468 }
467 if (strncmp(line, "/dev/", 5) == 0) 469 if (strncmp(line, "/dev/", 5) == 0)
468 line += 5; 470 line += 5;
469 memset(&utent, 0, sizeof utent); 471 memset(&utent, 0, sizeof(utent));
470 utent.ut_type = LOGIN_PROCESS; 472 utent.ut_type = LOGIN_PROCESS;
471 utent.ut_pid = pid; 473 utent.ut_pid = pid;
472 strncpy(utent.ut_line, line, sizeof utent.ut_line); 474 strncpy(utent.ut_line, line, sizeof(utent.ut_line));
473 /* XXX - assumes /dev/tty?? */ 475 /* XXX - assumes /dev/tty?? */
474 strncpy(utent.ut_id, utent.ut_line + 3, sizeof utent.ut_id); 476 strncpy(utent.ut_id, utent.ut_line + 3, sizeof(utent.ut_id));
475 strncpy(utent.ut_user, "LOGIN", sizeof utent.ut_user); 477 strncpy(utent.ut_user, "LOGIN", sizeof(utent.ut_user));
476 t_tmp = (time_t)utent.ut_time; 478 t_tmp = (time_t)utent.ut_time;
477 time(&t_tmp); 479 time(&t_tmp);
478 } 480 }
@@ -490,7 +492,7 @@ static void setutmp(const char *name, const char *line ATTRIBUTE_UNUSED)
490 time_t t_tmp = (time_t)utent.ut_time; 492 time_t t_tmp = (time_t)utent.ut_time;
491 493
492 utent.ut_type = USER_PROCESS; 494 utent.ut_type = USER_PROCESS;
493 strncpy(utent.ut_user, name, sizeof utent.ut_user); 495 strncpy(utent.ut_user, name, sizeof(utent.ut_user));
494 time(&t_tmp); 496 time(&t_tmp);
495 /* other fields already filled in by checkutmp above */ 497 /* other fields already filled in by checkutmp above */
496 setutent(); 498 setutent();