Skip to content

CLI commands that write to the storage don't check which OS user they run as #4042

Open

Description

@pbleser-oc

Describe the bug

Some opencloud commands work on the storage of the storage-users service directly, in a process of their own, next to the running server:

Whatever these commands create on the storage belongs to the user that runs them, with permissions only for that user:

  • lock files (lockedfile.OpenFile(…, 0600), created the first time a node is locked and never removed, see Treesize propagation seems to be broken #1793),
  • lock folders of the hybrid metadata backend (mode 0700),
  • metadata files.

If an admin runs such a command as root on a bare-metal installation where the server runs as opencloud, the server afterwards gets "permission denied" when it locks these nodes. Writing, moving or deleting the affected files then fails. Nothing tells the admin that the command was run as the wrong user, and the damage only shows later.

None of these commands checks the user it runs as. The admin documentation only mentions the required ownership for posix in general ("All files and directories must be owned by the same user and group under which the OpenCloud process is running"), not for the commands.

Steps to reproduce

  1. On a bare-metal installation, run OpenCloud as the user opencloud.
  2. As root, run a command that locks nodes that have no lock file yet, e.g. opencloud storage-users revisions cleanup --all --strategy 1000 after files were added to a posix storage from outside. Keeping 1000 versions deletes nothing, but the cleanup locks every file it visits.
  3. Change one of these files through OpenCloud.

Expected behavior

The command refuses to run, or at least warns, when it runs as another user than the owner of the storage.

Actual behavior

The command runs and creates lock files owned by root. OpenCloud then fails to lock these files.

Suggestion

A shared check for these commands: compare the effective uid with the owner of the storage root, and warn (or refuse, which needs a team decision) when they differ, naming the right user, e.g. sudo -u opencloud …. revisions cleanup prints such a warning since #3778, its helper storageOwnerWarning could become the shared one. With Docker, docker exec already runs commands as the user of the container, so only bare-metal installations are affected.

Setup

opencloud main, bare-metal installation, all storage-users drivers (decomposed, decomposeds3, posix).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions