* 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.9 (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
;
if (!(sh
= getusershell())) {
/* only admin can set "restricted" shells */
"chpass: %s: non-standard shell.\n", p
);
/* allow just shell name */
if ((t
= rindex(sh
, '/')) && !strcmp(p
, t
)) {
if (!(pw
->pw_shell
= strdup(p
))) {
(void)fprintf(stderr
, "chpass: can't save entry.\n");