repl.txt (3974B)
1 2 {{alias}}( [mask,] [options] ) 3 Returns the current process mask, if not provided a mask; otherwise, sets 4 the process mask and returns the previous mask. 5 6 A mask is a set of bits, each of which restricts how its corresponding 7 permission is set for newly created files. 8 9 On POSIX platforms, each file has a set of attributes that control who can 10 read, write, or execute that file. Upon creating a file, file permissions 11 must be set to an initial setting. The process mask restricts those 12 permission settings. 13 14 If the mask contains a bit set to "1", the corresponding initial file 15 permission is disabled. If the mask contains a bit set to "0", the 16 corresponding permission is left to be determined by the requesting process 17 and the system. 18 19 The process mask is thus a filter that removes permissions as a file is 20 created; i.e., each bit set to a "1" removes its corresponding permission. 21 22 In octal representation, a mask is a four digit number, e.g., 0077, 23 comprised as follows: 24 25 - 0: special permissions (setuid, setgid, sticky bit) 26 - 0: (u)ser/owner permissions 27 - 7: (g)roup permissions 28 - 7: (o)thers/non-group permissions 29 30 Octal codes correspond to the following permissions: 31 32 - 0: read, write, execute 33 - 1: read, write 34 - 2: read, execute 35 - 3: read 36 - 4: write, execute 37 - 5: write 38 - 6: execute 39 - 7: no permissions 40 41 If provided fewer than four digits, the mask is left-padded with zeros. 42 43 Note, however, that only the last three digits (i.e., the file permissions 44 digits) of the mask are actually used when the mask is applied. 45 46 Permissions can be represented using the following symbolic form: 47 48 u=rwx,g=rwx,o=rwx 49 50 where 51 52 - u: user permissions 53 - g: group permissions 54 - o: other/non-group permissions 55 - r: read 56 - w: write 57 - x: execute 58 59 When setting permissions using symbolic notation, the function accepts a 60 mask expression of the form: 61 62 [<classes>]<operator><symbols> 63 64 where "classes" may be a combination of 65 66 - u: user 67 - g: group 68 - o: other/non-group 69 - a: all 70 71 "symbols" may be a combination of 72 73 - r: read 74 - w: write 75 - x: execute 76 - X: special execute 77 - s: setuid/gid on execution 78 - t: sticky 79 80 and "operator" may be one of 81 82 - `+`: enable 83 - `-`: disable 84 - `=`: enable specified and disable unspecified permissions 85 86 For example, 87 88 - `u-w`: disable user write permissions 89 - `u+w`: enable user write permissions 90 - `u=w`: enable user write permissions and disable user read and execute 91 92 To specify multiple changes, provide a comma-separated list of mask 93 expressions. For example, 94 95 u+rwx,g-x,o=r 96 97 would enable user read, write, and execute permissions, disable group 98 execute permissions, enable other read permissions, and disable other 99 write and execute permissions. 100 101 The `a` class indicates "all", which is the same as specifying "ugo". This 102 is the default class if a class is omitted when specifying permissions. For 103 example, `+x` is equivalent to `a+x` which is equivalent to `ugo+x` which 104 is equivalent to `u+x,g+x,o+x` and enables execution for all classes. 105 106 Parameters 107 ---------- 108 mask: integer|string (optional) 109 Mask or mask expression. If the mask is a string, the mask is assumed to 110 be in symbolic notation. 111 112 options: Object (optional) 113 Options. 114 115 options.symbolic: boolean (optional) 116 Boolean indicating whether to return the mask using symbolic notation. 117 118 Returns 119 ------- 120 mask: integer|string 121 Process mask. If provided a mask, the returned value is the previous 122 mask; otherwise, the returned value is the current process mask. 123 124 Examples 125 -------- 126 > var mask = {{alias}}() 127 <number> 128 > mask = {{alias}}( { 'symbolic': true } ) 129 <string> 130 131 See Also 132 -------- 133