Expand description
Recursive permission/ownership changes (chmod/chgrp/chown) over a fileset.
The public entry point is chmod; it mirrors crate::rm() but transforms
metadata in place (from a per-type rule) instead of removing entries.
Structs§
- Getent
Resolver - Decides which
getentbinary name resolution spawns, hardened against PATH attacks when privileged. Built once from the CLI viaGetentResolver::from_cli. - Mode
Program - Per-type mode rules. Symlinks are never included (mode bits aren’t settable on Linux symlinks).
- Owner
Program - Which user/group id (if any) to apply to each entry type.
Noneleaves that type unchanged for this operation. - Settings
- Configuration for a recursive chmod/chgrp/chown run.
- Summary
- Symbolic
Clause - One
[ugoa][+-=][rwxXst]clause.who/permsare bitmasks (seeWHO_*/PERM_*).
Enums§
- IdKind
- Whether a DSL id token refers to a user or group.
- ModeOp
- The operator in a symbolic mode clause: add, remove, or set permissions.
- Mode
Spec - A parsed
chmodmode expression: either a symbolic program (applied relative to the current mode) or an absolute octal value (12-bit).
Functions§
- apply_
mode - Apply a mode spec to a current 12-bit mode, returning the new 12-bit mode.
is_dirdrives the conditionalXpermission. - chmod
- Public entry point. Applies metadata changes to
pathand, recursively, its contents. Mirrorscrate::rm::rmfor the root-filter check. - is_
privileged - Whether this process runs with elevated privilege: effective-root, or a setuid
mismatch (real ≠ effective uid). rchm is not installed setuid, but the mismatch
check is cheap defense-in-depth. The check keys on uid, not Linux capabilities, so a
CAP_CHOWNdeployment without effective-root is treated as unprivileged (there the PATH is the operator’s own, not a third party’s). - parse_
mode_ dsl - Parse a
--modeDSL string. A bare token is the default for files+dirs;f:/d:sections override per type.l:is rejected (symlink mode bits are not settable on Linux). - parse_
owner_ dsl - Parse a
--group/--ownerDSL string. A bare token is the default for all types;f:/d:/l:sections override per type.getentlocates thegetentbinary used to resolve any non-numeric, NSS-only names (seeGetentResolver).
Type Aliases§
- Error
- Error type for chmod operations. See
crate::error::OperationError.