File Sharing
Peios can share folders with Windows, Mac and Linux computers on your network. People reach a shared folder from their own computer's file manager and work with its files as if they were local, signed in with an account on the Peios machine. If you have used file sharing on Windows, this will be familiar: Peios speaks the same protocol, SMB, and uses the same model of shares, share permissions, and file permissions.
The file server is fservd, a service that peinit runs. You manage it with
the File Sharing window or the fserv command.
Shares #
A share offers one folder on this machine under a name, such as
Projects for /srv/projects. A Windows user reaches it as
\\peios-box\Projects, and a Mac or Linux user as
smb://peios-box/Projects, where peios-box is this machine's name on the
network.
A share is defined once and switched on for each protocol it is served over. SMB is the only protocol so far, and a new share is served over it unless you say otherwise. Removing a share stops offering the folder; the folder and its files stay exactly where they are.
Shares live in the registry under Machine\Software\Fservd\Shares. fservd
watches the key, so a change applies to new connections within a few
seconds, without restarting anything. People already connected keep the
share they connected to until they disconnect.
Browsing to the server, such as opening \\peios-box in File Explorer,
lists the shares the person browsing can use: fservd tries each one as
them, so nobody sees the name of a share they can't open. An administrator
can list every share to everyone instead, with Show every share in the
File Sharing window or fserv listing all. A share whose name ends in $
is never listed, but people who know its address can still open it.
Signing in #
People who connect sign in with an account this machine knows, such as a local account. The client proves it knows the account's password with NTLMv2, and fservd passes that proof to authd, which checks it against the account. fservd never sees the password. A successful sign-in creates a logon session for the person, as signing in at the console does, except that its logon type is Network.
fservd doesn't accept guest sign-ins, or the older LM and NTLMv1 proofs. Every signed-in session is signed, so a message changed on its way across the network is refused. Traffic is not encrypted, so share sensitive files only over networks you trust.
A client can sign its session in again without disconnecting, as Windows does on long-lived connections, and may switch to another account as it does. Files already open stay open with the access they were granted; everything after that is done as the new account. When a client reconnects after its network drops, it names its earlier session, and fservd closes that session's files first if it belongs to the same account, so nobody is locked out of their own files by a connection that is already gone.
Anonymous connections #
Some devices, such as scanners and media players, connect without signing
in. Every share refuses them unless you turn on Allow anonymous for it,
in the share's Network Access in the File Sharing window, or with
fserv share set <name> --anonymous on. Browsing the server anonymously
shows only the shares that allow it.
An anonymous connection acts as the Anonymous identity. It belongs to Everyone but not to Authenticated Users, and has Untrusted integrity, so it can use only files and shares that grant Everyone access, and it can't change anything labelled above Untrusted, which by default is everything. The Read-only for everyone signed in and Administrators can change; others read restrictions refuse it, since they grant signed-in people only. An anonymous session's messages are signed only if the device asks, and then with keys anyone can work out, so a message changed in transit isn't reliably detected.
Who can do what #
fservd acts as each signed-in person for every file operation: when someone opens a file through a share, the kernel checks the file's own permissions against that person's token, exactly as it would for a program they ran on this machine. A file someone couldn't read at the console, they can't read through a share either.
A share can also have its own network access, a security descriptor that limits what people can do through that share. When someone connects, fservd checks the share's network access; every file they then open is limited to what it granted. Network access only ever narrows the files' own permissions. It can make a share read-only for everyone, but it can't let anyone change a file whose permissions refuse them.
A share with no network access of its own leaves the decision to the files' permissions alone. That is the default, and it is usually what you want: the folder's permissions already say who can use the files. Add network access when the network should be more restricted than this machine, as described in Restricting Network Access.
Files in use #
When a Windows program opens a file it can say what others can do with the file while it has it open: read it, change it, or delete it. On Peios the kernel keeps those rules for everyone, so they apply to programs on this machine as well as to other people on the network. A program here that tries to change or delete a file someone has open without allowing it gets a "device or resource busy" error until they close it.
Deleting works as it does on Windows: a file deleted while others have it open keeps its name until the last of them closes it, and can't be opened again meanwhile.
File attributes #
Windows gives files attributes such as read-only and hidden. Through a share they work like this:
- Read-only is a Peios attribute too, so it sticks. A read-only file
can't be changed or deleted, by anyone, on the network or on this machine,
until the attribute is cleared;
attrib -rclears it here. - Hidden follows the Linux convention: a file or folder whose name starts with a dot is shown as hidden. Marking another file hidden from Windows has no lasting effect.
- Created is the file's creation date. Copying a file onto a share keeps its original date, and Windows can change it. Peios also keeps the date the file system created it, which nothing can change.
- Archive always shows as set on files, and changes to it aren't kept.
A backup that copies only files with Archive set, such as
robocopy /Morxcopy /M, copies every file each time. - Not indexed is kept as the file's PGSS Indexing preference, the
user.pgss.indexingattribute thatattrib +isets here: setting it from Windows keeps the file's contents out of search, and clearing it removes the preference. A folder's preference covers everything inside it, but Windows shows it only on the folder itself. On a file system that can't keep it, it's accepted and not kept. - Temporary is accepted from Windows and not kept.
- Extended attributes, the name and value pairs some Windows programs
attach to files, are kept as Linux extended attributes named
user.followed by the name in capitals, sogetfattrshows them here. Linux programs' ownuser.attributes appear to Windows the same way, exceptuser.peios.ones, which Peios reserves, and the indexing preference, which appears as not indexed. Peios standards'user.pgss.attributes, such as a file's icon, keep their lower-case names when Windows writes them back.
What is recorded #
fservd records an event when someone sets up a session, connects to a
share, signs in again, or their session ends, and when its configuration is
loaded. Each
records the client's address and the person's security identifier.
fservd.session.started carries the logon session that authd created, so
you can join it to authd's authd.logon.attempted record and to the
kernel's audit records of the files that person opened. Run
evman fservd.share.connected to see what each event holds, and see
Diagnosing File Sharing
for queries.
For the command and its options, read fserv(8); for the service, read
fservd(8). Every registry value is documented by regman: run
regman 'Machine\Software\Fservd'.