Run jobs as each OS user¶
By default, every job runs as the account that runs the website, and every file it writes belongs to that account. That is fine for a small group, but many sites want each person’s work to look like their work on disk. This page shows you how to connect a nextPYP user to an operating-system user, one person at a time, on an administrator install.
When a connected user runs a job:
The job processes run as that operating-system user, rather than the service account.
The files created by the job are owned by that user, rather than the service account.
The user’s jobs respect any resource quota system your computing center has for that user, like filesystem storage limits or SLURM resource privileges.
File sharing between users is controlled by the filesystem, rather than nextPYP configuration, so people can be prevented from reading each others’ files when browsing the filesystem directly.
Note
A regular-account install cannot do this. The website already runs as your login, and the helper and sudoers rule are only installed by a root run.
How the website becomes that user¶
Under the hood, the website needs a safe way to “become” the person who owns a project. nextPYP offers three ways to do that. You choose one for the web host and, on a cluster, one for the login nodes:
web.userSwitchchooses the method on the web host:setuidorsudo.slurm.userSwitchchooses the method on the hosts behindslurm.host:setuid,sudo, orsshkey. When it is unset, it followsweb.userSwitch.
Which account does what is tabulated on Security.
- setuid
The mode nextPYP used before the sudo backend existed, and what an install made then still uses. A per-user copy of
user-processorlives undershared/user-processors, owned by that person, with the setuid bit. The service account runs that copy and becomes the person. No sudoers rule is needed. On a cluster, login nodes use the same copies as long as they see the same shared folder.Tip
The shared data folder must not be mounted
nosuid, because the setuid bit would be ignored there. If your site forbids setuid on that filesystem, use sudo instead.- sudo (default for a new install)
No setuid files. One root-owned helper at
/usr/libexec/nextpyp/user-processoris run throughsudo -u <user>./etc/sudoers.d/nextpypallows the service account to run exactly that program as members ofweb.usersGroup(nextpyp-usersby default). The helper is not setuid, so a shared folder mountednosuidis fine. Every SLURM login node needs the same three files (the helper, the group, and the sudoers drop-in); see Request for the HPC team. Compute nodes do not.- sshkey (login nodes only)
A third option, just for the login nodes. Set
slurm.userSwitch = "sshkey". The web host stays on setuid or sudo. On the login node, SSH as the linked person runs the helper through anauthorized_keysforced command. Per-user keys live undershared/os-users/<user>/. The administration page and the user’s own account page show the line to append to that person’s~/.ssh/authorized_keys. Install the helper,/usr/libexec/nextpyp/user-processor, on each login node; the sudoers drop-in and users group are not used for this backend.
A new install writes web.userSwitch = "sudo" when PYP_USER_SWITCH is unset, and a system install sets up the helper, the nextpyp-users group and the sudo rule. An install whose config.toml has no web.userSwitch line (one made before the setting existed) uses setuid. To choose explicitly at install time:
PYP_USER_SWITCH=setuid ./install
PYP_USER_SWITCH=sudo ./install
Changed your mind later? sudo nextpyp migrate-user-switch shows what moving an existing setuid install to sudo would do, and changes nothing; --apply does it (the helper, the group, the sudo rule, each linked person, and the key), and --apply --delete also removes the old per-user helpers. --revert sets the key back to setuid while those helpers still exist. Restart the website after either.
Add each person¶
Do the first step once per mode, and the next two for every person you link.
Prepare the host for the mode you chose.
setuid. Confirm the shared data folder is not mounted
nosuid. An administrator install already createdshared/user-processorswith the right ownership. On a cluster, every login node must see that same folder.sudo. Install the helper, the group, and the sudoers drop-in on the web server and on every SLURM login node. An administrator
./installwithweb.userSwitch = "sudo"does the web server after the systemd units are in place; its transcript shows those steps as[root]lines, andsudo nextpyp doctorreports if any is missing. For login nodes that are not the web host, use Request for the HPC team, which is written to be handed to your cluster administrators.sshkey. Keep setuid or sudo on the web host. Install the helper on every login node: copy
user-processorfrom the release there and runsudo nextpyp install-login-node --helper <file> --sha256 <its line in SHA256SUMS>, or do the same three things by hand (the helper in/usr/libexec/nextpyp, thenextpyp-usersgroup, the sudo rule). Setslurm.userSwitchtosshkeywithnextpyp config setornextpyp config edit.Note
For every mode, the operating-system accounts you want to link must resolve on the web server (
id <username>works there) as well as on the login nodes, with the same UIDs. That usually means a directory service like LDAP.Let the website become that operating-system user.
While logged into the web server, run:
sudo nextpyp user-add <username>where
<username>is the operating-system user (not the nextPYP user).On a setuid install this creates
shared/user-processors/user-processor-<username>with the setuid bit, then proves the switch with--expect-uid. On a sudo install it adds the person toweb.usersGroupwhen that group is local, then runssudo -n -u <username> /usr/libexec/nextpyp/user-processor --expect-uid <uid> checkand prints any PAM or sudoers denial as sudo wrote it.Tip
If your users group lives in a directory service rather than on this machine,
user-addcan’t edit it. It leaves the group alone and tells you so. Ask your directory administrators to add the person toweb.usersGroup, then run the command again. The Admin Check button in the next step repeats the same check per login address.user-addrefuses when that person cannot open the shared data folder:ERROR: alice cannot open /data/shared., followed by the directory that stops them. Give that person access, then run it again. On a setuid install it also refuses when the helper folder is mountednosuid:ERROR: /data/shared/user-processors is mounted nosuid., because a setuid helper there would not switch users. See troubleshooting.Made a mistake?
sudo nextpyp user-remove <username>undoes the add (and on a setuid install removes their helper copy).Link the nextPYP user to the operating-system user.
In nextPYP, on the administration page, go to the “Users” tab. Pick a user you’d like to associate with an operating-system user and edit that user. In the “OS Username” box, enter the name of the operating-system username and then click Check.
If the helper is missing, has the wrong ownership, or the switch is refused, on the web server or on a login node, the check fails and the UI says which host and why. Otherwise, the check passes. For a passed check, your screen should look similar to this:
The edit user panel showing a successful
user-processorexecutable check.¶Click Save to save your changes. The association takes effect the next time that user creates a project.
Warning
Operating system user changes cannot be applied to existing projects for the user, because those files were already created under a different owner.
To break the association, remove the username from the “OS Username” box and Save. That also takes effect the next time the user creates a new project.
For sshkey on the login node, open the linked user’s account page (or the admin edit panel after the OS username is saved) and append the shown forced-command line to that person’s
~/.ssh/authorized_keyson each login host. Click Check again to verify.