diff options
author | Lennart Poettering <lennart@poettering.net> | 2011-05-24 04:20:35 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-06-21 19:29:44 +0200 |
commit | 5eda94dda25bccda928c4b33c790dbe748573a22 (patch) | |
tree | dd5402db68b03e448873b97c3c2e0cd9582272db /src/logind.c | |
parent | 90821c935e5f4258dc21fc515cf721beb0914a85 (diff) |
logind: implement ACL management
Diffstat (limited to 'src/logind.c')
-rw-r--r-- | src/logind.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/src/logind.c b/src/logind.c index 0c26aaddbf..7e9b706d13 100644 --- a/src/logind.c +++ b/src/logind.c @@ -26,6 +26,8 @@ #include <string.h> #include <unistd.h> #include <sys/epoll.h> +#include <sys/ioctl.h> +#include <linux/vt.h> #include "logind.h" #include "dbus-common.h" @@ -290,7 +292,7 @@ int manager_enumerate_devices(Manager *m) { e = udev_enumerate_new(m->udev); if (!e) - return -ENOMEM; + goto finish; if (udev_enumerate_add_match_subsystem(e, "graphics") < 0) goto finish; @@ -627,9 +629,37 @@ int manager_dispatch_console(Manager *m) { return 0; } +static int vt_is_busy(int vtnr) { + struct vt_stat vt_stat; + int r = 0, fd; + + assert(vtnr >= 1); + + fd = open_terminal("/dev/tty0", O_RDWR|O_NOCTTY|O_CLOEXEC); + if (fd < 0) + return -errno; + + if (ioctl(fd, VT_GETSTATE, &vt_stat) < 0) + r = -errno; + else + r = !!(vt_stat.v_state & (1 << vtnr)); + + close_nointr_nofail(fd); + + return r; +} + int manager_spawn_autovt(Manager *m, int vtnr) { + int r; + assert(m); + r = vt_is_busy(vtnr); + if (r != 0) + return r; + + /* ... */ + return 0; } @@ -849,7 +879,7 @@ int manager_run(Manager *m) { int main(int argc, char *argv[]) { Manager *m = NULL; - int r = 0; + int r; log_set_target(LOG_TARGET_AUTO); log_parse_environment(); |