[systemd-commits] 2 commits - src/nspawn
Lennart Poettering
lennart at kemper.freedesktop.org
Fri Sep 21 07:56:05 PDT 2012
src/nspawn/nspawn.c | 53 +++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 44 insertions(+), 9 deletions(-)
New commits:
commit 77e63fafa5736c235920b8deef73afbf733a7fda
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Sep 21 16:55:56 2012 +0200
nspawn: document why we don't check resolv.conf mount errors
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index d181e3b..959df4e 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -404,6 +404,8 @@ static int setup_resolv_conf(const char *dest) {
if (!where)
return log_oom();
+ /* We don't really care for the results of this really. If it
+ * fails, it fails, but meh... */
if (mount("/etc/resolv.conf", where, "bind", MS_BIND, NULL) >= 0)
mount("/etc/resolv.conf", where, "bind", MS_BIND|MS_REMOUNT|MS_RDONLY, NULL);
commit d40361453be0525a0455d549b2b863931b069358
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Sep 21 16:54:54 2012 +0200
nspawn: we can't overmount /etc/localtime anymore since it's usually a symlink now
Create the right symlink if possible for /etc/localtime
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index ab7a239..d181e3b 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -332,28 +332,61 @@ static int mount_all(const char *dest) {
}
static int setup_timezone(const char *dest) {
- char *where;
+ _cleanup_free_ char *where = NULL, *p = NULL, *q = NULL, *check = NULL, *what = NULL;
+ char *z, *y;
+ int r;
assert(dest);
/* Fix the timezone, if possible */
+ r = readlink_malloc("/etc/localtime", &p);
+ if (r < 0) {
+ log_warning("/etc/localtime is not a symlink, not updating container timezone.");
+ return 0;
+ }
+
+ z = path_startswith(p, "../usr/share/zoneinfo/");
+ if (!z)
+ z = path_startswith(p, "/usr/share/zoneinfo/");
+ if (!z) {
+ log_warning("/etc/localtime does not point into /usr/share/zoneinfo/, not updating container timezone.");
+ return 0;
+ }
+
where = strappend(dest, "/etc/localtime");
if (!where)
return log_oom();
- if (mount("/etc/localtime", where, "bind", MS_BIND, NULL) >= 0)
- mount("/etc/localtime", where, "bind", MS_BIND|MS_REMOUNT|MS_RDONLY, NULL);
+ r = readlink_malloc(where, &q);
+ if (r >= 0) {
+ y = path_startswith(q, "../usr/share/zoneinfo/");
+ if (!y)
+ y = path_startswith(q, "/usr/share/zoneinfo/");
- free(where);
- where = strappend(dest, "/etc/timezone");
- if (!where)
+ /* Already pointing to the right place? Then do nothing .. */
+ if (y && streq(y, z))
+ return 0;
+ }
+
+ check = strjoin(dest, "/usr/share/zoneinfo/", z, NULL);
+ if (!check)
return log_oom();
- if (mount("/etc/timezone", where, "bind", MS_BIND, NULL) >= 0)
- mount("/etc/timezone", where, "bind", MS_BIND|MS_REMOUNT|MS_RDONLY, NULL);
+ if (access(check, F_OK) < 0) {
+ log_warning("Timezone %s does not exist in container, not updating container timezone.", z);
+ return 0;
+ }
- free(where);
+ what = strappend("../usr/share/zoneinfo/", z);
+ if (!what)
+ return log_oom();
+
+ unlink(where);
+ if (symlink(what, where) < 0) {
+ log_error("Failed to correct timezone of container: %m");
+ return 0;
+ }
return 0;
}
More information about the systemd-commits
mailing list