* Copyright (c) 1988 The Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
static char sccsid
[] = "@(#)field.c 5.13 (Berkeley) 2/12/91";
(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");