Skip to content

rserver ownership pass: recognise session files by owner rather than by path shape #19537

Description

@kevinushey

Context

rserver's startup ownership pass (ServerMain.cpp, serverDataDir.changeOwnership(serverUserObj, true, shouldChownServerDataFile)) chowns everything under server-data-dir to the server user, except for session files that shouldChownServerDataFile in ServerPaths.hpp recognises by position and suffix: depth 3 under a -ds directory, or depth 1 with a -d, -d.pid, -d.ctx or -d.lock suffix.

#19453 added -d.lock because the session claim lock is 0600 and a lock chowned to the server user makes open() fail on the next launch. That raises the stakes of the filter: before, a mistakenly chowned socket was harmless (mode 0666); now any session file the filter doesn't anticipate becomes a session that can't start after an rserver restart. Each new per-session file also needs its own suffix here.

Proposal

Consider a more general rule, e.g. never give a file that a non-root user already owns to the server user (stat the file in the filter and skip it when st_uid is neither 0 nor the server user). That would cover any future per-session file at any depth without changes here.

Trade-off to work out: today the pass also reassigns rserver's own files after an admin changes server-user; an owner-based rule would leave files owned by the previous server user alone. That may be fine (rserver recreates its sockets at startup), but it needs checking before switching rules.

Raised by @gtritchie in the review of #19453.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions