]> git.pld-linux.org Git - packages/xorg-app-xdm.git/blob - xorg-app-xdm-consolekit.patch
885ac6f4e95c49861e5208c4b5b954c9be96d155
[packages/xorg-app-xdm.git] / xorg-app-xdm-consolekit.patch
1 ---
2  configure.ac |   14 ++++++++
3  dm.h         |    3 +
4  resource.c   |   13 +++++++
5  session.c    |  100 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6  xdm.man.cpp  |    6 +++
7  5 files changed, 135 insertions(+), 1 deletion(-)
8
9 Index: xdm-1.1.10/configure.ac
10 ===================================================================
11 --- xdm-1.1.10.orig/configure.ac
12 +++ xdm-1.1.10/configure.ac
13 @@ -434,6 +434,20 @@ fi
14  
15  AM_CONDITIONAL(DYNAMIC_GREETER, test x$DYNAMIC_GREETER = xyes)
16  
17 +# ConsoleKit support
18 +AC_ARG_WITH(consolekit, AC_HELP_STRING([--with-consolekit], [Use ConsoleKit]),
19 +       [USE_CONSOLEKIT=$withval], [USE_CONSOLEKIT=yes])
20 +if test x"$USE_CONSOLEKIT" != xno; then
21 +       PKG_CHECK_MODULES(CK_CONNECTOR, ck-connector,
22 +               [USE_CONSOLEKIT=yes], [USE_CONSOLEKIT=no])
23 +       if test x"$USE_CONSOLEKIT" = xyes; then
24 +               AC_DEFINE([USE_CONSOLEKIT], 1, [Define to 1 to use ConsoleKit])
25 +               XDM_CFLAGS="$XDM_CFLAGS $CK_CONNECTOR_CFLAGS"
26 +               XDM_LIBS="$XDM_LIBS $CK_CONNECTOR_LIBS"
27 +       fi
28 +fi
29 +dnl AM_CONDITIONAL(USE_CONSOLEKIT, test$USE_CONSOLEKIT = xyes)
30 +
31  #
32  #  XDM
33  #
34 --- xdm-1.1.12/xdm/session.c.orig       2019-03-02 23:06:13.000000000 +0100
35 +++ xdm-1.1.12/xdm/session.c    2019-03-05 18:55:19.964592706 +0100
36 @@ -73,6 +73,11 @@ extern int key_setnet(struct key_netstar
37  # endif
38  #endif /* USE_PAM */
39  
40 +#ifdef USE_CONSOLEKIT
41 +#include <ck-connector.h>
42 +#include <dbus/dbus.h>
43 +#endif
44 +
45  #ifdef USE_SELINUX
46  #include <selinux/selinux.h>
47  #include <selinux/get_context_list.h>
48 @@ -523,6 +528,97 @@ UnsecureDisplay (struct display *d, Disp
49      }
50  }
51  
52 +#ifdef USE_CONSOLEKIT
53 +
54 +static CkConnector *connector;
55 +
56 +static int openCKSession(struct verify_info *verify, struct display *d)
57 +{
58 +    int ret;
59 +    DBusError error;
60 +    char  *remote_host_name = "";
61 +    dbus_bool_t is_local;
62 +    char *display_name = "";
63 +    char *display_device = "";
64 +    char devtmp[16];
65 +
66 +    if (!use_consolekit)
67 +       return 1;
68 +
69 +    is_local = d->displayType.location == Local;
70 +    if (d->peerlen > 0 && d->peer)
71 +       remote_host_name = d->peer;
72 +    if (d->name)
73 +       display_name = d->name;
74 +    /* how can we get the corresponding tty at best...? */
75 +    if (d->windowPath) {
76 +       display_device = strchr(d->windowPath, ':');
77 +       if (display_device && display_device[1])
78 +           display_device++;
79 +       else
80 +           display_device = d->windowPath;
81 +       snprintf(devtmp, sizeof(devtmp), "/dev/tty%s", display_device);
82 +       display_device = devtmp;
83 +    }
84 +
85 +    connector = ck_connector_new();
86 +    if (!connector) {
87 +       LogOutOfMem("ck_connector");
88 +       return 0;
89 +    }
90 +
91 +    dbus_error_init(&error);
92 +    ret = ck_connector_open_session_with_parameters(
93 +               connector, &error,
94 +               "unix-user", &verify->uid,
95 +               "x11-display", &display_name,
96 +               "x11-display-device", &display_device,
97 +               "remote-host-name", &remote_host_name,
98 +               "is-local", &is_local,
99 +               NULL);
100 +    if (!ret) {
101 +       if (dbus_error_is_set(&error)) {
102 +           LogError("Dbus error: %s\n", error.message);
103 +           dbus_error_free(&error);
104 +       } else {
105 +           LogError("ConsoleKit error\n");
106 +       }
107 +       LogError("console-kit-daemon not running?\n");
108 +       ck_connector_unref(connector);
109 +       connector = NULL;
110 +       return 0;
111 +    }
112 +
113 +    verify->userEnviron = setEnv(verify->userEnviron,
114 +               "XDG_SESSION_COOKIE", ck_connector_get_cookie(connector));
115 +    return 1;
116 +}
117 +
118 +static void closeCKSession(void)
119 +{
120 +    DBusError error;
121 +
122 +    if (!connector)
123 +       return;
124 +
125 +    dbus_error_init(&error);
126 +    if (!ck_connector_close_session(connector, &error)) {
127 +       if (dbus_error_is_set(&error)) {
128 +           LogError("Dbus error: %s\n", error.message);
129 +           dbus_error_free(&error);
130 +       } else {
131 +           LogError("ConsoleKit close error\n");
132 +       }
133 +       LogError("console-kit-daemon not running?\n");
134 +    }
135 +    ck_connector_unref(connector);
136 +    connector = NULL;
137 +}
138 +#else
139 +#define openCKSession(v,d)     1
140 +#define closeCKSession()
141 +#endif
142 +
143  void
144  SessionExit (struct display *d, int status, int removeAuth)
145  {
146 @@ -537,6 +633,8 @@ SessionExit (struct display *d, int stat
147      }
148  #endif
149  
150 +    closeCKSession();
151 +
152      /* make sure the server gets reset after the session is over */
153      if (d->serverPid >= 2 && d->resetSignal)
154         kill (d->serverPid, d->resetSignal);
155 @@ -614,6 +712,10 @@ StartClient (
156  #ifdef USE_PAM
157      if (pamh) pam_open_session(pamh, 0);
158  #endif
159 +
160 +    if (!openCKSession(verify, d))
161 +       return 0;
162 +
163      switch (pid = fork ()) {
164      case 0:
165         CleanUpChild ();
166 --- xdm-1.1.11.orig/include/dm.h
167 +++ xdm-1.1.11/include/dm.h
168 @@ -323,6 +323,9 @@ extern char *randomFile;
169  extern char    *prngdSocket;
170  extern int     prngdPort;
171  # endif
172 +#ifdef USE_CONSOLEKIT
173 +extern int     use_consolekit;
174 +#endif
175  
176  extern char    *greeterLib;
177  extern char    *willing;
178 --- xdm-1.1.11.orig/xdm/resource.c
179 +++ xdm-1.1.11/xdm/resource.c
180 @@ -65,6 +65,9 @@ char  *randomDevice;
181  char   *prngdSocket;
182  int    prngdPort;
183  #endif
184 +#ifdef USE_CONSOLEKIT
185 +int    use_consolekit;
186 +#endif
187  
188  char   *greeterLib;
189  char   *willing;
190 @@ -196,6 +199,10 @@ struct dmResources {
191                                 "false"} ,
192  { "willing",   "Willing",      DM_STRING,      &willing,
193                                 ""} ,
194 +#ifdef USE_CONSOLEKIT
195 +{ "consoleKit",        "ConsoleKit",   DM_BOOL,        (char **) &use_consolekit,
196 +                               "true"} ,
197 +#endif
198  };
199  
200  #define NUM_DM_RESOURCES       (sizeof DmResources / sizeof DmResources[0])
201 @@ -378,7 +385,11 @@ XrmOptionDescRec optionTable [] = {
202  {"-debug",     "*debugLevel",          XrmoptionSepArg,        (caddr_t) NULL },
203  {"-xrm",       NULL,                   XrmoptionResArg,        (caddr_t) NULL },
204  {"-daemon",    ".daemonMode",          XrmoptionNoArg,         "true"         },
205 -{"-nodaemon",  ".daemonMode",          XrmoptionNoArg,         "false"        }
206 +{"-nodaemon",  ".daemonMode",          XrmoptionNoArg,         "false"        },
207 +#ifdef USE_CONSOLEKIT
208 +{"-consolekit",        ".consoleKit",          XrmoptionNoArg,         "true"  },
209 +{"-noconsolekit", ".consoleKit",       XrmoptionNoArg,         "false" }
210 +#endif
211  };
212  
213  static int     originalArgc;
214 --- xdm-1.1.10.orig/man/xdm.man
215 +++ xdm-1.1.10/man/xdm.man
216 @@ -48,6 +48,8 @@ xdm \- X Display Manager with support fo
217  ] [
218  .B \-session
219  .I session_program
220 +] [
221 +.B \-noconsolekit
222  ]
223  .SH DESCRIPTION
224  .I Xdm
225 @@ -215,6 +217,10 @@ indicates the program to run as the sess
226  .IP "\fB\-xrm\fP \fIresource_specification\fP"
227  Allows an arbitrary resource to be specified, as in most
228  X Toolkit applications.
229 +.IP "\fB\-noconsolekit\fP"
230 +Specifies ``false'' as the value for the \fBDisplayManager.consoleKit\fP
231 +resource.
232 +This suppresses the session management using ConsoleKit.
233  .SH RESOURCES
234  At many stages the actions of
235  .I xdm
This page took 0.038188 seconds and 2 git commands to generate.