summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej Wereski <m.wereski@partner.samsung.com>2013-08-21 16:43:55 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-08-23 12:48:14 -0400
commitea92ae33e0fbbf8a98cd2e08ca5a850d83d57fae (patch)
tree9a4285fc26e58f99c41d8d7bed8e60732ff4227c
parentac8e20c6e95975316279740778f381ad50a1a21a (diff)
"-" prefix for InaccessibleDirectories and ReadOnlyDirectories
-rw-r--r--TODO6
-rw-r--r--man/systemd.exec.xml10
-rw-r--r--src/core/namespace.c12
-rw-r--r--src/shared/conf-parser.c10
4 files changed, 31 insertions, 7 deletions
diff --git a/TODO b/TODO
index 3800ce476..fe305ecb6 100644
--- a/TODO
+++ b/TODO
@@ -23,6 +23,9 @@ Bugfixes:
- make the resulting line the requested number of *characters*, not *bytes*,
- avoid truncuating multi-byte sequences in the middle.
+* When we detect invalid UTF-8, we cant't use it in an error message:
+ log...("Path is not UTF-8 clean, ignoring assignment: %s", rvalue);
+
* shorten the message to sane length:
Cannot add dependency job for unit display-manager.service, ignoring: Unit display-manager.service failed to load: No such file or directory. See system logs and 'systemctl status display-manager.service' for details.
@@ -285,9 +288,6 @@ Features:
* timedate: have global on/off switches for auto-time (NTP), and auto-timezone that connman can subscribe to.
-* Honour "-" prefix for InaccessibleDirectories= and ReadOnlyDirectories= to
- suppress errors of the specified path doesn't exist
-
* dev-setup.c: when running in a container, create a tiny stub udev
database with the systemd tag set for all network interfaces found,
so that libudev reports them as present, and systemd's .device units
diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml
index c0e1d862a..b761832ed 100644
--- a/man/systemd.exec.xml
+++ b/man/systemd.exec.xml
@@ -828,7 +828,15 @@
the empty string is assigned to this
option the specific list is reset, and
all prior assignments have no
- effect.</para></listitem>
+ effect.</para>
+ <para>Paths in
+ <varname>ReadOnlyDirectories=</varname>
+ and
+ <varname>InaccessibleDirectories=</varname>
+ may be prefixed with
+ <literal>-</literal>, in which case
+ they will be ignored when they don't
+ exist.</para></listitem>
</varlistentry>
<varlistentry>
diff --git a/src/core/namespace.c b/src/core/namespace.c
index 7e33d8415..16b132ba5 100644
--- a/src/core/namespace.c
+++ b/src/core/namespace.c
@@ -51,6 +51,7 @@ typedef struct BindMount {
const char *path;
MountMode mode;
bool done;
+ bool ignore;
} BindMount;
static int append_mounts(BindMount **p, char **strv, MountMode mode) {
@@ -58,6 +59,13 @@ static int append_mounts(BindMount **p, char **strv, MountMode mode) {
STRV_FOREACH(i, strv) {
+ (*p)->ignore = false;
+
+ if ((mode == INACCESSIBLE || mode == READONLY) && (*i)[0] == '-') {
+ (*p)->ignore = true;
+ (*i)++;
+ }
+
if (!path_is_absolute(*i))
return -EINVAL;
@@ -155,6 +163,8 @@ static int apply_mount(
r = mount(what, m->path, NULL, MS_BIND|MS_REC, NULL);
if (r >= 0)
log_debug("Successfully mounted %s to %s", what, m->path);
+ else if (m->ignore && errno == ENOENT)
+ r = 0;
return r;
}
@@ -168,7 +178,7 @@ static int make_read_only(BindMount *m) {
return 0;
r = mount(NULL, m->path, NULL, MS_BIND|MS_REMOUNT|MS_RDONLY|MS_REC, NULL);
- if (r < 0)
+ if (r < 0 && !(m->ignore && errno == ENOENT))
return -errno;
return 0;
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index 2303d9a50..6085d3339 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -599,6 +599,7 @@ int config_parse_path(const char *unit,
char **s = data;
char *n;
+ int offset;
assert(filename);
assert(lvalue);
@@ -611,7 +612,9 @@ int config_parse_path(const char *unit,
return 0;
}
- if (!path_is_absolute(rvalue)) {
+ offset = rvalue[0] == '-' && (streq(lvalue, "InaccessibleDirectories") ||
+ streq(lvalue, "ReadOnlyDirectories"));
+ if (!path_is_absolute(rvalue + offset)) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
"Not an absolute path, ignoring: %s", rvalue);
return 0;
@@ -713,6 +716,7 @@ int config_parse_path_strv(const char *unit,
FOREACH_WORD_QUOTED(w, l, rvalue, state) {
_cleanup_free_ char *n;
+ int offset;
n = strndup(w, l);
if (!n)
@@ -724,7 +728,9 @@ int config_parse_path_strv(const char *unit,
continue;
}
- if (!path_is_absolute(n)) {
+ offset = n[0] == '-' && (streq(lvalue, "InaccessibleDirectories") ||
+ streq(lvalue, "ReadOnlyDirectories"));
+ if (!path_is_absolute(n + offset)) {
log_syntax(unit, LOG_ERR, filename, line, EINVAL,
"Not an absolute path, ignoring: %s", rvalue);
continue;