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
This commit is contained in:
Alex Richardson 2020-08-03 18:08:04 +00:00
parent 338b22234b
commit 9053c1a431
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=363805

View File

@ -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 @@ apply: if (!*p)
}
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.