Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/user Fix warning in userdel -r.



details:   https://anonhg.NetBSD.org/src/rev/7a7d572c012d
branches:  trunk
changeset: 1000570:7a7d572c012d
user:      wiz <wiz%NetBSD.org@localhost>
date:      Mon Jul 29 09:33:21 2019 +0000

description:
Fix warning in userdel -r.

If the 'rm -rf' works, then the home directory does not exist any more,
and rmdir() on it will return an error (ENOENT). Catch and ignore it.

Avoids:

# useradd -m foo
# userdel -r foo
userdel: Unable to remove all files in `/home/foo': No such file or directory

diffstat:

 usr.sbin/user/user.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r e4460fb93f71 -r 7a7d572c012d usr.sbin/user/user.c
--- a/usr.sbin/user/user.c      Mon Jul 29 08:13:50 2019 +0000
+++ b/usr.sbin/user/user.c      Mon Jul 29 09:33:21 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: user.c,v 1.132 2018/06/10 07:52:05 zafer Exp $ */
+/* $NetBSD: user.c,v 1.133 2019/07/29 09:33:21 wiz Exp $ */
 
 /*
  * Copyright (c) 1999 Alistair G. Crooks.  All rights reserved.
@@ -33,7 +33,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1999\
  The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: user.c,v 1.132 2018/06/10 07:52:05 zafer Exp $");
+__RCSID("$NetBSD: user.c,v 1.133 2019/07/29 09:33:21 wiz Exp $");
 #endif
 
 #include <sys/types.h>
@@ -300,7 +300,7 @@
        (void)asystem("%s -rf %s > /dev/null 2>&1 || true", _PATH_RM,
                      pwp->pw_dir);
        (void)seteuid(0);
-       if (rmdir(pwp->pw_dir) < 0) {
+       if (rmdir(pwp->pw_dir) < 0 && errno != ENOENT) {
                warn("Unable to remove all files in `%s'", pwp->pw_dir);
                return 0;
        }



Home | Main Index | Thread Index | Old Index