summaryrefslogtreecommitdiffstats
path: root/usr.bin/login
diff options
context:
space:
mode:
authorugen <ugen@FreeBSD.org>1994-11-30 15:40:09 +0000
committerugen <ugen@FreeBSD.org>1994-11-30 15:40:09 +0000
commit489bbb2313ab22a23fba385fab9ba8eb9b53cc46 (patch)
tree020b3fbf56618fdc4f9695d8f478e51a5e8ffc0b /usr.bin/login
parent14e675c028e22a6aff358d9db1fea6a7d87d3823 (diff)
downloadFreeBSD-src-489bbb2313ab22a23fba385fab9ba8eb9b53cc46.zip
FreeBSD-src-489bbb2313ab22a23fba385fab9ba8eb9b53cc46.tar.gz
Patch of password expired bug.
Now password changed for right user and no longer possible to skip password change. I hope it will be ok....
Diffstat (limited to 'usr.bin/login')
-rw-r--r--usr.bin/login/login.c37
1 files changed, 11 insertions, 26 deletions
diff --git a/usr.bin/login/login.c b/usr.bin/login/login.c
index a3b2683..be6946f 100644
--- a/usr.bin/login/login.c
+++ b/usr.bin/login/login.c
@@ -79,7 +79,6 @@ void checknologin __P((void));
void dolastlog __P((int));
void getloginname __P((void));
void motd __P((void));
-void change_passwd __P((void));
int rootterm __P((char *));
void sigint __P((int));
void sleepexit __P((int));
@@ -122,6 +121,7 @@ main(argc, argv)
struct timeval tp;
struct utmp utmp;
int ask, ch, cnt, fflag, hflag, pflag, quietlog, rootlogin, rval;
+ int changepass;
uid_t uid;
char *domain, *p, *ep, *salt, *ttyn;
char tbuf[MAXPATHLEN + 2], tname[sizeof(_PATH_TTY) + 10];
@@ -348,10 +348,11 @@ main(argc, argv)
if (pwd->pw_change || pwd->pw_expire)
(void)gettimeofday(&tp, (struct timezone *)NULL);
+ changepass=0;
if (pwd->pw_change)
if (tp.tv_sec >= pwd->pw_change) {
(void)printf("Sorry -- your password has expired.\n");
- change_passwd();
+ changepass=1;
} else if (pwd->pw_change - tp.tv_sec <
2 * DAYSPERWEEK * SECSPERDAY && !quietlog)
(void)printf("Warning: your password expires on %s",
@@ -471,8 +472,8 @@ main(argc, argv)
(void)strcpy(tbuf + 1, (p = strrchr(pwd->pw_shell, '/')) ?
p + 1 : pwd->pw_shell);
- if (setlogin(pwd->pw_name) < 0)
- syslog(LOG_ERR, "setlogin() failure: %m");
+ if (setlogin(pwd->pw_name) < 0)
+ syslog(LOG_ERR, "setlogin() failure: %m");
/* Discard permissions last so can't get killed and drop core. */
if (rootlogin)
@@ -480,6 +481,12 @@ main(argc, argv)
else
(void) setuid(pwd->pw_uid);
+ if (changepass) {
+ int res;
+ if ((res=system(_PATH_CHPASS)))
+ sleepexit(1);
+ }
+
execlp(pwd->pw_shell, tbuf, 0);
err(1, "%s", pwd->pw_shell);
}
@@ -657,26 +664,4 @@ sleepexit(eval)
exit(eval);
}
-void
-change_passwd()
-{
- int pid, status, w;
- register void (*istat)(), (*qstat)();
-
- if (( pid=fork() ) == 0)
- {
- execl( "/usr/bin/passwd", "passwd", NULL );
- fprintf( stderr, "ERROR: Can't execute passwd!\n" );
- sleepexit( 1 );
- }
-
- istat = signal( SIGINT, SIG_IGN );
- qstat = signal( SIGQUIT, SIG_IGN );
-
- while ((w = wait( &status )) != pid && w != -1)
- ;
-
- signal( SIGINT, istat );
- signal( SIGQUIT, qstat );
-}
OpenPOWER on IntegriCloud