SD Core for Linux LC2.0-0

Other hardening

The catalog and pcode locks, the logs, line endings, and the rest of the smaller changes.

Everything on this page is a change you may notice while testing, grouped by what it touches. The identity model and the file permissions are on Security; this is the remainder.

The global catalog#

Adding to or removing from the system-wide catalog requires SDSYS, whichever way you ask for it.

This matters because the system-wide catalog holds the programs SD runs for everybody, $login among them. Replacing one runs your code in every session on the machine, SDSYS included; deleting one stops everybody signing in.

Nothing changes for local and private cataloging, which is what programmers use day to day:

catalog bp myprog          private catalog, this account
catalog bp myprog local    this account's VOC

Both still work, in any account you are allowed to logto into. The only thing an ordinary user cannot do is catalog a program whose name starts with !, _ or $ — those characters mean system-wide. Name it without one.

To catalog system-wide you need to be SDSYS — logged in to the machine locally, as sdsys. There is no other route in to try instead.

The pcode library#

/usr/local/sdsys/bin holds the pcode library — the interpreter itself, which SD loads into shared memory at start-up and every session then runs.

It is readable by SD users and writable only by root (from 2.0-0; it was SDSYS's before, see The files root runs in the Administrator set). Nothing needs to write it after an install — only the process that starts SD reads it, and sd -start already runs privileged (see Running SD).

Scheduled jobs#

A cron job or systemd timer can run an SD command without SDSYS rights, and only the commands an administrator has named for it. The permit list is the SDSYS file batch.jobs, locked read-only to SD users (sdsys:sdusers 750).

It has its own page: Scheduled jobs.

The logs#

There are two SD keeps itself, and they are not interchangeable.

File Where For
audit /usr/local/sdsys who did what — logins, refusals, logto, account grants. See Security and the operating system
errlog /usr/local/sdsys diagnostics

A third place is worth checking, and it is not a file SD writes at all: journalctl. API connections and sd-elevate's own actions go to syslog (syslog(3), logger), not to errlog. Filter by tag:

journalctl -t sd-elevate
journalctl SYSLOG_IDENTIFIER=sdlnxd

sd-elevate keeps no separate log file of its own. What records its work: a logger line for some of its actions (for example when an account's own SD password is set), the SD-level audit trail for account creation/deletion/grants (which sd-elevate performs on SD's behalf), and sudo's own logging of every invocation it authorizes (journalctl _COMM=sudo, or /var/log/auth.log depending on the distribution's syslog configuration) — which is where to look for "the account was not created — what actually happened".

API connections in the journal#

Every accepted API connection is logged with the address and port it came from:

sd_Log[115214]: API connection over TCP from 203.0.113.4 port 51322 (SD login required)

or, over the Unix socket used for a local connection:

sd_Log[115214]: Connection over Unix socket /run/sd/api.sock from uid 1000 (fred)

Nothing is refused on the strength of it. This records who connected; it does not decide who may. The API's own checks are unchanged.

A connection forwarded over ssh shows the tunnel's own endpoint, not the person at the far end: the tunnel genuinely does terminate on this machine, so the line cannot name a remote person.

This matters beyond the log. A tunnelled connection arrives from 127.0.0.1 because it really does start here, and SD treats that as this computer. SDSYS over the API is not admitted from a loopback address, so a tunnel cannot carry SDSYS's login in; the address list of remote.sdsys api on is consulted only for connections from other computers, and listing 127.0.0.1 does not change that. Keep the door shut (remote.sdsys api off) unless you need it, and turn port forwarding off in sshd_config if you do not want tunnels at all.

Listed users are a third way to SDSYS, and it is off as delivered. The administrator can list Linux users (local.sdsys ssh add, local.sdsys api add) who may become SDSYS from this computer with SDSYS's SD password. Both lists are empty until someone lists a name. List only your own administrator login, and check with local.sdsys that the lists say what you expect.

Line endings#

Directory files exist so you can edit their records with an ordinary text editor, and a file that started life on a Windows machine — a CSV saved from Excel, a record pasted from Notepad — may still carry CR+LF line endings. SD reads either ending correctly: only the CR+LF pair that ends a line is treated as a line ending, so a bare CR that happens to be data is left exactly as it is.

What SD itself writes follows the platform's own convention, LF only, for writeseq/writecsv output, como-captured output and the error log. SD's CSV statements are documented as following RFC 4180, which technically asks for CR+LF — if you need output another program expects to be CR+LF-terminated, check that program's own tolerance for LF-only lines rather than assume SD supplies the pair.

Dynamic files are unaffected — they are stored in SD's own format and are not readable by other programs.

The terminal#

The default terminal type is linux. term on its own should report your session's actual TERM — over ssh, whatever your client sent; locally, whatever the terminal emulator or console set.

25 definitions ship, compiling to 36 terminal names — the extra names are variants such as vt100-w — so term wyse60 still works. (The -at types of AccuTerm and SDTerm's sdterm were removed: SD does not support those terminal programs.)

A name that is not installed is refused and your current type is kept — "Unrecognized terminal name" — so a typo costs you nothing. term with no argument reports the type actually in force, which is how to check.

Watch for near-misses all the same. There is no vt320 definition; vt220 or xterm does the same job. terminfo.src ships with SD, so sdtic can add a definition that is not there.

Backspace works, at the prompt and when you are asked for a password.

The page is 140 × 43, not 80 × 24#

SD's default terminal size is 140 columns by 43 lines. A terminal narrower than that makes wide reports look wrapped or truncated, which reads as a formatting bug and is not one. SD's own full-screen programs (sed, ced, ide, the home screen) want at least 140 columns by 43 lines and refuse a smaller window.

term reports the size in force, above the Device line:

:term
Page width: 140
Page depth: 43
Device    : linux

The size is worked out at login, in this order: the LINES and COLUMNS environment variables if they are numeric, otherwise the terminfo entry's lines and cols, otherwise 43 and 140 — then raised to a minimum of 10 × 20 if smaller. So a console or ssh session normally gets its real window size and 140 × 43 is the fallback when nothing answers, which is the case for a phantom or a piped script.

term default restores it, and it prints nothing when it does. It sets the same 140 × 43 the login path falls back to and returns silently, so run a bare term after it to see the result. term 120,36 does the same by hand for the old size.

Running SD#

The unit sd.service, sdclient.socket
After an unclean shutdown SD starts anyway, once the daemon's own liveness — not just the segment's presence — is checked. See Running SD
Nested sessions SD will not start a second time inside itself — see Running SD
sd <command> needs SDSYS, or an entry in batch.jobs — see above
End of piped input ends the session — at the command prompt, at PAUSE and at the Ctrl-R search

Setting no password#

An SD password only ever matters for the API. An account with none set still works normally at the console and over ssh — Linux has already authenticated it — but has no way to authenticate an API connection, so a client trying to reach it there is refused as if the password were simply wrong. You can still choose one at any time; modify.password asks again whenever you run it.