Chmod Input

Reads a Unix file mode back in plain words and flags permissions that leak data or lock people out, like a world-readable key.

StopsWorld-writable file or exposed key

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/chmod-input.json

The files land in your project. They're yours to edit.

Usage

chmod-input-usage.tsx
import { ChmodInput } from "@/components/ui/chmod-input"

<ChmodInput key={sample.name} path={sample.path} value={value} onValueChange={setValue} />

What it catches

  • World-writable files and directories, and setuid/setgid bits
  • Private keys and .env files readable by group or others
  • ~/.ssh or authorized_keys writable by others (sshd StrictModes rejects these)
  • Execute bits on data files, and 775 typed where 755 was likely meant
  • Short, symbolic or decimal-looking modes, read back exactly

Props

ChmodInput props
PropTypeDefault
value

Controlled text, exactly as typed (644, u+x, -rw-r--r--).

string—
defaultValue

Initial text when uncontrolled.

string""
onValueChange

Called with the new text on every edit, toggle or fix.

(value: string) => void—
onModeChange

Called with the resulting numeric mode, or null when the text isn't a mode.

(mode: number | null) => void—
path

The file or folder this is for (~/.ssh/id_ed25519, uploads/). Its name decides which rules apply.

string—
kind

What it is, when the name doesn't say. Overrides the guess from `path`.

FileKind—
current

The current mode, the starting point for symbolic changes like u+x.

number—
umask

Umask for symbolic changes with no u/g/o. Default 0o022.

number0o022
groupShared

The group is meant to share write access (a team folder), so 775 isn't flagged.

booleanfalse
label

Visible label; shorthand for `messages.label`.

string—
messages

Every visible string. `{who}`, `{verbs}`, `{name}`, `{fix}`, `{detail}`, `{input}`, `{base}`, `{result}`, `{octal}` are filled in.

Partial<ChmodInputMessages>—

* required. Also accepts the native props of <input> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Visible <label>; aria-invalid and aria-describedby to the readback and report
  • Summary in a role="status" region; an unreadable mode uses role="alert"
  • Permission grid checkboxes have aria-labels naming who and which right
  • After a fix, focus moves to the next fix or back to the field

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

This is a UX guard rail. Enforce on the server: Set and audit permissions in your deployment tooling; this field only advises.

  • Judges by the path and kind you pass; it can't see the real file, owner or ACLs
  • Advice assumes a typical Linux/OpenSSH setup; shared-group setups may be intentional (groupShared)

Rules

Rules last verified:

Informational. Checked: StrictModes (default yes) checks file modes and ownership before login; authorized_keys must not be writable by others. Other per-file recommendations are conventions, not checked against a standard. Copied components don't update themselves, so re-check after rule changes (see updating a component).

What it stops

World-writable file or exposed key

Also known as

chmod · file permissions · rwx · unix permissions · octal mode · 755 · 644 · linux

Field type

Dependencies

Pairs well with