Source-Changes-HG archive

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

[src/trunk]: src/tests/net/net Remove unneeded sete{u,g}id pointed out by kre.



details:   https://anonhg.NetBSD.org/src/rev/410145fd04d5
branches:  trunk
changeset: 943184:410145fd04d5
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Aug 28 11:46:05 2020 +0000

description:
Remove unneeded sete{u,g}id pointed out by kre.
Remove dup unlink.

diffstat:

 tests/net/net/t_unix.c |  18 ++++++------------
 1 files changed, 6 insertions(+), 12 deletions(-)

diffs (55 lines):

diff -r 62715193ea10 -r 410145fd04d5 tests/net/net/t_unix.c
--- a/tests/net/net/t_unix.c    Fri Aug 28 11:15:08 2020 +0000
+++ b/tests/net/net/t_unix.c    Fri Aug 28 11:46:05 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_unix.c,v 1.21 2020/08/27 14:00:01 christos Exp $     */
+/*     $NetBSD: t_unix.c,v 1.22 2020/08/28 11:46:05 christos Exp $     */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
 #define _GNU_SOURCE
 #include <sys/cdefs.h>
 #ifdef __RCSID
-__RCSID("$Id: t_unix.c,v 1.21 2020/08/27 14:00:01 christos Exp $");
+__RCSID("$Id: t_unix.c,v 1.22 2020/08/28 11:46:05 christos Exp $");
 #else
 #define getprogname() argv[0]
 #endif
@@ -251,8 +251,6 @@
 #endif
        sun->sun_family = AF_UNIX;
 
-       unlink(sun->sun_path);
-
        if (bind(srvr, (struct sockaddr *)sun, sl) == -1) {
                if (errno == EINVAL && sl >= 256) {
                        close(srvr);
@@ -272,23 +270,19 @@
                        srvrpid = getppid();
                        clntpid = getpid();
                        if (srvruid == 0) {
-                               clntuid = UID;
-                               clntgid = GID;
-                               setgid(clntgid);
-                               setegid(clntgid);
-                               setuid(clntuid);
-                               seteuid(clntuid);
+                               setgid(clntgid = GID);
+                               setuid(clntuid = UID);
                        } else {
+                               clntgid = srvrgid;
                                clntuid = srvruid;
-                               clntgid = srvrgid;
                        }
                        break;
                case -1:
                        FAIL("fork");
                default:
                        if (srvruid == 0) {
+                               clntgid = GID;
                                clntuid = UID;
-                               clntgid = GID;
                        }
                        break;
                }



Home | Main Index | Thread Index | Old Index