Deleted Added
full compact
pw_user.c (262865) pw_user.c (263114)
1/*-
2 * Copyright (C) 1996
3 * David L. Nugent. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 */
27
28#ifndef lint
29static const char rcsid[] =
1/*-
2 * Copyright (C) 1996
3 * David L. Nugent. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 */
27
28#ifndef lint
29static const char rcsid[] =
30 "$FreeBSD: head/usr.sbin/pw/pw_user.c 262865 2014-03-06 19:58:03Z julian $";
30 "$FreeBSD: head/usr.sbin/pw/pw_user.c 263114 2014-03-13 18:16:42Z dteske $";
31#endif /* not lint */
32
33#include <ctype.h>
34#include <err.h>
35#include <fcntl.h>
36#include <sys/param.h>
37#include <dirent.h>
38#include <paths.h>

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

375 edited = 1;
376 } else if (mode == M_DELETE) {
377 /*
378 * Handle deletions now
379 */
380 char file[MAXPATHLEN];
381 char home[MAXPATHLEN];
382 uid_t uid = pwd->pw_uid;
31#endif /* not lint */
32
33#include <ctype.h>
34#include <err.h>
35#include <fcntl.h>
36#include <sys/param.h>
37#include <dirent.h>
38#include <paths.h>

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

375 edited = 1;
376 } else if (mode == M_DELETE) {
377 /*
378 * Handle deletions now
379 */
380 char file[MAXPATHLEN];
381 char home[MAXPATHLEN];
382 uid_t uid = pwd->pw_uid;
383 struct group *gr;
384 char grname[LOGNAMESIZE];
383
384 if (strcmp(pwd->pw_name, "root") == 0)
385 errx(EX_DATAERR, "cannot remove user 'root'");
386
387 if (!PWALTDIR()) {
388 /*
389 * Remove opie record from /etc/opiekeys
390 */

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

401 }
402 }
403 /*
404 * Save these for later, since contents of pwd may be
405 * invalidated by deletion
406 */
407 sprintf(file, "%s/%s", _PATH_MAILDIR, pwd->pw_name);
408 strlcpy(home, pwd->pw_dir, sizeof(home));
385
386 if (strcmp(pwd->pw_name, "root") == 0)
387 errx(EX_DATAERR, "cannot remove user 'root'");
388
389 if (!PWALTDIR()) {
390 /*
391 * Remove opie record from /etc/opiekeys
392 */

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

403 }
404 }
405 /*
406 * Save these for later, since contents of pwd may be
407 * invalidated by deletion
408 */
409 sprintf(file, "%s/%s", _PATH_MAILDIR, pwd->pw_name);
410 strlcpy(home, pwd->pw_dir, sizeof(home));
411 gr = GETGRGID(pwd->pw_gid);
412 if (gr != NULL)
413 strlcpy(grname, gr->gr_name, LOGNAMESIZE);
414 else
415 grname[0] = '\0';
409
410 rc = delpwent(pwd);
411 if (rc == -1)
412 err(EX_IOERR, "user '%s' does not exist", pwd->pw_name);
413 else if (rc != 0) {
414 warn("passwd update");
415 return EX_IOERR;
416 }

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

421 warnx("WARNING: user '%s' does not exist in NIS passwd", pwd->pw_name);
422 else if (rc != 0)
423 warn("WARNING: NIS passwd update");
424 /* non-fatal */
425 }
426
427 grp = GETGRNAM(a_name->val);
428 if (grp != NULL &&
416
417 rc = delpwent(pwd);
418 if (rc == -1)
419 err(EX_IOERR, "user '%s' does not exist", pwd->pw_name);
420 else if (rc != 0) {
421 warn("passwd update");
422 return EX_IOERR;
423 }

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

428 warnx("WARNING: user '%s' does not exist in NIS passwd", pwd->pw_name);
429 else if (rc != 0)
430 warn("WARNING: NIS passwd update");
431 /* non-fatal */
432 }
433
434 grp = GETGRNAM(a_name->val);
435 if (grp != NULL &&
429 (grp->gr_mem == NULL || *grp->gr_mem == NULL))
436 (grp->gr_mem == NULL || *grp->gr_mem == NULL) &&
437 strcmp(a_name->val, grname) == 0)
430 delgrent(GETGRNAM(a_name->val));
431 SETGRENT();
432 while ((grp = GETGRENT()) != NULL) {
433 int i;
434 char group[MAXLOGNAME];
435 if (grp->gr_mem != NULL) {
436 for (i = 0; grp->gr_mem[i] != NULL; i++) {
437 if (!strcmp(grp->gr_mem[i], a_name->val)) {

--- 880 unchanged lines hidden ---
438 delgrent(GETGRNAM(a_name->val));
439 SETGRENT();
440 while ((grp = GETGRENT()) != NULL) {
441 int i;
442 char group[MAXLOGNAME];
443 if (grp->gr_mem != NULL) {
444 for (i = 0; grp->gr_mem[i] != NULL; i++) {
445 if (!strcmp(grp->gr_mem[i], a_name->val)) {

--- 880 unchanged lines hidden ---