Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Aug 2020 18:08:04 +0000 (UTC)
From:      Alex Richardson <arichardson@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r363805 - head/lib/libc/gen
Message-ID:  <202008031808.073I84oi052984@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: arichardson
Date: Mon Aug  3 18:08:04 2020
New Revision: 363805
URL: https://svnweb.freebsd.org/changeset/base/363805

Log:
  Allow building setmode.c on Linux/macOS
  
  We bootstrap this file to allow compiling FreeBSD on Linux systems since
  some boostrap tools use setmode(). Unfortunately, glibc's sys/stat.h
  declares a non-static getumask() function (which is unimplemented!) and
  that conflicts with the local getumask() function. To work around this
  simply use a different name here.
  
  Reviewed By:	brooks, emaste
  Differential Revision: https://reviews.freebsd.org/D25929

Modified:
  head/lib/libc/gen/setmode.c

Modified: head/lib/libc/gen/setmode.c
==============================================================================
--- head/lib/libc/gen/setmode.c	Mon Aug  3 17:53:15 2020	(r363804)
+++ head/lib/libc/gen/setmode.c	Mon Aug  3 18:08:04 2020	(r363805)
@@ -70,7 +70,7 @@ typedef struct bitcmd {
 #define	CMD2_OBITS	0x08
 #define	CMD2_UBITS	0x10
 
-static mode_t	 getumask(void);
+static mode_t	 get_current_umask(void);
 static BITCMD	*addcmd(BITCMD *, mode_t, mode_t, mode_t, mode_t);
 static void	 compress_mode(BITCMD *);
 #ifdef SETMODE_DEBUG
@@ -186,7 +186,7 @@ setmode(const char *p)
 	 * Get a copy of the mask for the permissions that are mask relative.
 	 * Flip the bits, we want what's not set.
 	 */
-	mask = ~getumask();
+	mask = ~get_current_umask();
 
 	setlen = SET_LEN + 2;
 
@@ -343,13 +343,14 @@ out:
 }
 
 static mode_t
-getumask(void)
+get_current_umask(void)
 {
 	sigset_t sigset, sigoset;
 	size_t len;
 	mode_t mask;
 	u_short smask;
 
+#ifdef KERN_PROC_UMASK
 	/*
 	 * First try requesting the umask without temporarily modifying it.
 	 * Note that this does not work if the sysctl
@@ -359,7 +360,7 @@ getumask(void)
 	if (sysctl((int[4]){ CTL_KERN, KERN_PROC, KERN_PROC_UMASK, 0 },
 	    4, &smask, &len, NULL, 0) == 0)
 		return (smask);
-
+#endif
 	/*
 	 * Since it's possible that the caller is opening files inside a signal
 	 * handler, protect them as best we can.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008031808.073I84oi052984>