* Copyright (c) 1988 The Regents of the University of California.
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)field.c 5.13 (Berkeley) %G%";
(void)fprintf(stderr
, "chpass: empty login field.\n");
"chpass: login names may not begin with a hyphen.\n");
if (!(pw
->pw_name
= strdup(p
))) {
(void)fprintf(stderr
, "chpass: can't save entry.\n");
"chpass: \'.\' is dangerous in a login name.\n");
"chpass: upper-case letters are dangerous in a login name.\n");
pw
->pw_passwd
= ""; /* "NOLOGIN"; */
else if (!(pw
->pw_passwd
= strdup(p
))) {
(void)fprintf(stderr
, "chpass: can't save password entry.\n");
(void)fprintf(stderr
, "chpass: empty uid field.\n");
(void)fprintf(stderr
, "chpass: illegal uid.\n");
if ((u_int
)id
> USHRT_MAX
) {
(void)fprintf(stderr
, "chpass: %d > max uid value (%d).\n",
(void)fprintf(stderr
, "chpass: empty gid field.\n");
if (!(gr
= getgrnam(p
))) {
"chpass: unknown group %s.\n", p
);
if ((u_int
)id
> USHRT_MAX
) {
(void)fprintf(stderr
, "chpass: %d > max gid value (%d).\n",
else if (!(pw
->pw_class
= strdup(p
))) {
(void)fprintf(stderr
, "chpass: can't save entry.\n");
if (!atot(p
, &pw
->pw_change
))
(void)fprintf(stderr
, "chpass: illegal date for change field.\n");
if (!atot(p
, &pw
->pw_expire
))
(void)fprintf(stderr
, "chpass: illegal date for expire field.\n");
else if (!(ep
->save
= strdup(p
))) {
(void)fprintf(stderr
, "chpass: can't save entry.\n");
(void)fprintf(stderr
, "chpass: empty home directory field.\n");
if (!(pw
->pw_dir
= strdup(p
))) {
(void)fprintf(stderr
, "chpass: can't save entry.\n");
pw
->pw_shell
= _PATH_BSHELL
;
/* only admin can change from or to "restricted" shells */
if (uid
&& pw
->pw_shell
&& !ok_shell(pw
->pw_shell
)) {
"chpass: %s: current shell non-standard.\n", pw
->pw_shell
);
if (!(t
= ok_shell(p
))) {
"chpass: %s: non-standard shell.\n", p
);
if (!(pw
->pw_shell
= strdup(p
))) {
(void)fprintf(stderr
, "chpass: can't save entry.\n");