1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2011 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
28 int main(int argc, char *argv[]) {
31 const char *seat = NULL;
33 _cleanup_free_ char *path = NULL;
35 _cleanup_fclose_ FILE *f = NULL;
37 /* This binary will go away as soon as X natively takes the
38 * arguments in question as command line parameters, instead
39 * of requiring them in the configuration file. */
41 /* If this file is removed, don't forget to remove the code
42 * that invokes this in gdm and other display managers. */
44 for (i = 1; i < argc; i++)
45 if (streq(argv[i], "-seat"))
48 if (isempty(seat) || streq(seat, "seat0")) {
49 argv[0] = (char*) X_SERVER;
50 execv(X_SERVER, argv);
51 log_error("Failed to execute real X server: %m");
55 r = mkdir_safe_label("/run/systemd/multi-session-x", 0755, 0, 0);
57 log_error("Failed to create directory: %s", strerror(-r));
61 path = strappend("/run/systemd/multi-session-x/", seat);
67 f = fopen(path, "we");
69 log_error("Failed to write configuration file: %m");
74 "Section \"ServerFlags\"\n"
75 " Option \"AutoAddDevices\" \"True\"\n"
76 " Option \"AllowEmptyInput\" \"True\"\n"
77 " Option \"DontVTSwitch\" \"True\"\n"
79 "Section \"InputClass\"\n"
80 " Identifier \"Force Input Devices to Seat\"\n"
81 " Option \"GrabDevice\" \"True\"\n"
87 log_error("Failed to write configuration file: %m");
94 new_argv = newa(char*, argc + 3 + 1);
95 memcpy(new_argv, argv, sizeof(char*) * (argc + 2 + 1));
97 new_argv[0] = (char*) X_SERVER;
98 new_argv[argc+0] = (char*) "-config";
99 new_argv[argc+1] = path;
100 new_argv[argc+2] = (char*) "-sharevts";
101 new_argv[argc+3] = NULL;
103 execv(X_SERVER, new_argv);
104 log_error("Failed to execute real X server: %m");