Skip to content

tacctl 0.2.28 - #45

Merged
rett merged 60 commits into
masterfrom
release/0.2.28
Nov 9, 2026
Merged

rett merged 60 commits into
masterfrom
release/0.2.28

Conversation

@rett

@rett rett commented Nov 9, 2026

Copy link
Copy Markdown
Owner

release 0.2.28

rett added 30 commits November 9, 2026 00:13
…ng line

WithWrappedEcho only simulates a device that writes the start of a long
command on a line of its own and the tail on lines that start with '$'.
A Cisco 2811 running 0.2.27 left a support bundle whose first identity
line was the tail alone (`$clock timezone|snmp-server location|...`), so
the reader never sees the start of the echo as a line. Two options cover
the shapes that give a body starting with the tail:

- WithTailEcho(width) writes only the '$' lines.
- WithRedrawnEcho(width) writes one line: the first width characters,
  backspaces back over them, and the '$' tail drawn over them with blanks
  to the end, so a terminal shows the tail alone.

WithWrappedEcho is unchanged (a wrapStyle field selects the shape). No
test uses the options yet; the next commit does.
…a line

The echo of a command longer than the terminal is wide was only dropped
when the first line of the answer was the start of the command. On a
Cisco 2811 the file of `show running-config | include ^(hostname|ip
domain|clock timezone|snmp-server location|snmp-server contact)` in a
support bundle began with `$clock timezone|snmp-server location|snmp-server
contact)` and then the hostname line: the body that reached stripEcho
started with the tail (a '$' and the rest of the command), the start of
the echo not being a line of its own, and wrappedEcho wanted the first
line to be a prefix of the command, so it left the body alone.

wrappedEcho now also takes a first line that a terminal shows as a '$'
and pieces of the command as the start of the echo (echoStart). Every
other guard stays: all of the line must be made of pieces of the
command, the last piece must end the command (3 characters or more),
output lines that only resemble a piece are kept, and a command shorter
than 40 characters is untouched.

Tests: stripEcho on tail-only bodies and the lines that must be kept,
Run against the fake device with WithTailEcho and WithRedrawnEcho, and
`device support-bundle` over the three echo shapes.
…ives

