File: chown-if-needed.patch

package info (click to toggle)
ucspi-unix 1.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 452 kB
  • sloc: ansic: 2,606; python: 535; makefile: 14; sh: 1
file content (20 lines) | stat: -rw-r--r-- 706 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Description: Do not call chown(2) unless we need to
 Apparently some glibc/kernel combinations will fail for unprivileged
 users even for chown(-1, -1).
 Fixes the FTBFS on sparc64.
Forwarded: no
Author: Peter Pentchev <roam@ringlet.net>
Last-Update: 2024-12-13

--- a/unixserver.c
+++ b/unixserver.c
@@ -243,7 +243,8 @@
   if(bind(s, (struct sockaddr*)saddr, SUN_LEN(saddr)) != 0)
     die("bind");
   umask(old_umask);
-  if(chown(opt_socket, opt_socket_uid, opt_socket_gid) == -1)
+  if((opt_socket_uid != (uid_t)-1 || opt_socket_gid != (gid_t)-1) &&
+	chown(opt_socket, opt_socket_uid, opt_socket_gid) == -1)
     die("chown");
   if(opt_perms && chmod(opt_socket, opt_perms) == -1)
     die("chmod");