Skip to content

Conversation

@h2zh
Copy link
Contributor

@h2zh h2zh commented Feb 2, 2026

This PR is structured as several self-contained commits. Each one fixes a particular permissions or drop-privileges bug in isolation. We recommend reviewing the PR commit-by-commit to follow the changes.

  • TLS credentials: On startup with drop-privileges, check that the pelican user can read TLS cert/key files; exit with a clear error if not (no automatic chown of external/mounted files). Clarify that XRootD always uses runtimeXRootD/copied-tls-creds.crt.
  • Cleanup: Remove deprecated configs from the drop-privileges path; adjust launcher and config ordering as needed.
  • Globus: Fix ownership of Origin_GlobusConfigLocation and parents so XRootD run dirs stay xrootd-owned; use setgid on the tokens dir so xrootd can read tokens written by pelican.
  • Broker: Do not set the federation broker URL to the server’s own URL by default; start the broker listener after the initial advertisement so metadata is available.
  • Cache: Fix self-test under drop-privileges; add drop-priv–related tests in xrootd/drop_privilege_test.go.
  • Federation token: When drop-privs is on, use xrdhttp-pelican plugin to receive fed token updates via FD. Add separate permanent (xrootd-owned) and temporary (pelican/root) fed-token dirs with correct ownership and permissions; use callback injection so server_utils does not depend on xrootd.

The federation token change requires a matching xrdhttp-pelican PR for fed-token handling (command 9 / atomic overwrite). You need to rebuild this plugin in your local environment to test it.

You can set Server.DropPrivileges to true to enable the feature. This PR leaves the default as false. I think a reasonable rollout plan would be first pilot it in a few servers running the 7.23, and eventually set the default to true in 7.24.

@h2zh h2zh linked an issue Feb 2, 2026 that may be closed by this pull request
@h2zh h2zh added enhancement New feature or request cache Issue relating to the cache component origin Issue relating to the origin component director Issue relating to the director component registry Issue relating to the registry component labels Feb 2, 2026
@h2zh h2zh added this to the v7.24 milestone Feb 2, 2026
h2zh added 10 commits February 3, 2026 00:17
- LaunchBrokerListener() have to read the metadata, which is acquired through the advertisement
- In config.go, the Origin_GlobusConfigLocation directory (/run/pelican/xrootd/origin/globus) was being added to pelicanDirs and created with pelican user ownership. This caused all parent directories (/run/pelican, /run/pelican/xrootd, /run/pelican/xrootd/origin) to be created with pelican ownership before CheckXrootdEnv() ran, which couldn't fix them because config.MkdirAll() returns early for existing directories, causing the XRootD RunLocation is not owned by xrootd but pelican user and group
- Origin.GlobusConfigLocation should be accessed by both pelican and xrootd user, to allow:
1. XRootD to read token files (*.tok, *.transfer.tok) at runtime, to authenticate requests to the Globus API
2. Pelican to write (create/update) token files, see persistToken()
- How to let xrootd read the tokens after drop-privileges? The setgid bit is applied to Origin_GlobusConfigLocation/tokens to inherit the directory's group on files created in the directory
- If the default broker url is set, the federation discovery won't overwrite it with federation's broker url
- Only Director run the broker. Setting it here would prevent federation discovery from populating the correct broker URL for caches/origins joining an existing federation.
- No matter in normal or drop-privileges mode, the TLS certificate file used by XRootD is always  `runtimeXRootD/copied-tls-creds.crt`. The other file `runtimeXRootD/pelican/copied-tls-creds.crt` is just an intermediate product in drop privileges mode
- When drop privileges is enabled, check the pelican user can read TLS credentials.
- If it doesn't, shut down the program with an error message to prompt the admin to manually change the perms.
- Pelican won't automatically change them because these files are usually mounted from outside filesystem. Pelican can't change their perms.
- Note that XRootD does not need direct access to these files as Pelican copies them to a runtime location.
- Skip this check on Windows because few Pelican server is running on Windows. syscall.Stat_t only exists on Unix-like systems (Linux, macOS). On Windows, it doesn't exist and causes a compile-time error.
…mode

- Note there's a counterpart PR in xrdhttp-pelican plugin repo
- Setup the permanent and temporary directory for the federation token file
and sets proper perms.
- The permanent directory is always owned by xrootd user.
- In normal mode, the temporary directory is owned by the root. While in drop privileges mode, it is owned by the pelican user.
- In drop-privileges mode the process runs as the unprivileged user after
dropPrivileges() and can no longer write to RuntimeDir (e.g. /run/pelican),
which caused "permission denied" when writing the address file and a fatal
startup error.
- This is safe because Server_ExternalWebUrl, Origin_Url, and
Cache_Url are not set or changed after the drop in LaunchModules.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cache Issue relating to the cache component director Issue relating to the director component enhancement New feature or request origin Issue relating to the origin component registry Issue relating to the registry component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable DropPrivilege by default

1 participant