Deleted Added
full compact
field.c (117430) field.c (124692)
1/*
2 * Copyright (c) 1988, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 2002 Networks Associates Technology, Inc.
5 * All rights reserved.
6 *
7 * Portions of this software were developed for the FreeBSD Project by
8 * ThinkSec AS and NAI Labs, the Security Research Division of Network

--- 31 unchanged lines hidden (view full) ---

40
41#if 0
42#ifndef lint
43static char sccsid[] = "@(#)field.c 8.4 (Berkeley) 4/2/94";
44#endif /* not lint */
45#endif
46
47#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1988, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 2002 Networks Associates Technology, Inc.
5 * All rights reserved.
6 *
7 * Portions of this software were developed for the FreeBSD Project by
8 * ThinkSec AS and NAI Labs, the Security Research Division of Network

--- 31 unchanged lines hidden (view full) ---

40
41#if 0
42#ifndef lint
43static char sccsid[] = "@(#)field.c 8.4 (Berkeley) 4/2/94";
44#endif /* not lint */
45#endif
46
47#include <sys/cdefs.h>
48__FBSDID("$FreeBSD: head/usr.bin/chpass/field.c 117430 2003-07-11 05:47:05Z kan $");
48__FBSDID("$FreeBSD: head/usr.bin/chpass/field.c 124692 2004-01-18 21:46:39Z charnier $");
49
50#include <sys/param.h>
51#include <sys/stat.h>
52
53#include <ctype.h>
54#include <err.h>
55#include <errno.h>
56#include <grp.h>
57#include <paths.h>
58#include <pwd.h>
49
50#include <sys/param.h>
51#include <sys/stat.h>
52
53#include <ctype.h>
54#include <err.h>
55#include <errno.h>
56#include <grp.h>
57#include <paths.h>
58#include <pwd.h>
59#include <stdio.h>
60#include <stdlib.h>
61#include <string.h>
59#include <stdlib.h>
60#include <string.h>
62#include <unistd.h>
63
64#include "chpass.h"
65
66/* ARGSUSED */
67int
68p_login(char *p, struct passwd *pw, ENTRY *ep __unused)
69{
70 if (!*p) {

--- 142 unchanged lines hidden (view full) ---

213 }
214 return (0);
215}
216
217/* ARGSUSED */
218int
219p_shell(char *p, struct passwd *pw, ENTRY *ep __unused)
220{
61
62#include "chpass.h"
63
64/* ARGSUSED */
65int
66p_login(char *p, struct passwd *pw, ENTRY *ep __unused)
67{
68 if (!*p) {

--- 142 unchanged lines hidden (view full) ---

211 }
212 return (0);
213}
214
215/* ARGSUSED */
216int
217p_shell(char *p, struct passwd *pw, ENTRY *ep __unused)
218{
221 char *t;
222 struct stat sbuf;
223
224 if (!*p) {
225 pw->pw_shell = strdup(_PATH_BSHELL);
226 return (0);
227 }
228 /* only admin can change from or to "restricted" shells */
229 if (!master_mode && pw->pw_shell && !ok_shell(pw->pw_shell)) {
230 warnx("%s: current shell non-standard", pw->pw_shell);
231 return (-1);
232 }
219 struct stat sbuf;
220
221 if (!*p) {
222 pw->pw_shell = strdup(_PATH_BSHELL);
223 return (0);
224 }
225 /* only admin can change from or to "restricted" shells */
226 if (!master_mode && pw->pw_shell && !ok_shell(pw->pw_shell)) {
227 warnx("%s: current shell non-standard", pw->pw_shell);
228 return (-1);
229 }
233 if (!(t = ok_shell(p))) {
230 if (!ok_shell(p)) {
234 if (!master_mode) {
235 warnx("%s: non-standard shell", p);
236 return (-1);
237 }
231 if (!master_mode) {
232 warnx("%s: non-standard shell", p);
233 return (-1);
234 }
235 pw->pw_shell = strdup(p);
238 }
239 else
236 }
237 else
240 p = t;
241 if (!(pw->pw_shell = strdup(p))) {
238 pw->pw_shell = dup_shell(p);
239 if (!pw->pw_shell) {
242 warnx("can't save entry");
243 return (-1);
244 }
245 if (stat(pw->pw_shell, &sbuf) < 0) {
246 if (errno == ENOENT)
247 warnx("WARNING: shell '%s' does not exist",
248 pw->pw_shell);
249 else

--- 14 unchanged lines hidden ---
240 warnx("can't save entry");
241 return (-1);
242 }
243 if (stat(pw->pw_shell, &sbuf) < 0) {
244 if (errno == ENOENT)
245 warnx("WARNING: shell '%s' does not exist",
246 pw->pw_shell);
247 else

--- 14 unchanged lines hidden ---