chiark / gitweb /
logind: VT_GETSTATE "cannot return state for more than 16 VTs" (#6625)
authorAlan Jenkins <alan.christopher.jenkins@gmail.com>
Wed, 30 Aug 2017 15:06:12 +0000 (16:06 +0100)
committerSven Eden <yamakuzure@gmx.net>
Mon, 25 Sep 2017 12:36:07 +0000 (14:36 +0200)
`vt_is_busy(16)` would always return FALSE.  So we could have started
autovt@16.service even when VT 16 was already being used for something.

src/login/logind-core.c
src/login/logind.h

index 7e6b63f1286004fa720fd33a77407ac17f47e926..6eb1e4c93596b9be719c8801fb4b3811b70f1860 100644 (file)
@@ -408,6 +408,42 @@ bool manager_shall_kill(Manager *m, const char *user) {
 }
 
 #if 0 /// UNNEEDED by elogind
+int config_parse_n_autovts(
+                const char *unit,
+                const char *filename,
+                unsigned line,
+                const char *section,
+                unsigned section_line,
+                const char *lvalue,
+                int ltype,
+                const char *rvalue,
+                void *data,
+                void *userdata) {
+
+        unsigned *n = data;
+        unsigned o;
+        int r;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        r = safe_atou(rvalue, &o);
+        if (r < 0) {
+                log_syntax(unit, LOG_ERR, filename, line, r, "Failed to parse number of autovts, ignoring: %s", rvalue);
+                return 0;
+        }
+
+        if (o > 15) {
+                log_syntax(unit, LOG_ERR, filename, line, r, "A maximum of 15 autovts are supported, ignoring: %s", rvalue);
+                return 0;
+        }
+
+        *n = o;
+        return 0;
+}
+
 static int vt_is_busy(unsigned int vtnr) {
         struct vt_stat vt_stat;
         int r = 0;
@@ -415,6 +451,9 @@ static int vt_is_busy(unsigned int vtnr) {
 
         assert(vtnr >= 1);
 
+        /* VT_GETSTATE "cannot return state for more than 16 VTs, since v_state is short" */
+        assert(vtnr <= 15);
+
         /* We explicitly open /dev/tty1 here instead of /dev/tty0. If
          * we'd open the latter we'd open the foreground tty which
          * hence would be unconditionally busy. By opening /dev/tty1
index 8f6fb72dbeb853d56ea2d49d833cda14d455e10e..7df3cbc2ed0f7c6e2b9ee9276d588c1775656b07 100644 (file)
@@ -238,6 +238,7 @@ const struct ConfigPerfItem* logind_gperf_lookup(const char *key, GPERF_LEN_TYPE
 
 int manager_set_lid_switch_ignore(Manager *m, usec_t until);
 
+int config_parse_n_autovts(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_tmpfs_size(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
 int config_parse_user_tasks_max(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);