]> git.saurik.com Git - apple/libc.git/blame - gen/FreeBSD/setmode.c.patch
Libc-594.1.4.tar.gz
[apple/libc.git] / gen / FreeBSD / setmode.c.patch
CommitLineData
34e8f829
A
1--- setmode.c.orig 2008-02-08 00:45:35.000000000 -0800
2+++ setmode.c 2008-02-17 19:36:02.000000000 -0800
3@@ -70,12 +70,15 @@ typedef struct bitcmd {
4 #define CMD2_OBITS 0x08
5 #define CMD2_UBITS 0x10
6
7+#define compress_mode _sm_compress_mode
8+
9 static BITCMD *addcmd(BITCMD *, int, int, int, u_int);
10-static void compress_mode(BITCMD *);
11+__private_extern__ void compress_mode(BITCMD *);
12 #ifdef SETMODE_DEBUG
13 static void dumpmode(BITCMD *);
14 #endif
15
16+#ifndef BUILDING_VARIANT
17 /*
18 * Given the old mode and an array of bitcmd structures, apply the operations
19 * described in the bitcmd structures to the old mode, and return the new mode.
20@@ -151,6 +154,7 @@ common: if (set->cmd2 & CMD2_CLR) {
21 return (newmode);
22 }
23 }
24+#endif /* BUILDING_VARIANT */
25
26 #define ADDCMD(a, b, c, d) \
27 if (set >= endset) { \
28@@ -169,7 +173,11 @@ common: if (set->cmd2 & CMD2_CLR) {
29 } \
30 set = addcmd(set, (a), (b), (c), (d))
31
32+#ifndef VARIANT_LEGACY
33+#define STANDARD_BITS (S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO|S_ISTXT)
34+#else /* VARIANT_LEGACY */
35 #define STANDARD_BITS (S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO)
36+#endif /* !VARIANT_LEGACY */
37
38 void *
39 setmode(p)
40@@ -211,12 +219,21 @@ setmode(p)
41 */
42 if (isdigit((unsigned char)*p)) {
43 perml = strtol(p, &ep, 8);
44- if (*ep || perml < 0 || perml & ~(STANDARD_BITS|S_ISTXT)) {
45+#ifndef VARIANT_LEGACY
46+ if (*ep || perml < 0 || perml & ~STANDARD_BITS)
47+#else /* VARIANT_LEGACY */
48+ if (*ep || perml < 0 || perml & ~(STANDARD_BITS|S_ISTXT))
49+#endif /* !VARIANT_LEGACY */
50+ {
51 free(saveset);
52 return (NULL);
53 }
54 perm = (mode_t)perml;
55+#ifndef VARIANT_LEGACY
56+ ADDCMD('=', STANDARD_BITS, perm, mask);
57+#else /* VARIANT_LEGACY */
58 ADDCMD('=', (STANDARD_BITS|S_ISTXT), perm, mask);
59+#endif /* !VARIANT_LEGACY */
60 set->cmd = 0;
61 return (saveset);
62 }
63@@ -253,7 +270,9 @@ getop: if ((op = *p++) != '+' && op !=
64 if (op == '=')
65 equalopdone = 0;
66
67+#ifdef VARIANT_LEGACY
68 who &= ~S_ISTXT;
69+#endif /* VARIANT_LEGACY */
70 for (perm = 0, permXbits = 0;; ++p) {
71 switch (*p) {
72 case 'r':
73@@ -267,7 +286,9 @@ getop: if ((op = *p++) != '+' && op !=
74 case 't':
75 /* If only "other" bits ignore sticky. */
76 if (!who || who & ~S_IRWXO) {
77+#ifdef VARIANT_LEGACY
78 who |= S_ISTXT;
79+#endif /* VARIANT_LEGACY */
80 perm |= S_ISTXT;
81 }
82 break;
83@@ -402,13 +423,14 @@ dumpmode(set)
84 }
85 #endif
86
87+#ifndef BUILDING_VARIANT
88 /*
89 * Given an array of bitcmd structures, compress by compacting consecutive
90 * '+', '-' and 'X' commands into at most 3 commands, one of each. The 'u',
91 * 'g' and 'o' commands continue to be separate. They could probably be
92 * compacted, but it's not worth the effort.
93 */
94-static void
95+__private_extern__ void
96 compress_mode(set)
97 BITCMD *set;
98 {
99@@ -457,3 +479,4 @@ compress_mode(set)
100 }
101 }
102 }
103+#endif /* BUILDING_VARIANT */