* 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
[] = "@(#)field.c 5.5 (Berkeley) %G%";
fprintf(stderr
, "chpass: empty login field");
"chpass: login names may not begin with a hyphen.\n");
if (!(pw
->pw_name
= strdup(p
))) {
fprintf(stderr
, "chpass: can't save entry");
fprintf(stderr
, "chpass: empty uid field");
fprintf(stderr
, "chpass: illegal uid");
if ((u_int
)id
> USHRT_MAX
) {
fprintf(stderr
, "chpass: %d > max uid value (%d)",
fprintf(stderr
, "chpass: empty gid field");
if (!(gr
= getgrnam(p
))) {
fprintf(stderr
, "chpass: unknown group %s", p
);
if ((u_int
)id
> USHRT_MAX
) {
fprintf(stderr
, "chpass: %d > max gid value (%d)",
else if (!(pw
->pw_class
= strdup(p
))) {
fprintf(stderr
, "chpass: can't save entry");
if (!atot(p
, &pw
->pw_change
))
fprintf(stderr
, "chpass: illegal date for change field");
if (!atot(p
, &pw
->pw_expire
))
fprintf(stderr
, "chpass: illegal date for expire field");
else if (!(ep
->save
= strdup(p
))) {
fprintf(stderr
, "chpass: can't save entry");
fprintf(stderr
, "chpass: empty home directory field");
if (!(pw
->pw_dir
= strdup(p
))) {
fprintf(stderr
, "chpass: can't save entry");
pw
->pw_shell
= _PATH_BSHELL
;
if (!(sh
= getusershell())) {
/* only admin can set "restricted" shells */
fprintf(stderr
, "chpass: %s: non-standard shell", p
);
/* allow just shell name */
if ((t
= rindex(sh
, '/')) && !strcmp(p
, t
)) {
if (!(pw
->pw_shell
= strdup(p
))) {
fprintf(stderr
, "chpass: can't save entry");