--- title: Grant admin rights with RBAC profiles in users.users, and run privileged commands with pfexec area: rbac impact: HIGH tags: [rbac, pfexec, profiles, roles, user_attr, sudo, privileges] verified: 2026-11-04 --- # Grant admin rights with RBAC profiles in users.users, and run privileged commands with pfexec illumos has no wheel group, and the illumos gate ships no sudo (OpenIndiana adds one, with a sudoers file). The rights `pfexec` uses come from RBAC execution profiles: those listed for the user in `/etc/user_attr`, plus any default profiles in `/etc/security/policy.conf` (profiles(1)); authorizations, privileges and roles are further `user_attr` fields. `pfexec` runs a command with the profiles. On Solnix you declare the profiles in `users.users..profiles`. Watch out: when no profile covers a command, `pfexec` does not refuse it. It runs the command unprivileged and can still exit 0, so a script may think it ran as root when it did not. **Antipattern** ```sh usermod -aG wheel alice; visudo # Linux habits; illumos usermod has no -a, Solnix has no sudoers pfexec usermod -P "Primary Administrator" alice # on Solnix: edits this BE's user_attr, not the config pfexec some-admin-cmd && echo "ran as root" # wrong if no profile grants root ``` **The Solnix way** ```nix users.users.alice = { uid = 1001; profiles = [ "Primary Administrator" ]; # -> /etc/user_attr: alice::::type=normal;profiles=Primary Administrator }; # security.sudo.enable defaults to true: `sudo` is a wrapper over pfexec, with no sudoers and no password prompt. ``` ```sh pfexec solnix-rebuild switch --flake # # or boot (no --flake needed if /etc/nixos/flake.nix exists; # check `beadm list` first: a hand-made BE named like the next solnix-N is destroyed; ask the user); # install-be writes the declared user_attr line into the new BE only, # so reboot into it before checking (the live switch reconciles SMF only; it does not write /etc/user_attr) profiles alice # the profiles alice has (plus policy.conf defaults) pfexec id -u # 0 if a profile grants root to /usr/bin/id (Primary Administrator does); another uid: unprivileged ``` The handbook writes `pfexec` for every privileged command. Solnix's `sudo` (to root, the default target) checks `pfexec id -u` and refuses unless it prints 0, so a profile must grant root to `/usr/bin/id` for `sudo` to work. `users.users` has no option for roles, authorizations or custom `prof_attr`/`exec_attr` entries (users.nix writes `type=normal` and `profiles=` only). **The illumos way** (OpenIndiana, OmniOS, SmartOS) ```sh # as root, as in the OpenIndiana example usermod -P "Software Installation" alice # assign profiles (replaces the existing list) roleadd shutdown; passwd shutdown # a role is an account that users assume usermod -R shutdown alice # let alice assume it # OpenIndiana. On Solnix, first check the file is not a link (ls -l): install-be lays /etc from the gate's stock tree # as copies, but a root write through a link into /nix/store rewrites the store file (install-be.sh measured it). echo "SHUTDOWN:::profile to shutdown:help=shutdown.html" >> /etc/security/prof_attr echo "SHUTDOWN:suser:cmd:::/usr/sbin/shutdown:uid=0" >> /etc/security/exec_attr rolemod -P SHUTDOWN shutdown # as alice: su shutdown (roles are assumed after login, not logged into) roles alice; auths alice; profiles -l alice ``` **The difference.** The RBAC databases and `pfexec` come from the gate; per-command profiles are the open question (see Unverified) (pfexec(1) also documents the profile shells pfsh, pfcsh and pfksh; that Solnix ships them is not checked here). On Solnix, `user_attr` lines are generated for declared users and merged into the BE's file: declared names replace stock ones, and other lines stay. So for a user with declared `profiles`, the whole `user_attr` line is replaced in the next generation's BE: a hand-run `usermod -P`, `-R` (roles) or `-K` (auths, defaultpriv) is lost. Users without declared profiles get no generated line. Other hand-made lines are carried into BEs cloned from this one, but the config does not record them, and a rollback to an older BE loses them. OpenIndiana uses the stock `sudo` with a sudoers file; Solnix ships a sudo-compatible wrapper over pfexec instead. **Check.** `pfexec id -u` prints `0` for an administrator, and `profiles` lists `Primary Administrator`. If pfexec seems to do nothing, `svcs svc:/system/pfexec:default` must show `online`, because pfexec needs the pfexecd daemon. **Unverified** - Whether a per-command `exec_attr` entry (like SHUTDOWN in the illumos-way block) matches on Solnix, where `/usr/sbin` is a link into the store (install-be.sh), and whether the profile shells a role needs are installed. - Whether `/etc/security/prof_attr` and `exec_attr` are real files or links into the store on a Solnix BE. The managed-/etc list does not name them; the illumos-way block's `ls -l` check is how to tell on a given BE. **Sources** - [pfexec(1)](https://solnix.io/docs/man/pfexec.1) (illumos, CDDL), DESCRIPTION (exec_attr, user_attr order, pfexecd, svc:/system/pfexec:default) - [profiles(1)](https://solnix.io/docs/man/profiles.1), [roles(1)](https://solnix.io/docs/man/roles.1), [auths(1)](https://solnix.io/docs/man/auths.1) (illumos, CDDL), DESCRIPTION, OPTIONS -l - [user_attr(5)](https://solnix.io/docs/man/user_attr.5), [prof_attr(5)](https://solnix.io/docs/man/prof_attr.5), [exec_attr(5)](https://solnix.io/docs/man/exec_attr.5) (illumos, CDDL), entry formats; keys profiles, roles, type - [usermod(8)](https://solnix.io/docs/man/usermod.8), [roleadd(8)](https://solnix.io/docs/man/roleadd.8), [rolemod(8)](https://solnix.io/docs/man/rolemod.8) (illumos, CDDL), -P, -R - [compare: usermod(8)](https://solnix.io/docs/man/compare/usermod.8), -G replaces the group list (no -a); [compare: pfexec(1)](https://solnix.io/docs/man/compare/pfexec.1), authorization model - [modules/system/activation/install-be.sh](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/modules/system/activation/install-be.sh) (solnix 5a8e5ce), accounts merge ("stock lines stay"); /etc from the stock tree; "a root write THROUGH a link rewrites the store file" - [modules/system/activation/default.nix](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/modules/system/activation/default.nix) (solnix 5a8e5ce), `switch)`: `do_activate` (the SMF activate script only) then `do_boot` (install-be into a new BE) - [modules/config/users.nix](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/modules/config/users.nix) (solnix 5a8e5ce), options `profiles`, `extraGroups`, `uid`; `userAttrLine` - [modules/config/sudo.nix](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/modules/config/sudo.nix) and [modules/config/scripts/sudo.sh](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/modules/config/scripts/sudo.sh) (solnix 5a8e5ce), `security.sudo.enable`; the `pfexec id -u` check (measured) - [Handbook: Boot environments](https://solnix.io/docs/handbook/boot-environments#create) (site 307b67f), Create (`beadm create` clones the running BE) - [configurations/arnold.nix](https://codeberg.org/solnix/solnix/src/commit/5a8e5ce75a33086d7be4410149847bdf7501b8fc/configurations/arnold.nix) (solnix 5a8e5ce), a declared user with `profiles` - [Handbook: For Linux (and NixOS) users](https://solnix.io/docs/handbook/for-linux-users#the-differences-that-actually-bite) (site 307b67f), "`pfexec`, not `sudo`"; [Handbook: Debugging](https://solnix.io/docs/handbook/debugging#debugging) (site 307b67f), the pfexec note - [OpenIndiana handbook: System Administration](https://docs.openindiana.org/handbook/systems-administration/#roles-and-role-based-access-control) (PDL), Roles (and Role-Based Access Control), Use RBAC to enable a user to shutdown the system - [OpenIndiana handbook: Getting Started](https://docs.openindiana.org/handbook/getting-started/#quick-start-to-ips) (PDL), Quick Start to IPS (`usermod -P "Software Installation"`)