[systemd-commits] 11 commits - .gitignore Makefile.am src/cgtop src/journal src/locale src/login src/modules-load src/sysctl
Lennart Poettering
lennart at kemper.freedesktop.org
Fri Sep 21 07:17:40 PDT 2012
.gitignore | 1
Makefile.am | 11 ++
src/cgtop/cgtop.c | 2
src/journal/journal-file.c | 5 -
src/locale/localed.c | 4
src/login/loginctl.c | 1
src/login/logind-session-dbus.c | 6 +
src/login/logind-session.c | 4
src/login/logind-user.c | 4
src/login/multi-seat-x.c | 190 ++++++++++++++++++++++++++++++++++++++++
src/login/pam-module.c | 1
src/modules-load/modules-load.c | 2
src/sysctl/sysctl.c | 2
13 files changed, 224 insertions(+), 9 deletions(-)
New commits:
commit 8e7705e52a5f84489d3037c09fa5f9397185560d
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Sep 21 16:17:22 2012 +0200
pam: document that we don't do error checking when parsing vtnr
diff --git a/src/login/pam-module.c b/src/login/pam-module.c
index d7f4128..0d38791 100644
--- a/src/login/pam-module.c
+++ b/src/login/pam-module.c
@@ -452,6 +452,7 @@ _public_ PAM_EXTERN int pam_sm_open_session(
tty = "";
}
+ /* If this fails vtnr will be 0, that's intended */
if (!isempty(cvtnr))
safe_atou32(cvtnr, &vtnr);
commit 0559d3a58ac25a37b832f12fbdefef58fd351270
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Sep 21 16:16:39 2012 +0200
journal: don't allow journal_file_open() to be called with ret being NULL
diff --git a/src/journal/journal-file.c b/src/journal/journal-file.c
index e778e1c..6db9955 100644
--- a/src/journal/journal-file.c
+++ b/src/journal/journal-file.c
@@ -2012,6 +2012,7 @@ int journal_file_open(
bool newly_created = false;
assert(fname);
+ assert(ret);
if ((flags & O_ACCMODE) != O_RDONLY &&
(flags & O_ACCMODE) != O_RDWR)
@@ -2156,9 +2157,7 @@ int journal_file_open(
if (r < 0)
goto fail;
- if (ret)
- *ret = f;
-
+ *ret = f;
return 0;
fail:
commit 5d5e98eb8c859d5a85fe6cd5e3cc433bd8a096ba
Author: Lukas Nykryn <lnykryn at redhat.com>
Date: Fri Sep 21 12:33:32 2012 +0200
login: missing break for getopt ARG_NO_ASK_PASSWORD in loginctl
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
index 5ff8ea6..7ef9dde 100644
--- a/src/login/loginctl.c
+++ b/src/login/loginctl.c
@@ -1446,6 +1446,7 @@ static int parse_argv(int argc, char *argv[]) {
case ARG_NO_ASK_PASSWORD:
arg_ask_password = false;
+ break;
case ARG_KILL_WHO:
arg_kill_who = optarg;
commit 089d4a08d0cda5bae0bf9bb3273bfdb397200ee8
Author: Lukas Nykryn <lnykryn at redhat.com>
Date: Fri Sep 21 12:30:56 2012 +0200
sysctl: fix error code handling
After if (r <= 0) r can't be 0 so
if (k < 0 && r == 0) never happens.
diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c
index 793796d..62d4c81 100644
--- a/src/sysctl/sysctl.c
+++ b/src/sysctl/sysctl.c
@@ -260,6 +260,8 @@ int main(int argc, char *argv[]) {
if (r <= 0)
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
+ r = 0;
+
log_set_target(LOG_TARGET_AUTO);
log_parse_environment();
log_open();
commit d42c44fb6dd926271bfd56157114ba9d29935ea7
Author: Václav PavlÃn <vpavlin at redhat.com>
Date: Fri Sep 21 15:03:28 2012 +0200
modules-load: initalize files to null
diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c
index 6aeaf45..e72e382 100644
--- a/src/modules-load/modules-load.c
+++ b/src/modules-load/modules-load.c
@@ -171,7 +171,7 @@ static int load_module(struct kmod_ctx *ctx, const char *m) {
int main(int argc, char *argv[]) {
int r = EXIT_FAILURE, k;
- char **files, **fn, **i;
+ char **files = NULL, **fn, **i;
struct kmod_ctx *ctx;
if (argc > 1) {
commit f2cc3753ce0e85960f0299855c3b98ba60efa580
Author: Václav PavlÃn <vpavlin at redhat.com>
Date: Fri Sep 21 15:00:43 2012 +0200
locale: make sure that l is freed
diff --git a/src/locale/localed.c b/src/locale/localed.c
index 667c5d1..a2d3814 100644
--- a/src/locale/localed.c
+++ b/src/locale/localed.c
@@ -1123,7 +1123,9 @@ static DBusHandlerResult locale_message_handler(
"Locale\0");
if (!changed)
goto oom;
- }
+ } else
+ strv_free(l);
+
} else if (dbus_message_is_method_call(message, "org.freedesktop.locale1", "SetVConsoleKeyboard")) {
const char *keymap, *keymap_toggle;
commit ca4f2b6d6dbecce80d28a4b5126f8e83e1d4093b
Author: Václav PavlÃn <vpavlin at redhat.com>
Date: Fri Sep 21 13:38:40 2012 +0200
login: check return value of session_get_idle_hint
diff --git a/src/login/logind-session-dbus.c b/src/login/logind-session-dbus.c
index 9103781..2e7bfe0 100644
--- a/src/login/logind-session-dbus.c
+++ b/src/login/logind-session-dbus.c
@@ -183,12 +183,16 @@ static int bus_session_append_idle_hint_since(DBusMessageIter *i, const char *pr
Session *s = data;
dual_timestamp t;
uint64_t u;
+ int r;
assert(i);
assert(property);
assert(s);
- session_get_idle_hint(s, &t);
+ r = session_get_idle_hint(s, &t);
+ if (r < 0)
+ return r;
+
u = streq(property, "IdleSinceHint") ? t.realtime : t.monotonic;
if (!dbus_message_iter_append_basic(i, DBUS_TYPE_UINT64, &u))
commit 5a165aa6b9aa921d8b069059026d84e879ac38cc
Author: Václav PavlÃn <vpavlin at redhat.com>
Date: Fri Sep 21 13:01:39 2012 +0200
logind: check return value, log warning on error
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
index f670db8..958b516 100644
--- a/src/login/logind-session.c
+++ b/src/login/logind-session.c
@@ -526,7 +526,9 @@ static int session_create_cgroup(Session *s) {
}
}
- hashmap_put(s->manager->session_cgroups, s->cgroup_path, s);
+ r = hashmap_put(s->manager->session_cgroups, s->cgroup_path, s);
+ if (r < 0)
+ log_warning("Failed to create mapping between cgroup and session");
return 0;
}
diff --git a/src/login/logind-user.c b/src/login/logind-user.c
index 9dfead9..b692b53 100644
--- a/src/login/logind-user.c
+++ b/src/login/logind-user.c
@@ -339,7 +339,9 @@ static int user_create_cgroup(User *u) {
log_warning("Failed to create cgroup %s:%s: %s", *k, p, strerror(-r));
}
- hashmap_put(u->manager->user_cgroups, u->cgroup_path, u);
+ r = hashmap_put(u->manager->user_cgroups, u->cgroup_path, u);
+ if (r < 0)
+ log_warning("Failed to create mapping between cgroup and user");
return 0;
}
commit 2f29c419b01c104475f04d58a873b181273cfd8b
Author: Václav PavlÃn <vpavlin at redhat.com>
Date: Fri Sep 21 12:04:02 2012 +0200
cgtop: missing '-'
Return codes in systemd are negated and
if (r < 0) if (r == ENOENT)
was never true.
diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c
index 3756328..9eb2d2f 100644
--- a/src/cgtop/cgtop.c
+++ b/src/cgtop/cgtop.c
@@ -300,7 +300,7 @@ static int refresh_one(
r = cg_enumerate_subgroups(controller, path, &d);
if (r < 0) {
- if (r == ENOENT)
+ if (r == -ENOENT)
return 0;
return r;
commit e57d4fa35ece7c506e6ed16bb245591252143f9c
Author: Dave Airlie <airlied at gmail.com>
Date: Fri Sep 21 15:53:10 2012 +0200
multi-seat-x: drop framebuffer specific stuff, as we have a DRM driver now
diff --git a/src/login/multi-seat-x.c b/src/login/multi-seat-x.c
index 59f7088..370b12f 100644
--- a/src/login/multi-seat-x.c
+++ b/src/login/multi-seat-x.c
@@ -132,11 +132,6 @@ int main(int argc, char *argv[]) {
}
fprintf(f,
- "Section \"Device\"\n"
- " Identifier \"udev\"\n"
- " Driver \"fbdev\"\n"
- " Option \"fbdev\" \"%s\"\n"
- "EndSection\n"
"Section \"ServerFlags\"\n"
" Option \"AutoAddDevices\" \"True\"\n"
" Option \"AllowEmptyInput\" \"True\"\n"
@@ -145,8 +140,7 @@ int main(int argc, char *argv[]) {
"Section \"InputClass\"\n"
" Identifier \"Force Input Devices to Seat\"\n"
" Option \"GrabDevice\" \"True\"\n"
- "EndSection\n",
- device_node);
+ "EndSection\n");
fflush(f);
commit ec29187225c0b404f6b9f59a416c4fa0c0afaaff
Author: Lennart Poettering <lennart at poettering.net>
Date: Fri Sep 21 15:51:04 2012 +0200
Revert "multi-seat: drop multi-seat-x wrapper, as upstream X can handle multi-seat graphics on its own now"
This reverts commit 636d30a0895f17eca8313d50f9b2fc1ec5e128da.
Turns out we will need the multi-seat wrapper a bit longer, however
without the fb-specific bits in it.
diff --git a/.gitignore b/.gitignore
index c1459ae..cc904f1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,6 +13,7 @@
/build-aux
/test-watchdog
/test-journal-send
+/systemd-multi-seat-x
/systemd-cgtop
/systemd-coredump
/systemd-cat
diff --git a/Makefile.am b/Makefile.am
index 1828d7f..36b33c2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3347,6 +3347,17 @@ logind-install-data-hook:
INSTALL_DATA_HOOKS += \
logind-install-data-hook
+systemd_multi_seat_x_SOURCES = \
+ src/login/multi-seat-x.c
+
+systemd_multi_seat_x_LDADD = \
+ libsystemd-label.la \
+ libsystemd-shared.la \
+ libudev.la
+
+rootlibexec_PROGRAMS += \
+ systemd-multi-seat-x
+
dist_udevrules_DATA += \
src/login/70-uaccess.rules \
src/login/70-power-switch.rules
diff --git a/src/login/multi-seat-x.c b/src/login/multi-seat-x.c
new file mode 100644
index 0000000..59f7088
--- /dev/null
+++ b/src/login/multi-seat-x.c
@@ -0,0 +1,196 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/***
+ This file is part of systemd.
+
+ Copyright 2011 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <string.h>
+#include <unistd.h>
+
+#include <libudev.h>
+
+#include "util.h"
+#include "mkdir.h"
+
+int main(int argc, char *argv[]) {
+
+ struct udev *udev = NULL;
+ struct udev_enumerate *enumerator = NULL;
+ struct udev_list_entry *first, *item;
+ int i;
+ const char *seat = NULL;
+ char **new_argv;
+ char *path = NULL, *device_node = NULL;
+ int r;
+ FILE *f = NULL;
+
+ /* This binary will go away as soon as X natively supports
+ * display enumeration with udev in a way that covers both PCI
+ * and USB. */
+
+ /* This will simply determine the fb device id of the graphics
+ * device assigned to a seat and write a configuration file
+ * from it and then spawn the real X server. */
+
+ /* If this file is removed, don't forget to remove the code
+ * that invokes this in gdm and other display managers. */
+
+ for (i = 1; i < argc; i++)
+ if (streq(argv[i], "-seat"))
+ seat = argv[i+1];
+
+ if (isempty(seat) || streq(seat, "seat0")) {
+ argv[0] = (char*) X_SERVER;
+ execv(X_SERVER, argv);
+ log_error("Failed to execute real X server: %m");
+ goto fail;
+ }
+
+ udev = udev_new();
+ if (!udev) {
+ log_error("Failed to allocate udev environment.");
+ goto fail;
+ }
+
+ enumerator = udev_enumerate_new(udev);
+ if (!enumerator) {
+ log_error("Failed to allocate udev enumerator.");
+ goto fail;
+ }
+
+ udev_enumerate_add_match_subsystem(enumerator, "graphics");
+ udev_enumerate_add_match_tag(enumerator, seat);
+
+ r = udev_enumerate_scan_devices(enumerator);
+ if (r < 0) {
+ log_error("Failed to enumerate devices.");
+ goto fail;
+ }
+
+ first = udev_enumerate_get_list_entry(enumerator);
+ udev_list_entry_foreach(item, first) {
+ struct udev_device *d;
+ const char *dn;
+
+ d = udev_device_new_from_syspath(udev, udev_list_entry_get_name(item));
+ if (!d)
+ continue;
+
+ dn = udev_device_get_devnode(d);
+
+ if (dn) {
+ device_node = strdup(dn);
+ if (!device_node) {
+ udev_device_unref(d);
+ log_oom();
+ goto fail;
+ }
+ }
+
+ udev_device_unref(d);
+
+ if (device_node)
+ break;
+ }
+
+ if (!device_node) {
+ log_error("Failed to find device node for seat %s.", seat);
+ goto fail;
+ }
+
+ r = mkdir_safe_label("/run/systemd/multi-session-x", 0755, 0, 0);
+ if (r < 0) {
+ log_error("Failed to create directory: %s", strerror(-r));
+ goto fail;
+ }
+
+ path = strappend("/run/systemd/multi-session-x/", seat);
+ if (!path) {
+ log_oom();
+ goto fail;
+ }
+
+ f = fopen(path, "we");
+ if (!f) {
+ log_error("Failed to write configuration file: %m");
+ goto fail;
+ }
+
+ fprintf(f,
+ "Section \"Device\"\n"
+ " Identifier \"udev\"\n"
+ " Driver \"fbdev\"\n"
+ " Option \"fbdev\" \"%s\"\n"
+ "EndSection\n"
+ "Section \"ServerFlags\"\n"
+ " Option \"AutoAddDevices\" \"True\"\n"
+ " Option \"AllowEmptyInput\" \"True\"\n"
+ " Option \"DontVTSwitch\" \"True\"\n"
+ "EndSection\n"
+ "Section \"InputClass\"\n"
+ " Identifier \"Force Input Devices to Seat\"\n"
+ " Option \"GrabDevice\" \"True\"\n"
+ "EndSection\n",
+ device_node);
+
+ fflush(f);
+
+ if (ferror(f)) {
+ log_error("Failed to write configuration file: %m");
+ goto fail;
+ }
+
+ fclose(f);
+ f = NULL;
+
+ new_argv = alloca(sizeof(char*) * (argc + 3 + 1));
+ memcpy(new_argv, argv, sizeof(char*) * (argc + 2 + 1));
+
+ new_argv[0] = (char*) X_SERVER;
+ new_argv[argc+0] = (char*) "-config";
+ new_argv[argc+1] = path;
+ new_argv[argc+2] = (char*) "-sharevts";
+ new_argv[argc+3] = NULL;
+
+ udev_enumerate_unref(enumerator);
+ enumerator = NULL;
+
+ udev_unref(udev);
+ udev = NULL;
+
+ free(device_node);
+ device_node = NULL;
+
+ execv(X_SERVER, new_argv);
+ log_error("Failed to execute real X server: %m");
+
+fail:
+ if (enumerator)
+ udev_enumerate_unref(enumerator);
+
+ if (udev)
+ udev_unref(udev);
+
+ free(path);
+ free(device_node);
+
+ if (f)
+ fclose(f);
+
+ return EXIT_FAILURE;
+}
More information about the systemd-commits
mailing list