SD Core Solo for Windows WS2.0-0

SDNet - Files on Another SD Server

Open a file that lives on another SD server and use it with READ, WRITE, SELECT and LIST; what the administrator turns on, and what stays off.

Read this first. SDNet lets a program open a file on another SD server through an ordinary OPEN and then use it with the ordinary file statements. In SD Core Solo for Windows it is delivered off, in four places: the account has no NET gate, no server is defined, nobody has a login on one, and no VOC entry points at one. The administrator turns each on, deliberately, and each can be turned off again. Solo is a client of SDNet here, and it is also a target:

Solo reaches a server (Solo to Core, Solo to Solo) limited: a program may read, select and query the remote files and their indices; and, only for a server the administrator defined write, write, delete and lock, and administer a file where the other machine allows it (the next page). Nothing else crosses: no other commands, no programs, no operating system paths.
A SD Core server reaches Solo through Solo's API login, as any API client does; see API access in the GettingStarted set for what that login gives and for API request 29. A session signed in with the global password (managed mode) may also administer the account's files; one signed in with the account password may not.

Commands are shown here in lower case. Italics mark something you supply.

What has to be true before a program can open a remote file#

All of these, checked in this order, before anything is dialled:

  1. The account has the NET gate. set.net.access on (the administrator, after admin). The gate is off as delivered and a blank or missing field is off. It is the same gate that lets an API client open a file here with request 29.
  2. A server is defined with set.server, by the administrator, and the account is named in the definition's accounts list (Solo has one account, sduser, so that is accounts sduser).
  3. There is a stored login for that server: set.netlogin.
  4. The key the server presents is the one the definition pins. A server that presents another key is sent nothing at all.
  5. A VOC entry names the file: a record whose field 1 is N, field 2 the server's name and field 3 the file's name on that server. The administrator writes it (it is a VOC record).

The administrator is exempt from the gate and from the accounts list. Every other check applies to it.

Defining a server: set.server, list.servers, delete.server#

set.server name host port account {pin | connect} {read | write} {accounts a,b,c} {no.query}
list.servers {name}
delete.server name

The three are the administrator's: each stops with "Command requires administrator privileges" for anyone else. A definition is one line of a file, netservers, in the SD system folder: the name, the host, the port, the account to enter on the remote server, the hash of the server's public key (the pin), the mode, the accounts that may use it and the date. The file never holds a secret, and it is readable by whoever can read that folder.

field rule
name a lower case letter, then up to 15 lower case letters or digits (upper case is converted)
host a DNS name, an IPv4 address or an IPv6 literal; no one but the administrator ever chooses a host
port 1 to 65535, the port of the other server's API: 4247 for SD Core, 4249 for a Solo
account the account to enter on the remote server (1 to 32 letters, digits, . _ -)
pin exactly 64 hexadecimal digits, or the word connect (below)
read / write what a program may do with the server's files. read unless you say write
accounts the accounts here that may use the server. Left out, none may: the definition says so when it is made

A definition that is wrong is refused with a message of its own for each field, and nothing is written. At most ten servers can be defined. Replacing a name asks first; no.query skips that question and never the key question below.

The pin is the hash of the server's public key (its SubjectPublicKeyInfo), not of its certificate, so a certificate renewed over the same key keeps it. Two ways to get it:

Each of the three verbs writes a line in the audit trail (set.server name=..., delete.server name=...), which never carries the pin.

Your login on a server: set.netlogin and delete.netlogin#

set.netlogin server
delete.netlogin server

set.netlogin asks for the user name and the password you have on the remote server (the password is typed hidden), runs the SCRAM-SHA-256 exchange with that server once, and keeps the values derived from the password: the salt and the iteration count the server gave, the ClientKey and the ServerKey. That is enough to log in later and not enough to learn the password or try it anywhere else. The password is never stored, printed, logged, audited or written; it is held in one variable and spent on the derivation.

delete.netlogin removes it. Both write an audit line (set.netlogin server=... remote=..., delete.netlogin server=...), with no password, key or hash in it.

The VOC pointer#

N
nfa
customers

A VOC record with N in field 1, the server's name in field 2 and the file's name on that server in field 3 (lower case; up to 63 letters, digits and . _ - $). Opening it, open 'customers' to f, gives a file variable that these statements work on: read, matread, readv, select, selectv, sselect, readnext, fileinfo (type 7), close, and getlocks(). open 'dict', 'customers' to d opens the dictionary of the remote file from the same server, so list, count, sort, select, list.item and list dict work on the VOC name. A select takes every record id of the remote file in one reply; each record a query then needs is one request, so a query that reads every record of a big file costs one round trip per record.

A pointer someone wrote for themselves gives them nothing they were not granted: the gate, the list, the login and the pin are asked every time, an $internal program included.

Writing and locking: a server defined write#

For a server defined write, a file opened through it also takes write, writeu, matwrite, writev, writevu, delete, deleteu, clearfile, readu and the other locking reads, recordlocku, recordlockl, release, filelock and fileunlock, and recordlocked() asks the server. A lock is the server's: it is held there, for this session, and release or a close or the end of the process gives it up. A statement that changes or locks a file of a server defined read is refused with message 12506 (or sets status() under on error) and nothing is sent.

recordlocked(f, id) needs the same two things as a lock: the server must be defined write here, and the login on the other machine must be allowed to ask. A read definition stops the program with message 12506 (recordlocked is refused) and nothing is sent; the function has no on error clause, so a refusal always stops the program. A SD Core server answers request 34, the one recordlocked() sends, only to a login that is in its write group; to any other it replies with an error, and the program stops with message 12505 and that machine's words, which end (request 34). The answer names the holder of the lock by his user number on the other machine, which is why a login that can only read is not given it. Inside begin transaction it still works for a write definition, because it changes nothing. getlocks() of a remote file is the local view only.

Continued in#

SDNet - Administering a Remote File — administering a remote file, its indices, the two waits, what is audited and what is not here