SD Core for Linux LC2.0-0

The Master Files: The Group and the Modes

Who is in the group, and what the files must say.

This page continues run.in.

Who is in the group, and what the files must say#

A write into an account (an edit, a delete or a compile from tool.entries, a save in the editor it opens) needs the sdsys user in the account's group and the account's files writable by that group. As delivered both are arranged for a user account (see below). The state is the Linux group membership, as it is for ssh and the API (sdssh, sdapi); nothing is written to the register, and there is no row for it in the gate matrix (tool.gates).

modify.account name sdsys-on and sdsys-off (a user account only; a group account has no group of its own for the sdsys user and is refused: it owns the files of a group account, so it needs nothing):

modify.account acme sdsys-on
modify.account acme sdsys-off

What is expected to stop working when an account is off. An edit, delete or compile from tool.entries into it. So is SDSYS writing inside the account in any other way: logto the account and make a file, edit a program, catalog; an interactive update.accounts for it (update.accounts all skips such an account and says so, see Account maintenance); sd -aaccount from the operating system. (The installer's own update.accounts all runs as root and is not affected.) create.account, delete.account, backup.account, restore.account, and reading the account (logto and a listing, tool.entries' lists) are done by the root helper or only read the files, and are expected to work. Before 2.0-0 that general write was there for every account, because the membership was; switch the account on for the time SDSYS needs to work inside it.

A new user account gets its group sdu_name from create.account with root and the user as members, and create.account then puts the sdsys user in it (sd-elevate sdsys-join; if that fails the account is still made, and the message says so and names the repair, modify.accountnamesdsys-on). A group account is made with root and sdsys in its group sdg_name and is owned by sdsys, so it needs nothing. delete.account needs nothing: the group goes with the account.

The install and every upgrade make one decision, once: they put the sdsys user in the group of every registered user account that does not list it - an sdu_name group whose account the register holds, with that same group on its record - and make that account's VOC and dictionaries group-writable at the account's registered place (sd-elevate sdsys-join, then group-write). There is no question. An sdu_ group that no registered account owns is left alone and named in one line (Left alone, no registered SD account owns them: ...). Each account joined is printed (the sdsys user is now in the group sdu_acme), and then the installer writes the marker /home/sd/$sdsys.access, so that the administrator's later sdsys-off or sdsys-on stands: with the marker present the installer does not touch a group. If a join or a repair the helper was asked to make failed, the install warns (with the command that repairs it, modify.account <account> sdsys-on), goes on, and does not write the marker: running the installer again tries again. An account registered outside /home/sd/user_accounts and /home/sd/group_accounts, with no path, or at a path that does not exist is joined but its modes are not repaired (the helper repairs only those two places); it is named, with the reason, in a warning of its own, and does not hold back the marker - set its modes by hand (chmod g+rw, setgid on the directories). The marker is in /home/sd, not in the sdsys directory, because deletesdcore.sh removes the sdsys directory in every cycle and would lose it; /home/sd is kept with the accounts and removed with them. (Only groups named sdu_name are looked at; sdusers and a group account's group never are.)

Three sd-elevate verbs do the work, each confined, and none is more than modify.account and the install need. Each leaves a line in the system log (logger -t sd-elevate) after it has changed something:

sd-elevate does refuses
sdsys-join sdu_name puts the user sdsys, and no other user, in that group (usermod -aG: it adds, it never replaces) any group that is not sdu_user of an SD user who exists (not sdusers, not a route group, not sdg_, not sdu_root, not sdu_sdsys), a group that does not exist
sdsys-leave sdu_name takes the user sdsys, and no other user, out of that group (gpasswd -d sdsys: it removes that one membership and no other); a group that does not list sdsys is answered sdsys is not in sdu_name with exit 0 and left as it is the same groups as sdsys-join, and the same user part; the user is written in the helper, never an argument and never taken from the environment
group-write account directory gives the account's own group write on its VOC and its dictionaries (g+rwx and setgid on the directories, g+rw on the files in them) an account directory that is not a direct child of user_accounts or group_accounts, or whose group is not sdu_name (sdg_name for a group account): never sdusers, which every account is in

sdsys-join and sdsys-leave change one membership of one user and nothing else. group-write changes modes only, never owners or groups. It works on file descriptors opened without following links, so a link a user plants in the tree cannot make root change another file; it changes only what has the account directory's owner (or sdsys) and the account's own group, leaves the other bits as they are, and does not leave the account directory's filesystem. It says what it did, and a second run changes nothing.

The modes of what SD makes#

Every session in an ordinary account starts with a umask of 002 (022 in the SDSYS account), so a VOC or a dictionary made in the ordinary way is already group-writable (664 files, 775 directories). A user who changes the umask (the umask verb) would make them closed, so SD gives a VOC or a dictionary that it has just made its group's write bit, whatever the umask: the directory g+rwx and setgid, %0 and %1 g+rw. It does so only where the account's own directory lets that group write (if the directory is 755, nothing is added: a group that cannot write the account directory is not given the VOC), and only where the sdsys user is in that group (from 2.0-0: where the account is off, group write on a new VOC or dictionary would serve nobody, and nothing is forced), only to what the session itself has just made, and it adds group bits and takes nothing away. The data file next to a dictionary is not touched. A VOC or dictionary that arrives some other way (restore.account, a copy at the operating system level) keeps the modes it came with: modify.account name sdsys-on (sd-elevate group-write) puts them right, the ones made while the account was off included.

Accounts being made, restored and deleted#

What it does not do#

What went with the copies#

SD keeps no copies in the SDSYS account, because tool.entries edits the real records. A system that had them (a development build) loses:

What did not go: the sdsys user's membership of the account groups and its two verbs, the group write of a new VOC or dictionary, run.in, and the edit gates.