SD Core for Windows WC2.0-0

Installation and the service

What the installer puts on the machine, what an upgrade replaces, and how the service behaves.

This page covers the parts of installation an administrator has to live with afterwards: the groups and permissions the installer creates, the service, and what an upgrade does and does not touch.

This document is separate so that it can be withheld. It links to nothing outside the administrator set. Where a page in another set is worth naming, it is named in words.

The wizard itself — the pages, the tick boxes and their defaults — is covered in the SD Core for Windows release documentation, under Installing SD Core, and is not repeated here.

Two things to know before the first install#

SD cannot be installed silently. /SILENT and /VERYSILENT are refused with a message rather than ignored.

The reason is the password. Installing ends by asking for one, and an unattended install has nobody to ask — it would finish with no password on any account, and an account without a password cannot be used at all: not at the keyboard, not over ssh, and not through the API. A /NOPASSWORD escape was written and then removed, on the grounds that a switch buying a credential-less system is a switch somebody will paste from a forum.

Remote Desktop is not unattended and is unaffected. The wizard runs and a person answers it.

The installer refuses to start on a machine with an ssh server it does not own. It changes nothing and tells you what it found. Three cases:

The check runs before the wizard is drawn, so a refusal costs nothing. Remove the other server, or put the ssh configuration back the way Windows shipped it, and run the installer again.

This is why SD can make promises about ssh behavior at all: it configures the server so that SD sessions land inside SD and cannot reach a command prompt, and it can only promise that about a server it installed and configured itself.

What lands where#

What Where
Binaries, and the MSYS2 DLLs beside them C:\Program Files\SD\usr\bin\
The client DLLs, for applications C:\Program Files\SD\usr\clients\
The installed PowerShell scripts C:\Program Files\SD\
The changelog C:\Program Files\SD\changelog
Configuration C:\ProgramData\SD\sd.conf
The SDSYS account C:\ProgramData\SD\sdsys\
User accounts C:\ProgramData\SD\user_accounts\
Group accounts C:\ProgramData\SD\group_accounts\
Shared memory C:\ProgramData\SD\shm\

Neither root can be changed. The installer does not ask.

Do not move the binaries. usr\bin is load-bearing. Shipping msys-2.0.dll beside the executable relocates the POSIX root to the DLL's directory minus two components, so moving them moves SD's idea of the file system.

The client DLLs are the one thing under Program Files meant to be copied elsewhere. usr\clients\client64\ holds the 64-bit pair, for applications that link against SD; there is no 32-bit client. The pair also appears in usr\bin, and that copy is the server's own — a local client connection resolves sd.exe beside the DLL, so only a copy sitting next to sd.exe can make one.

What the installer creates#

sdusers group grants access to the files under C:\ProgramData\SD
sdsshonly group carries the deny rights that confine an account to ssh
sdu_<name> one group per account, created by create.account
The service SD Core for Windows, automatic start
ACLs inheritance broken on C:\ProgramData\SD, access granted narrowly

Group membership is carried in a Windows logon token, which is issued at sign-in. An administrator added to sdusers while signed in does not have it until they sign out and back in, and until then cannot read the data tree at all. The symptom looks like a broken install and is not one.

The service#

Display name SD Core for Windows
Service name SD
Start type automatic — Windows starts it at every boot
Starting Start-Service SD, or sd -start
Stopping Stop-Service SD, or sd -stop
Created by the installer
Removed by the uninstaller

Stopping the service ends every session on the machine, without asking. It signals every entry in the user table and has no "are users logged in" check, so treat it as a machine-wide action rather than an administrative convenience. A session waiting at its prompt may not leave on that signal, so ten seconds later sd -stop (and sd -restart) ends every SD process still running with SIGKILL and says how many it ended, for example 1 process(es) still running after ten seconds were ended with SIGKILL. A process whose program is not in SD's own folder is not touched. A session ended this way does not run its own logout.

After an unclean shutdown#

A shared memory segment left behind by an abrupt stop survives a reboot on Windows. SD discards it and starts normally, saying so:

Discarding the shared segment left by the previous boot -
SD did not shut down cleanly.

SD Core for Windows has shared memory and semaphores of its own#

The shared memory and semaphores every SD session uses once had the same names as upstream SD's. They now have names of their own, different from upstream SD's and from each other SD Core product's, so SD Core for Windows can run beside either. The installer stops SD before an upgrade, as it always did, and that matters more now: an SD left running from the old version could not be stopped by the new one, because the two no longer share a name.

Rights SD relies on, and checks#

SD trusts a program in its global catalog (C:\ProgramData\SD\sdsys\gcat) to run as part of the system, because only administrators can write there: the installer gives sdusers read and execute on the folder and nothing more, and every file in it inherits that. The kernel therefore refuses to load a global catalog object that other users can write - that is, one whose access list gives a right to write, append, delete, or change its permissions or owner to Everyone, Authenticated Users, Interactive, Users or sdusers - and stops with <name> in the global catalog can be written by other users, so it was not loaded. An installation never meets the check. If you see the message, someone changed the file's rights: icacls the file named back to the folder's rights (icacls <file> /reset), and look for why. A file whose rights cannot be read is refused too.

