diff options
author | ed <ed@FreeBSD.org> | 2012-09-01 14:45:15 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2012-09-01 14:45:15 +0000 |
commit | 02dcf28b5875df173bef8c14a9ddd3d3ce67c5d4 (patch) | |
tree | 496a0b9a3b14c27d50e1ae3b28265ecf5c2023f2 /release/picobsd | |
parent | a6edc1e4b7ca5750cf84fb6a6b048b796c0cc77f (diff) | |
download | FreeBSD-src-02dcf28b5875df173bef8c14a9ddd3d3ce67c5d4.zip FreeBSD-src-02dcf28b5875df173bef8c14a9ddd3d3ce67c5d4.tar.gz |
Rework all non-contributed files that use `struct timezone'.
This structure is not part of POSIX. According to POSIX, gettimeofday()
has the following prototype:
int gettimeofday(struct timeval *restrict tp, void *restrict tzp);
Also, POSIX states that gettimeofday() shall return 0 (as long as tzp is
not used). Remove dead error handling code. Also use NULL for a
nul-pointer instead of integer 0.
While there, change all pieces of code that only use tv_sec to use
time(3), as this provides less overhead.
Diffstat (limited to 'release/picobsd')
-rw-r--r-- | release/picobsd/tinyware/login/pico-login.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/release/picobsd/tinyware/login/pico-login.c b/release/picobsd/tinyware/login/pico-login.c index 7834623..e540ca8 100644 --- a/release/picobsd/tinyware/login/pico-login.c +++ b/release/picobsd/tinyware/login/pico-login.c @@ -150,12 +150,11 @@ main(argc, argv) extern char **environ; struct group *gr; struct stat st; - struct timeval tp; struct utmpx utmp; int rootok, retries, backoff; int ask, ch, cnt, fflag, hflag, pflag, quietlog, rootlogin, rval; int changepass; - time_t warntime; + time_t now, warntime; uid_t uid, euid; gid_t egid; char *p, *ttyn; @@ -430,8 +429,7 @@ main(argc, argv) if (!quietlog) quietlog = access(_PATH_HUSHLOGIN, F_OK) == 0; - if (pwd->pw_change || pwd->pw_expire) - (void)gettimeofday(&tp, (struct timezone *)NULL); + now = time(NULL); #define DEFAULT_WARN (2L * 7L * 86400L) /* Two weeks */ @@ -439,10 +437,10 @@ main(argc, argv) DEFAULT_WARN); if (pwd->pw_expire) { - if (tp.tv_sec >= pwd->pw_expire) { + if (now >= pwd->pw_expire) { refused("Sorry -- your account has expired", "EXPIRED", 1); - } else if (pwd->pw_expire - tp.tv_sec < warntime && !quietlog) + } else if (pwd->pw_expire - now < warntime && !quietlog) (void)printf("Warning: your account expires on %s", ctime(&pwd->pw_expire)); } @@ -452,12 +450,12 @@ main(argc, argv) changepass = 0; if (pwd->pw_change) { - if (tp.tv_sec >= pwd->pw_change) { + if (now >= pwd->pw_change) { (void)printf("Sorry -- your password has expired.\n"); changepass = 1; syslog(LOG_INFO, "%s Password expired - forcing change", pwd->pw_name); - } else if (pwd->pw_change - tp.tv_sec < warntime && !quietlog) + } else if (pwd->pw_change - now < warntime && !quietlog) (void)printf("Warning: your password expires on %s", ctime(&pwd->pw_change)); } |