[systemd-commits] 2 commits - src/nspawn src/python-systemd
Zbigniew JÄdrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Thu Apr 18 16:47:11 PDT 2013
src/nspawn/nspawn.c | 17 ++++++++++++-----
src/python-systemd/_reader.c | 23 ++++++++++++++++++++++-
2 files changed, 34 insertions(+), 6 deletions(-)
New commits:
commit 7f876bc4281145e6c74e98de07c6648a5b51ed90
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Thu Apr 18 19:37:26 2013 -0400
systemd-python: wrap sd_journal_add_conjunction
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__},
commit f333fbb1efc2f32527f78cbdb003d59bae01aa07
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Wed Apr 17 14:13:09 2013 -0400
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.
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;
}
More information about the systemd-commits
mailing list