Skip to content

Raise OSError on jail(2) failures with the kernel error message - #14

Merged
gronke merged 2 commits into
gronke:mainfrom
no-pictures:fix/jail-errors
Jul 9, 2026
Merged

Raise OSError on jail(2) failures with the kernel error message#14
gronke merged 2 commits into
gronke:mainfrom
no-pictures:fix/jail-errors

Conversation

@gronke

@gronke gronke commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Failures were only visible as negative return codes and an errmsg buffer nobody was required to check.

  • New jail_set, jail_get, jail_attach and jail_remove wrappers raise OSError carrying errno and, where a Jiov is involved, the errmsg the kernel filled in — "jail 5 already exists" instead of a
    generic message.
  • jail_attach is wrapped for the first time; a test attaches a child process to a fresh jail and checks that its root moved.
  • The JAIL_CREATE, JAIL_UPDATE, JAIL_ATTACH and JAIL_DYING constants replace the magic flag numbers.
  • get_jid_by_name and is_jid_dying keep returning -1 and False for missing jails and raise for every other failure; raw jail.dll access stays available.

gronke added 2 commits July 8, 2026 08:31
The jail_set, jail_get, jail_attach and jail_remove wrappers check the return value and raise OSError carrying errno and, where a Jiov is involved, the errmsg the kernel filled in.
get_jid_by_name and is_jid_dying keep returning -1 and False for missing jails and raise for every other failure.
The JAIL_CREATE, JAIL_UPDATE, JAIL_ATTACH and JAIL_DYING constants replace the magic numbers, while raw access through jail.dll stays available.
Duplicate creation reports EEXIST together with the kernel message, and removing or attaching missing jails reports EINVAL.
A child process attaches to a fresh jail and checks that its root moved into the jail path.
@no-pictures
no-pictures Bot force-pushed the fix/jail-errors branch from 8c59136 to 80b8189 Compare July 8, 2026 09:15
@gronke
gronke merged commit 0e3bf79 into gronke:main Jul 9, 2026
4 checks passed
@no-pictures
no-pictures Bot deleted the fix/jail-errors branch July 9, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant