* src/chage.c: expdays renamed to expdate. It is a date, even if
expressed in a number of days since Jan 1, 1970. * src/chage.c: Likewise: lastday renamed to lstchgdate. Also fix the --lastday documentation.
This commit is contained in:
parent
52238dd6a7
commit
304b0ec202
@ -1,6 +1,10 @@
|
|||||||
2009-04-06 Nicolas François <nicolas.francois@centraliens.net>
|
2009-04-06 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* src/chage.c: More strtol() replaced by getlong().
|
* src/chage.c: More strtol() replaced by getlong().
|
||||||
|
* src/chage.c: expdays renamed to expdate. It is a date, even if
|
||||||
|
expressed in a number of days since Jan 1, 1970.
|
||||||
|
* src/chage.c: Likewise: lastday renamed to lstchgdate. Also fix
|
||||||
|
the --lastday documentation.
|
||||||
|
|
||||||
2009-04-06 Nicolas François <nicolas.francois@centraliens.net>
|
2009-04-06 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
64
src/chage.c
64
src/chage.c
@ -80,10 +80,10 @@ static uid_t user_uid = -1;
|
|||||||
|
|
||||||
static long mindays;
|
static long mindays;
|
||||||
static long maxdays;
|
static long maxdays;
|
||||||
static long lastday;
|
static long lstchgdate;
|
||||||
static long warndays;
|
static long warndays;
|
||||||
static long inactdays;
|
static long inactdays;
|
||||||
static long expdays;
|
static long expdate;
|
||||||
|
|
||||||
#define EPOCH "1969-12-31"
|
#define EPOCH "1969-12-31"
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ static void usage (void)
|
|||||||
fputs (_("Usage: chage [options] [LOGIN]\n"
|
fputs (_("Usage: chage [options] [LOGIN]\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
" -d, --lastday LAST_DAY set last password change to LAST_DAY\n"
|
" -d, --lastday LAST_DAY set date of last password change to LAST_DAY\n"
|
||||||
" -E, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE\n"
|
" -E, --expiredate EXPIRE_DATE set account expiration date to EXPIRE_DATE\n"
|
||||||
" -h, --help display this help message and exit\n"
|
" -h, --help display this help message and exit\n"
|
||||||
" -I, --inactive INACTIVE set password inactive after expiration\n"
|
" -I, --inactive INACTIVE set password inactive after expiration\n"
|
||||||
@ -213,15 +213,15 @@ static int new_fields (void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
date_to_str (buf, sizeof buf, lastday * SCALE);
|
date_to_str (buf, sizeof buf, lstchgdate * SCALE);
|
||||||
|
|
||||||
change_field (buf, sizeof buf, _("Last Password Change (YYYY-MM-DD)"));
|
change_field (buf, sizeof buf, _("Last Password Change (YYYY-MM-DD)"));
|
||||||
|
|
||||||
if (strcmp (buf, EPOCH) == 0) {
|
if (strcmp (buf, EPOCH) == 0) {
|
||||||
lastday = -1;
|
lstchgdate = -1;
|
||||||
} else {
|
} else {
|
||||||
lastday = strtoday (buf);
|
lstchgdate = strtoday (buf);
|
||||||
if (lastday == -1) {
|
if (lstchgdate == -1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,16 +240,16 @@ static int new_fields (void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
date_to_str (buf, sizeof buf, expdays * SCALE);
|
date_to_str (buf, sizeof buf, expdate * SCALE);
|
||||||
|
|
||||||
change_field (buf, sizeof buf,
|
change_field (buf, sizeof buf,
|
||||||
_("Account Expiration Date (YYYY-MM-DD)"));
|
_("Account Expiration Date (YYYY-MM-DD)"));
|
||||||
|
|
||||||
if (strcmp (buf, EPOCH) == 0) {
|
if (strcmp (buf, EPOCH) == 0) {
|
||||||
expdays = -1;
|
expdate = -1;
|
||||||
} else {
|
} else {
|
||||||
expdays = strtoday (buf);
|
expdate = strtoday (buf);
|
||||||
if (expdays == -1) {
|
if (expdate == -1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -303,12 +303,12 @@ static void list_fields (void)
|
|||||||
* was last modified. The date is the number of days since 1/1/1970.
|
* was last modified. The date is the number of days since 1/1/1970.
|
||||||
*/
|
*/
|
||||||
(void) fputs (_("Last password change\t\t\t\t\t: "), stdout);
|
(void) fputs (_("Last password change\t\t\t\t\t: "), stdout);
|
||||||
if (lastday < 0) {
|
if (lstchgdate < 0) {
|
||||||
(void) puts (_("never"));
|
(void) puts (_("never"));
|
||||||
} else if (lastday == 0) {
|
} else if (lstchgdate == 0) {
|
||||||
(void) puts (_("password must be changed"));
|
(void) puts (_("password must be changed"));
|
||||||
} else {
|
} else {
|
||||||
changed = lastday * SCALE;
|
changed = lstchgdate * SCALE;
|
||||||
print_date ((time_t) changed);
|
print_date ((time_t) changed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,9 +317,9 @@ static void list_fields (void)
|
|||||||
* date plus the number of days the password is valid for.
|
* date plus the number of days the password is valid for.
|
||||||
*/
|
*/
|
||||||
(void) fputs (_("Password expires\t\t\t\t\t: "), stdout);
|
(void) fputs (_("Password expires\t\t\t\t\t: "), stdout);
|
||||||
if (lastday == 0) {
|
if (lstchgdate == 0) {
|
||||||
(void) puts (_("password must be changed"));
|
(void) puts (_("password must be changed"));
|
||||||
} else if ( (lastday < 0)
|
} else if ( (lstchgdate < 0)
|
||||||
|| (maxdays >= (10000 * (DAY / SCALE)))
|
|| (maxdays >= (10000 * (DAY / SCALE)))
|
||||||
|| (maxdays < 0)) {
|
|| (maxdays < 0)) {
|
||||||
(void) puts (_("never"));
|
(void) puts (_("never"));
|
||||||
@ -335,9 +335,9 @@ static void list_fields (void)
|
|||||||
* active will be disabled.
|
* active will be disabled.
|
||||||
*/
|
*/
|
||||||
(void) fputs (_("Password inactive\t\t\t\t\t: "), stdout);
|
(void) fputs (_("Password inactive\t\t\t\t\t: "), stdout);
|
||||||
if (lastday == 0) {
|
if (lstchgdate == 0) {
|
||||||
(void) puts (_("password must be changed"));
|
(void) puts (_("password must be changed"));
|
||||||
} else if ( (lastday < 0)
|
} else if ( (lstchgdate < 0)
|
||||||
|| (inactdays < 0)
|
|| (inactdays < 0)
|
||||||
|| (maxdays >= (10000 * (DAY / SCALE)))
|
|| (maxdays >= (10000 * (DAY / SCALE)))
|
||||||
|| (maxdays < 0)) {
|
|| (maxdays < 0)) {
|
||||||
@ -352,10 +352,10 @@ static void list_fields (void)
|
|||||||
* password expiring or not.
|
* password expiring or not.
|
||||||
*/
|
*/
|
||||||
(void) fputs (_("Account expires\t\t\t\t\t\t: "), stdout);
|
(void) fputs (_("Account expires\t\t\t\t\t\t: "), stdout);
|
||||||
if (expdays < 0) {
|
if (expdate < 0) {
|
||||||
(void) puts (_("never"));
|
(void) puts (_("never"));
|
||||||
} else {
|
} else {
|
||||||
expires = expdays * SCALE;
|
expires = expdate * SCALE;
|
||||||
print_date ((time_t) expires);
|
print_date ((time_t) expires);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,9 +405,9 @@ static void process_flags (int argc, char **argv)
|
|||||||
case 'd':
|
case 'd':
|
||||||
dflg = true;
|
dflg = true;
|
||||||
if (!isnum (optarg)) {
|
if (!isnum (optarg)) {
|
||||||
lastday = strtoday (optarg);
|
lstchgdate = strtoday (optarg);
|
||||||
} else if ( (getlong (optarg, &lastday) == 0)
|
} else if ( (getlong (optarg, &lstchgdate) == 0)
|
||||||
|| (lastday < -1)) {
|
|| (lstchgdate < -1)) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: invalid date '%s'\n"),
|
_("%s: invalid date '%s'\n"),
|
||||||
Prog, optarg);
|
Prog, optarg);
|
||||||
@ -417,9 +417,9 @@ static void process_flags (int argc, char **argv)
|
|||||||
case 'E':
|
case 'E':
|
||||||
Eflg = true;
|
Eflg = true;
|
||||||
if (!isnum (optarg)) {
|
if (!isnum (optarg)) {
|
||||||
expdays = strtoday (optarg);
|
expdate = strtoday (optarg);
|
||||||
} else if ( (getlong (optarg, &expdays) == 0)
|
} else if ( (getlong (optarg, &expdate) == 0)
|
||||||
|| (expdays < -1)) {
|
|| (expdate < -1)) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_("%s: invalid date '%s'\n"),
|
_("%s: invalid date '%s'\n"),
|
||||||
Prog, optarg);
|
Prog, optarg);
|
||||||
@ -701,10 +701,10 @@ static void update_age (const struct spwd *sp, const struct passwd *pw)
|
|||||||
*/
|
*/
|
||||||
spwent.sp_max = maxdays;
|
spwent.sp_max = maxdays;
|
||||||
spwent.sp_min = mindays;
|
spwent.sp_min = mindays;
|
||||||
spwent.sp_lstchg = lastday;
|
spwent.sp_lstchg = lstchgdate;
|
||||||
spwent.sp_warn = warndays;
|
spwent.sp_warn = warndays;
|
||||||
spwent.sp_inact = inactdays;
|
spwent.sp_inact = inactdays;
|
||||||
spwent.sp_expire = expdays;
|
spwent.sp_expire = expdate;
|
||||||
|
|
||||||
if (spw_update (&spwent) == 0) {
|
if (spw_update (&spwent) == 0) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
@ -731,7 +731,7 @@ static void get_defaults (const struct spwd *sp)
|
|||||||
mindays = sp->sp_min;
|
mindays = sp->sp_min;
|
||||||
}
|
}
|
||||||
if (!dflg) {
|
if (!dflg) {
|
||||||
lastday = sp->sp_lstchg;
|
lstchgdate = sp->sp_lstchg;
|
||||||
}
|
}
|
||||||
if (!Wflg) {
|
if (!Wflg) {
|
||||||
warndays = sp->sp_warn;
|
warndays = sp->sp_warn;
|
||||||
@ -740,7 +740,7 @@ static void get_defaults (const struct spwd *sp)
|
|||||||
inactdays = sp->sp_inact;
|
inactdays = sp->sp_inact;
|
||||||
}
|
}
|
||||||
if (!Eflg) {
|
if (!Eflg) {
|
||||||
expdays = sp->sp_expire;
|
expdate = sp->sp_expire;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
@ -754,7 +754,7 @@ static void get_defaults (const struct spwd *sp)
|
|||||||
mindays = -1;
|
mindays = -1;
|
||||||
}
|
}
|
||||||
if (!dflg) {
|
if (!dflg) {
|
||||||
lastday = -1;
|
lstchgdate = -1;
|
||||||
}
|
}
|
||||||
if (!Wflg) {
|
if (!Wflg) {
|
||||||
warndays = -1;
|
warndays = -1;
|
||||||
@ -763,7 +763,7 @@ static void get_defaults (const struct spwd *sp)
|
|||||||
inactdays = -1;
|
inactdays = -1;
|
||||||
}
|
}
|
||||||
if (!Eflg) {
|
if (!Eflg) {
|
||||||
expdays = -1;
|
expdate = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user