mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
namespace: fix mode for TemporaryFileSystem=
... when no mount options are passed. Change the code, to avoid the following failure in the newly added tests: exec-temporaryfilesystem-rw.service: Executing: /usr/bin/sh -x -c '[ "$(stat -c %a /var)" == 755 ]' ++ stat -c %a /var + '[' 1777 == 755 ']' Received SIGCHLD from PID 30364 (sh). Child 30364 (sh) died (code=exited, status=1/FAILURE) (And I spotted an opportunity to use TAKE_PTR() at the end).
This commit is contained in:
parent
69338c3dfb
commit
ad8e66dcc4
@ -304,7 +304,7 @@ static int append_tmpfs_mounts(MountEntry **p, const TemporaryFileSystem *tmpfs,
|
||||
for (i = 0; i < n; i++) {
|
||||
const TemporaryFileSystem *t = tmpfs + i;
|
||||
_cleanup_free_ char *o = NULL, *str = NULL;
|
||||
unsigned long flags = MS_NODEV|MS_STRICTATIME;
|
||||
unsigned long flags;
|
||||
bool ro = false;
|
||||
|
||||
if (!path_is_absolute(t->path)) {
|
||||
@ -312,29 +312,25 @@ static int append_tmpfs_mounts(MountEntry **p, const TemporaryFileSystem *tmpfs,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!isempty(t->options)) {
|
||||
str = strjoin("mode=0755,", t->options);
|
||||
if (!str)
|
||||
return -ENOMEM;
|
||||
str = strjoin("mode=0755,", t->options);
|
||||
if (!str)
|
||||
return -ENOMEM;
|
||||
|
||||
r = mount_option_mangle(str, MS_NODEV|MS_STRICTATIME, &flags, &o);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to parse mount option '%s': %m", str);
|
||||
r = mount_option_mangle(str, MS_NODEV|MS_STRICTATIME, &flags, &o);
|
||||
if (r < 0)
|
||||
return log_debug_errno(r, "Failed to parse mount option '%s': %m", str);
|
||||
|
||||
ro = flags & MS_RDONLY;
|
||||
if (ro)
|
||||
flags ^= MS_RDONLY;
|
||||
}
|
||||
ro = flags & MS_RDONLY;
|
||||
if (ro)
|
||||
flags ^= MS_RDONLY;
|
||||
|
||||
*((*p)++) = (MountEntry) {
|
||||
.path_const = t->path,
|
||||
.mode = TMPFS,
|
||||
.read_only = ro,
|
||||
.options_malloc = o,
|
||||
.options_malloc = TAKE_PTR(o),
|
||||
.flags = flags,
|
||||
};
|
||||
|
||||
o = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -10,6 +10,9 @@ ExecStart=/bin/sh -c 'test -d /var/test-exec-temporaryfilesystem/rw && test -d /
|
||||
# Check TemporaryFileSystem= are empty
|
||||
ExecStart=/bin/sh -c 'for i in $$(ls -A /var); do test $$i = test-exec-temporaryfilesystem || false; done'
|
||||
|
||||
# Check default mode
|
||||
ExecStart=sh -x -c 'test "$$(stat -c %%a /var)" = "755"'
|
||||
|
||||
# Cannot create a file in /var
|
||||
ExecStart=/bin/sh -c '! touch /var/hoge'
|
||||
|
||||
|
@ -10,6 +10,9 @@ ExecStart=test -d /var/test-exec-temporaryfilesystem/rw -a -d /var/test-exec-tem
|
||||
# Check TemporaryFileSystem= are empty
|
||||
ExecStart=sh -c 'for i in $$(ls -A /var); do test $$i = test-exec-temporaryfilesystem || false; done'
|
||||
|
||||
# Check default mode
|
||||
ExecStart=sh -x -c 'test "$$(stat -c %%a /var)" = "755"'
|
||||
|
||||
# Create a file in /var
|
||||
ExecStart=touch /var/hoge
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user