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