CHANGELOG item 1 of 0.2.28 (new unreleased section), one sentence in the
support-bundle page and in the manual page. The 0.2.27 text said the echo
of a command longer than the terminal is wide is dropped; on a Cisco 2811
only the tail of it (a line of '$' and the rest of the command) reached
the session, and it is dropped too now (the previous commit).
Every release ships a rollback target for the release before it. 0.2.28 so
far changes no stored file 0.2.27 reads strictly (the reader of a Cisco IOS
device's answer to a long command and the documentation), so the plan of the
target converts nothing, removes no key and no field (reports.max_size,
reports.max_count and a user's own limits stay: 0.2.27 has them), takes no
snapshot, needs no --yes and leaves the per-tier sudoers drop-in (0.2.27 and
0.2.28 write the same text), the pull records, the reports in the users'
homes, the PDF ones included, and the marker of the offer of the PDF tools.
The steps of rollbackAdditions undo changes for targets older than their
release, so none fires for it. It is refused only while a device's apply is
not settled, as every target is.

0.2.27 stops being "not a release to roll back to" in the version refusal and
becomes the release before this one; 0.2.26 stops being that. The usage, the
completion, the top-level help and its golden file list it. The lists of
"every target but" in the code comments (an emergency lockdown with enrolled
hosts, the email addresses, the SNMP credential files, the covered staging
entries, the break-glass firewall) name 0.2.27 beside 0.2.26, and the
comments of the 0.2.26, 0.2.25, 0.2.24, 0.2.23 and 0.2.22 targets say what
0.2.27 and the later releases changed, not "this release". The next steps of
the 0.2.26 target are those of 0.2.27, which reads the same files.

rollbackFrom, the release a snapshot's state is of in the note that follows a
rollback, is 0.2.28, and the tests that quote the note say so
(TestRollbackFromIsTheReleaseOfTheChangelog passes again).

Tests: the version check, the plan with and without limits (nothing removed,
no snapshot, no --yes), the pull records, a report, a PDF report and the
marker left byte for byte, the command (the dry run, the apply and a second
run, the 0.2.25 and 0.2.26 targets told apart, the lockdown, the drop-in), the
0.2.27 tag's reader and per-tier text, the completion and the usage golden.
Rolling back in docs/install/upgrading.md gets a "To 0.2.27" section (nothing
is converted, no key or field is removed, no snapshot, no --yes; the limits of
the stored reports, the reports in the homes, the PDF ones included, the
marker of the offer of the PDF tools and the per-tier drop-in stay) and says
fourteen targets. The manual page, docs/cli/conventions.md and
docs/releasing.md list 0.2.27 as the release before this one, and the
CHANGELOG has item 2 of 0.2.28.

The lists of "every target but" for the break-glass firewall, the users' email
addresses, the SNMP credential files, the covered staging entries, the server
name and timing scale, the scope of the server's own login, the user's
required password change and an emergency lockdown with enrolled hosts name
0.2.27 beside 0.2.26 and 0.2.25. The limits of the stored reports are said to
be kept by 0.2.26 and 0.2.27 (docs/cli/user.md and docs/devices/reports.md
say so too). The PDF paragraph says that 0.2.27 has the format and that the
advice to fetch or remove a PDF report is for a rollback to 0.2.26 or older.
The To 0.2.26, 0.2.25, 0.2.23 and 0.2.22 sections and the man page entries
name 0.2.27 beside 0.2.26 where they say what the target reads. The snapshot
note quoted in the pages names 0.2.28.
…s one

The case sets a server name, the limits of the stored reports (the setting
and a user's own) and the marker of the offer of the PDF tools, runs the dry
run with --hosts (nothing to remove, nothing written, no snapshot, no --yes)
and --apply (Nothing to convert, the upgrade line of the tag, no closing
note), and checks that the limits, the server name and the marker are still
there. The case of 0.2.26 stays, now the release before 0.2.27, and the
refusal case asks for 0.2.28, which is no release to roll back to, and
expects the message to name 0.2.27 first.
The console is to serve SFTP itself instead of handing the subsystem to
the system's sftp-server. github.com/pkg/sftp (BSD-2-Clause, v1.13.12)
supplies the protocol and a RequestServer that takes handlers, so the
rooting, the .ssh rule, the quota and the audit stay in tacctl's own code.
Its one other dependency is github.com/kr/fs (BSD-3-Clause).

go.mod and go.sum name the two modules, vendor/ holds their packages and
vendor/modules.txt lists them. internal/sftpd/doc.go is the package the
dependency is imported from, empty of code until the server lands, so that
go mod tidy and go mod vendor keep it.
internal/sftpd runs the SFTP protocol (github.com/pkg/sftp RequestServer)
for the console. Serve takes a byte stream and a Config; nothing is wired
to it yet and it prints nothing.

The home is the virtual "/". A client path is cleaned lexically (".."
stops at the root), and resolved one component at a time against a held
descriptor of the home with openat and O_NOFOLLOW, the last component with
the *at calls of its parent. No call resolves a name through a symbolic
link, so a link in the home is listed and lstat'ed as a link and refused
for everything else, and a directory swapped for a link between a check and
its use cannot be followed because there is no check apart from the call.
os.Root was not used for this: it follows links inside the root, which
would let a link reach .ssh.

The entry named .ssh in the home is hidden from the listing and refused,
with permission denied, for stat, open, create, mkdir, remove, rename as
source or target, and setstat, under every spelling that cleans to it.
Symlink and hard-link requests are refused, setstat is limited to the
permission bits and the times, and a regular-file check keeps FIFOs and
devices from being opened.

Supported are stat, lstat, fstat, list, download, upload (create, truncate,
append, pwrite offsets, read-write handles), mkdir, rmdir, remove, rename
and posix-rename. Audit calls the callback for each upload and download (at
close, with the bytes), delete, rename, mkdir, setstat and refusal, with the
virtual paths. A path with a NUL, one that is too long and a panic in a
handler give a status.

IsSubsystemCommand tells the command sshd passes for the sftp subsystem.

The tests run an in-process pkg/sftp client against Serve on a pipe with a
real directory, including a test that exchanges a directory and a link
while the client reads through the name.
Config.Quota limits the bytes of the whole home. The usage is the sum of
the sizes of the regular files below the home, measured with the same
no-follow walk (links not followed, each inode once, .ssh counted) when the
session starts, and kept current from the session's own writes, deletes,
truncations by open and renames that replace a file. A file that has other
names frees nothing when one of them goes. When a file is opened for
writing and the last measure is more than 5 seconds old the home is
measured again, so a second session or a file tacctl wrote itself is
noticed; the overshoot between two sessions is accepted. Quota 0 (or less)
sets nothing up and measures nothing.

A write that would take the usage over the quota is refused whole with the
status message "disk quota exceeded", so nothing goes past the limit;
the check and the write are under one lock so that two writes cannot both
take the same room. A write that does not grow the file (an overwrite in
place) is always allowed, and deleting, renaming, downloading and setstat
are never limited. The refusal is audited once per handle, with reason
"quota", not once per packet of an upload.

statvfs (the df of sftp) reports the quota as the size of the file system
and what is left of it in 4 KiB blocks; without a quota it reports the
file system of the home.

The clock is an unexported seam (seams.now) so the tests move time by hand.
Config.Rate limits the bytes a session moves, reads and writes together, to
a rate in bytes per second with a burst of one second. It is a token bucket
that lets a caller go into debt and sleeps for the time the debt takes to
refill, so requests that arrive together wait one behind the other and the
session moves Rate bytes per second over time. Reads are charged after the
read with the bytes returned, writes after the write with the bytes written,
so a write the quota refused costs nothing. Rate 0 sets up no bucket and
nothing is charged.

The sleep ends when the client's stream ends or fails: the library waits for
its workers before Serve returns, and a request sleeping for the limit would
otherwise hold a closed session open. The stream is wrapped to say so.

The clock and the sleep are unexported seams (seams.now, seams.sleep), so
the tests run the bucket on a frozen or hand-moved clock and record the
sleeps instead of sleeping. The only real timers are the 5 ms of the test
that checks the timer path and the test that checks the stream ends the sleep;
both say so.
The console gets a built-in file transfer that is off by default. This
adds the settings and the policy that decide it, written and read like
the system shell's: settings.file_transfer holds the tiers that have it,
the users with a switch of their own (an enable carries the tier it was
set for and ends when the user moves to another tier, a disable holds at
any tier), a quota and a rate per tier, and a quota and a rate per user
that win over the tier's.

The superuser tier always has it, a caller with no tier never. The
engineer tier is not closed to it, unlike the system shell and
forwarding: a transfer reaches the home only.

The quota is the bytes of the whole home, 256 MiB for the read-only,
operator and engineer tiers and none for the superuser tier when nothing
is set. The rate is bytes per second, off by default. Sizes are plain
bytes or a number with K, M, G or T (powers of 1024), at most 1 TiB;
zero, negative, fractional and overflowing values are refused. The file
holds them in the largest exact unit. The key is written only when
something in it is not the built-in setting.

Policy.FileTransfer(user, tier) returns console.FileTransfer{Enabled,
Quota, Rate} (0: unlimited, 0: off) for the console's wiring. A user's
settings follow a rename and go with a removal, like the system shell's,
so the next user of a name does not inherit them.
'tacctl console file-transfer' reads and sets the settings the model
commit added, in the forms of the system-shell command: no argument lists
each tier and the users with a switch of their own; '<tier> enable|disable'
and 'user <name> enable|disable|clear' set the switch; 'quota' and 'rate'
show and set the limits per tier ('<tier> <size>|unlimited|default' for
the quota, '<tier> <size>|off' for the rate) and per user ('user <name>
<size>|unlimited|off|clear'). The superuser sets; the forms that only read
are not held to the superuser tier, as the system shell's are not. A
refusal comes before the snapshot, and every change goes through
consoleWrite and is audited as 'console set key=file-transfer'.

'console show' lists the tiers' file transfer, quota and rate, and the
users table gets the file transfer, quota and rate of each user next to
the system shell. 'user rename' and 'user remove' report the file
transfer settings they move or drop. Completion offers the tiers, the user
names and the words of each position (the new kind Both decides a
position on two earlier words), and the usage table, the console help and
the manual page describe the forms; the existing 'show' tests drop the
line end they matched after the system shell column.

The tier table has no row for the command in this change, so the gate in
front of the verb lets only the superuser tier run it; the verb itself
reads for every tier and refuses the writes below the superuser tier
(a test puts the row in to show it).
The console runs as the user and cannot read root's console.yaml, so it
asks 'tacctl _console-policy' through sudo. The answer now ends with
' file_transfer=yes ft_quota=<bytes> ft_rate=<bytes>' for a caller whose
settings give them file transfer (the user's own switch over the tier's,
the quota and the rate resolved the same way), and has no such field for a
caller who has none, which the reader takes as off. A caller with no tier
restriction, a caller with no tier and a name that is no store user are
never given it.

On the console's side console.Remote gets the FileTransfer field, read by
ParseRemote (a damaged or out-of-range number is left out, so a quota of
0 means no limit and a rate of 0 none; no field, no answer and the
defaults are no file transfer), and Remote.FileTransferSettings is the
call the later wiring makes on the policy consoleRemotePolicy fetched.
The existing policy line tests gain the field the superuser's line now
holds.
0.2.27's console.yaml reader rejects the key settings.file_transfer
("settings: unknown key"), as every older reader does: the console then
falls back to its defaults and every 'console' command that writes the
file fails. So the rollback to 0.2.27, and to every older target, removes
the key and keeps every other setting. The rollback to 0.2.27 is no longer
a plan that never converts a file: with the settings set it takes the
snapshot first, and says what to avoid until the upgrade and why 0.2.27
cannot restore that snapshot.

console gets Keys0228, PlanRollbackSince0228, RollbackSince0228 and
Text0227 for the releases from 0.2.20 to 0.2.27, and the plans of the
older releases (PlanRollback, PlanRollbackSince0220) take the key out with
their other settings; the plan level is now one type instead of a bool.
In lifecycle the targets from 0.2.20 to 0.2.27 have no console plan of
their own, so an entry of rollbackAdditions plans the file for them and
adds the console step; the older targets already read it.

Tests: a fixture of 0.2.27's parser, checked against the 0.2.27 tag's
source where git and the tag are there, rejects the file of this release
and accepts the converted one; every target's plan and apply, the 0.2.27
and 0.2.26 command with its snapshot and its note, and the files left
alone.
The line that names what the rollback removes from console.yaml counted
the user switches by adding an s to the noun, which gave 'switchs'. Each
count now has its own singular and plural, and the test pins the plural.
CHANGELOG item 3 says what the owner gets: file transfer settings per tier
and per user, off by default, the superuser tier always, the engineer tier
not closed, a quota and a rate per tier and per user, and that the
settings only decide until the console's file transfer, which a later
change of this release turns on, reads them. Item 2 no longer says the
rollback to 0.2.27 removes no key: it removes the file transfer settings.

docs/cli/console.md gets the settings in the file sample, the forms of the
command and a File transfer section; login-console.md, user.md (the
settings follow the user) and audit.md (the 'console set' key and items)
mention them; docs/install/upgrading.md and the manual page (the command's
entries, the key in the list of console.yaml settings, and the rollback
paragraphs of 0.2.27, 0.2.26 and 0.2.25 and the one that holds for every
target) say that every target removes the key, and that 0.2.27 and 0.2.26
convert nothing else.
console_file_transfer.bats runs the command line end to end: the defaults
and the switch of a tier (the engineer tier included, the superuser tier
that cannot be disabled), a user's setting over the tier's with clear, the
quota and the rate for tiers and users with the size words, the default,
unlimited and off, the listings and the lines of console.yaml, 'console
show', the refusals that write nothing, and the line of _console-policy
that carries the settings to the console.

console_cli.bats gains the usage lines of the new forms and the file
transfer fields the superuser's policy line now holds.
The quota walk skipped what it could not see: a directory it may not
list or search, a failed open of a subdirectory, no descriptor left, a
tree deeper than the cap. The usage then dropped, and a client could
hide its files from the next measure (setstat a directory to mode 0100)
and store more than the quota; 500 bytes were stored under a quota of
100.

measure now says whether the walk was complete (only a vanished entry,
ENOENT, is not a failure). The quota keeps that, and while the last walk
was incomplete the usage the checks and statvfs go by is at least the
limit, so every write that grows the home is refused with the quota
message until a later walk is complete. Downloads, deletes and writes in
place that do not grow the home keep working.

Setstat of a directory is refused (reason "unsupported") when it would
clear the owner's read or search bit, so a client cannot make its own
tree unlistable either.

The depth of the walk is a seam so that a test needs no 4000-level tree.

Before the fix the new tests failed with, for each mode:
  growing upload while a directory cannot be measured succeeded, want disk quota exceeded
  a walk cut at depth 1 says it was complete
  free blocks = 2, want 0 while the home cannot be measured
  chmod 0100 of a directory: <nil>, want unsupported
Removing or replacing a file took its size off the usage at once, but a
handle that is still open keeps the data: open, write 100 bytes, remove,
keep the handle, repeat, and 500 bytes were held under a quota of 100.

The quota now keeps, per session, the files that are open by inode. A
remove, or a rename that replaces a file, does not release the size of
a file that has an open handle (the look at the entry, the call and the
accounting are one step under the quota lock, so a handle opened at the
same moment is seen either there or when it registers). The next measure
adds the size of every open file that has no name left, and the close of
the last handle on a file with no name gives its room back.

A truncating open still releases the size: the bytes really go.

Before the fix the new tests failed with:
  write 1 of 100 bytes succeeded under a quota of 100 with 1 removed files held
  upload with two handles on a removed file succeeded, want disk quota exceeded
  41 bytes with 110 in use succeeded, want disk quota exceeded
A hard link made outside SFTP (the server makes none) to
.ssh/authorized_keys or to a private key gave the client read and write
access to that data through a name in the home: the .ssh rule is about
names, and the inode is the same.

A regular file with a link count over 1 is now refused (reason "link",
permission denied) for open (read, write, append, read-write, before
anything is truncated; judged on the opened descriptor) and for
setstat. Listing, stat, rename and remove of such a name stay allowed:
they act on the entry and never reach the data, and the quota already
counts the inode once. doc.go says so.

Before the fix the new tests failed with:
  download of keys: <nil>, want permission denied
  open of keys with flags 0x241: <nil>, want permission denied
  chmod of keys: <nil>, want permission denied
  authorized_keys mode = -rwxrwxrwx
A session had no limit on open handles, and a directory open read the
whole directory into memory: 300 opendirs of a 2000-entry directory held
229 MiB, and 3000 opens held 3001 descriptors.

A session now has at most 256 handles (files and directory listings
together; a constant, the tests lower it through a seam). An open past
the limit answers a failure status and is audited as a refusal with
the reason "too many open files". A place is given back when the handle
closes: file.Close, and the lister's Close, which the library calls with
the handle; an open that fails holds none.

The listing no longer snapshots the directory. It keeps the directory
open and reads names in batches as the library asks (Readdirnames(n),
each entry lstat'ed through the open directory); the memory of a handle
is a batch. The library asks at the offset of the entries it has been
given: sequential reads continue, an earlier offset reads the directory
again from its start on a new description, a later one skips ahead. The
price is that a listing is no longer sorted (a client sorts it when it
wants it so), which doc.go says.

Before the change the new tests failed with:
  the fifth open succeeded, want too many open files
  a refused open created the file
  a listing with three files open succeeded, want too many open files
and the listing was not an io.Closer, so it was never closed.
For a handle opened only for writing the library serves WRITE and READ
requests with the same writer, and calls WriteAt with a zeroed buffer
for a READ: a client that read from such a handle wrote zeros into the
file at the offset it asked for (growing the file, and quota-checked
like any write).

WriteAt gets no sign of the request type, so the handler tells the
buffers apart: the library allocates a READ's buffer with room for the
reply header (capacity 9 over its length), while the data of a WRITE is
cut from the incoming packet and has no such room. A write-only handle
refuses a buffer of the first kind with the "unsupported" status and
audits it once per handle. A client cannot make a READ look like a
WRITE; a WRITE with exactly nine padding bytes after its data looks like
a READ and is refused, which hurts only the client that sent it. The
test pins this to the vendored library: a different allocation there
fails it. Read-write handles use the library's own separate path and are
not touched.

Before the fix the new test failed with:
  read at 0 on a write-only handle: <nil>, want unsupported
  a read request changed the file from "hello world" to "\x00\x00\x00\x00\x00\x00\x00\x00rld..."
An open for upload or download that failed in the kernel (permission
denied over a 0444 file, a missing directory, a missing file, a
directory) produced no event, so the audit showed nothing of a failed
attempt; the other operations already audit a failure with Err set.

The three open handlers now emit the transfer's own event ("upload" or
"download", Path the client's cleaned path) with Err set when the open
fails and the error is not a refusal; a refusal keeps its "refused"
event with the reason. The new test covers every operation's failure.

Before the fix the new test failed with:
  upload over a read-only file: no event
  download of a missing file: no event
  download of a directory: no event
Comments and package documentation only.

The quota text said nothing goes past the limit. It guarantees that a
write is refused when it would take the usage the session measured over
the limit; sessions are independent, so N parallel sessions can come to
about N times the quota; only the sizes of regular files count (not
inodes, directory blocks or disk blocks); an incomplete measure counts
the home as full; a removed file with an open handle keeps its room.

The Config.Audit comment said the callback is never called with a lock
held, but the upload and download events fire from file.Close, which
the library calls under the lock of its set of open handles. It now says
no lock of this package is held, the library may hold one of its own,
and the callback must not block.

The library answers fstat and fsetstat of a handle through the handle's
path name and not the open file; doc.go says so, and why confinement and
.ssh are unaffected.
rett added 28 commits November 9, 2026 02:57
…sfer

A -c string that internal/sftpd calls the sftp subsystem (sshd's
ForceCommand hands it over in SSH_ORIGINAL_COMMAND) is no longer refused
with the generic text. The console asks its policy as for any session and
then:

- serves the protocol on standard input and output with sftpd.Serve, as
  the logged-in user, with the home directory the account database names
  for the process's uid (never $HOME) and the quota and rate of the
  policy;
- refuses, before any protocol byte, with status 126 and a text on
  standard error when file transfer is not enabled for the account, when
  a required password change holds the session (or it cannot be read
  whether one is), when there is no policy answer for a superuser, or
  when the home is not known; each refusal is logged as a DENY line;
- keeps refusing scp -O, rsync, programs and shell words, with
  RefusedText reworded: it said file transfer is not available, which is
  no longer true; it now says programs and shell commands are not run and
  file transfer is SFTP only.

The session start line carries mode=sftp. The console's shell, idle
timeout and history have no part in a transfer: a closed input ends it
with status 0, a protocol error is one short line on standard error with
status 1, and a signal closes the stream like a closed connection. The
console's standard output is wrapped to strip colour sequences when it is
not a terminal, which would damage binary packets, so the protocol writes
to the file behind it.
Each sftpd.Event of a transfer becomes one line under the console's syslog
tag, with the session id and the user like the console's other lines:

  console sftp start   the tier, the home, the quota and the rate in effect
  console sftp upload|download|delete|rename|mkdir|setstat  (auth.info)
  console sftp DENY    a refused request, with reason= (auth.warning)
  console sftp end     bytes up and down, requests, refusals

The console never logs a typed word that is not a verb, because it could
be a password. A path is a file name, so it is logged, but through
console.QuoteName: a Go string literal in double quotes (control
characters such as a newline or an escape sequence, quotes, backslashes,
bytes that are not UTF-8 and characters that do not print are escapes),
cut at 200 bytes with '...' after the closing quote. No name can end the
field or the line, or forge a field. An error text goes through the same
quoting, and a refusal's reason has its spaces turned into hyphens.

The lines are written in order by one goroutine, behind a queue, because
each is a logger process and the server calls the audit from the
goroutines that serve the requests; the end line waits for the queue.
sshd starts the sftp subsystem only when its configuration defines
'Subsystem sftp ...', and a Match block cannot define one, so the line has
to be in sshd_config itself; tacctl adds nothing global. Without it the
console is never started for a transfer, whatever file transfer settings
say.

'console file-transfer' with no argument and the server section of
'console show' now print 'sshd sftp subsystem: <program>' (or 'none', or
'could not be checked: ...'), read from 'sshd -T' through the runner like
the forwarding settings (console.SSHD gets the SFTP field, and
console.SFTPSubsystem asks for it without the forwarding settings, as the
user root). When file transfer is on for someone and sshd defines none, a
red warning line follows: sshd defines no sftp subsystem: file transfer
cannot start; add `Subsystem sftp ...` to sshd_config.

"On for someone" does not count the superuser tier, which always has file
transfer: it would make every server that does not use the feature warn.
A tier that was opened to it, or a user who was given it and is still in
the tier it was set for, does count.
The documentation of the file transfer settings said the operator tier
and up can read every form of 'console file-transfer'. They cannot: the
verb has no row in the tier table (internal/tier), so the gate refuses
every form of it, reads included, below the superuser tier; the system
shell's rows are what the sentence was copied from. A row is not added,
because it would change the sudoers text that the 0.2.27 rollback target
freezes.

What the lower tiers can see is 'console show': it lists every user's
file transfer state, quota and rate, and the operator tier and up can run
it (the readonly tier cannot). The console help, the console page, the
login console page, the manual page and item 3 of the changelog say so,
and a test pins both gates (the rows through tier.Permits, and a run as
an operator, an engineer-less sandbox and a readonly user).
The console page gets the File transfer section it lacked: what the console
serves (SFTP only: sftp and the scp of OpenSSH 9 or later; scp -O and
rsync stay refused, with the reworded refusal text), the home as the root
with .ssh invisible and refused and no symbolic link followed, the quota
(the whole home, reports and support bundles included) and the rate, the
audit lines, that the idle timeout does not apply, how to switch it on for
a tier and a user, and that sshd must define 'Subsystem sftp ...' itself,
which 'console show' and 'console file-transfer' now check.

The audit page and the manual page (console show, console file-transfer,
Console sessions, the syslog lines) describe the new lines, the login
console page says what the drop-in lets through, and the pages for
'device reports show' say the scp line it prints works only if file
transfer is enabled for the user. The changelog gets item 4. The console's
help drops 'no scp, sftp' from its description of the drop-in.
console_sftp.bats starts the real binary as tacctl-console -c with a canned
SFTP init on standard input: with file transfer on, standard output starts
with the version packet and nothing is printed to standard error, the log
has the sftp start and end lines and the session ends with status 0
(skipped when the running user has no home in the account database; no
file of the home is touched); off, the subsystem is refused with status
126, the text on standard error only, and a DENY line; scp -f stays
refused with the program text.

console_file_transfer.bats stubs sshd (the list form now asks it) and
checks the sftp subsystem line and the warning; console.bats follows the
length of the refused string.
An open that truncates read the size of the file, cut it and then took that
size off the usage, the last step under the quota lock but the first two
outside it. A write on another handle of the same file that had made its
size check before the cut and was still writing then refilled the file
while the old size was subtracted, and the usage stayed below the disk
until the next measure.

The size is now read by Fstat, the file cut and the usage lowered as one
step in quota.truncating, under the lock that a write holds from its check
to the end of its write; the size released is the one seen under the lock.
Without a quota the cut just runs. The session's quotaRelease and
quota.release, which had no other caller, are gone.

The test holds a truncating open before its cut (a test seam,
beforeTruncate), starts a write on a second handle and lets the cut go
while the write runs. On the unfixed code it fails with
"quota_test.go:737: usage 0, the file on the disk has 100".
setstat looked at the entry by name (lstat: link, directory, link count)
and then set the mode and the times by name. Between the look and the
change another session could rename a hard link of a file in .ssh over
that name, and the change then went to the key file.

The entry is now pinned with openat(O_PATH|O_NOFOLLOW), so a symbolic
link is the link itself and is refused as before; the type and the link
count are read with fstat on that descriptor, and the mode (chmod) and the
times (utimensat) are applied through /proc/self/fd/N, which names the
pinned inode whatever its name becomes. The refusals are unchanged (link,
symlink, a directory without the owner's read and search). The fchmodat2
call and its fallback are replaced by this one path, so /proc must be
mounted, as the fallback already required on kernels before 6.6.

doc.go no longer says the setstat check is a look followed by a change; it
says what the pin covers and what it does not (a name added to the pinned
file by something outside SFTP after the check).

Two tests: one exchanges the name with a hard link of a key file after the
check, through a test seam (afterPin), for chmod and for chtimes; the other
runs RENAME_EXCHANGE all the time against a stream of chmods. On the
unfixed code they fail with
"ssh_test.go:507: chmod reached the key file through the exchanged name",
"ssh_test.go:507: chtimes reached the key file through the exchanged name"
and "ssh_test.go:550: the key file after 31 setstats: ..." (mode changed).
TestChmodPinned now goes through target.pin.
The library calls Readlink and RealPath outside the Filelist and Filecmd
handlers that defer guard, so their refusals were the only ones not
audited: a client probing for links by readlink, or sending a path that is
not one to realpath, left no "refused" event.

Both now call noteRefusal themselves: a Readlink (always refused, reason
"symlink") and a RealPath of a bad path (reason "bad path") emit the Op
"refused" event like every other refusal. A RealPath that answers is still
not audited, as clients ask for it constantly.

The test reads a link and a plain file and sends a path with a NUL to
realpath, and expects the three events, and none for an answered RealPath.
On the unfixed code it fails with "audit_test.go:474: events:" (empty)
against the three expected.
…ne fits

logger cuts a log line at 1 KiB by default. QuoteName cut the raw name at
200 bytes and then escaped it, so a name of control bytes filled about 800
bytes of one field and a line with path=, to= and error= reached 1.6 KiB:
the trailing fields (reason=, error=) were lost.

QuoteName now builds the text rune by rune from strconv.Quote and keeps at
most NameMax bytes of the escaped text, never a part of an escape sequence
or of a character. The error text of an event no longer repeats the path
that an os error names (open <path>: ...): it is the operation and the
reason, since the line has the path in its own field. A test asserts that a
line of every kind (upload, download, delete, rename, mkdir, setstat, DENY
with each reason, start, end, deny) stays under 1000 bytes with the longest
user, path, new name and error text.
The start line of a file transfer carried the caller's tier, but the lines
of what the client did (upload, download, delete, rename, mkdir, setstat and
DENY) carried only the user and the session, so a line read on its own did
not say which tier's policy let the request through. Each event line now has
tier=<tier> after user=, taken from the session's tier. The tests check it
on the lines of a normal transfer and of the refusals.
ParseSize("K") (a unit with no digits) fell through to the integer parser
and answered "Size 'K' is too large"; it now returns the normal
invalid-size error. The settings reader refused "rate: {operator: off}" for
a tier while rate_users accepted off; it now reads it as the built-in
setting (no rate), the same as leaving the tier out, and stores nothing for
it. The error for a bad tier rate says "a size or off".
When logger fails during a file transfer, the audit warning goes to
standard error and the transfer goes on unaudited (the owner's decision:
refusing the transfer would be worse). The test pins it: a client uploads
and downloads a file with no logger, the console exits 0, standard output
holds nothing but whole SFTP packets and the warning is on standard error.
…les, the quota and the audit

The pages said "hard links are not supported", which reads as "cannot be
created", and left out how the transfer behaves:

- a file with more than one name cannot be opened, downloaded, written or
  have its mode or times changed (reason link); it can be listed, renamed
  and removed; symbolic and hard links cannot be created;
- at most 256 handles per session (reason too-many-open-files);
- listings are in file-system order, not sorted;
- the quota counts the sizes of regular files, each inode once, per
  session, a deleted file still held by a handle stays counted, and a
  directory the session cannot read makes the home count as full;
- setting a directory's mode without the owner's read and search bits is
  refused.

The audit text lists every reason (link, too-many-open-files, and stream for
the subsystem refused), says refusals of every kind are logged and the
successful stat, listing, readlink and realpath are not (CHANGELOG item 4
said every request), names the tier= of every event line, says the 200 bytes
are of the escaped text, and says the warning "The audit line was not
written" can appear on standard error during a transfer while the transfer
goes on. Item 3 of the CHANGELOG no longer says the transfer is a later
change, and the login console page no longer says sftp is refused for
everyone. In docs/cli/console.md, docs/security/audit.md,
docs/security/login-console.md, man/tacctl.1 and CHANGELOG.md.
The OpenSSH scp sends an fsetstat with the size alone after every upload,
to give the file its exact final size. The server refused any request
with the size flag, so every scp upload ended with "remote fsetstat:
Operation unsupported" (and failed for some files).

Setstat and fsetstat now cut or extend a regular file to the size asked
for, through the pinned entry as the mode and times are. The request is
judged before anything is changed: a symlink, a file with more than one
name, a directory, anything that is not a regular file, .ssh, a size
above 4 EiB (which is also what a negative size becomes) and a request
that also asks for a new owner are refused whole. The size is applied
first, then the mode, then the times.

With a quota the size is read, the file changed and the usage corrected
as one step under the quota's lock, as a write and a truncating open do:
a growth over the limit (an incomplete measure counts as full) is
refused with "disk quota exceeded", a shrink gives its bytes back, and
a file that lost its last name is counted only while a handle of the
session holds it, so the rule for an unlinked file that is still open
stays true. The size the file has now is the one the lock reads, so a
write on another handle of the file cannot make the usage lag the disk.
The manual page, docs/cli/console.md, docs/security/login-console.md and
item 4 of the 0.2.28 changelog now say what was measured with the real
OpenSSH sftp and scp clients against the console:

- the size of a file can be set, which scp does after every upload, and
  counts against the quota; the owner cannot be changed;
- an upload refused by the quota leaves the part written before the
  refusal in the home, and the clients show only "Failure" for it; the
  reason is in the audit log;
- an account without file transfer sees only "Connection closed"; the
  reason is in the audit log and console show lists who has file
  transfer;
- the mode a new file or directory gets (reduced by the umask of the
  console), the ignored special bits, and the need for /proc to change a
  mode or times.

The unmeasurable-directory rule of the quota was already described and is
not repeated.
Add docs/release-notes-0.2.28.md, modelled on the notes of 0.2.27: a
paragraph on the release, the file transfer through the console (how a
superuser switches it on, the clients, the home as the root, the quota,
the rate, the modes, the audit lines, what the clients show for a refused
transfer, what sshd and /proc must provide), its known limits, the fix of
the echo tail in the Cisco IOS support bundle, the rollback to 0.2.27 and
the upgrading notes. The headline sentence of each of the four CHANGELOG
items appears in the notes as the CHANGELOG words it, which
tests/tools/release-notes-check.sh requires the notes to point at.
Add the 0.2.28 row to the roadmap: what the release holds and what is
still open. The open list keeps the items of the 0.2.27 row that are not
done (chassis components of a member, a dual-RE or SRX-cluster capture, a
standalone Catalyst capture) and adds the file transfer follow-ups
(honouring the client's mode on an upload, a rate-limited session that can
stay a moment after the client leaves). The 0.2.27 row loses "file
transfer through the console", which 0.2.28 does.
@rett
rett merged commit d2d6310 into master Nov 9, 2026
8 checks passed
@rett
rett deleted the release/0.2.28 branch November 9, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant