From 6844c2066c30e94ba06ab98ac1d05d5c2706b30c Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Apr 19 2013 12:39:16 +0000 Subject: systemd-202-2 - nspawn create empty /etc/resolv.conf if necessary - python wrapper: add sd_journal_add_conjunction() - fix s390 booting Resolves: rhbz#953217 --- diff --git a/0001-nspawn-create-empty-etc-resolv.conf-if-necessary.patch b/0001-nspawn-create-empty-etc-resolv.conf-if-necessary.patch new file mode 100644 index 0000000..6f9d99a --- /dev/null +++ b/0001-nspawn-create-empty-etc-resolv.conf-if-necessary.patch @@ -0,0 +1,58 @@ +From f333fbb1efc2f32527f78cbdb003d59bae01aa07 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Wed, 17 Apr 2013 14:13:09 -0400 +Subject: [PATCH] nspawn: create empty /etc/resolv.conf if necessary + +nspawn will overmount resolv.conf if it exists. Since e.g. +default install with yum doesn't create /etc/resolv.conf, +a container created with yum will not have network. This +seems undesirable, and since we overmount the file anyway, +let's create it too. + +Also, mounting a read-write /etc/resolv.conf in the container +is treated as a failure, since it makes it possible to +modify hosts /etc/resolv.conf from inside the container. +--- + src/nspawn/nspawn.c | 17 ++++++++++++----- + 1 file changed, 12 insertions(+), 5 deletions(-) + +diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c +index f57c75f..5a43d5e 100644 +--- a/src/nspawn/nspawn.c ++++ b/src/nspawn/nspawn.c +@@ -492,7 +492,8 @@ static int setup_timezone(const char *dest) { + } + + static int setup_resolv_conf(const char *dest) { +- char *where; ++ char _cleanup_free_ *where = NULL; ++ _cleanup_close_ int fd = -1; + + assert(dest); + +@@ -504,12 +505,18 @@ static int setup_resolv_conf(const char *dest) { + if (!where) + return log_oom(); + ++ fd = open(where, O_WRONLY|O_CREAT|O_EXCL|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW, 0644); ++ + /* 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); +- +- free(where); ++ if (mount("/etc/resolv.conf", where, "bind", MS_BIND, NULL) < 0) ++ log_warning("Failed to bind mount /etc/resolv.conf: %m"); ++ else ++ if (mount("/etc/resolv.conf", where, "bind", ++ MS_BIND|MS_REMOUNT|MS_RDONLY, NULL) < 0) { ++ log_error("Failed to remount /etc/resolv.conf readonly: %m"); ++ return -errno; ++ } + + return 0; + } +-- +1.8.2 + diff --git a/0002-systemd-python-wrap-sd_journal_add_conjunction.patch b/0002-systemd-python-wrap-sd_journal_add_conjunction.patch new file mode 100644 index 0000000..96ea821 --- /dev/null +++ b/0002-systemd-python-wrap-sd_journal_add_conjunction.patch @@ -0,0 +1,60 @@ +From 7f876bc4281145e6c74e98de07c6648a5b51ed90 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Thu, 18 Apr 2013 19:37:26 -0400 +Subject: [PATCH] systemd-python: wrap sd_journal_add_conjunction + +--- + src/python-systemd/_reader.c | 23 ++++++++++++++++++++++- + 1 file changed, 22 insertions(+), 1 deletion(-) + +diff --git a/src/python-systemd/_reader.c b/src/python-systemd/_reader.c +index 05993b3..b836597 100644 +--- a/src/python-systemd/_reader.c ++++ b/src/python-systemd/_reader.c +@@ -567,7 +567,10 @@ static PyObject* Reader_add_match(Reader *self, PyObject *args, PyObject *keywds + + PyDoc_STRVAR(Reader_add_disjunction__doc__, + "add_disjunction() -> None\n\n" +- "Inserts a logical OR between matches added before and afterwards."); ++ "Inserts a logical OR between matches added since previous\n" ++ "add_disjunction() or add_conjunction() and the next\n" ++ "add_disjunction() or add_conjunction().\n\n" ++ "See man:sd_journal_add_disjunction(3) for explanation."); + static PyObject* Reader_add_disjunction(Reader *self, PyObject *args) + { + int r; +@@ -579,6 +582,23 @@ static PyObject* Reader_add_disjunction(Reader *self, PyObject *args) + } + + ++PyDoc_STRVAR(Reader_add_conjunction__doc__, ++ "add_conjunction() -> None\n\n" ++ "Inserts a logical AND between matches added since previous\n" ++ "add_disjunction() or add_conjunction() and the next\n" ++ "add_disjunction() or add_conjunction().\n\n" ++ "See man:sd_journal_add_disjunction(3) for explanation."); ++static PyObject* Reader_add_conjunction(Reader *self, PyObject *args) ++{ ++ int r; ++ r = sd_journal_add_conjunction(self->j); ++ set_error(r, NULL, NULL); ++ if (r < 0) ++ return NULL; ++ Py_RETURN_NONE; ++} ++ ++ + PyDoc_STRVAR(Reader_flush_matches__doc__, + "flush_matches() -> None\n\n" + "Clear all current match filters."); +@@ -980,6 +1000,7 @@ static PyMethodDef Reader_methods[] = { + {"_get_monotonic", (PyCFunction) Reader_get_monotonic, METH_NOARGS, Reader_get_monotonic__doc__}, + {"add_match", (PyCFunction) Reader_add_match, METH_VARARGS|METH_KEYWORDS, Reader_add_match__doc__}, + {"add_disjunction", (PyCFunction) Reader_add_disjunction, METH_NOARGS, Reader_add_disjunction__doc__}, ++ {"add_conjunction", (PyCFunction) Reader_add_conjunction, METH_NOARGS, Reader_add_conjunction__doc__}, + {"flush_matches", (PyCFunction) Reader_flush_matches, METH_NOARGS, Reader_flush_matches__doc__}, + {"seek_head", (PyCFunction) Reader_seek_head, METH_NOARGS, Reader_seek_head__doc__}, + {"seek_tail", (PyCFunction) Reader_seek_tail, METH_NOARGS, Reader_seek_tail__doc__}, +-- +1.8.2 + diff --git a/0003-Update-NEWS.patch b/0003-Update-NEWS.patch new file mode 100644 index 0000000..5b8a85e --- /dev/null +++ b/0003-Update-NEWS.patch @@ -0,0 +1,30 @@ +From cbeabcfbc5a5fa27385e5794780e8f034e090606 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= +Date: Thu, 18 Apr 2013 19:59:12 -0400 +Subject: [PATCH] Update NEWS + +--- + NEWS | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/NEWS b/NEWS +index 2b46246..afaadf3 100644 +--- a/NEWS ++++ b/NEWS +@@ -53,6 +53,13 @@ CHANGES WITH 202: + found the tool will now automatically fall back to prompting + the user. + ++ * Python systemd.journal module was updated to wrap recently ++ added functions from libsystemd-journal. The interface was ++ changed to bring the low level interface in s.j._Reader ++ closer to the C API, and the high level interface in ++ s.j.Reader was updated to wrap and convert all data about ++ an entry. ++ + Contributions from: Anatol Pomozov, Auke Kok, Harald Hoyer, + Henrik Grindal Bakken, Josh Triplett, Kay Sievers, Lennart + Poettering, Lukas Nykryn, Mantas Mikulėnas Marius Vollmer, +-- +1.8.2 + diff --git a/0004-Reintroduce-f_type-comparison-macro.patch b/0004-Reintroduce-f_type-comparison-macro.patch new file mode 100644 index 0000000..7741a67 --- /dev/null +++ b/0004-Reintroduce-f_type-comparison-macro.patch @@ -0,0 +1,118 @@ +From bdd29249a882e599e5e365536372d08dee398cd4 Mon Sep 17 00:00:00 2001 +From: Harald Hoyer +Date: Fri, 19 Apr 2013 13:44:56 +0200 +Subject: [PATCH] Reintroduce f_type comparison macro + +This reverts commit 4826f0b7b5c0aefa08b8cc7ef64d69027f84da2c. + +Because statfs.t_type can be int on some architecures, we have to cast +the const magic to the type, otherwise the compiler warns about +signed/unsigned comparison, because the magic can be 32 bit unsigned. + +statfs(2) man page is also wrong on some systems, because +f_type is not __SWORD_TYPE on some architecures. + +The following program: + +int main(int argc, char**argv) +{ + struct statfs s; + statfs(argv[1], &s); + + printf("sizeof(f_type) = %d\n", sizeof(s.f_type)); + printf("sizeof(__SWORD_TYPE) = %d\n", sizeof(__SWORD_TYPE)); + printf("sizeof(long) = %d\n", sizeof(long)); + printf("sizeof(int) = %d\n", sizeof(int)); + if (sizeof(s.f_type) == sizeof(int)) { + printf("f_type = 0x%x\n", s.f_type); + } else { + printf("f_type = 0x%lx\n", s.f_type); + } + return 0; +} + +executed on s390x gives for a btrfs: + +sizeof(f_type) = 4 +sizeof(__SWORD_TYPE) = 8 +sizeof(long) = 8 +sizeof(int) = 4 +f_type = 0x9123683e +--- + src/journal/sd-journal.c | 10 +++++----- + src/readahead/readahead-collect.c | 2 +- + src/shared/macro.h | 7 +++++++ + src/shared/util.c | 5 +++-- + 4 files changed, 16 insertions(+), 8 deletions(-) + +diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c +index e021d98..15239b5 100644 +--- a/src/journal/sd-journal.c ++++ b/src/journal/sd-journal.c +@@ -1251,11 +1251,11 @@ static void check_network(sd_journal *j, int fd) { + return; + + j->on_network = +- sfs.f_type == (__SWORD_TYPE) CIFS_MAGIC_NUMBER || +- sfs.f_type == (__SWORD_TYPE) CODA_SUPER_MAGIC || +- sfs.f_type == (__SWORD_TYPE) NCP_SUPER_MAGIC || +- sfs.f_type == (__SWORD_TYPE) NFS_SUPER_MAGIC || +- sfs.f_type == (__SWORD_TYPE) SMB_SUPER_MAGIC; ++ F_TYPE_CMP(sfs.f_type, CIFS_MAGIC_NUMBER) || ++ F_TYPE_CMP(sfs.f_type, CODA_SUPER_MAGIC) || ++ F_TYPE_CMP(sfs.f_type, NCP_SUPER_MAGIC) || ++ F_TYPE_CMP(sfs.f_type, NFS_SUPER_MAGIC) || ++ F_TYPE_CMP(sfs.f_type, SMB_SUPER_MAGIC); + } + + static int add_file(sd_journal *j, const char *prefix, const char *filename) { +diff --git a/src/readahead/readahead-collect.c b/src/readahead/readahead-collect.c +index 02ecbe5..75ec5b7 100644 +--- a/src/readahead/readahead-collect.c ++++ b/src/readahead/readahead-collect.c +@@ -505,7 +505,7 @@ done: + on_ssd = fs_on_ssd(root) > 0; + log_debug("On SSD: %s", yes_no(on_ssd)); + +- on_btrfs = statfs(root, &sfs) >= 0 && sfs.f_type == (__SWORD_TYPE) BTRFS_SUPER_MAGIC; ++ on_btrfs = statfs(root, &sfs) >= 0 && F_TYPE_CMP(sfs.f_type, BTRFS_SUPER_MAGIC); + log_debug("On btrfs: %s", yes_no(on_btrfs)); + + if (asprintf(&pack_fn_new, "%s/.readahead.new", root) < 0) { +diff --git a/src/shared/macro.h b/src/shared/macro.h +index 9bf81dc..ac61b49 100644 +--- a/src/shared/macro.h ++++ b/src/shared/macro.h +@@ -264,6 +264,13 @@ do { \ + } \ + } while(false) + ++ /* Because statfs.t_type can be int on some architecures, we have to cast ++ * the const magic to the type, otherwise the compiler warns about ++ * signed/unsigned comparison, because the magic can be 32 bit unsigned. ++ */ ++#define F_TYPE_CMP(a, b) (a == (typeof(a)) b) ++ ++ + /* Returns the number of chars needed to format variables of the + * specified type as a decimal string. Adds in extra space for a + * negative '-' prefix. */ +diff --git a/src/shared/util.c b/src/shared/util.c +index 5d03272..1fc6c5a 100644 +--- a/src/shared/util.c ++++ b/src/shared/util.c +@@ -2779,8 +2779,9 @@ int rm_rf_children_dangerous(int fd, bool only_dirs, bool honour_sticky, struct + + static int is_temporary_fs(struct statfs *s) { + assert(s); +- return s->f_type == (__SWORD_TYPE) TMPFS_MAGIC || +- s->f_type == (__SWORD_TYPE) RAMFS_MAGIC; ++ return ++ F_TYPE_CMP(s->f_type, TMPFS_MAGIC) || ++ F_TYPE_CMP(s->f_type, RAMFS_MAGIC); + } + + int rm_rf_children(int fd, bool only_dirs, bool honour_sticky, struct stat *root_dev) { +-- +1.8.2 + diff --git a/systemd.spec b/systemd.spec index d20b5e5..9efb745 100644 --- a/systemd.spec +++ b/systemd.spec @@ -13,7 +13,7 @@ Name: systemd Url: http://www.freedesktop.org/wiki/Software/systemd Version: 202 -Release: 1%{?gitcommit:.git%{gitcommit}}%{?dist} +Release: 2%{?gitcommit:.git%{gitcommit}}%{?dist} # For a breakdown of the licensing, see README License: LGPLv2+ and MIT and GPLv2+ Summary: A System and Service Manager @@ -34,6 +34,11 @@ Source4: listen.conf # Prevent accidental removal of the systemd package Source6: yum-protect-systemd.conf +Patch1: 0001-nspawn-create-empty-etc-resolv.conf-if-necessary.patch +Patch2: 0002-systemd-python-wrap-sd_journal_add_conjunction.patch +Patch3: 0003-Update-NEWS.patch +Patch4: 0004-Reintroduce-f_type-comparison-macro.patch + # kernel-install patch for grubby, drop if grubby is obsolete Patch1000: kernel-install-grubby.patch @@ -753,6 +758,12 @@ fi %{_libdir}/pkgconfig/gudev-1.0* %changelog +* Fri Apr 19 2013 Harald Hoyer 202-2 +- nspawn create empty /etc/resolv.conf if necessary +- python wrapper: add sd_journal_add_conjunction() +- fix s390 booting +Resolves: rhbz#953217 + * Thu Apr 18 2013 Lennart Poettering - 202-1 - New upstream release @@ -1397,7 +1408,7 @@ fi * Mon Jun 14 2010 Rahul Sundaram - 0-0.4.20100614git393024 - Pull the latest snapshot that fixes a segfault. Resolves rhbz#603231 -* Thu Jun 11 2010 Rahul Sundaram - 0-0.3.20100610git2f198e +* Fri Jun 11 2010 Rahul Sundaram - 0-0.3.20100610git2f198e - More minor fixes as per review * Thu Jun 10 2010 Rahul Sundaram - 0-0.2.20100610git2f198e