3 Copyright 2001-2005 Oswald Buddenhagen <ossi@kde.org>
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 OTHER DEALINGS IN THE SOFTWARE.
22 Except as contained in this notice, the name of a copyright holder shall
23 not be used in advertising or otherwise to promote the sale, use or
24 other dealings in this Software without prior written authorization
25 from the copyright holder.
30 * xdm - display manager daemon
31 * Author: Keith Packard, MIT X Consortium
33 * interface to xdm's external greeter and config reader
39 #include <config-workspace.h>
40 #include <config-unix.h>
41 #include <config-kdm.h>
43 #if defined(__sun) && !defined(__sun__)
49 #elif defined(HAVE_GETSPNAM)
57 /* This needs to be run-time configurable, additionally. */
61 #define DEBUG_CORE 0x01
62 #define DEBUG_CONFIG 0x02
63 #define DEBUG_GREET 0x04
64 #define DEBUG_HLPCON 0x08
65 #define DEBUG_WSESS 0x10
66 #define DEBUG_WCONFIG 0x20
67 #define DEBUG_WGREET 0x40
68 #define DEBUG_NOSYSLOG 0x80
69 #define DEBUG_AUTH 0x100
70 #define DEBUG_THEMING 0x200
71 #define DEBUG_VALGRIND 0x400
72 #define DEBUG_STRACE 0x800
79 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
80 # define ATTR_UNUSED __attribute__((unused))
81 # define ATTR_NORETURN __attribute__((noreturn))
82 # define ATTR_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
85 # define ATTR_NORETURN
86 # define ATTR_PRINTFLIKE(fmt,var)
90 # define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
93 #define as(ar) ((int)(sizeof(ar)/sizeof(ar[0])))
95 #define __stringify(x) #x
96 #define stringify(x) __stringify(x)
99 * Exit codes for fork()ed session process, greeter, and config reader
101 #define EX_NORMAL 30 /* do whatever seems appropriate */
102 #define EX_REMANAGE_DPY 31 /* force remanage; same as EX_NORMAL, but cannot return to reserve mode immediately */
103 #define EX_UNMANAGE_DPY 32 /* force deletion */
104 #define EX_RESERVER_DPY 33 /* force server termination */
105 #define EX_AL_RESERVER_DPY 34 /* reserver; maybe, auto-(re-)login */
106 #define EX_OPENFAILED_DPY 35 /* XOpenDisplay failed, retry */
107 #define EX_RESERVE 37 /* put in reserve mode */
109 #define EX_REMOTE 38 /* start -query-ing X-server */
110 #define EX_MAX EX_REMOTE
112 #define EX_MAX EX_RESERVE
116 * Command codes core -> greeter
118 #define G_Greet 1 /* get login; bidi */
119 #define G_ErrorGreet 2 /* print failed auto-login */
121 #define G_Choose 3 /* run chooser; bidi */
122 # define G_Ch_AddHost 301
123 # define G_Ch_ChangeHost 302
124 # define G_Ch_RemoveHost 303
125 # define G_Ch_BadHost 304
126 # define G_Ch_Exit 305
128 #define G_SessMan 4 /* start "session manager" */
129 #define G_ConfShutdown 5 /* confirm forced shutdown */
130 #define G_GreetTimed 6 /* get login; timed login permitted */
133 #define G_Ch_Refresh 10 /* XXX change */
134 #define G_Ch_RegisterHost 11 /* str name XXX change */
135 #define G_Ch_DirectChoice 12 /* str name XXX change */
139 * Status/command codes greeter -> core
141 #define G_Ready 0 /* nop */
142 #define G_Cancel 1 /* abort login, etc. */
144 #define G_DGreet 2 /* get login */
146 #define G_DChoose 3 /* run chooser */
149 #define G_Shutdown 101 /* 5*int, string; async */
150 # define SHUT_REBOOT 1 /* how */
152 # define SHUT_CONSOLE -1 /* pseudo-code */
153 # define SHUT_SCHEDULE 0 /* when; config only */
154 # define SHUT_TRYNOW 1
155 # define SHUT_FORCENOW 2
156 # define SHUT_CANCEL 0 /* force */
157 # define SHUT_FORCEMY 1
158 # define SHUT_FORCE 2
160 # define TO_INF 0x7fffffff
161 #define G_SessionExit 102 /* int code; async */
162 #define G_GetCfg 103 /* int what; int sts, <variable> */
163 #define G_SetupDpy 104 /* ; int <syncer> */
164 #define G_ReadDmrc 105 /* str user; int sts - curdmrc */
165 #define G_GetDmrc 106 /* str key; str value - curdmrc */
166 /*#define G_ResetDmrc 107*/ /* ; async - newdmrc */
167 #define G_PutDmrc 108 /* str key, str value; async - newdmrc */
168 #define G_Verify 109 /* str type; ..., int V_ret */
169 #define G_VerifyRootOK 110 /* str type; ..., int V_ret */
170 #define G_List 111 /* int flags; ?*(str,str,[int,]str,str,int), int 0 */
172 # define lstPassive 2
176 #define G_QueryShutdown 112 /* ; 5*int; string */
177 #define G_Activate 113 /* int vt; async */
178 #define G_ListBootOpts 114 /* ; int sts, [argv opts, int dflt, int cur] */
183 #define G_Console 116 /* ; async */
184 #define G_AutoLogin 117 /* ; async */
185 #define G_QryDpyShutdown 118 /* ; int, int, str */
188 * Command codes core -> config reader
190 #define GC_Files 1 /* get file list */
191 #define GC_GetConf 2 /* get a config group */
192 # define GC_gGlobal 1 /* get global config array */
194 # define GC_gXaccess 3 /* get Xaccess equivalent */
196 # define GC_gDisplay 4 /* get per-display config array */
199 * Error code core -> greeter
202 #define GE_NoFkt 1 /* no such function (only for extensions!) */
203 #define GE_Error 2 /* internal error, like OOM */
204 /* for config reading */
205 #define GE_NoEnt 10 /* no such config entry */
206 #define GE_BadType 11 /* unknown config entry type */
207 /* for dmrc reading */
208 #define GE_NoUser 20 /* no such user */
209 #define GE_NoFile 21 /* no such file */
210 #define GE_Denied 22 /* permission denied */
214 * Used independently in core, greeter & config reader.
223 * Status codes from verify
225 /* terminal status codes */
227 #define V_FAIL 10 /* whatever, already reported with V_MSG_* */
228 #define V_AUTH 11 /* authentication failed */
229 /* non-terminal status codes */
230 #define V_MSG_INFO 110 /* info message attached; 0 return */
231 #define V_MSG_ERR 111 /* error message attached (null for generic); 0 return */
232 #define V_PUT_USER 112 /* user name attached; only with pam & no user send */
233 #define V_CHTOK 113 /* password expired; change now */
234 #define V_CHTOK_AUTH 114 /* password expired; change now, but authenticate first */
235 #define V_PRE_OK 115 /* authentication succeeded, continue with password change */
236 #define V_MSG_INFO_AUTH 116 /* info message during auth attached; 0 return */
238 #define V_GET_TEXT 200 /* str prompt, int echo, int ndelay; str return, int tag */
239 # define V_IS_SECRET 1
241 # define V_IS_PASSWORD 4
242 # define V_IS_OLDPASSWORD 8
243 # define V_IS_NEWPASSWORD 16
244 #define V_GET_BINARY 201 /* array prompt, int ndelay; array return */
247 * Config/Runtime data keys
249 #define C_WHO_MASK 0x00ff0000 /* Non-zero for proprietary extensions (see manufacturer table [to be written]) */
250 #define C_TYPE_MASK 0x0f000000 /* Type of the value */
251 # define C_TYPE_INT 0x00000000 /* Integer */
252 # define C_TYPE_STR 0x01000000 /* String */
253 # define C_TYPE_ARGV 0x02000000 /* 0-terminated Array of Strings */
254 # define C_TYPE_ARR 0x03000000 /* Array (only when XDCMP is enabled) */
255 #define C_PRIVATE 0xf0000000 /* Private, don't make it visible to interfaces! */
257 /* display variables */
258 #define C_isLocal (C_TYPE_INT | 0x200)
259 #define C_hasConsole (C_TYPE_INT | 0x201)
260 #define C_isAuthorized (C_TYPE_INT | 0x202)
261 #define C_isReserve (C_TYPE_INT | 0x203)
269 * flags in acl entries
271 #define a_notAllowed 1 /* both direct and indirect */
272 #define a_notBroadcast 2 /* only direct */
273 #define a_useChooser 2 /* only indirect */
276 * type of host entries
279 #define HOST_ADDRESS 1
280 #define HOST_PATTERN 2
281 #define HOST_BROADCAST 3