The image creates SWW_STATE_DIR when it is missing (closes #337)
check / check (push) Waiting to run
check / check (push) Waiting to run
Before `waf` starts, the image's `run` script now makes `SWW_STATE_DIR` if it is missing (`mkdir -p`), gives it to `sww:sww` and sets its mode to `0700`, as it already does for the cache directory's owner. A value that is not an absolute path, or an unreadable `SWW_STATE_DIR_FILE`, still changes nothing, and `waf` stops naming the setting. The `Dockerfile` comment, `docs/image.md`, `docs/settings.md` and `SPEC.md` say the image makes the directory. `script/example-app` checks that a missing `SWW_STATE_DIR` is made, owned by `sww` with mode `0700`. - `chmod 0700` also applies to an existing directory, a mounted volume included, at every start of `waf`. Model: opus-5-5
This commit was merged in pull request #351.
This commit is contained in:
1 parent
b93bad5842
commit
697c2225d9
6 files changed
+40
-32
No files matched your search
+17
-18
@@ -12,7 +12,7 @@ main() {
|
||||
case "$command" in
|
||||
rproxy) ;;
|
||||
waf)
|
||||
give_state_dir_to_sww
|
||||
make_state_dir_for_sww
|
||||
make_cache_dir_for_sww
|
||||
;;
|
||||
*)
|
||||
@@ -24,28 +24,27 @@ main() {
|
||||
exec chpst -u sww:sww /usr/local/bin/sww "$command"
|
||||
}
|
||||
|
||||
# give_state_dir_to_sww gives the state directory and every file in
|
||||
# it to the sww user, so that a volume mounted there needs no change
|
||||
# of owner; chown -R changes a symbolic link itself, never what it points
|
||||
# to. When SWW_STATE_DIR, in either form, cannot be read or is not the
|
||||
# absolute path of a directory, no owner is changed, and waf starts and
|
||||
# stops with a message naming the setting. A change of owner that fails, as
|
||||
# on a volume mounted read-only, does not end the script either: waf
|
||||
# reports a directory it cannot write.
|
||||
give_state_dir_to_sww() {
|
||||
# make_state_dir_for_sww makes the state directory, SWW_STATE_DIR in
|
||||
# either form, when it is missing, gives it and every file in it to the
|
||||
# sww user, and sets its mode to 0700. So a volume mounted there needs no
|
||||
# change of owner; chown -R changes a symbolic link itself, never what it
|
||||
# points to. When the setting cannot be read or is not an absolute path,
|
||||
# nothing is changed, and waf starts and stops with a message naming the
|
||||
# setting. A step that fails, as on a volume mounted read-only, does not
|
||||
# end the script either: waf reports a directory it cannot write.
|
||||
make_state_dir_for_sww() {
|
||||
local dir
|
||||
if dir="$(setting SWW_STATE_DIR /var/lib/sww)" &&
|
||||
[[ "$dir" == /* && -d "$dir" ]]; then
|
||||
chown -R sww:sww "$dir" || true
|
||||
if dir="$(setting SWW_STATE_DIR /var/lib/sww)" && [[ "$dir" == /* ]]; then
|
||||
{ mkdir -p -- "$dir" && chown -R sww:sww "$dir" &&
|
||||
chmod 0700 "$dir"; } || true
|
||||
fi
|
||||
}
|
||||
|
||||
# make_cache_dir_for_sww makes the cache directory, SWW_CACHE_DIR in
|
||||
# either form, and gives it and every file in it to the sww user, as
|
||||
# give_state_dir_to_sww does the state directory. Unlike that one, it is
|
||||
# made when it is missing, since the cache files need no volume. As there,
|
||||
# a setting that cannot be read or is not an absolute path changes
|
||||
# nothing, and a failure does not end the script.
|
||||
# either form, when it is missing, and gives it and every file in it to
|
||||
# the sww user. As for the state directory, a setting that cannot be read
|
||||
# or is not an absolute path changes nothing, and a failure does not end
|
||||
# the script.
|
||||
make_cache_dir_for_sww() {
|
||||
local dir
|
||||
if dir="$(setting SWW_CACHE_DIR /var/cache/sww)" && [[ "$dir" == /* ]]; then
|
||||
|
||||
Reference in new issue
Block a user