SD's shared memory (the file under C:\ProgramData\SD\shm) and its semaphores can be reached by sdusers, SYSTEM and the Administrators only. A member of sdusers can still write the shared memory, because every SD session must, so nothing a session or the daemon decides on is read from it. In particular the daemon, sdwind, which runs as SYSTEM, takes the system directory from the SDSYS= line of sd.conf, not from the shared memory, and does not start without that line.

The audit trail (C:\ProgramData\SD\sdsys\audit) lets the SD users group add to the end of the file and nothing else: an ordinary user cannot read it, overwrite a line, rename it or delete it. A session sends each record to the SD service (sdsvc.exe, which runs as LocalSystem) over the named pipe \\.\pipe\sd-audit, and the service writes the line. The user= and the pid= on the line are the ones Windows reports for the sending process, not anything in the record's text, so no one can make a line that names someone else; the text of a record comes after them, and the uid= is the SD user number the sender gave, which the service cannot check. If the service is not running a session appends to the file itself, and such a line's user= is the name the session gives. One user cannot flood the trail. The service takes at most 600 records from one Windows user in any 60 seconds and drops the rest; when that user's minute is over it writes one line saying how many were dropped. The figure is fixed when SD is built, not a setting. The service rotates the file: at one megabyte it renames it to audit.yyyymmdd-hhmmss and starts a new one with the same permissions, with no restart of SD. SD deletes nothing; pruning the old files is yours. The Audit Trail has the rest.

What this does not close#

The lock table, the file table and the user table are still in the shared memory and still writable by an SD user with a shell: such a person can release other people's locks, log other sessions out or fill the user table. That is damage and denial of service, not a way to a privilege. The gates are walls for an SD session; a person with a shell is trusted with the shared memory. Giving SD users no way to a shell, or only the forced-command ssh route, is how an installation that cannot accept that closes it.

The file $ipc. $ipc, in the system directory, is the one SD file every user's process has to write, so a member of sdusers with a shell can write it as well. It holds working records and nothing a session is configured from: the start-up records of a phantom (its command, its DATA queue and its log file name), the messages waiting for a user, the phantom register that status shows, and the tables that profiler, hsm and pstat ask another session for. A phantom does not take its command, options, DATA lines or log file from it on trust. phantom seals the records with a secret that it makes for each phantom and gives only to the new process, in its environment, which the new process copies and overwrites at once. The phantom runs, stacks and sets nothing unless the seal on what it read checks; if it does not, the phantom ends at once, says so in its como log and to its parent, and writes phantom refused to the audit trail. SD does not run, stack or set anything from the other records; they are only shown. The conversation of the phantom debugger (pdebug) is not carried in $ipc: its messages are records of a directory file in a private directory below the profile of the person who runs pdebug (AppData\Local\sd\pdebug). SD finds the profile from the person's sign-in token (never from an environment variable) and uses the directory only when every directory from the profile down is a real directory that nobody else can write and the store itself is the person's alone. A pdebug and the phantom it debugs therefore reach each other only when both run as the same Windows user, which is how they are started in practice. pdebug says it cannot start (message 12953) when the store cannot be set up.

Upgrading#

Installing a new release over an existing one replaces the shipped files and preserves everything the site owns.

Replaced Preserved
the catalog and compiled programs your accounts and their passwords
the BASIC source the private catalog
the messages and include records which Windows users are linked to which SD accounts
the VOC templates and library routines your print queue and held reports
terminfo, the license, the contributor list everything under your own accounts, and sd.conf

An upgrade asks nothing. No tasks page is shown, on the principle that the machine already carries the answers and every setting has a verb that changes it afterwards — ssh.server, remote.ssh, remote.api and append.sd.path, covered under Remote access and the machine in this set.

Two steps run for you, and both report#

Every account's VOC is refreshed. The installer runs update.accounts all, which walks every registered account so that a verb this release adds can be typed in accounts that already existed.

The dictionaries are reapplied. The definitions the release ships are added and updated, and any you added are left alone. If that step cannot run, the installer says so at the end rather than finishing quietly, and upgrade-dicts.log in C:\ProgramData\SD records what happened.

Neither step removes anything of yours. update.accounts adds and puts back only the records SD ships, and removes a record only when a release has withdrawn it and the account still holds the record SD shipped (the deletion list, in Account maintenance).

An upgrade keeps what accounts could do: sh, OS.EXECUTE and the edit switches#

An account made before the per-account switches existed has always been able to use what they now guard, so the installer carries it forward once. In the same step it runs upgrade-gates.ps1 (log: upgrade-gates.log in the data folder), which runs two programs as the administrator:

Ssh and the API are left exactly as they were. Group and other accounts are not touched. SDSYS can then take either away one account at a time with modify.account, and a later install does not turn anything back on: each program leaves a marker ($gates.done and $editgates.done) in the system directory and does nothing while it is there. Accounts created after the upgrade start with every switch off. The installer says so at the end if either program could not run, and upgrade-gates.ps1 can be run again by hand from the program folder, as an administrator, while SD Core is running.

Uninstalling#

Settings ▸ Apps, or unins000.exe.

The default does not touch your accounts, the database or the configuration. Removing the data is a separate prompt that defaults to keeping it.

The uninstaller does not remove OpenSSH. It may predate SD or be in use for something else. It does restore sshd_config, keeping the version SD wrote as sshd_config.before-sd.