aboutsummaryrefslogtreecommitdiff
path: root/release/picobsd/tinyware/login
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2012-09-01 14:45:15 +0000
committerEd Schouten <ed@FreeBSD.org>2012-09-01 14:45:15 +0000
commit902d9eafbf66c52f8513bc38f4d0c8063c0b8a03 (patch)
tree496a0b9a3b14c27d50e1ae3b28265ecf5c2023f2 /release/picobsd/tinyware/login
parentaeb99b567a54f0ce25c0cf33eb758f15add4580c (diff)
downloadsrc-902d9eafbf66c52f8513bc38f4d0c8063c0b8a03.tar.gz
src-902d9eafbf66c52f8513bc38f4d0c8063c0b8a03.zip
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.
Notes
Notes: svn path=/head/; revision=239991
Diffstat (limited to 'release/picobsd/tinyware/login')
-rw-r--r--release/picobsd/tinyware/login/pico-login.c14
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 78346238a8d8..e540ca861a51 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));
}