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