chiark / gitweb /
util: fix tty_is_vc_resolve() in a container where /sys/class/tty/console/active...
authorLennart Poettering <lennart@poettering.net>
Sat, 21 Apr 2012 23:59:11 +0000 (01:59 +0200)
committerLennart Poettering <lennart@poettering.net>
Sat, 21 Apr 2012 23:59:11 +0000 (01:59 +0200)
TODO
src/core/condition.c
src/shared/util.c
src/shared/util.h

diff --git a/TODO b/TODO
index a008fe61504e9a49717004da35c3f93663d8913b..62b5ebf6e4054b0c6ee8f37b26eed35d00806951 100644 (file)
--- a/TODO
+++ b/TODO
@@ -20,6 +20,9 @@ Bugfixes:
 * properly handle .mount unit state tracking when two mount points are stacked one on top of another on the exact same mount point.
 
 Features:
+
+* Add pretty name for seats in logind
+
 * nspawn wants dev_setup() for /dev/fd/ and friends?
 
 * selinux: merge systemd selinux access controls (dwalsh)
index 3b246f1a64ed479fee757439abf60940617ebd25..5d44039e5d24cd07c3e94ad2e49f1a3629b88578 100644 (file)
@@ -223,14 +223,8 @@ bool condition_test(Condition *c) {
         case CONDITION_PATH_IS_MOUNT_POINT:
                 return (path_is_mount_point(c->parameter, true) > 0) == !c->negate;
 
-        case CONDITION_PATH_IS_READ_WRITE: {
-                struct statvfs st;
-
-                if (statvfs(c->parameter, &st) < 0)
-                        return c->negate;
-
-                return !(st.f_flag & ST_RDONLY) == !c->negate;
-        }
+        case CONDITION_PATH_IS_READ_WRITE:
+                return (path_is_read_only_fs(c->parameter) > 0) == c->negate;
 
         case CONDITION_DIRECTORY_NOT_EMPTY: {
                 int k;
index 15c7f4d3257459b0865ed76b9ce2f66a51dd5dad..43948ccbd8970c5076d2f00659d26f2d449fa4ce 100644 (file)
@@ -56,6 +56,7 @@
 #include <glob.h>
 #include <grp.h>
 #include <sys/mman.h>
+#include <sys/statvfs.h>
 
 #include "macro.h"
 #include "util.h"
@@ -4319,8 +4320,10 @@ bool tty_is_vc_resolve(const char *tty) {
         if (startswith(tty, "/dev/"))
                 tty += 5;
 
-        /* Resolve where /dev/console is pointing to */
-        if (streq(tty, "console"))
+        /* Resolve where /dev/console is pointing to, if /sys is
+         * actually ours (i.e. not read-only-mounted which is a sign
+         * for container setups) */
+        if (streq(tty, "console") && path_is_read_only_fs("/sys") <= 0)
                 if (read_one_line_file("/sys/class/tty/console/active", &active) >= 0) {
                         /* If multiple log outputs are configured the
                          * last one is what /dev/console points to */
@@ -6145,3 +6148,14 @@ int setrlimit_closest(int resource, const struct rlimit *rlim) {
 
         return 0;
 }
+
+int path_is_read_only_fs(const char *path) {
+        struct statvfs st;
+
+        assert(path);
+
+        if (statvfs(path, &st) < 0)
+                return -errno;
+
+        return !!(st.f_flag & ST_RDONLY);
+}
index efb2c7d324afa0858212c6922ad09c52e401cd9a..76bc7b3572ee94d2f1a3356d1beacd10ab577a9c 100644 (file)
@@ -350,6 +350,7 @@ ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll);
 ssize_t loop_write(int fd, const void *buf, size_t nbytes, bool do_poll);
 
 int path_is_mount_point(const char *path, bool allow_symlink);
+int path_is_read_only_fs(const char *path);
 
 bool is_device_path(const char *path);