* Copyright (c) 1988 The Regents of the University of California.
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)util.c 5.13 (Berkeley) %G%";
{ -1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
{ "January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November",
(void)sprintf(tbuf
, "%s %d, 19%d", months
[tp
->tm_mon
],
tp
->tm_mday
, tp
->tm_year
);
if (!(t
= strtok(p
, " \t")))
for (mp
= months
;; ++mp
) {
if (!strncasecmp(*mp
, t
, 3)) {
if (!(t
= strtok((char *)NULL
, " \t,")) || !isdigit(*t
))
if (!(t
= strtok((char *)NULL
, " \t,")) || !isdigit(*t
))
if (day
< 1 || day
> 31 || month
< 1 || month
> 12 || !year
)
tval
= isleap(year
) && month
> 2;
for (--year
; year
>= EPOCH_YEAR
; --year
)
DAYSPERLYEAR
: DAYSPERNYEAR
;
tval
= tval
* HOURSPERDAY
* MINSPERHOUR
* SECSPERMIN
;
* print out the file for the user to edit; strange side-effect:
* return if the user is allowed to modify their shell.
char *getusershell(), *ok_shell(), *ttoa();
(void)fprintf(fp
, "#Changing user database information for %s.\n",
(void)fprintf(fp
, "Login: %s\n", pw
->pw_name
);
(void)fprintf(fp
, "Password: %s\n", pw
->pw_passwd
);
(void)fprintf(fp
, "Uid [#]: %d\n", pw
->pw_uid
);
(void)fprintf(fp
, "Gid [# or name]: %d\n", pw
->pw_gid
);
(void)fprintf(fp
, "Change [month day year]: %s\n",
(void)fprintf(fp
, "Expire [month day year]: %s\n",
(void)fprintf(fp
, "Class: %s\n", pw
->pw_class
);
(void)fprintf(fp
, "Home directory: %s\n", pw
->pw_dir
);
(void)fprintf(fp
, "Shell: %s\n",
*pw
->pw_shell
? pw
->pw_shell
: _PATH_BSHELL
);
/* only admin can change "restricted" shells */
else if (ok_shell(pw
->pw_shell
))
(void)fprintf(fp
, "Shell: %s\n",
*pw
->pw_shell
? pw
->pw_shell
: _PATH_BSHELL
);
(void)fprintf(fp
, "Full Name: %s\n", p
? p
: "");
(void)fprintf(fp
, "Location: %s\n", p
? p
: "");
(void)fprintf(fp
, "Office Phone: %s\n", p
? p
: "");
(void)fprintf(fp
, "Home Phone: %s\n", p
? p
: "");
while (sh
= getusershell()) {
/* allow just shell name, but use "real" path */
if ((p
= rindex(sh
, '/')) && !strcmp(name
, p
+ 1))