18aac90f1SBaptiste Daroussin.\"- 28aac90f1SBaptiste Daroussin.\" SPDX-License-Identifier: BSD-2-Clause 38aac90f1SBaptiste Daroussin.\" 4*bc201841SOlivier Certner.\" Copyright (c) 2024 Baptiste Daroussin <bapt@FreeBSD.org> 5*bc201841SOlivier Certner.\" Copyright (c) 2024 The FreeBSD Foundation 6*bc201841SOlivier Certner.\" 7*bc201841SOlivier Certner.\" Portions of this documentation were written by Olivier Certner 8*bc201841SOlivier Certner.\" <olce@FreeBSD.org> at Kumacom SARL under sponsorship from the FreeBSD 9*bc201841SOlivier Certner.\" Foundation. 10*bc201841SOlivier Certner.\" 11*bc201841SOlivier Certner.Dd December 19, 2024 128aac90f1SBaptiste Daroussin.Dt MAC_DO 4 138aac90f1SBaptiste Daroussin.Os 148aac90f1SBaptiste Daroussin.Sh NAME 158aac90f1SBaptiste Daroussin.Nm mac_do 16*bc201841SOlivier Certner.Nd "policy allowing unprivileged users to change process credentials" 178aac90f1SBaptiste Daroussin.Sh SYNOPSIS 188aac90f1SBaptiste DaroussinTo compile the 19*bc201841SOlivier Certner.Sy mac_do 20*bc201841SOlivier Certnerpolicy into your kernel, place the following lines in your kernel configuration 21*bc201841SOlivier Certnerfile: 228aac90f1SBaptiste Daroussin.Bd -ragged -offset indent 238aac90f1SBaptiste Daroussin.Cd "options MAC" 248aac90f1SBaptiste Daroussin.Cd "options MAC_DO" 258aac90f1SBaptiste Daroussin.Ed 26*bc201841SOlivier Certner.Pp 27*bc201841SOlivier CertnerAlternately, to load this policy module at boot time, place the following line 28*bc201841SOlivier Certnerin your kernel configuration file: 29*bc201841SOlivier Certner.Bd -ragged -offset indent 30*bc201841SOlivier Certner.Cd "options MAC" 31*bc201841SOlivier Certner.Ed 32*bc201841SOlivier Certner.Pp 33*bc201841SOlivier Certnerand in 34*bc201841SOlivier Certner.Xr loader.conf 5 : 35*bc201841SOlivier Certner.Bd -literal -offset indent 36*bc201841SOlivier Certnermac_do_load="YES" 37*bc201841SOlivier Certner.Ed 388aac90f1SBaptiste Daroussin.Sh DESCRIPTION 398aac90f1SBaptiste DaroussinThe 408aac90f1SBaptiste Daroussin.Nm 41*bc201841SOlivier Certnerpolicy module allows unprivileged users to change process credentials according 42*bc201841SOlivier Certnerto rules configured by the administrator. 43*bc201841SOlivier CertnerIt supports per-jail configuration. 448aac90f1SBaptiste Daroussin.Pp 45*bc201841SOlivier CertnerCurrently, the 46*bc201841SOlivier Certner.Nm 47*bc201841SOlivier Certnerpolicy module only produces effects to processes spwaned from the 48*bc201841SOlivier Certner.Pa /usr/bin/mdo 49*bc201841SOlivier Certnerexecutable, please see 50*bc201841SOlivier Certner.Xr mdo 1 51*bc201841SOlivier Certnerfor more details on this program. 52*bc201841SOlivier Certner.Sh CREDENTIALS RULES 53*bc201841SOlivier CertnerRules specify which transitions of process credentials 54*bc201841SOlivier Certner.Nm 55*bc201841SOlivier Certnerwill allow, based on current process credentials and the desired final ones. 56*bc201841SOlivier CertnerThey are passed by an administrator in the form of a string having the specific 57*bc201841SOlivier Certnersyntax described below in a top-bottom manner. 58*bc201841SOlivier CertnerThey have been designed to be able to finely describe the desired target 59*bc201841SOlivier Certnercredentials in a safe and compact way. 60*bc201841SOlivier Certner.Ss Top-Level List of Rules 61*bc201841SOlivier CertnerAt the top, rules are a possibly empty list of individual rules separated by 62*bc201841SOlivier Certnera semi-colon 63*bc201841SOlivier Certner.Pq Ql ";" : 64*bc201841SOlivier Certner.Dl Ao rules Ac \ ⟶\ Oo Ao rule Ac Oo So ";" Sc Ao rule Ac Oc Ns * Oc 65*bc201841SOlivier CertnerThey form a disjunction, i.e., 66*bc201841SOlivier Certner.Nm 67*bc201841SOlivier Certnerauthorizes a credentials transition as soon as at least one rule in the list 68*bc201841SOlivier Certnermatches. 69*bc201841SOlivier Certner.Pp 70*bc201841SOlivier CertnerOne rule is composed of a 71*bc201841SOlivier Certner.Li Aq from 72*bc201841SOlivier Certnerpart 73*bc201841SOlivier Certner.Pq also called Dq match 74*bc201841SOlivier Certnerand a 75*bc201841SOlivier Certner.Li Aq to 76*bc201841SOlivier Certnerpart 77*bc201841SOlivier Certner.Pq also called Dq target , 78*bc201841SOlivier Certnerin this order, separated by a colon 79*bc201841SOlivier Certner.Pq Ql ":" : 80*bc201841SOlivier Certner.Dl Ao rule Ac \ ⟶\ Ao from Ac So ":" Sc Ao to Ac 81*bc201841SOlivier Certner.Ss Rule's Ao from Ac Part 82*bc201841SOlivier CertnerThe first part of a rule, 83*bc201841SOlivier Certner.Li Aq from , 84*bc201841SOlivier Certneris matched against the credentials of the process requesting some credentials 85*bc201841SOlivier Certnertransition. 86*bc201841SOlivier CertnerIt has the form: 87*bc201841SOlivier Certner.Dl Ao from Ac \ ⟶\ Ao type Ac So = Sc Ao id Ac 88*bc201841SOlivier Certner.Pp 89*bc201841SOlivier Certner.Li Aq type 90*bc201841SOlivier Certnermust be: 91*bc201841SOlivier Certner.Dl Ao type Ac \ ⟶\ Op So uid Sc | So gid Sc 92*bc201841SOlivier Certneri.e., one of the literal strings 93*bc201841SOlivier Certner.Ql uid 94*bc201841SOlivier Certneror 95*bc201841SOlivier Certner.Ql gid . 96*bc201841SOlivier Certner.Li Aq id 97*bc201841SOlivier Certnermust be the numerical ID of a user or group, and is matched with the current 98*bc201841SOlivier Certnerprocess real ID of the corresponding type. 99*bc201841SOlivier Certner.Ss Rule's Ao to Ac Part 100*bc201841SOlivier CertnerThe second part of a rule, 101*bc201841SOlivier Certner.Li Aq to , 102*bc201841SOlivier Certneris a comma-separated 103*bc201841SOlivier Certner.Pq Ql "," 104*bc201841SOlivier Certnernon-empty list of target clauses: 105*bc201841SOlivier Certner.Dl Ao to Ac \ ⟶\ Ao target_clause Ac Oo So "," Sc Ao target_clause Ac Oc Ns * 106*bc201841SOlivier CertnerTarget clauses of a given rule also form a disjunction, i.e., the IDs they 107*bc201841SOlivier Certnerspecify are alternatives for the target credentials, except in some cases 108*bc201841SOlivier Certnerdescribed below. 109*bc201841SOlivier Certner.Pp 110*bc201841SOlivier CertnerThe next subsections describe the syntax of target clauses, the defaults that 111*bc201841SOlivier Certnerapply and the principle of non-redundancy and non-contradiction in each rule's 112*bc201841SOlivier Certner.Li Aq to 113*bc201841SOlivier Certnerpart. 114*bc201841SOlivier Certner.Ss Target Clauses 115*bc201841SOlivier CertnerA target clause in a rule's 116*bc201841SOlivier Certner.Li Aq to 117*bc201841SOlivier Certnerpart must be of one of the following forms: 118*bc201841SOlivier Certner.Dl Ao target_clause Ac \ ⟶\ So any Sc 119*bc201841SOlivier Certner.Dl Ao target_clause Ac \ ⟶\ Ao flags Ac Ao type Ac So = Sc Ao id Ac 120*bc201841SOlivier CertnerThe first form is a compact way to specify that any target credentials are 121*bc201841SOlivier Certnerallowed. 122*bc201841SOlivier CertnerThe second form is similar to that of 123*bc201841SOlivier Certner.Li Aq from 124*bc201841SOlivier Certnerclauses, with the following extensions: 125*bc201841SOlivier Certner.Bl -bullet -compact 126*bc201841SOlivier Certner.It 127*bc201841SOlivier Certner.Li Aq id 128*bc201841SOlivier Certnermay also be a literal 129*bc201841SOlivier Certner.Ql * 130*bc201841SOlivier Certneror 131*bc201841SOlivier Certner.Ql any 132*bc201841SOlivier Certneror 133*bc201841SOlivier Certner.Ql "." . 134*bc201841SOlivier Certner.Ql * 135*bc201841SOlivier Certnerand 136*bc201841SOlivier Certner.Ql any 137*bc201841SOlivier Certnerboth designate any ID for the specified 138*bc201841SOlivier Certner.Li Aq type , 139*bc201841SOlivier Certnerand are treated identically. 140*bc201841SOlivier Certner.Ql "." 141*bc201841SOlivier Certnerdesignates the process' current IDs for the specified 142*bc201841SOlivier Certner.Li Aq type , 143*bc201841SOlivier Certneras explained below. 144*bc201841SOlivier Certner.It 145*bc201841SOlivier Certner.Li Aq flags 146*bc201841SOlivier Certnermay contain at most one of the 147*bc201841SOlivier Certner.Ql + , 148*bc201841SOlivier Certner.Ql - 149*bc201841SOlivier Certnerand 150*bc201841SOlivier Certner.Ql "!" 151*bc201841SOlivier Certnercharacters, and may be non-empty only when 152*bc201841SOlivier Certner.Li Aq type 153*bc201841SOlivier Certneris 154*bc201841SOlivier Certner.Ql gid . 155*bc201841SOlivier CertnerAdditionally, if 156*bc201841SOlivier Certner.Li Aq id 157*bc201841SOlivier Certneris 158*bc201841SOlivier Certner.Ql * 159*bc201841SOlivier Certneror 160*bc201841SOlivier Certner.Ql any , 161*bc201841SOlivier Certneronly the 162*bc201841SOlivier Certner.Ql + 163*bc201841SOlivier Certnerflag may appear. 1648aac90f1SBaptiste Daroussin.El 1658aac90f1SBaptiste Daroussin.Pp 166*bc201841SOlivier CertnerFor target clauses of 167*bc201841SOlivier Certner.Ql gid 168*bc201841SOlivier Certnertype, an absence of flag indicates that the specified group ID is allowed as the 169*bc201841SOlivier Certnerreal, effective and/or saved group IDs 170*bc201841SOlivier Certner.Pq the Do primary Dc groups . 171*bc201841SOlivier CertnerConversely, the presence of any allowed flag indicates that the specification 172*bc201841SOlivier Certnerconcerns supplementary groups. 173*bc201841SOlivier CertnerEach flag has a specific meaning: 174*bc201841SOlivier Certner.Bl -bullet -compact 175*bc201841SOlivier Certner.It 176*bc201841SOlivier Certner.Ql + 177*bc201841SOlivier Certnerindicates that the group ID is allowed as a supplementary group. 178*bc201841SOlivier Certner.It 179*bc201841SOlivier Certner.Ql "!" 180*bc201841SOlivier Certnerindicates that the group ID is mandatory, i.e., it must be listed in the 181*bc201841SOlivier Certnersupplementary groups. 182*bc201841SOlivier Certner.It 183*bc201841SOlivier Certner.Ql - 184*bc201841SOlivier Certnerindicates that the group ID must not be listed in the supplementary groups. 185*bc201841SOlivier Certner.El 186*bc201841SOlivier CertnerA specification with 187*bc201841SOlivier Certner.Ql - 188*bc201841SOlivier Certneris only useful in conjunction with a 189*bc201841SOlivier Certner.Ql + Ns 190*bc201841SOlivier Certner-tagged specification where only one of them has 191*bc201841SOlivier Certner.Ql "." 192*bc201841SOlivier Certneras its 193*bc201841SOlivier Certner.Li Aq id . 194*bc201841SOlivier CertnerTarget clauses having the 195*bc201841SOlivier Certner.Ql "!" 196*bc201841SOlivier Certneror 197*bc201841SOlivier Certner.Ql - 198*bc201841SOlivier Certnerflag are 199*bc201841SOlivier Certner.Dq forcing 200*bc201841SOlivier Certnerclauses, and as such do not take part in the disjunction of the other 201*bc201841SOlivier Certnertarget clauses but rather unconditionally apply in their rule. 202*bc201841SOlivier Certner.Pp 203*bc201841SOlivier Certner.Ql "." 204*bc201841SOlivier Certneris a placeholder for IDs that the calling process already has on privilege 205*bc201841SOlivier Certnercheck. 206*bc201841SOlivier CertnerFor type 207*bc201841SOlivier Certner.Ql uid , 208*bc201841SOlivier Certnerit designates any of the process' real, effective or 209*bc201841SOlivier Certnersaved user IDs. 210*bc201841SOlivier CertnerFor type 211*bc201841SOlivier Certner.Ql gid , 212*bc201841SOlivier Certnerits effect depends on whether flags are present. 213*bc201841SOlivier CertnerIf none is present, it designates any of the process' real, effective or saved 214*bc201841SOlivier Certnergroup IDs. 215*bc201841SOlivier CertnerIf one is present, it designates any of the process' supplementary groups. 216*bc201841SOlivier Certner.Ss Defaults for the Ao to Ac Part 217*bc201841SOlivier CertnerIf the 218*bc201841SOlivier Certner.Li Aq to 219*bc201841SOlivier Certnerpart does not list a target clause with type 220*bc201841SOlivier Certner.Ql uid , 221*bc201841SOlivier Certnerany of the current user IDs of the calling process is accepted. 222*bc201841SOlivier CertnerIn other words, in this case, 223*bc201841SOlivier Certner.Nm 224*bc201841SOlivier Certnerbehaves as if a target clause of: 225*bc201841SOlivier Certner.Dl uid=. 226*bc201841SOlivier Certnerhad been listed. 227*bc201841SOlivier Certner.Pp 228*bc201841SOlivier CertnerSimilarly, if the 229*bc201841SOlivier Certner.Li Aq to 230*bc201841SOlivier Certnerpart does not list a target clause with type 231*bc201841SOlivier Certner.Ql gid , 232*bc201841SOlivier Certnerall the groups of the calling process are assumed to be required. 233*bc201841SOlivier CertnerMore precisely, each of the desired real, effective and saved group IDs must be 234*bc201841SOlivier Certnerone of the current real, effective or saved group ID, and all supplementary 235*bc201841SOlivier Certnergroups must be the same as those that are current. 236*bc201841SOlivier CertnerIt is as if the 237*bc201841SOlivier Certner.Li Aq to 238*bc201841SOlivier Certnerpart had contained the following two clauses: 239*bc201841SOlivier Certner.Dl gid=.,!gid=. 240*bc201841SOlivier Certner.Ss Non-Redundancy and Non-Contradiction in a Ao to Ac Part 241*bc201841SOlivier CertnerNo two target clauses of a single rule may express the exact same logical intent 242*bc201841SOlivier Certnernor contradictory ones. 243*bc201841SOlivier Certner.Pp 244*bc201841SOlivier CertnerIn practice, no two clauses may display the same ID except for group IDs but 245*bc201841SOlivier Certneronly if, each time the same ID appears, it does so with a different flag, or no 246*bc201841SOlivier Certnerflags only once. 247*bc201841SOlivier CertnerAdditionally, the specified flags in multiple occurences must not be 248*bc201841SOlivier Certnercontradictory. 249*bc201841SOlivier CertnerFor example, the same group ID appearing with both 250*bc201841SOlivier Certner.Ql + 251*bc201841SOlivier Certnerand 252*bc201841SOlivier Certner.Ql - 253*bc201841SOlivier Certnerwill cause rejection of the rule. 254*bc201841SOlivier Certner.Ss Parsing Specifics 255*bc201841SOlivier CertnerAny amount of whitespace is allowed around tokens of the above grammar, except 256*bc201841SOlivier Certnerthat there may be no spaces between 257*bc201841SOlivier Certner.Li Aq flags 258*bc201841SOlivier Certnerand 259*bc201841SOlivier Certner.Li Aq id 260*bc201841SOlivier Certnerin target clauses. 261*bc201841SOlivier Certner.Pp 262*bc201841SOlivier CertnerFor convenience, numerical IDs may be specified as negative integers, which are 263*bc201841SOlivier Certnerthen converted to unsigned ones as specified in the C standard for the 264*bc201841SOlivier Certner.Vt uid_t 265*bc201841SOlivier Certnerand 266*bc201841SOlivier Certner.Vt gid_t 267*bc201841SOlivier Certnertypes, which are both 64-bit unsigned integers. 268*bc201841SOlivier Certner.Sh RUNTIME CONFIGURATION 2698aac90f1SBaptiste DaroussinThe following 2708aac90f1SBaptiste Daroussin.Xr sysctl 8 271*bc201841SOlivier Certnerknobs are available: 2728aac90f1SBaptiste Daroussin.Bl -tag -width indent 2738aac90f1SBaptiste Daroussin.It Va security.mac.do.enabled 2748aac90f1SBaptiste DaroussinEnable the 2758aac90f1SBaptiste Daroussin.Nm 2768aac90f1SBaptiste Daroussinpolicy. 2778aac90f1SBaptiste Daroussin(Default: 1). 2788aac90f1SBaptiste Daroussin.It Va security.mac.do.rules 279*bc201841SOlivier CertnerThe list of credential rules, whose syntax is described in the 280*bc201841SOlivier Certner.Sx CREDENTIALS RULES 281*bc201841SOlivier Certnersection above. 282*bc201841SOlivier CertnerThis list is specific to each jail. 283*bc201841SOlivier CertnerPlease see the 284*bc201841SOlivier Certner.Sx JAIL SUPPORT 285*bc201841SOlivier Certnersection below for more details on the interaction of 286*bc201841SOlivier Certner.Nm 287*bc201841SOlivier Certnerwith jails. 288*bc201841SOlivier Certner.It Va security.mac.do.print_parse_error 289*bc201841SOlivier CertnerLogs a message on trying to set incorrect rules via the 290*bc201841SOlivier Certner.Va security.mac.do.rules 291*bc201841SOlivier Certner.Xr sysctl 8 292*bc201841SOlivier Certnerknob. 293*bc201841SOlivier Certner.El 294*bc201841SOlivier Certner.Sh JAIL SUPPORT 295*bc201841SOlivier Certner.Nm 296*bc201841SOlivier Certnersupports per-jail configuration of rules. 297*bc201841SOlivier Certner.Pp 298*bc201841SOlivier CertnerBy default, at creation, a new jail has no credentials rules, effectively 299*bc201841SOlivier Certnerdisabling 300*bc201841SOlivier Certner.Nm 301*bc201841SOlivier Certnerfor its processes. 302*bc201841SOlivier Certner.Pp 303*bc201841SOlivier CertnerThe following jail parameters are defined: 304*bc201841SOlivier Certner.Bl -tag -width indent 305*bc201841SOlivier Certner.It Va mac.do 306*bc201841SOlivier CertnerPossible values are: 307*bc201841SOlivier Certner.Bl -tag -width "'disable'" -compact 308*bc201841SOlivier Certner.It Ql enable 309*bc201841SOlivier Certner.Nm 310*bc201841SOlivier Certnerwill enforce specific credential rules in the jail. 311*bc201841SOlivier CertnerThe 312*bc201841SOlivier Certner.Va mac.do.rules 313*bc201841SOlivier Certnerjail parameter must also be set in this case. 314*bc201841SOlivier Certner.It Ql disable 315*bc201841SOlivier CertnerDisables 316*bc201841SOlivier Certner.Nm 317*bc201841SOlivier Certnerin the jail. 318*bc201841SOlivier CertnerStrictly equivalent to jail creation's default behavior and to setting the rules 319*bc201841SOlivier Certnerto an empty string. 320*bc201841SOlivier Certner.It Ql inherit 321*bc201841SOlivier CertnerThe jail's credentials rules are inherited from the jail's parent 322*bc201841SOlivier Certner.Pq which may themselves have been inherited . 323*bc201841SOlivier CertnerModified rules propagate to all children jails configured for inheritance. 324*bc201841SOlivier Certner.El 325*bc201841SOlivier Certner.It Va mac.do.rules 326*bc201841SOlivier CertnerThe credentials rules for the jail. 327*bc201841SOlivier CertnerIt is always equal to the value that can be retrieved by the 328*bc201841SOlivier Certner.Xr sysctl 8 329*bc201841SOlivier Certnerknob 330*bc201841SOlivier Certner.Va security.mac.do.rules 331*bc201841SOlivier Certnerdescribed in section 332*bc201841SOlivier Certner.Sx RUNTIME CONFIGURATION . 333*bc201841SOlivier CertnerIf set, and the jail parameter 334*bc201841SOlivier Certner.Va mac.do 335*bc201841SOlivier Certneris not so explicitly, the value of the latter will default to 336*bc201841SOlivier Certner.Ql disable 337*bc201841SOlivier Certnerif empty, else to 338*bc201841SOlivier Certner.Ql enable . 3398aac90f1SBaptiste Daroussin.El 3408aac90f1SBaptiste Daroussin.Pp 341*bc201841SOlivier CertnerEach jail must have 342*bc201841SOlivier Certner.Xr mdo 1 343*bc201841SOlivier Certnerinstalled at path 344*bc201841SOlivier Certner.Pa /usr/bin/mdo , 345*bc201841SOlivier Certneras this path is currently not configurable. 3468aac90f1SBaptiste Daroussin.Sh EXAMPLES 347*bc201841SOlivier CertnerHere are several examples of single rules matching processes having a real user 348*bc201841SOlivier CertnerID of 10001: 349*bc201841SOlivier Certner.Bl -tag -width indent 350*bc201841SOlivier Certner.It Li uid=10001:uid=10002 351*bc201841SOlivier CertnerAllows the process to switch any of its real, effective or saved user ID to 352*bc201841SOlivier Certner10002, but keeping the groups it is already in, and with the same 353*bc201841SOlivier Certnerprimary/supplementary groups split. 354*bc201841SOlivier Certner.It Li uid=10001:uid=10002,uid=10003 355*bc201841SOlivier CertnerSame as the first example, but also allows to switch to UID 10003 instead of 356*bc201841SOlivier Certner10002. 357*bc201841SOlivier Certner.It Li uid=10001:uid=10002,gid=10002 358*bc201841SOlivier CertnerSame as the first example, but the new primary groups must be set to 10002 and 359*bc201841SOlivier Certnerno supplementary groups should be set. 360*bc201841SOlivier Certner.It Li uid=10001:uid=10002,gid=10002,+gid=.\& 361*bc201841SOlivier CertnerSame as the previous example, but in addition allowing to retain any current 362*bc201841SOlivier Certnersupplementary groups. 363*bc201841SOlivier Certner.It Li uid=10001:uid=10002,gid=10002,!gid=.\& 364*bc201841SOlivier CertnerSame as the previous example, but with the additional constraint that all 365*bc201841SOlivier Certnercurrent supplementary groups must be kept. 366*bc201841SOlivier Certner.It Li uid=10001:uid=10002,gid=10002,+gid=.,-gid=10001 367*bc201841SOlivier CertnerSame as 368*bc201841SOlivier Certner.Ql uid=10001:uid=10002,gid=10002,+gid=.\& 369*bc201841SOlivier Certnerabove, but 10001 cannot be retained as a supplementary group. 370*bc201841SOlivier Certner.It Li uid=10001:uid=10002,gid=10002,+gid=.,!gid=10003 371*bc201841SOlivier CertnerSame as 372*bc201841SOlivier Certner.Ql uid=10001:uid=10002,gid=10002,+gid=.\& 373*bc201841SOlivier Certnerabove, with the additional constraint that 10003 must appear in the 374*bc201841SOlivier Certnersupplementary groups. 375*bc201841SOlivier Certner.It Li uid=10001:uid=10002,gid=*,+gid=* 376*bc201841SOlivier CertnerSame as the first example, but lifting any constraints on groups, allowing the 377*bc201841SOlivier Certnerprocess to become part of any groups it sees fit. 378*bc201841SOlivier Certner.El 3798aac90f1SBaptiste Daroussin.Pp 380*bc201841SOlivier CertnerHere are several examples of single rules matching processes having a real group 381*bc201841SOlivier CertnerID of 10001: 382*bc201841SOlivier Certner.Bl -tag -width indent 383*bc201841SOlivier Certner.It Li gid=10001:uid=0 384*bc201841SOlivier CertnerMakes 10001 a more powerful 385*bc201841SOlivier Certner.Ql wheel 386*bc201841SOlivier Certnergroup, allowing its members to switch to root without password. 387*bc201841SOlivier Certner.It Li gid=10001:gid=10002 388*bc201841SOlivier CertnerAllows the process to enter GID 10002 as a primary group, but only if 389*bc201841SOlivier Certnergiving up all its supplementary groups. 390*bc201841SOlivier Certner.It Li security.mac.do.rules=gid=10001:gid=10002,+gid=.\& 391*bc201841SOlivier CertnerSame as the previous example, but allows to retain any current supplementary 392*bc201841SOlivier Certnergroups. 393*bc201841SOlivier Certner.It Li gid=10001:gid=10002,!gid=.\& 394*bc201841SOlivier CertnerSame as the previous example, but with the additional constraint that all 395*bc201841SOlivier Certnercurrent supplementary groups must be kept. 396*bc201841SOlivier Certner.El 3978aac90f1SBaptiste Daroussin.Sh SEE ALSO 3986e1fc011SGraham Percival.Xr mdo 1 , 399*bc201841SOlivier Certner.Xr setcred 2 , 400*bc201841SOlivier Certner.Xr mac 4 , 401*bc201841SOlivier Certner.Xr jail 8 , 402*bc201841SOlivier Certner.Xr sysctl 8 403*bc201841SOlivier Certner.Sh AUTHORS 404*bc201841SOlivier Certner.An Olivier Certner Aq Mt olce@FreeBSD.org 405*bc201841SOlivier Certner.An Baptiste Daroussin Aq Mt bapt@FreeBSD.org 406*bc201841SOlivier Certner.Sh BUGS 407*bc201841SOlivier CertnerCurrently, 408*bc201841SOlivier Certner.Nm 409*bc201841SOlivier Certnerconsiders only credentials transitions requested through the 410*bc201841SOlivier Certner.Xr setcred 2 411*bc201841SOlivier Certnersystem call. 412*bc201841SOlivier CertnerThis system call was in large part created so that 413*bc201841SOlivier Certner.Nm 414*bc201841SOlivier Certnercan see whole credentials transitions to decide whether to authorize them, which 415*bc201841SOlivier Certnerthe traditional UNIX's piecewise approach of successively changing different 416*bc201841SOlivier Certnerparts of them cannot allow. 417*bc201841SOlivier Certner.Pp 418*bc201841SOlivier CertnerHowever, calls to traditional or standard credentials-changing functions can be 419*bc201841SOlivier Certnerconsidered as full transitions on their own, however limited, and as such should 420*bc201841SOlivier Certnerbe equally monitored by 421*bc201841SOlivier Certner.Nm . 422*bc201841SOlivier CertnerFuture work will lift this restriction. 423*bc201841SOlivier Certner.Sh SECURITY CONSIDERATIONS 424*bc201841SOlivier CertnerThe threat model for 425*bc201841SOlivier Certner.Nm 426*bc201841SOlivier Certneris to consider userland programs as generally untrustable to decide upon which 427*bc201841SOlivier Certnercredentials changes are acceptable. 428*bc201841SOlivier CertnerIt is in contrast with the traditional UNIX way to change credentials, in which 429*bc201841SOlivier Certnerspecialized programs are installed with the setuid bit, giving them full 430*bc201841SOlivier Certneradministrator privileges so that they are effectively able to establish new 431*bc201841SOlivier Certnerones. 432*bc201841SOlivier CertnerVulnerabilities in such credentials-changing programs can have catastrophic 433*bc201841SOlivier Certnerconsequences on the integrity of the system. 434*bc201841SOlivier Certner.Pp 435*bc201841SOlivier CertnerConsequently, 436*bc201841SOlivier Certner.Nm 437*bc201841SOlivier Certnerdoes not rely on companion userland programs to decide whether some credentials 438*bc201841SOlivier Certnertransition is acceptable. 439*bc201841SOlivier CertnerInstead, it maintains its own configuration independently from the userland 440*bc201841SOlivier Certnerpassword and group databases. 441*bc201841SOlivier CertnerEstablishing this configuration currently itself relies on userland programs 442*bc201841SOlivier Certnerissuing calls to 443*bc201841SOlivier Certner.Xr sysctl 3 444*bc201841SOlivier Certneror 445*bc201841SOlivier Certner.Xr jail 2 . 446*bc201841SOlivier CertnerIt should thus be established near system boot or jail start, before any 447*bc201841SOlivier Certnerpossible attacks could happen on the system, and further measures should be 448*bc201841SOlivier Certnertaken to ensure that potential corruptions does not affect the configuration in 449*bc201841SOlivier Certnersubsequent restarts, such as re-establishing pristine state or ensuring that the 450*bc201841SOlivier Certnerboot procedure up to the configuration of 451*bc201841SOlivier Certner.Nm 452*bc201841SOlivier Certnercan be trusted. 453