* Copyright (c) 1988 The Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
static char sccsid
[] = "@(#)util.c 5.1 (Berkeley) %G%";
#include </usr/src/include/pwd.h>
{ -1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
{ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
"Sep", "Oct", "Nov", "Dec", NULL
};
(void)sprintf(tbuf
, "%02d %s 19%02d", tp
->tm_mday
,
months
[tp
->tm_mon
], tp
->tm_year
);
if (!strncasecmp(p
, "none", 4)) {
if (!(t
= strsep(p
, " \t")) || !isdigit(*t
))
if (!(t
= strsep((char *)NULL
, " \t")))
for (mp
= months
;; ++mp
) {
if (!strncasecmp(*mp
, t
, 3)) {
if (!(t
= strsep((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
)
DAYS_PER_LYEAR
: DAYS_PER_NYEAR
;
tval
= tval
* HOURS_PER_DAY
* MINS_PER_HOUR
* SECS_PER_MIN
;
char *getusershell(), *ttoa();
fprintf(fp
, "Changing user database information for %s.\n",
fprintf(fp
, "Login: %s\n", pw
->pw_name
);
fprintf(fp
, "Uid [#]: %d\n", pw
->pw_uid
);
fprintf(fp
, "Gid [# or name]: %d\n", pw
->pw_gid
);
fprintf(fp
, "Change [dd month yy]: %s\n", ttoa(pw
->pw_change
));
fprintf(fp
, "Expire [dd month yy]: %s\n", ttoa(pw
->pw_expire
));
fprintf(fp
, "Class: %s\n", pw
->pw_class
);
fprintf(fp
, "Home directory: %s\n", pw
->pw_dir
);
fprintf(fp
, "Shell: %s\n",
*pw
->pw_shell
? pw
->pw_shell
: "/bin/sh");
/* only admin can change "restricted" shells */
if (!(p
= getusershell()))
else if (!strcmp(pw
->pw_shell
, p
)) {
fprintf(fp
, "Shell: %s\n",
*pw
->pw_shell
? pw
->pw_shell
: "/bin/sh");
p
= strsep(pw
->pw_gecos
, ",");
fprintf(fp
, "Full Name: %s\n", p
? p
: "");
p
= strsep((char *)NULL
, ",");
fprintf(fp
, "Location: %s\n", p
? p
: "");
p
= strsep((char *)NULL
, ",");
fprintf(fp
, "Home Phone: %s\n", p
? p
: "");
p
= strsep((char *)NULL
, ",");
fprintf(fp
, "Office Phone: %s\n", p
? p
: "");