Skip to content

service: add workdir support for daemon instances - #51

Open
1715173329 wants to merge 1 commit into
openwrt:mainfrom
1715173329:workdir
Open

1715173329 wants to merge 1 commit into
openwrt:mainfrom
1715173329:workdir

Conversation

@1715173329

Copy link
Copy Markdown
Member

Allow instances to select a working directory with the workdir option.
Change directory after setting the process identity and fail startup
if the directory cannot be entered. Preserve the existing behavior
when workdir is omitted.

Pass the directory to ujail through a new -W option, reusing its
existing directory switch after jail setup. Track workdir changes,
include the value in instance dumps, and release owned strings.

@1715173329

Copy link
Copy Markdown
Member Author

Kindly ping @dangowrt @PolynomialDivision

@dangowrt

Copy link
Copy Markdown
Member

Thanks for the workdir option, it is a welcome addition. In the meantime a larger series landed on main, and the PR needs a few changes before it can go in:

  1. Option letter. -W <file> is now taken in ujail by the resources override (5beb80f), and procd passes -W for the jail resources attribute (26a0309). Merged as is, procd would hand the working directory to ujail as a resources file. Please use one of the letters still free in OPT_ARGS: B, H, L, Q, v or z.
  2. Rebase. The PR no longer applies to main (conflicts in jail/jail.c). main() and its getopt loop now sit at the end of jail.c, and OPT_ARGS and the usage text have changed, so the hunks need to move along with them.
  3. procd.sh. _procd_set_param() in package/system/procd/files/procd.sh (openwrt/openwrt) only forwards the keys it knows, so procd_set_param workdir /some/dir in an init script is silently dropped. Please open the matching openwrt/openwrt PR adding workdir to the string parameters and link it here, so that both can be merged together.

For bundle (OCI) instances, process.cwd from the bundle still takes precedence because parseOCIprocess() runs after option parsing. That looks right to me, and a sentence about it in the commit message would help.

Allow instances to select a working directory with the workdir option.
Change directory after setting the process identity and fail startup
if the directory cannot be entered. Preserve the existing behavior
when workdir is omitted.

Pass the directory to ujail through a new -B option, reusing its
existing directory switch after jail setup. Track workdir changes,
include the value in instance dumps, and release owned strings.

For OCI bundle instances, process.cwd from the bundle takes precedence
over workdir because the bundle is parsed after the command-line options.

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
@1715173329

Copy link
Copy Markdown
Member Author

Rebased upon master branch.

  1. procd.sh. _procd_set_param() in package/system/procd/files/procd.sh (openwrt/openwrt) only forwards the keys it knows, so procd_set_param workdir /some/dir in an init script is silently dropped. Please open the matching openwrt/openwrt PR adding workdir to the string parameters and link it here, so that both can be merged together.

procd.sh depends on this PR so I plan to do it after this get merged.

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.

2 participants