# Diagnosing File Sharing

_Peios / Using Peios / Sharing Folders_

> Find out why someone can't connect to a share or use its files, from fservd's events, authd's sign-in records, and the service log.

Diagnose a file-sharing problem when someone can't reach a share, can't sign
in, or can't open or change its files. fservd records each step of a
connection as an event, so the records usually say which step failed and
why.

## Before you start

- Sign in as a member of Administrators, so you can read the events and the
  file server's log.
- Note the time of the failure, and the address of the computer that
  failed, if you know it.

## Check the file server

Run `fserv status`. **Service** should be `active`, and **Shares** should
count the share as on SMB. If the service is stopped, start it with
`fserv service start`. A warning such as
`fserv: warning: share Old: Path is missing` names a share that can't be
used; fix it with `fserv share set`, or remove it.

If a client can't connect at all and fservd records no
`fservd.session.started`, check that the firewall admits SMB: `net policy`
should show the `smb` flow rule, which passes inbound TCP port 445. fservd's
package adds it; a rule an administrator wrote that refuses the port, or a
missing rule, stops every connection before it reaches fservd.

## Read the connection's events

List the last hour of fservd's events:

```sh
evctl 'EVENTS fservd.* SINCE 1h ago TAKE 50'
```

A connection produces `fservd.session.started` when the person signs in,
then `fservd.share.connected` for each share they open. Each record has
the client's address in `source.address`. Show only failures:

```sh
evctl 'EVENTS fservd.* SINCE 1h ago WHERE outcome.success == false'
```

Then read `outcome.reason` on the failed record:

| Event | Reason | What to do |
|---|---|---|
| `fservd.session.started` | `authentication-failed` | Read authd's record, below |
| `fservd.session.started` | `not-ntlmv2` | Sign in with an account, not as a guest, using NTLMv2 |
| `fservd.share.connected` | `no-such-share` | Check the name, and that SMB is on for the share |
| `fservd.share.connected` | `access-denied` | The share's network access grants this person nothing, or they connected anonymously and the share doesn't allow it |

Run `evman fservd.session.started` for every reason and field.

## Find out why a sign-in failed

authd records every sign-in it handles as `authd.logon.attempted`:

```sh
evctl 'EVENTS authd.logon.attempted SINCE 1h ago WHERE outcome.success == false'
```

Its `outcome.reason` says whether the account name or password was wrong
(`authentication-failed`), the account is restricted, or the account isn't
allowed to sign in over the network (`logon-type-not-permitted`). authd never
records the account name a failed sign-in gave.

## When someone can connect but can't use a file

fservd acts as the person for every file operation, so a file they can't
open over the network is usually one they couldn't open at the console
either. Check the file's permissions on this machine first. If those allow
the operation, check the share's network access: `fserv share show` with
the share's name shows it, and a restriction such as **Read-only for
everyone signed in** refuses every change.

To record exactly which file access the kernel refused, add an audit entry
to the folder's descriptor. Every record of the person's file access then
carries the same `subject.token.auth-id` as the `object.session.id` on
their `fservd.session.started` record.

## Read the file server's log

fservd writes a line to its log for each share it serves when it starts,
and for each share it can't use:

```sh
evctl 'LOGS FROM fservd SINCE 1h ago TAKE 40'
```

## Check the result

Ask the person to connect again. A successful connection records
`fservd.session.started` and `fservd.share.connected` with
`outcome.success` true.

Related content:

- [File Sharing](/peios/using-peios/sharing-folders/file-sharing.md)
- [Connecting to a Share](/peios/using-peios/sharing-folders/connecting-to-a-share.md)
