docs · pre-release
Menu
Day to day / Dog grants

Dog grants

A dog talks to the shepherd over a connection of its own, and by default it may ask for anything the CLI can. Grants list what it may ask instead, so an honest dog stays in bounds and what it asks is attributable.

Granting

$ shep adopt ~/.cargo/bin/shep-otel --name otel
otel declares these permissions:
  flock.read (required): reads the flock to report on it
  events:process. (optional): hears when a sheep exits
Grants keep otel's requests in bounds and do not confine it: it runs as you and can do anything you can.
adopt otel and grant it these? [y/N] y

# shep.toml
[daemon.dog_grants.otel]
granted = ["flock.read", "events:process."]
  • A no leaves the dog adopted and disabled with nothing granted. The first shep enable asks again.
  • --yes grants everything declared. With no terminal and no --yes, nothing changes and the exit is 2.
  • A dog with no manifest prompts declares nothing, runs with full access, and a yes records no entry.
  • An unknown required permission refuses the command. An unknown optional one is dropped with a warning.
  • The built-in dogs ask too. metrics declares flock.read, events:channel.metric and events:process.; bark declares flock.read, events:process. and an optional events:log. for log rules. A built-in enabled before grants existed is granted its list at upgrade, marked not reviewed.

The shepherd reads the list at boot. A name it cannot read stops the boot, and shep adopt and shep enable refuse it too, so a typo never silently grants nothing.

Changing one

$ shep dogs revoke otel events:process.
$ shep dogs grant otel events:process.
  • Both write shep.toml and reach a running dog with no restart.
  • grant accepts only a permission the dog's manifest declares.
  • A dog with no dog_grants entry is refused: shep enable asks for its list first.

Upgrading

shep keeps the record in the same table. The shepherd still reads granted alone.

# shep.toml
[daemon.dog_grants.otel]
granted = ["flock.read"]
waiting = ["events:process."]
reviewed = false
  • The first shep with grants writes an enabled dog's declared list as granted, with reviewed = false. That covers metrics and bark too.
  • A dog with no manifest stays undeclared, with full access.
  • A rebuilt dog that declares more puts the new permissions in waiting, and runs on granted meanwhile.
  • shep enable asks about what waits. A no, or no terminal without --yes, changes nothing.
  • shep dogs grant approves the one permission it names and clears reviewed = false.
  • shep lookout ticks the same record: e on a settings dog row opens its grants checklist, and a tick runs the same check as the two verbs.
  • shep notices a rebuild at the next boot, reload, enable or grant.

shep dogs and the Dogs table of shep flock show an ACCESS column for this machine's dogs: undeclared, not reviewed or waiting. --format json adds access to each dog row, and the schema version does not move.

Permissions

PermissionLets the dog
flock.readlook at the flock and its configuration
flock.controlstart, stop, restart and signal sheep
flock.editadd and delete sheep and change their configuration
logs.readread the end of a sheep's log
logs.managereopen and flush logs
events:<prefix>subscribe to topics that begin with the prefix
secrets.read:<scope>read a sheep's dog settings with secrets resolved, in the environment the scope names
secrets.write:<namespace>push values into that namespace
dogs.controlenable, disable and configure other dogs
dogs.trigger:<name>send an action to the named dog
shepherd.controlstop the shepherd
  • A dog always keeps its own dogs.toml section and its own sheep settings, whatever it was granted. Another dog's config.dog.<name> needs events:config.dog.<name>.
  • events:dog.<name> covers the events that dog publishes and no other dog's. Publishing takes no grant: the kind has to be in the dog's manifest.
  • A subscription is judged on the part of each topic before its first glob character: events:process. covers process.* and events:process.exit does not.

A refusal

A dog granted only flock.read that asks to stop a sheep gets this back:

dog `otel` was refused `stop`: it needs `flock.control`, which was not granted to it

A launched sheep

A sheep sandboxed by a dog gets a link of its own, opened before it drops to its user. The link reads only that sheep's table for the dog and hears only that sheep's config.sheep.<dog> events. Anything else is forbidden, naming the request. The control socket still refuses the sheep.

Older shepherds

A shepherd older than protocol 12 records grants and enforces nothing. shep adopt and shep enable say so when they reach one.

careful
Grants are not a sandbox. A dog runs as you and could open the control socket the way the CLI does. They keep an honest dog inside the lines you drew and do not contain a hostile one.