Drop timedated-don-t-rely-on-usr-being-mounted-in-the-ini.patch

initramfs-tools has mounted /usr since Jessie, and tzdata now creates
/etc/localtime as a symlink too (see https://bugs.debian.org/803144).
This commit is contained in:
Martin Pitt
2016-02-08 22:58:32 +01:00
parent d6ab749bf9
commit d8b2e9f5d5
3 changed files with 3 additions and 148 deletions
+3
View File
@@ -4,6 +4,9 @@ systemd (228-7) UNRELEASED; urgency=medium
unit, which is a race condition with plymouthd auto-stopping.
(LP: #1543144)
* Do not warn about Wants depencencies on masked units. (LP: #1543282)
* Drop timedated-don-t-rely-on-usr-being-mounted-in-the-ini.patch.
initramfs-tools has mounted /usr since Jessie, and tzdata now creates
/etc/localtime as a symlink too (see #803144).
-- Martin Pitt <mpitt@debian.org> Mon, 08 Feb 2016 22:43:55 +0100
-1
View File
@@ -19,7 +19,6 @@ core-do-not-warn-about-Wants-depencencies-on-masked-units.patch
## Debian specific patches
Add-back-support-for-Debian-specific-config-files.patch
don-t-try-to-start-autovt-units-when-not-running-wit.patch
timedated-don-t-rely-on-usr-being-mounted-in-the-ini.patch
Make-logind-hostnamed-localed-timedated-D-Bus-activa.patch
Start-logind-on-demand-via-libpam-systemd.patch
Update-localed-to-use-the-Debian-config-files.patch
@@ -1,147 +0,0 @@
From: Michael Stapelberg <stapelberg@debian.org>
Date: Wed, 27 Nov 2013 22:48:47 +0100
Subject: =?utf-8?q?timedated=3A_don=E2=80=99t_rely_on_/usr_being_mounted_i?=
=?utf-8?q?n_the_initrd?=
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
This reverts commit 92c4ef2d357baeef78b6f82f119b92f7ed12ac77
We dont have /usr mounted in the initramfs yet in Debian, so lets
support split usr by copying the file instead of symlinking if
necessary, for now.
Closes: #726256
---
src/timedate/timedated.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 95 insertions(+), 1 deletion(-)
diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c
index 9df38b1..2199f29 100644
--- a/src/timedate/timedated.c
+++ b/src/timedate/timedated.c
@@ -22,6 +22,9 @@
#include <errno.h>
#include <string.h>
#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
#include "sd-bus.h"
#include "sd-event.h"
@@ -41,6 +44,9 @@
#include "strv.h"
#include "user-util.h"
#include "util.h"
+#include "random-util.h"
+#include "copy.h"
+#include "hexdecoct.h"
#define NULL_ADJTIME_UTC "0.0 0 0\n0\nUTC\n"
#define NULL_ADJTIME_LOCAL "0.0 0 0\n0\nLOCAL\n"
@@ -65,6 +71,94 @@ static void context_free(Context *c) {
bus_verify_polkit_async_registry_free(c->polkit_registry);
}
+static int symlink_or_copy(const char *from, const char *to) {
+ char *pf = NULL, *pt = NULL;
+ struct stat a, b;
+ int r;
+
+ assert(from);
+ assert(to);
+
+ if (!(pf = dirname_malloc(from)) ||
+ !(pt = dirname_malloc(to))) {
+ r = -ENOMEM;
+ goto finish;
+ }
+
+ if (stat(pf, &a) < 0 ||
+ stat(pt, &b) < 0) {
+ r = -errno;
+ goto finish;
+ }
+
+ if (a.st_dev != b.st_dev) {
+ free(pf);
+ free(pt);
+
+ return copy_file(from, to, O_EXCL, 0644, 0);
+ }
+
+ if (symlink(from, to) < 0) {
+ r = -errno;
+ goto finish;
+ }
+
+ r = 0;
+
+finish:
+ free(pf);
+ free(pt);
+
+ return r;
+}
+
+static int symlink_or_copy_atomic(const char *from, const char *to) {
+ char *t, *x;
+ const char *fn;
+ size_t k;
+ uint64_t u;
+ unsigned i;
+ int r;
+
+ assert(from);
+ assert(to);
+
+ t = new(char, strlen(to) + 1 + 16 + 1);
+ if (!t)
+ return -ENOMEM;
+
+ fn = basename(to);
+ k = fn-to;
+ memcpy(t, to, k);
+ t[k] = '.';
+ x = stpcpy(t+k+1, fn);
+
+ u = random_u64();
+ for (i = 0; i < 16; i++) {
+ *(x++) = hexchar(u & 0xF);
+ u >>= 4;
+ }
+
+ *x = 0;
+
+ r = symlink_or_copy(from, t);
+ if (r < 0) {
+ unlink(t);
+ free(t);
+ return r;
+ }
+
+ if (rename(t, to) < 0) {
+ r = -errno;
+ unlink(t);
+ free(t);
+ return r;
+ }
+
+ free(t);
+ return r;
+}
+
static int context_read_data(Context *c) {
_cleanup_free_ char *t = NULL;
int r;
@@ -107,7 +201,7 @@ static int context_write_data_timezone(Context *c) {
if (!p)
return log_oom();
- r = symlink_atomic(p, "/etc/localtime");
+ r = symlink_or_copy_atomic(p, "/etc/localtime");
if (r < 0)
return r;