1
/* GDM - The GNOME Display Manager
2
* Copyright (C) 1998, 1999, 2000 Martin K. Petersen <mkp@mkp.net>
3
* Copyright (C) 2005 Brian Cameron <brian.cameron@sun.com>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
* gdmconfig.c isolates most logic that interacts with vicious-extensions
22
* into a single file and provides a mechanism for interacting with GDM
23
* configuration optins via access functions for getting/setting values.
24
* This logic also ensures that the same configuration validation happens
25
* when loading the values initially or setting them via the
26
* GDM_UPDATE_CONFIG socket command.
28
* When adding a new configuration option, simply add the new option to
29
* gdm.h and to the val_hash and type_hash hashes in the gdm_config_init
30
* function. Any validation for the configuration option should be
31
* placed in the _gdm_set_value_string, _gdm_set_value_int, or
32
* _gdm_set_value_bool functions.
40
#include <sys/types.h>
41
#include <sys/resource.h>
43
#include <sys/resource.h>
49
#include <glib/gi18n.h>
54
#include "gdmconfig.h"
59
#include "filecheck.h"
62
gchar *config_file = NULL;
63
gchar *custom_config_file = NULL;
64
static time_t config_file_mtime = 0;
65
static time_t custom_config_file_mtime = 0;
67
extern gboolean no_console;
68
extern gboolean gdm_emergency_server;
70
GSList *displays = NULL;
71
GSList *displays_inactive = NULL;
72
GSList *xservers = NULL;
74
gint high_display_num = 0;
82
static GHashTable *type_hash = NULL;
83
static GHashTable *val_hash = NULL;
84
static GHashTable *translated_hash = NULL;
85
static GHashTable *realkey_hash = NULL;
86
static GdmConfigType bool_type = CONFIG_BOOL;
87
static GdmConfigType int_type = CONFIG_INT;
88
static GdmConfigType string_type = CONFIG_STRING;
90
static uid_t GdmUserId; /* Userid under which gdm should run */
91
static gid_t GdmGroupId; /* Gruopid under which gdm should run */
93
/* Config options used by daemon */
94
/* ----------------------------- */
95
static gchar *GdmUser = NULL;
96
static gchar *GdmGroup = NULL;
97
static gchar *GdmGtkRC = NULL;
98
static gchar *GdmGtkTheme = NULL;
99
static gchar *GdmSessDir = NULL;
100
static gchar *GdmBaseXsession = NULL;
101
static gchar *GdmDefaultSession = NULL;
102
static gchar *GdmAutomaticLogin = NULL;
103
static gchar *GdmConfigurator = NULL;
104
static gchar *GdmGlobalFaceDir = NULL;
105
static gchar *GdmGreeter = NULL;
106
static gchar *GdmRemoteGreeter = NULL;
107
static gchar *GdmGtkModulesList = NULL;
108
static gchar *GdmChooser = NULL;
109
static gchar *GdmLogDir = NULL;
110
static gchar *GdmDisplayInitDir = NULL;
111
static gchar *GdmPostLogin = NULL;
112
static gchar *GdmPreSession = NULL;
113
static gchar *GdmPostSession = NULL;
114
static gchar *GdmFailsafeXserver = NULL;
115
static gchar *GdmXKeepsCrashing = NULL;
116
static gchar *GdmHalt = NULL;
117
static gchar *GdmReboot = NULL;
118
static gchar *GdmSuspend = NULL;
119
static gchar *GdmServAuthDir = NULL;
120
static gchar *GdmMulticastAddr;
121
static gchar *GdmUserAuthDir = NULL;
122
static gchar *GdmUserAuthFile = NULL;
123
static gchar *GdmUserAuthFallback = NULL;
124
static gchar *GdmPidFile = NULL;
125
static gchar *GdmPath = NULL;
126
static gchar *GdmRootPath = NULL;
127
static gchar *GdmWilling = NULL;
128
static gchar *GdmXdmcpProxyXserver = NULL;
129
static gchar *GdmXdmcpProxyReconnect = NULL;
130
static gchar *GdmTimedLogin = NULL;
131
static gchar *GdmStandardXserver = NULL;
132
static gchar *GdmXnest = NULL;
133
static gchar *GdmSoundProgram = NULL;
134
static gchar *GdmSoundOnLoginFile = NULL;
135
static gchar *GdmSoundOnLoginSuccessFile = NULL;
136
static gchar *GdmSoundOnLoginFailureFile = NULL;
137
static gchar *GdmConsoleCannotHandle = NULL;
138
static gchar *GdmPamStack = NULL;
140
static gint GdmXineramaScreen = 0;
141
static gint GdmUserMaxFile = 0;
142
static gint GdmDisplaysPerHost = 0;
143
static gint GdmMaxPending = 0;
144
static gint GdmMaxSessions = 0;
145
static gint GdmUdpPort = 0;
146
static gint GdmMaxIndirect = 0;
147
static gint GdmMaxWaitIndirect = 0;
148
static gint GdmPingInterval = 0;
149
static gint GdmRelaxPerm = 0;
150
static gint GdmRetryDelay = 0;
151
static gint GdmTimedLoginDelay = 0;
152
static gint GdmFlexibleXservers = 5;
153
static gint GdmFirstVt = 7;
154
static gint GdmXserverTimeout = 10;
156
/* The SDTLOGIN feature is Solaris specific, and causes the Xserver to be
157
* run with user permissionsinstead of as root, which adds security but
158
* disables the AlwaysRestartServer option as highlighted in the gdm
161
gboolean GdmAlwaysRestartServer = TRUE;
163
gboolean GdmAlwaysRestartServer = FALSE;
165
static gboolean GdmAutomaticLoginEnable = FALSE;
166
static gboolean GdmConfigAvailable = FALSE;
167
static gboolean GdmSystemMenu = FALSE;
168
static gboolean GdmChooserButton = FALSE;
169
static gboolean GdmBrowser = FALSE;
170
static gboolean GdmAddGtkModules = FALSE;
171
static gboolean GdmDoubleLoginWarning = TRUE;
172
static gboolean GdmAlwaysLoginCurrentSession = FALSE;
173
static gboolean GdmDisplayLastLogin = TRUE;
174
static gboolean GdmMulticast;
175
static gboolean GdmNeverPlaceCookiesOnNfs = TRUE;
176
static gboolean GdmPasswordRequired = FALSE;
177
static gboolean GdmKillInitClients = FALSE;
178
static gboolean GdmXdmcp = FALSE;
179
static gboolean GdmIndirect = FALSE;
180
static gboolean GdmXdmcpProxy = FALSE;
181
static gboolean GdmDebug = FALSE;
182
static gboolean GdmDebugGestures = FALSE;
183
static gboolean GdmAllowRoot = FALSE;
184
static gboolean GdmAllowRemoteRoot = FALSE;
185
static gboolean GdmAllowRemoteAutoLogin = FALSE;
186
static gboolean GdmCheckDirOwner = TRUE;
187
static gboolean GdmTimedLoginEnable = FALSE;
188
static gboolean GdmDynamicXservers = FALSE;
189
static gboolean GdmVTAllocation = TRUE;
190
static gboolean GdmDisallowTcp = TRUE;
191
static gboolean GdmSoundOnLogin = TRUE;
192
static gboolean GdmSoundOnLoginSuccess = FALSE;
193
static gboolean GdmSoundOnLoginFailure = FALSE;
194
static gboolean GdmConsoleNotify = TRUE;
196
/* Config options used by slave */
197
/* ---------------------------- */
198
static gchar *GdmGtkThemesToAllow = NULL;
199
static gchar *GdmInclude = NULL;
200
static gchar *GdmExclude = NULL;
201
static gchar *GdmDefaultFace = NULL;
202
static gchar *GdmLocaleFile = NULL;
203
static gchar *GdmLogo = NULL;
204
static gchar *GdmChooserButtonLogo = NULL;
205
static gchar *GdmWelcome = NULL;
206
static gchar *GdmRemoteWelcome = NULL;
207
static gchar *GdmBackgroundProgram = NULL;
208
static gchar *GdmBackgroundImage = NULL;
209
static gchar *GdmBackgroundColor = NULL;
210
static gchar *GdmGraphicalTheme = NULL;
211
static gchar *GdmInfoMsgFile = NULL;
212
static gchar *GdmInfoMsgFont = NULL;
213
static gchar *GdmHost = NULL;
214
static gchar *GdmHostImageDir = NULL;
215
static gchar *GdmHosts = NULL;
216
static gchar *GdmGraphicalThemeColor = NULL;
217
static gchar *GdmGraphicalThemeDir = NULL;
218
static gchar *GdmGraphicalThemes = NULL;
219
static gchar *GdmPreFetchProgram = NULL;
220
static gchar *GdmUse24Clock = NULL;
222
static gint GdmPositionX;
223
static gint GdmPositionY;
224
static gint GdmMinimalUid;
225
static gint GdmMaxIconWidth;
226
static gint GdmMaxIconHeight;
227
static gint GdmBackgroundType;
228
static gint GdmScanTime;
229
static gint GdmMaxWait;
230
static gint GdmFlexiReapDelayMinutes;
231
static gint GdmBackgroundProgramInitialDelay = 30;
232
static gint GdmBackgroundProgramRestartDelay = 30;
234
static gboolean GdmAllowGtkThemeChange;
235
static gboolean GdmTitleBar;
236
static gboolean GdmIncludeAll;
237
static gboolean GdmDefaultWelcome;
238
static gboolean GdmDefaultRemoteWelcome;
239
static gboolean GdmLockPosition;
240
static gboolean GdmBackgroundScaleToFit;
241
static gboolean GdmBackgroundRemoteOnlyColor;
242
static gboolean GdmRunBackgroundProgramAlways;
243
static gboolean GdmSetPosition;
244
static gboolean GdmQuiver;
245
static gboolean GdmShowGnomeFailsafe;
246
static gboolean GdmShowXtermFailsafe;
247
static gboolean GdmShowLastSession;
248
static gboolean GdmEntryCircles;
249
static gboolean GdmEntryInvisible;
250
static gboolean GdmGraphicalThemeRand;
251
static gboolean GdmBroadcast;
252
static gboolean GdmAllowAdd;
253
static gboolean GdmRestartBackgroundProgram;
256
* gdm_config_add_hash
258
* Add config value to the val_hash and type_hash. Strip the key so
259
* it doesn't contain a default value. This function assumes the
260
* val_hash, type_hash, and realkey_hash have been initialized.
263
gdm_config_add_hash (gchar *key, gpointer value, GdmConfigType *type)
266
gchar *newkey = g_strdup (key);
269
p = strchr (newkey, '=');
273
g_hash_table_insert (val_hash, newkey, value);
274
g_hash_table_insert (type_hash, newkey, type);
275
g_hash_table_insert (realkey_hash, newkey, key);
279
* gdm_config_hash_lookup
281
* Accesses hash with key, stripping it so it doesn't contain a default
285
gdm_config_hash_lookup (GHashTable *hash, gchar *key)
289
gchar *newkey = g_strdup (key);
292
p = strchr (newkey, '=');
296
ret = g_hash_table_lookup (hash, newkey);
304
* Since GDM keys sometimes have default values defined in the gdm.h header
305
* file (e.g. key=value), this function strips off the "=value" from both
306
* keys passed and compares them, returning TRUE if they are the same,
310
is_key (const gchar *key1, const gchar *key2)
312
gchar *key1d, *key2d, *p;
314
key1d = g_strdup (key1);
315
key2d = g_strdup (key2);
318
p = strchr (key1d, '=');
323
p = strchr (key2d, '=');
327
if (strcmp (ve_sure_string (key1d), ve_sure_string (key2d)) == 0) {
341
* Sets up initial hashes used by configuration routines.
344
gdm_config_init (void)
346
type_hash = g_hash_table_new (g_str_hash, g_str_equal);
347
val_hash = g_hash_table_new (g_str_hash, g_str_equal);
348
realkey_hash = g_hash_table_new (g_str_hash, g_str_equal);
351
gdm_config_add_hash (GDM_KEY_ALLOW_REMOTE_ROOT, &GdmAllowRemoteRoot, &bool_type);
352
gdm_config_add_hash (GDM_KEY_ALLOW_ROOT, &GdmAllowRoot, &bool_type);
353
gdm_config_add_hash (GDM_KEY_ALLOW_REMOTE_AUTOLOGIN,
354
&GdmAllowRemoteAutoLogin, &bool_type);
355
gdm_config_add_hash (GDM_KEY_PASSWORD_REQUIRED, &GdmPasswordRequired, &bool_type);
356
gdm_config_add_hash (GDM_KEY_AUTOMATIC_LOGIN_ENABLE,
357
&GdmAutomaticLoginEnable, &bool_type);
358
gdm_config_add_hash (GDM_KEY_ALWAYS_RESTART_SERVER,
359
&GdmAlwaysRestartServer, &bool_type);
360
gdm_config_add_hash (GDM_KEY_ADD_GTK_MODULES, &GdmAddGtkModules, &bool_type);
361
gdm_config_add_hash (GDM_KEY_DOUBLE_LOGIN_WARNING,
362
&GdmDoubleLoginWarning, &bool_type);
363
gdm_config_add_hash (GDM_KEY_ALWAYS_LOGIN_CURRENT_SESSION,
364
&GdmAlwaysLoginCurrentSession, &bool_type);
365
gdm_config_add_hash (GDM_KEY_DISPLAY_LAST_LOGIN, &GdmDisplayLastLogin, &bool_type);
366
gdm_config_add_hash (GDM_KEY_KILL_INIT_CLIENTS, &GdmKillInitClients, &bool_type);
367
gdm_config_add_hash (GDM_KEY_CONFIG_AVAILABLE, &GdmConfigAvailable, &bool_type);
368
gdm_config_add_hash (GDM_KEY_SYSTEM_MENU, &GdmSystemMenu, &bool_type);
369
gdm_config_add_hash (GDM_KEY_CHOOSER_BUTTON, &GdmChooserButton, &bool_type);
370
gdm_config_add_hash (GDM_KEY_BROWSER, &GdmBrowser, &bool_type);
371
gdm_config_add_hash (GDM_KEY_MULTICAST, &GdmMulticast, &bool_type);
372
gdm_config_add_hash (GDM_KEY_NEVER_PLACE_COOKIES_ON_NFS,
373
&GdmNeverPlaceCookiesOnNfs, &bool_type);
374
gdm_config_add_hash (GDM_KEY_CONSOLE_NOTIFY, &GdmConsoleNotify, &bool_type);
375
gdm_config_add_hash (GDM_KEY_TIMED_LOGIN_ENABLE, &GdmTimedLoginEnable, &bool_type);
376
gdm_config_add_hash (GDM_KEY_CHECK_DIR_OWNER, &GdmCheckDirOwner, &bool_type);
377
gdm_config_add_hash (GDM_KEY_XDMCP, &GdmXdmcp, &bool_type);
378
gdm_config_add_hash (GDM_KEY_INDIRECT, &GdmIndirect, &bool_type);
379
gdm_config_add_hash (GDM_KEY_XDMCP_PROXY, &GdmXdmcpProxy, &bool_type);
380
gdm_config_add_hash (GDM_KEY_DYNAMIC_XSERVERS, &GdmDynamicXservers, &bool_type);
381
gdm_config_add_hash (GDM_KEY_VT_ALLOCATION, &GdmVTAllocation, &bool_type);
382
gdm_config_add_hash (GDM_KEY_DISALLOW_TCP, &GdmDisallowTcp, &bool_type);
383
gdm_config_add_hash (GDM_KEY_SOUND_ON_LOGIN_SUCCESS,
384
&GdmSoundOnLoginSuccess, &bool_type);
385
gdm_config_add_hash (GDM_KEY_SOUND_ON_LOGIN_FAILURE,
386
&GdmSoundOnLoginFailure, &bool_type);
387
gdm_config_add_hash (GDM_KEY_DEBUG, &GdmDebug, &bool_type);
388
gdm_config_add_hash (GDM_KEY_DEBUG_GESTURES, &GdmDebugGestures, &bool_type);
389
gdm_config_add_hash (GDM_KEY_ALLOW_GTK_THEME_CHANGE,
390
&GdmAllowGtkThemeChange, &bool_type);
391
gdm_config_add_hash (GDM_KEY_TITLE_BAR, &GdmTitleBar, &bool_type);
392
gdm_config_add_hash (GDM_KEY_INCLUDE_ALL, &GdmIncludeAll, &bool_type);
393
gdm_config_add_hash (GDM_KEY_DEFAULT_WELCOME, &GdmDefaultWelcome, &bool_type);
394
gdm_config_add_hash (GDM_KEY_DEFAULT_REMOTE_WELCOME,
395
&GdmDefaultRemoteWelcome, &bool_type);
396
gdm_config_add_hash (GDM_KEY_LOCK_POSITION, &GdmLockPosition, &bool_type);
397
gdm_config_add_hash (GDM_KEY_BACKGROUND_SCALE_TO_FIT,
398
&GdmBackgroundScaleToFit, &bool_type);
399
gdm_config_add_hash (GDM_KEY_BACKGROUND_REMOTE_ONLY_COLOR,
400
&GdmBackgroundRemoteOnlyColor, &bool_type);
401
gdm_config_add_hash (GDM_KEY_RUN_BACKGROUND_PROGRAM_ALWAYS,
402
&GdmRunBackgroundProgramAlways, &bool_type);
403
gdm_config_add_hash (GDM_KEY_SET_POSITION, &GdmSetPosition, &bool_type);
404
gdm_config_add_hash (GDM_KEY_QUIVER, &GdmQuiver, &bool_type);
405
gdm_config_add_hash (GDM_KEY_SHOW_GNOME_FAILSAFE,
406
&GdmShowGnomeFailsafe, &bool_type);
407
gdm_config_add_hash (GDM_KEY_SHOW_XTERM_FAILSAFE,
408
&GdmShowXtermFailsafe, &bool_type);
409
gdm_config_add_hash (GDM_KEY_SHOW_LAST_SESSION,
410
&GdmShowLastSession, &bool_type);
411
gdm_config_add_hash (GDM_KEY_USE_24_CLOCK, &GdmUse24Clock, &string_type);
412
gdm_config_add_hash (GDM_KEY_ENTRY_CIRCLES, &GdmEntryCircles, &bool_type);
413
gdm_config_add_hash (GDM_KEY_ENTRY_INVISIBLE, &GdmEntryInvisible, &bool_type);
414
gdm_config_add_hash (GDM_KEY_GRAPHICAL_THEME_RAND,
415
&GdmGraphicalThemeRand, &bool_type);
416
gdm_config_add_hash (GDM_KEY_BROADCAST, &GdmBroadcast, &bool_type);
417
gdm_config_add_hash (GDM_KEY_ALLOW_ADD, &GdmAllowAdd, &bool_type);
418
gdm_config_add_hash (GDM_KEY_SOUND_ON_LOGIN, &GdmSoundOnLogin, &bool_type);
419
gdm_config_add_hash (GDM_KEY_RESTART_BACKGROUND_PROGRAM,
420
&GdmRestartBackgroundProgram, &bool_type);
423
gdm_config_add_hash (GDM_KEY_PATH, &GdmPath, &string_type);
424
gdm_config_add_hash (GDM_KEY_ROOT_PATH, &GdmRootPath, &string_type);
425
gdm_config_add_hash (GDM_KEY_CONSOLE_CANNOT_HANDLE,
426
&GdmConsoleCannotHandle, &string_type);
427
gdm_config_add_hash (GDM_KEY_CHOOSER, &GdmChooser, &string_type);
428
gdm_config_add_hash (GDM_KEY_GREETER, &GdmGreeter, &string_type);
429
gdm_config_add_hash (GDM_KEY_CONFIGURATOR, &GdmConfigurator, &string_type);
430
gdm_config_add_hash (GDM_KEY_POSTLOGIN, &GdmPostLogin, &string_type);
431
gdm_config_add_hash (GDM_KEY_PRESESSION, &GdmPreSession, &string_type);
432
gdm_config_add_hash (GDM_KEY_POSTSESSION, &GdmPostSession, &string_type);
433
gdm_config_add_hash (GDM_KEY_FAILSAFE_XSERVER, &GdmFailsafeXserver, &string_type);
434
gdm_config_add_hash (GDM_KEY_X_KEEPS_CRASHING, &GdmXKeepsCrashing, &string_type);
435
gdm_config_add_hash (GDM_KEY_BASE_XSESSION, &GdmBaseXsession, &string_type);
436
gdm_config_add_hash (GDM_KEY_REMOTE_GREETER, &GdmRemoteGreeter, &string_type);
437
gdm_config_add_hash (GDM_KEY_DISPLAY_INIT_DIR, &GdmDisplayInitDir, &string_type);
438
gdm_config_add_hash (GDM_KEY_AUTOMATIC_LOGIN, &GdmAutomaticLogin, &string_type);
439
gdm_config_add_hash (GDM_KEY_GTK_MODULES_LIST, &GdmGtkModulesList, &string_type);
440
gdm_config_add_hash (GDM_KEY_REBOOT, &GdmReboot, &string_type);
441
gdm_config_add_hash (GDM_KEY_HALT, &GdmHalt, &string_type);
442
gdm_config_add_hash (GDM_KEY_SUSPEND, &GdmSuspend, &string_type);
443
gdm_config_add_hash (GDM_KEY_LOG_DIR, &GdmLogDir, &string_type);
444
gdm_config_add_hash (GDM_KEY_PID_FILE, &GdmPidFile, &string_type);
445
gdm_config_add_hash (GDM_KEY_GLOBAL_FACE_DIR, &GdmGlobalFaceDir, &string_type);
446
gdm_config_add_hash (GDM_KEY_SERV_AUTHDIR, &GdmServAuthDir, &string_type);
447
gdm_config_add_hash (GDM_KEY_USER_AUTHDIR, &GdmUserAuthDir, &string_type);
448
gdm_config_add_hash (GDM_KEY_USER_AUTHFILE, &GdmUserAuthFile, &string_type);
449
gdm_config_add_hash (GDM_KEY_USER_AUTHDIR_FALLBACK,
450
&GdmUserAuthFallback, &string_type);
451
gdm_config_add_hash (GDM_KEY_SESSION_DESKTOP_DIR, &GdmSessDir, &string_type);
452
gdm_config_add_hash (GDM_KEY_DEFAULT_SESSION, &GdmDefaultSession, &string_type);
453
gdm_config_add_hash (GDM_KEY_MULTICAST_ADDR, &GdmMulticastAddr, &string_type);
454
gdm_config_add_hash (GDM_KEY_USER, &GdmUser, &string_type);
455
gdm_config_add_hash (GDM_KEY_GROUP, &GdmGroup, &string_type);
456
gdm_config_add_hash (GDM_KEY_GTKRC, &GdmGtkRC, &string_type);
457
gdm_config_add_hash (GDM_KEY_GTK_THEME, &GdmGtkTheme, &string_type);
458
gdm_config_add_hash (GDM_KEY_TIMED_LOGIN, &GdmTimedLogin, &string_type);
459
gdm_config_add_hash (GDM_KEY_WILLING, &GdmWilling, &string_type);
460
gdm_config_add_hash (GDM_KEY_XDMCP_PROXY_XSERVER,
461
&GdmXdmcpProxyXserver, &string_type);
462
gdm_config_add_hash (GDM_KEY_XDMCP_PROXY_RECONNECT,
463
&GdmXdmcpProxyReconnect, &string_type);
464
gdm_config_add_hash (GDM_KEY_STANDARD_XSERVER, &GdmStandardXserver, &string_type);
465
gdm_config_add_hash (GDM_KEY_XNEST, &GdmXnest, &string_type);
466
gdm_config_add_hash (GDM_KEY_SOUND_PROGRAM, &GdmSoundProgram, &string_type);
467
gdm_config_add_hash (GDM_KEY_SOUND_ON_LOGIN_FILE,
468
&GdmSoundOnLoginFile, &string_type);
469
gdm_config_add_hash (GDM_KEY_SOUND_ON_LOGIN_SUCCESS_FILE,
470
&GdmSoundOnLoginSuccessFile, &string_type);
471
gdm_config_add_hash (GDM_KEY_SOUND_ON_LOGIN_FAILURE_FILE,
472
&GdmSoundOnLoginFailureFile, &string_type);
473
gdm_config_add_hash (GDM_KEY_GTK_THEMES_TO_ALLOW,
474
&GdmGtkThemesToAllow, &string_type);
475
gdm_config_add_hash (GDM_KEY_INCLUDE, &GdmInclude, &string_type);
476
gdm_config_add_hash (GDM_KEY_EXCLUDE, &GdmExclude, &string_type);
477
gdm_config_add_hash (GDM_KEY_DEFAULT_FACE, &GdmDefaultFace, &string_type);
478
gdm_config_add_hash (GDM_KEY_LOCALE_FILE, &GdmLocaleFile, &string_type);
479
gdm_config_add_hash (GDM_KEY_LOGO, &GdmLogo, &string_type);
480
gdm_config_add_hash (GDM_KEY_CHOOSER_BUTTON_LOGO,
481
&GdmChooserButtonLogo, &string_type);
482
gdm_config_add_hash (GDM_KEY_WELCOME, &GdmWelcome, &string_type);
483
gdm_config_add_hash (GDM_KEY_REMOTE_WELCOME, &GdmRemoteWelcome, &string_type);
484
gdm_config_add_hash (GDM_KEY_BACKGROUND_PROGRAM,
485
&GdmBackgroundProgram, &string_type);
486
gdm_config_add_hash (GDM_KEY_BACKGROUND_IMAGE,
487
&GdmBackgroundImage, &string_type);
488
gdm_config_add_hash (GDM_KEY_BACKGROUND_COLOR,
489
&GdmBackgroundColor, &string_type);
490
gdm_config_add_hash (GDM_KEY_GRAPHICAL_THEME,
491
&GdmGraphicalTheme, &string_type);
492
gdm_config_add_hash (GDM_KEY_GRAPHICAL_THEME_DIR,
493
&GdmGraphicalThemeDir, &string_type);
494
gdm_config_add_hash (GDM_KEY_GRAPHICAL_THEMES,
495
&GdmGraphicalThemes, &string_type);
496
gdm_config_add_hash (GDM_KEY_GRAPHICAL_THEMED_COLOR,
497
&GdmGraphicalThemeColor, &string_type);
498
gdm_config_add_hash (GDM_KEY_INFO_MSG_FILE, &GdmInfoMsgFile, &string_type);
499
gdm_config_add_hash (GDM_KEY_INFO_MSG_FONT, &GdmInfoMsgFont, &string_type);
500
gdm_config_add_hash (GDM_KEY_DEFAULT_HOST_IMG, &GdmHost, &string_type);
501
gdm_config_add_hash (GDM_KEY_HOST_IMAGE_DIR, &GdmHostImageDir, &string_type);
502
gdm_config_add_hash (GDM_KEY_HOSTS, &GdmHosts, &string_type);
503
gdm_config_add_hash (GDM_KEY_PRE_FETCH_PROGRAM,
504
&GdmPreFetchProgram, &string_type);
505
gdm_config_add_hash (GDM_KEY_PAM_STACK, &GdmPamStack, &string_type);
508
gdm_config_add_hash (GDM_KEY_XINERAMA_SCREEN, &GdmXineramaScreen, &int_type);
509
gdm_config_add_hash (GDM_KEY_RETRY_DELAY, &GdmRetryDelay, &int_type);
510
gdm_config_add_hash (GDM_KEY_TIMED_LOGIN_DELAY, &GdmTimedLoginDelay, &int_type);
511
gdm_config_add_hash (GDM_KEY_RELAX_PERM, &GdmRelaxPerm, &int_type);
512
gdm_config_add_hash (GDM_KEY_USER_MAX_FILE, &GdmUserMaxFile, &int_type);
513
gdm_config_add_hash (GDM_KEY_DISPLAYS_PER_HOST, &GdmDisplaysPerHost, &int_type);
514
gdm_config_add_hash (GDM_KEY_MAX_PENDING, &GdmMaxPending, &int_type);
515
gdm_config_add_hash (GDM_KEY_MAX_WAIT, &GdmMaxWait, &int_type);
516
gdm_config_add_hash (GDM_KEY_MAX_SESSIONS, &GdmMaxSessions, &int_type);
517
gdm_config_add_hash (GDM_KEY_UDP_PORT, &GdmUdpPort, &int_type);
518
gdm_config_add_hash (GDM_KEY_MAX_INDIRECT, &GdmMaxIndirect, &int_type);
519
gdm_config_add_hash (GDM_KEY_MAX_WAIT_INDIRECT, &GdmMaxWaitIndirect, &int_type);
520
gdm_config_add_hash (GDM_KEY_PING_INTERVAL, &GdmPingInterval, &int_type);
521
gdm_config_add_hash (GDM_KEY_FLEXIBLE_XSERVERS, &GdmFlexibleXservers, &int_type);
522
gdm_config_add_hash (GDM_KEY_FIRST_VT, &GdmFirstVt, &int_type);
523
gdm_config_add_hash (GDM_KEY_POSITION_X, &GdmPositionX, &int_type);
524
gdm_config_add_hash (GDM_KEY_POSITION_Y, &GdmPositionY, &int_type);
525
gdm_config_add_hash (GDM_KEY_MINIMAL_UID, &GdmMinimalUid, &int_type);
526
gdm_config_add_hash (GDM_KEY_MAX_ICON_WIDTH, &GdmMaxIconWidth, &int_type);
527
gdm_config_add_hash (GDM_KEY_MAX_ICON_HEIGHT, &GdmMaxIconHeight, &int_type);
528
gdm_config_add_hash (GDM_KEY_BACKGROUND_TYPE, &GdmBackgroundType, &int_type);
529
gdm_config_add_hash (GDM_KEY_SCAN_TIME, &GdmScanTime, &int_type);
530
gdm_config_add_hash (GDM_KEY_FLEXI_REAP_DELAY_MINUTES,
531
&GdmFlexiReapDelayMinutes, &int_type);
532
gdm_config_add_hash (GDM_KEY_BACKGROUND_PROGRAM_INITIAL_DELAY,
533
&GdmBackgroundProgramInitialDelay, &int_type);
534
gdm_config_add_hash (GDM_KEY_BACKGROUND_PROGRAM_RESTART_DELAY,
535
&GdmBackgroundProgramRestartDelay, &int_type);
536
gdm_config_add_hash (GDM_KEY_XSERVER_TIMEOUT, &GdmXserverTimeout, &int_type);
545
gdm_get_default_config (struct stat *statbuf)
549
/* Not NULL if config_file was set by command-line option. */
550
if (config_file != NULL) {
551
VE_IGNORE_EINTR (r = g_stat (config_file, statbuf));
553
gdm_error (_("%s: No GDM configuration file: %s. Using defaults."),
554
"gdm_config_parse", config_file);
558
VE_IGNORE_EINTR (r = g_stat (GDM_DEFAULTS_CONF, statbuf));
560
gdm_error (_("%s: No GDM configuration file: %s. Using defaults."),
561
"gdm_config_parse", GDM_DEFAULTS_CONF);
564
config_file = GDM_DEFAULTS_CONF;
568
return ve_config_new (config_file);
572
* gdm_get_custom_config:
574
* Get the custom config file where gdmsetup saves its changes and
575
* where users are encouraged to make modifications.
578
gdm_get_custom_config (struct stat *statbuf)
583
* First check to see if the old configuration file name is on
584
* the system. If so, use that as the custom configuration
585
* file. "make install" will move this file aside, and
586
* distros probably can also manage moving this file on
589
* In case this file is on the system, then use it as
590
* the custom configuration file until the user moves it
591
* aside. This will likely mean all the defaults in
592
* defaults.conf will not get used since the old gdm.conf
593
* file has all the keys in it (except new ones). But
594
* that would be what the user wants.
598
* We disable this on Debian, as we already have the non-custom conf
599
* located in /usr/share. So, we make the old conf the custom config
600
* in /etc, with the same name as before. Users that upgrade to the new
601
* maintainer conf get just that (and a blank custom.conf to make changes
602
* in), and users that don't upgrade to the new conf, get both configs
603
* with the one they kept getting precedence.
606
VE_IGNORE_EINTR (r = g_stat (GDM_OLD_CONF, statbuf));
608
custom_config_file = g_strdup (GDM_OLD_CONF);
609
return ve_config_new (custom_config_file);
613
VE_IGNORE_EINTR (r = g_stat (GDM_CUSTOM_CONF, statbuf));
615
custom_config_file = g_strdup (GDM_CUSTOM_CONF);
616
return ve_config_new (custom_config_file);
623
* gdm_get_per_display_custom_config_file
625
* Returns the per-display config file for a given display
626
* This is always the custom config file name with the display
627
* appended, and never gdm.conf.
630
gdm_get_per_display_custom_config_file (gchar *display)
632
return g_strdup_printf ("%s%s", custom_config_file, display);
636
* gdm_get_custom_config_file
638
* Returns the custom config file being used.
641
gdm_get_custom_config_file (void)
643
return custom_config_file;
649
* Gets an integer configuration option by key. The option must
650
* first be loaded, say, by calling gdm_config_parse.
653
gdm_get_value_int (char *key)
655
GdmConfigType *type = gdm_config_hash_lookup (type_hash, key);
656
gpointer val = gdm_config_hash_lookup (val_hash, key);
658
if (type == NULL || val == NULL) {
659
gdm_error ("Request for invalid configuration key %s", key);
660
} else if (*type != CONFIG_INT) {
661
gdm_error ("Request for configuration key %s, but not type INT", key);
663
gint *intval = (int *)val;
671
* gdm_get_value_string
673
* Gets a string configuration option by key. The option must
674
* first be loaded, say, by calling gdm_config_parse.
677
gdm_get_value_string (char *key)
682
/* First look in translated_hash */
683
if (translated_hash != NULL) {
684
val = gdm_config_hash_lookup (translated_hash, key);
686
gchar **charval = (char **)val;
691
type = gdm_config_hash_lookup (type_hash, key);
692
val = gdm_config_hash_lookup (val_hash, key);
694
if (type == NULL || val == NULL) {
695
gdm_error ("Request for invalid configuration key %s", key);
696
} else if (*type != CONFIG_STRING) {
697
gdm_error ("Request for configuration key %s, but not type STRING", key);
699
gchar **charval = (char **)val;
709
* Gets a boolean configuration option by key. The option must
710
* first be loaded, say, by calling gdm_config_parse.
713
gdm_get_value_bool (char *key)
715
GdmConfigType *type = gdm_config_hash_lookup (type_hash, key);
716
gpointer val = gdm_config_hash_lookup (val_hash, key);
718
if (type == NULL || val == NULL) {
719
gdm_error ("Request for invalid configuration key %s", key);
720
} else if (*type != CONFIG_BOOL) {
721
gdm_error ("Request for configuration key %s, but not type BOOL", key);
723
gboolean *boolval = (gboolean *)val;
731
* Note that some GUI configuration parameters are read by the daemon,
732
* and in order for them to work, it is necessary for the daemon to
733
* access a few keys in a per-display fashion. These access functions
734
* allow the daemon to access these keys properly.
738
* gdm_get_value_int_per_display
740
* Gets the per-display version of the configuration, or the default
741
* value if none exists.
743
gint gdm_get_value_int_per_display (gchar *display, gchar *key)
747
gdm_config_key_to_string_per_display (display, key, &perdispval);
749
if (perdispval != NULL) {
750
gint val = atoi (perdispval);
754
return (gdm_get_value_int (key));
759
* gdm_get_value_bool_per_display
761
* Gets the per-display version of the configuration, or the default
762
* value if none exists.
764
gboolean gdm_get_value_bool_per_display (gchar *display, gchar *key)
768
gdm_config_key_to_string_per_display (display, key, &perdispval);
770
if (perdispval != NULL) {
771
if (perdispval[0] == 'T' ||
772
perdispval[0] == 't' ||
773
perdispval[0] == 'Y' ||
774
perdispval[0] == 'y' ||
775
atoi (perdispval) != 0) {
782
return (gdm_get_value_bool (key));
787
* gdm_get_value_string_per_display
789
* Gets the per-display version of the configuration, or the default
790
* value if none exists. Note that this value needs to be freed,
791
* unlike the non-per-display version.
793
gchar * gdm_get_value_string_per_display (gchar *display, gchar *key)
797
gdm_config_key_to_string_per_display (display, key, &perdispval);
799
if (perdispval != NULL) {
802
return (g_strdup (gdm_get_value_string (key)));
807
* gdm_config_key_to_string_per_display
809
* If the key makes sense to be per-display, return the value,
810
* otherwise return NULL. Keys that only apply to the daemon
811
* process do not make sense for per-display configuration
812
* Valid keys include any key in the greeter or gui categories,
813
* and the GDM_KEY_PAM_STACK key.
815
* If additional keys make sense for per-display usage, make
816
* sure they are added to the if-test below.
819
gdm_config_key_to_string_per_display (gchar *display, gchar *key, gchar **retval)
822
gchar **splitstr = g_strsplit (key, "/", 2);
828
file = gdm_get_per_display_custom_config_file (display);
830
if (strcmp (ve_sure_string (splitstr[0]), "greeter") == 0 ||
831
strcmp (ve_sure_string (splitstr[0]), "gui") == 0 ||
832
is_key (key, GDM_KEY_PAM_STACK)) {
833
gdm_config_key_to_string (file, key, retval);
842
* gdm_config_key_to_string
844
* Returns a specific key from the config file, or NULL if not found.
845
* Note this returns the value in string form, so the caller needs
846
* to parse it properly if it is a bool or int.
849
gdm_config_key_to_string (gchar *file, gchar *key, gchar **retval)
851
VeConfig *cfg = ve_config_get (file);
852
GdmConfigType *type = gdm_config_hash_lookup (type_hash, key);
853
gchar **splitstr = g_strsplit (key, "/", 2);
857
/* Should not fail, all keys should have a category. */
858
if (splitstr[0] == NULL)
861
/* If file doesn't exist, then just return */
865
list = ve_config_get_keys (cfg, splitstr[0]);
866
while (list != NULL) {
867
gchar *display_key = (char *)list->data;
868
gchar *display_fullkey = g_strdup_printf ("%s/%s", splitstr[0], display_key);
870
if (is_key (key, display_fullkey)) {
871
gdm_debug ("Returning value for key <%s>\n", key);
872
if (*type == CONFIG_BOOL) {
873
gboolean value = ve_config_get_bool (cfg, key);
875
*retval = g_strdup ("true");
877
*retval = g_strdup ("false");
879
} else if (*type == CONFIG_INT) {
880
gint value = ve_config_get_int (cfg, key);
881
*retval = g_strdup_printf ("%d", value);
883
} else if (*type == CONFIG_STRING) {
884
gchar *value = ve_config_get_string (cfg, key);
886
*retval = g_strdup (value);
890
g_free (display_fullkey);
897
* gdm_config_to_string
899
* Returns a configuration option as a string. Used by GDM's
900
* GET_CONFIG socket command.
903
gdm_config_to_string (gchar *key, gchar *display, gchar **retval)
905
GdmConfigType *type = gdm_config_hash_lookup (type_hash, key);
909
* See if there is a per-display config file, returning that value
913
gdm_config_key_to_string_per_display (display, key, retval);
918
/* First look in translated_hash */
919
if (translated_hash != NULL) {
920
gpointer val = gdm_config_hash_lookup (translated_hash, key);
922
*retval = g_strdup (val);
928
if (*type == CONFIG_BOOL) {
929
gboolean value = gdm_get_value_bool (key);
931
*retval = g_strdup ("true");
933
*retval = g_strdup ("false");
935
} else if (*type == CONFIG_INT) {
936
gint value = gdm_get_value_int (key);
937
*retval = g_strdup_printf ("%d", value);
939
} else if (*type == CONFIG_STRING) {
940
gchar *value = gdm_get_value_string (key);
942
*retval = g_strdup (value);
947
gdm_debug ("Error returning config key %s\n", key);
952
* gdm_compare_displays
954
* Support function for loading displays from the configuration
958
gdm_compare_displays (gconstpointer a, gconstpointer b)
960
const GdmDisplay *d1 = a;
961
const GdmDisplay *d2 = b;
962
if (d1->dispnum < d2->dispnum)
964
else if (d1->dispnum > d2->dispnum)
971
* notify_displays_int
972
* notify_displays_string
974
* The following two functions will notify the slave programs
975
* (gdmgreeter, gdmlogin, etc.) that a configuration option has
976
* been changed so the slave can update with the new option
977
* value. GDM does this notify when it receives a
978
* GDM_CONFIG_UPDATE socket command from gdmsetup or from the
979
* gdmflexiserver --command option. notify_displays_int
980
* is also used for notifying for boolean values.
983
notify_displays_int (const gchar *key, int val)
986
for (li = displays; li != NULL; li = li->next) {
987
GdmDisplay *disp = li->data;
988
if (disp->master_notify_fd >= 0) {
989
gdm_fdprintf (disp->master_notify_fd, "%c%s %d\n",
990
GDM_SLAVE_NOTIFY_KEY, key, val);
992
if (disp != NULL && disp->slavepid > 1)
993
kill (disp->slavepid, SIGUSR2);
999
notify_displays_string (const gchar *key, const gchar *val)
1002
for (li = displays; li != NULL; li = li->next) {
1003
GdmDisplay *disp = li->data;
1004
if (disp->master_notify_fd >= 0) {
1006
gdm_fdprintf (disp->master_notify_fd, "%c%s \n",
1007
GDM_SLAVE_NOTIFY_KEY, key);
1009
gdm_fdprintf (disp->master_notify_fd, "%c%s %s\n",
1010
GDM_SLAVE_NOTIFY_KEY, key, val);
1012
if (disp != NULL && disp->slavepid > 1)
1013
kill (disp->slavepid, SIGUSR2);
1019
* _gdm_set_value_string
1020
* _gdm_set_value_bool
1021
* _gdm_set_value_int
1023
* The following interfaces are used to set values. The "doing_update"
1024
* boolean argument which is only set when GDM_UPDATE_CONFIG is called.
1025
* If doing_update is TRUE, then a notify is sent to slaves. When
1026
* loading values at other times (such as when first loading
1027
* configuration options) there is no need to notify the slaves. If
1028
* there is a desire to send a notify to the slaves, the
1029
* gdm_update_config function should be used instead of calling these
1030
* functions directly.
1033
_gdm_set_value_string (gchar *key, gchar *value_in, gboolean doing_update)
1035
gchar **setting = gdm_config_hash_lookup (val_hash, key);
1036
gchar *setting_copy = NULL;
1040
if (! ve_string_empty (value_in))
1045
if (setting == NULL) {
1046
gdm_error ("Failure setting key %s to %s", key, value);
1050
if (*setting != NULL) {
1051
/* Free old value */
1052
setting_copy = g_strdup (*setting);
1057
if (is_key (key, GDM_KEY_PATH)) {
1059
temp_string = gdm_read_default ("PATH=");
1060
if (temp_string != NULL)
1061
*setting = temp_string;
1062
else if (value != NULL)
1063
*setting = g_strdup (value);
1067
/* Root user PATH */
1068
} else if (is_key (key, GDM_KEY_ROOT_PATH)) {
1070
temp_string = gdm_read_default ("SUPATH=");
1071
if (temp_string != NULL)
1072
*setting = temp_string;
1073
else if (value != NULL)
1074
*setting = g_strdup (value);
1078
/* Location of Xsession script */
1079
} else if (is_key (key, GDM_KEY_BASE_XSESSION)) {
1080
if (value != NULL) {
1081
*setting = g_strdup (value);
1083
gdm_info (_("%s: BaseXsession empty; using %s/gdm/Xsession"),
1086
*setting = g_build_filename (GDMCONFDIR,
1087
"gdm", "Xsession", NULL);
1090
/* Halt, Reboot, and Suspend commands */
1091
} else if (is_key (key, GDM_KEY_HALT) ||
1092
is_key (key, GDM_KEY_REBOOT) ||
1093
is_key (key, GDM_KEY_SUSPEND)) {
1095
*setting = ve_get_first_working_command (value, FALSE);
1099
/* Console cannot handle these languages */
1100
} else if (is_key (key, GDM_KEY_CONSOLE_CANNOT_HANDLE)) {
1102
*setting = g_strdup (value);
1105
gdm_ok_console_language ();
1107
/* Location of Xserver */
1108
} else if (is_key (key, GDM_KEY_STANDARD_XSERVER)) {
1112
bin = ve_first_word (value);
1114
if G_UNLIKELY (ve_string_empty (bin) ||
1115
g_access (bin, X_OK) != 0) {
1116
gdm_info (_("%s: Standard X server not found; trying alternatives"),
1117
"gdm_config_parse");
1118
if (g_access ("/usr/X11R6/bin/X", X_OK) == 0) {
1119
*setting = g_strdup ("/usr/X11R6/bin/X");
1120
} else if (g_access ("/opt/X11R6/bin/X", X_OK) == 0) {
1121
*setting = g_strdup ("/opt/X11R6/bin/X");
1122
} else if (g_access ("/usr/bin/X11/X", X_OK) == 0) {
1123
*setting = g_strdup ("/usr/bin/X11/X");
1125
*setting = g_strdup (value);
1127
*setting = g_strdup (value);
1130
/* Graphical Theme Directory */
1131
} else if (is_key (key, GDM_KEY_GRAPHICAL_THEME_DIR)) {
1132
if (value == NULL ||
1133
! g_file_test (value, G_FILE_TEST_IS_DIR))
1135
*setting = g_strdup (GREETERTHEMEDIR);
1137
*setting = g_strdup (value);
1140
/* Graphical Theme */
1141
} else if (is_key (key, GDM_KEY_GRAPHICAL_THEME)) {
1143
*setting = g_strdup ("circles");
1145
*setting = g_strdup (value);
1148
* Default Welcome Message. Don't translate here since the
1149
* GDM user may not be running with the same language as the user.
1150
* The slave programs will translate the string.
1152
} else if (is_key (key, GDM_KEY_WELCOME)) {
1154
*setting = g_strdup (value);
1156
*setting = g_strdup (GDM_DEFAULT_WELCOME_MSG);
1159
* Default Remote Welcome Message. Don't translate here since the
1160
* GDM user may not be running with the same language as the user.
1161
* The slave programs will translate the string.
1163
} else if (is_key (key, GDM_KEY_REMOTE_WELCOME)) {
1165
*setting = g_strdup (value);
1167
*setting = g_strdup (GDM_DEFAULT_REMOTE_WELCOME_MSG);
1172
*setting = g_strdup (value);
1174
if (is_key (key, GDM_KEY_GREETER))
1175
gdm_error (_("%s: No greeter specified."), "gdm_config_parse");
1176
else if (is_key (key, GDM_KEY_REMOTE_GREETER))
1177
gdm_error (_("%s: No remote greeter specified."), "gdm_config_parse");
1178
else if (is_key (key, GDM_KEY_SESSION_DESKTOP_DIR))
1179
gdm_error (_("%s: No sessions directory specified."), "gdm_config_parse");
1186
if (doing_update == TRUE &&
1187
strcmp (ve_sure_string (*setting),
1188
ve_sure_string (setting_copy)) != 0) {
1190
if (is_key (key, GDM_KEY_GREETER))
1191
notify_displays_string (GDM_NOTIFY_GREETER, *setting);
1192
else if (is_key (key, GDM_KEY_REMOTE_GREETER))
1193
notify_displays_string (GDM_NOTIFY_REMOTE_GREETER, *setting);
1194
else if (is_key (key, GDM_KEY_SOUND_ON_LOGIN_FILE))
1195
notify_displays_string (GDM_NOTIFY_SOUND_ON_LOGIN_FILE, *setting);
1196
else if (is_key (key, GDM_KEY_SOUND_ON_LOGIN_SUCCESS_FILE))
1197
notify_displays_string (GDM_NOTIFY_SOUND_ON_LOGIN_SUCCESS_FILE, *setting);
1198
else if (is_key (key, GDM_KEY_SOUND_ON_LOGIN_FAILURE_FILE))
1199
notify_displays_string (GDM_NOTIFY_SOUND_ON_LOGIN_FAILURE_FILE, *setting);
1200
else if (is_key (key, GDM_KEY_GTK_MODULES_LIST))
1201
notify_displays_string (GDM_NOTIFY_GTK_MODULES_LIST, *setting);
1202
else if (is_key (key, GDM_KEY_TIMED_LOGIN))
1203
notify_displays_string (GDM_NOTIFY_TIMED_LOGIN, *setting);
1206
if (setting_copy != NULL)
1207
g_free (setting_copy);
1209
if (*setting == NULL)
1210
gdm_debug ("set config key %s to string <NULL>", key);
1212
gdm_debug ("set config key %s to string %s", key, *setting);
1216
gdm_set_value_string (gchar *key, gchar *value_in)
1218
_gdm_set_value_string (key, value_in, TRUE);
1222
_gdm_set_value_bool (gchar *key, gboolean value, gboolean doing_update)
1224
gboolean *setting = gdm_config_hash_lookup (val_hash, key);
1225
gboolean setting_copy = *setting;
1228
if (setting == NULL) {
1230
gdm_error ("Failure setting key %s to true", key);
1232
gdm_error ("Failure setting key %s to false", key);
1236
/* Password Required */
1237
if (is_key (key, GDM_KEY_PASSWORD_REQUIRED)) {
1238
temp_string = gdm_read_default ("PASSREQ=");
1239
if (temp_string == NULL)
1241
else if (g_ascii_strcasecmp (temp_string, "YES") == 0)
1245
g_free (temp_string);
1247
/* Allow root login */
1248
} else if (is_key (key, GDM_KEY_ALLOW_REMOTE_ROOT)) {
1249
temp_string = gdm_read_default ("CONSOLE=");
1251
if (temp_string == NULL)
1253
else if (g_ascii_strcasecmp (temp_string, "/dev/console") != 0)
1257
g_free (temp_string);
1260
#ifndef HAVE_LIBXDMCP
1261
} else if (is_key (key, GDM_KEY_XDMCP)) {
1263
gdm_info (_("%s: XDMCP was enabled while there is no XDMCP support; turning it off"), "gdm_config_parse");
1272
if (doing_update == TRUE && *setting != setting_copy) {
1273
if (is_key (key, GDM_KEY_ALLOW_ROOT))
1274
notify_displays_int (GDM_NOTIFY_ALLOW_ROOT, *setting);
1275
else if (is_key (key, GDM_KEY_ALLOW_REMOTE_ROOT))
1276
notify_displays_int (GDM_NOTIFY_ALLOW_REMOTE_ROOT, *setting);
1277
else if (is_key (key, GDM_KEY_ALLOW_REMOTE_AUTOLOGIN))
1278
notify_displays_int (GDM_NOTIFY_ALLOW_REMOTE_AUTOLOGIN, *setting);
1279
else if (is_key (key, GDM_KEY_SYSTEM_MENU))
1280
notify_displays_int (GDM_NOTIFY_SYSTEM_MENU, *setting);
1281
else if (is_key (key, GDM_KEY_CONFIG_AVAILABLE))
1282
notify_displays_int (GDM_NOTIFY_CONFIG_AVAILABLE, *setting);
1283
else if (is_key (key, GDM_KEY_CHOOSER_BUTTON))
1284
notify_displays_int (GDM_NOTIFY_CHOOSER_BUTTON, *setting);
1285
else if (is_key (key, GDM_KEY_DISALLOW_TCP))
1286
notify_displays_int (GDM_NOTIFY_DISALLOW_TCP, *setting);
1287
else if (is_key (key, GDM_KEY_ADD_GTK_MODULES))
1288
notify_displays_int (GDM_NOTIFY_ADD_GTK_MODULES, *setting);
1289
else if (is_key (key, GDM_KEY_TIMED_LOGIN_ENABLE))
1290
notify_displays_int (GDM_NOTIFY_TIMED_LOGIN_ENABLE, *setting);
1294
gdm_debug ("set config key %s to boolean true", key);
1296
gdm_debug ("set config key %s to boolean false", key);
1300
gdm_set_value_bool (gchar *key, gboolean value)
1302
_gdm_set_value_bool (key, value, TRUE);
1306
_gdm_set_value_int (gchar *key, gint value, gboolean doing_update)
1308
gint *setting = gdm_config_hash_lookup (val_hash, key);
1309
gint setting_copy = *setting;
1311
if (setting == NULL) {
1312
gdm_error ("Failure setting key %s to %d", key, value);
1316
if (is_key (key, GDM_KEY_MAX_INDIRECT) ||
1317
is_key (key, GDM_KEY_XINERAMA_SCREEN)) {
1322
} else if (is_key (key, GDM_KEY_TIMED_LOGIN_DELAY)) {
1324
gdm_info (_("%s: TimedLoginDelay is less than 5, defaulting to 5."), "gdm_config_parse");
1328
} else if (is_key (key, GDM_KEY_MAX_ICON_WIDTH) ||
1329
is_key (key, GDM_KEY_MAX_ICON_HEIGHT)) {
1334
} else if (is_key (key, GDM_KEY_SCAN_TIME)) {
1345
if (doing_update == TRUE && *setting != setting_copy) {
1346
if (is_key (key, GDM_KEY_RETRY_DELAY))
1347
notify_displays_int (GDM_NOTIFY_RETRY_DELAY, *setting);
1348
else if (is_key (key, GDM_KEY_TIMED_LOGIN_DELAY))
1349
notify_displays_int (GDM_NOTIFY_TIMED_LOGIN_DELAY, *setting);
1352
gdm_debug ("set config key %s to integer %d", key, *setting);
1356
gdm_set_value_int (gchar *key, gint value)
1358
_gdm_set_value_int (key, value, TRUE);
1364
* This functon is used to set the config values in the hash. This is called
1365
* at initial config load time or when gdm_update_config is called to reload
1366
* them. It adds translated strings to the hash with their proper keys
1367
* (greeter/Welcome[cs] for example).
1370
gdm_set_value (VeConfig *cfg, GdmConfigType *type, gchar *key, gboolean doing_update)
1372
gchar * realkey = gdm_config_hash_lookup (realkey_hash, key);
1375
if (realkey == NULL) {
1379
if (*type == CONFIG_BOOL) {
1380
gboolean value = ve_config_get_bool (cfg, realkey);
1381
_gdm_set_value_bool (key, value, doing_update);
1383
} else if (*type == CONFIG_INT) {
1384
gint value = ve_config_get_int (cfg, realkey);
1385
_gdm_set_value_int (key, value, doing_update);
1387
} else if (*type == CONFIG_STRING) {
1389
/* Process translated strings */
1390
if (is_key (key, GDM_KEY_WELCOME) ||
1391
is_key (key, GDM_KEY_REMOTE_WELCOME)) {
1393
GList *list = ve_config_get_keys (cfg, "greeter");
1394
gchar *prefix, *basekey;
1396
if (is_key (key, GDM_KEY_WELCOME)) {
1397
basekey = g_strdup ("Welcome");
1398
prefix = g_strdup ("Welcome[");
1400
basekey = g_strdup ("RemoteWelcome");
1401
prefix = g_strdup ("RemoteWelcome[");
1405
* Loop over translated keys and put all values into the hash
1406
* Probably should loop through the hashs and delete any old values,
1407
* but this just means that if a translation is deleted from the
1408
* config, GDM won't forget about it until restart. I don't think
1409
* this will happen, or be a real problem if it does.
1411
while (list != NULL) {
1412
if (g_str_has_prefix ((char *)list->data, prefix) &&
1413
g_str_has_suffix ((char *)list->data, "]")) {
1414
gchar *transkey, *transvalue;
1416
if (translated_hash == NULL)
1417
translated_hash = g_hash_table_new (g_str_hash, g_str_equal);
1419
transkey = g_strdup_printf ("greeter/%s", (char *)list->data);
1420
transvalue = ve_config_get_string (cfg, transkey);
1422
g_hash_table_remove (translated_hash, transkey);
1425
* Store translated values in a separate hash. Note that we load
1426
* the initial values via a g_hash_table_foreach function, so if
1427
* we add these to the same hash, we would end up loading these
1428
* values in again a second time.
1430
g_hash_table_insert (translated_hash, transkey, transvalue);
1438
/* Handle non-translated strings as normal */
1439
value = ve_config_get_string (cfg, realkey);
1440
_gdm_set_value_string (key, value, doing_update);
1450
* Return an xserver with a given ID, or NULL if not found.
1453
gdm_find_xserver (const gchar *id)
1457
if (xservers == NULL)
1461
return xservers->data;
1463
for (li = xservers; li != NULL; li = li->next) {
1464
GdmXserver *svr = li->data;
1465
if (strcmp (ve_sure_string (svr->id), ve_sure_string (id)) == 0)
1474
* Prepare a string to be returned for the GET_SERVER_LIST
1478
gdm_get_xservers (void)
1481
gchar *retval = NULL;
1483
if (xservers == NULL)
1486
for (li = xservers; li != NULL; li = li->next) {
1487
GdmXserver *svr = li->data;
1489
retval = g_strconcat (retval, ";", svr->id, NULL);
1491
retval = g_strdup (svr->id);
1497
/* PRIO_MIN and PRIO_MAX are not defined on Solaris, but are -20 and 20 */
1500
#define PRIO_MIN -20
1510
* Load [server-foo] sections from a configuration file.
1513
gdm_load_xservers (VeConfig *cfg)
1517
/* Find server definitions */
1518
list = ve_config_get_sections (cfg);
1519
for (li = list; li != NULL; li = li->next) {
1520
const gchar *sec = li->data;
1522
if (strncmp (sec, "server-", strlen ("server-")) == 0) {
1525
id = g_strdup (sec + strlen ("server-"));
1528
* See if we already loaded a server with this id, skip if
1529
* one already exists.
1531
if (gdm_find_xserver (id) != NULL) {
1534
GdmXserver *svr = g_new0 (GdmXserver, 1);
1540
g_snprintf (buf, sizeof (buf), "%s/" GDM_KEY_SERVER_NAME, sec);
1541
svr->name = ve_config_get_string (cfg, buf);
1542
g_snprintf (buf, sizeof (buf), "%s/" GDM_KEY_SERVER_COMMAND, sec);
1543
svr->command = ve_config_get_string (cfg, buf);
1544
g_snprintf (buf, sizeof (buf), "%s/" GDM_KEY_SERVER_FLEXIBLE, sec);
1545
svr->flexible = ve_config_get_bool (cfg, buf);
1546
g_snprintf (buf, sizeof (buf), "%s/" GDM_KEY_SERVER_CHOOSABLE, sec);
1547
svr->choosable = ve_config_get_bool (cfg, buf);
1548
g_snprintf (buf, sizeof (buf), "%s/" GDM_KEY_SERVER_HANDLED, sec);
1549
svr->handled = ve_config_get_bool (cfg, buf);
1550
g_snprintf (buf, sizeof (buf), "%s/" GDM_KEY_SERVER_CHOOSER, sec);
1551
svr->chooser = ve_config_get_bool (cfg, buf);
1552
g_snprintf (buf, sizeof (buf), "%s/" GDM_KEY_SERVER_PRIORITY, sec);
1553
svr->priority = ve_config_get_int (cfg, buf);
1555
/* do some bounds checking */
1559
else if (n > PRIO_MAX)
1561
if (n != svr->priority) {
1562
gdm_error (_("%s: Priority out of bounds; changed to %d"),
1563
"gdm_config_parse", n);
1567
if (ve_string_empty (svr->command)) {
1568
gdm_error (_("%s: Empty server command; "
1569
"using standard command."), "gdm_config_parse");
1570
g_free (svr->command);
1571
svr->command = g_strdup (GdmStandardXserver);
1574
xservers = g_slist_append (xservers, svr);
1578
ve_config_free_list_of_strings (list);
1582
* gdm_update_xservers
1584
* Reload [server-foo] sections from the configuration files.
1587
gdm_update_xservers (VeConfig *cfg, VeConfig *custom_cfg)
1591
/* Free list if already loaded */
1592
if (xservers != NULL) {
1593
for (xli = xservers; xli != NULL; xli = xli->next) {
1594
GdmXserver *xsvr = xli->data;
1597
g_free (xsvr->name);
1598
g_free (xsvr->command);
1600
g_slist_free (xservers);
1604
/* Reload first from custom_cfg then from cfg. */
1605
if (custom_cfg != NULL)
1606
gdm_load_xservers (custom_cfg);
1609
gdm_load_xservers (cfg);
1611
/* If no "Standard" server was created, then add it */
1612
if (xservers == NULL || gdm_find_xserver (GDM_STANDARD) == NULL) {
1613
GdmXserver *svr = g_new0 (GdmXserver, 1);
1615
svr->id = g_strdup (GDM_STANDARD);
1616
svr->name = g_strdup ("Standard server");
1617
svr->command = g_strdup (GdmStandardXserver);
1618
svr->flexible = TRUE;
1619
svr->choosable = TRUE;
1620
svr->handled = TRUE;
1622
xservers = g_slist_append (xservers, svr);
1629
* Will cause a the GDM daemon to re-read the key from the configuration
1630
* file and cause notify signal to be sent to the slaves for the
1631
* specified key, if appropriate. Only specific keys defined in the
1632
* gdm_set_value functions above are associated with such notification.
1633
* Obviously notification is not needed for configuration options only
1634
* used by the daemon. This function is called when the UPDDATE_CONFIG
1635
* sockets command is called.
1637
* To add a new notification, a GDM_NOTIFY_* argument will need to be
1638
* defined in gdm.h, supporting logic placed in the gdm_set_value
1639
* functions and in the gdm_slave_handle_notify function in slave.c.
1642
gdm_update_config (gchar* key)
1644
GdmConfigType *type;
1645
struct stat statbuf, custom_statbuf;
1647
VeConfig *custom_cfg = NULL;
1648
gboolean rc = FALSE;
1651
* Do not allow these keys to be updated, since GDM would need
1652
* additional work, or at least heavy testing, to make these keys
1653
* flexible enough to be changed at runtime.
1655
if (is_key (key, GDM_KEY_PID_FILE) ||
1656
is_key (key, GDM_KEY_CONSOLE_NOTIFY) ||
1657
is_key (key, GDM_KEY_USER) ||
1658
is_key (key, GDM_KEY_GROUP) ||
1659
is_key (key, GDM_KEY_LOG_DIR) ||
1660
is_key (key, GDM_KEY_SERV_AUTHDIR) ||
1661
is_key (key, GDM_KEY_USER_AUTHDIR) ||
1662
is_key (key, GDM_KEY_USER_AUTHFILE) ||
1663
is_key (key, GDM_KEY_USER_AUTHDIR_FALLBACK)) {
1667
/* See if custom file is now there */
1668
if (custom_config_file == NULL) {
1669
custom_cfg = gdm_get_custom_config (&statbuf);
1672
/* Don't bother re-reading configuration if files have not changed */
1673
VE_IGNORE_EINTR (g_stat (config_file, &statbuf));
1674
VE_IGNORE_EINTR (g_stat (custom_config_file, &custom_statbuf));
1677
* Do not reset mtime to the latest values since there is no
1678
* guarantee that only one key was modified since last write.
1679
* This check simply avoids re-reading the files if neither
1680
* has changed since GDM was started.
1682
if (config_file_mtime == statbuf.st_mtime &&
1683
custom_config_file_mtime == custom_statbuf.st_mtime)
1686
/* Shortcut for updating all XDMCP parameters */
1687
if (is_key (key, "xdmcp/PARAMETERS")) {
1688
gdm_update_config (GDM_KEY_DISPLAYS_PER_HOST);
1689
gdm_update_config (GDM_KEY_MAX_PENDING);
1690
gdm_update_config (GDM_KEY_MAX_WAIT);
1691
gdm_update_config (GDM_KEY_MAX_SESSIONS);
1692
gdm_update_config (GDM_KEY_INDIRECT);
1693
gdm_update_config (GDM_KEY_MAX_INDIRECT);
1694
gdm_update_config (GDM_KEY_MAX_WAIT_INDIRECT);
1695
gdm_update_config (GDM_KEY_PING_INTERVAL);
1699
if (custom_config_file != NULL)
1700
custom_cfg = ve_config_new (custom_config_file);
1702
if (is_key (key, "xservers/PARAMETERS")) {
1703
cfg = ve_config_new (config_file);
1704
gdm_update_xservers (cfg, custom_cfg);
1705
ve_config_destroy (cfg);
1706
if (custom_cfg != NULL)
1707
ve_config_destroy (custom_cfg);
1711
type = gdm_config_hash_lookup (type_hash, key);
1715
/* First check the custom file */
1716
if (custom_cfg != NULL) {
1717
gchar **splitstr = g_strsplit (key, "/", 2);
1719
if (splitstr[0] != NULL) {
1720
GList *list = ve_config_get_keys (custom_cfg, splitstr[0]);
1722
while (list != NULL) {
1723
gchar *custom_key = (char *)list->data;
1724
gchar *custom_fullkey = g_strdup_printf ("%s/%s", splitstr[0], custom_key);
1726
if (is_key (key, custom_fullkey)) {
1727
rc = gdm_set_value (custom_cfg, type, key, TRUE);
1729
g_free (custom_fullkey);
1730
g_strfreev (splitstr);
1731
ve_config_destroy (custom_cfg);
1735
g_free (custom_fullkey);
1739
g_strfreev (splitstr);
1742
/* If not in the custom file, check main config file */
1743
cfg = ve_config_new (config_file);
1744
rc = gdm_set_value (cfg, type, key, TRUE);
1746
ve_config_destroy (cfg);
1747
if (custom_cfg != NULL)
1748
ve_config_destroy (custom_cfg);
1756
* Support functions for gdm_config_parse.
1761
struct stat statbuf;
1764
VE_IGNORE_EINTR (r = g_stat (GdmLogDir, &statbuf));
1766
! S_ISDIR (statbuf.st_mode)) {
1767
gdm_error (_("%s: Logdir %s does not exist or isn't a directory. Using ServAuthDir %s."), "gdm_config_parse",
1768
GdmLogDir, GdmServAuthDir);
1770
GdmLogDir = g_strdup (GdmServAuthDir);
1775
check_servauthdir (struct stat *statbuf)
1779
/* Enter paranoia mode */
1780
VE_IGNORE_EINTR (r = g_stat (GdmServAuthDir, statbuf));
1781
if G_UNLIKELY (r < 0) {
1782
if (GdmConsoleNotify) {
1783
gchar *s = g_strdup_printf
1784
(C_(N_("Server Authorization directory "
1785
"(daemon/ServAuthDir) is set to %s "
1786
"but this does not exist. Please "
1787
"correct GDM configuration and "
1788
"restart GDM.")), GdmServAuthDir);
1790
gdm_text_message_dialog (s);
1795
gdm_fail (_("%s: Authdir %s does not exist. Aborting."), "gdm_config_parse", GdmServAuthDir);
1798
if G_UNLIKELY (! S_ISDIR (statbuf->st_mode)) {
1799
if (GdmConsoleNotify) {
1800
gchar *s = g_strdup_printf
1801
(C_(N_("Server Authorization directory "
1802
"(daemon/ServAuthDir) is set to %s "
1803
"but this is not a directory. Please "
1804
"correct GDM configuration and "
1805
"restart GDM.")), GdmServAuthDir);
1807
gdm_text_message_dialog (s);
1812
gdm_fail (_("%s: Authdir %s is not a directory. Aborting."), "gdm_config_parse", GdmServAuthDir);
1816
typedef struct _GdmConfigFiles {
1818
VeConfig *custom_cfg;
1824
* Load the displays section of the config file
1827
gdm_load_displays (VeConfig *cfg, GList *list )
1832
for (li = list; li != NULL; li = li->next) {
1833
const gchar *key = li->data;
1835
if (isdigit (*key)) {
1838
int keynum = atoi (key);
1839
gboolean skip_entry = FALSE;
1841
fullkey = g_strdup_printf ("%s/%s", GDM_KEY_SECTION_SERVERS, key);
1842
dispval = ve_config_get_string (cfg, fullkey);
1845
/* Do not add if already in the list */
1846
for (li2 = displays; li2 != NULL; li2 = li2->next) {
1847
GdmDisplay *disp = li2->data;
1848
if (disp->dispnum == keynum) {
1854
/* Do not add if this display was marked as inactive already */
1855
for (li2 = displays_inactive; li2 != NULL; li2 = li2->next) {
1856
gchar *disp = li2->data;
1857
if (atoi (disp) == keynum) {
1863
if (skip_entry == TRUE) {
1868
if (g_ascii_strcasecmp (ve_sure_string (dispval), "inactive") == 0) {
1869
gdm_debug ("display %s is inactive", key);
1870
displays_inactive = g_slist_append (displays_inactive, g_strdup (key));
1872
GdmDisplay *disp = gdm_server_alloc (keynum, dispval);
1877
displays = g_slist_insert_sorted (displays, disp, gdm_compare_displays);
1878
if (keynum > high_display_num)
1879
high_display_num = keynum;
1885
gdm_info (_("%s: Invalid server line in config file. Ignoring!"), "gdm_config_parse");
1891
* gdm_load_config_option
1893
* Called by gdm_config_parse in a loop to set each key.
1896
gdm_load_config_option (gpointer key_in, gpointer value_in, gpointer data)
1898
gchar *key = (gchar *)key_in;
1899
GdmConfigType *type = (GdmConfigType *)value_in;
1900
GdmConfigFiles *cfgfiles = (GdmConfigFiles *)data;
1901
gboolean custom_retval;
1904
/* First check the custom file */
1905
if (cfgfiles->custom_cfg != NULL) {
1906
gchar **splitstr = g_strsplit (key_in, "/", 2);
1907
if (splitstr[0] != NULL) {
1908
GList *list = ve_config_get_keys (cfgfiles->custom_cfg, splitstr[0]);
1910
while (list != NULL) {
1911
gchar *custom_key = (char *)list->data;
1912
gchar *custom_fullkey = g_strdup_printf ("%s/%s", splitstr[0], custom_key);
1914
if (is_key (key_in, custom_fullkey)) {
1915
custom_retval = gdm_set_value (cfgfiles->custom_cfg, type, key, FALSE);
1916
g_free (custom_fullkey);
1917
g_strfreev (splitstr);
1921
g_free (custom_fullkey);
1925
g_strfreev (splitstr);
1928
/* If not in the custom file, check main config file */
1929
if (gdm_set_value (cfgfiles->cfg, type, key, FALSE))
1933
gdm_error ("Cannot set config option %s", key);
1939
* Loads initial configuration settings.
1942
gdm_config_parse (void)
1944
GdmConfigFiles cfgfiles;
1945
VeConfig *cfg, *custom_cfg;
1946
struct passwd *pwent;
1947
struct group *grent;
1948
struct stat statbuf;
1951
/* Init structures for configuration data */
1955
high_display_num = 0;
1958
* It is okay if the custom_cfg file is missing, then just use
1959
* main configuration file. If cfg is missing, then GDM will
1960
* use the built-in defaults found in gdm.h.
1962
cfg = gdm_get_default_config (&statbuf);
1963
config_file_mtime = statbuf.st_mtime;
1964
custom_cfg = gdm_get_custom_config (&statbuf);
1965
custom_config_file_mtime = statbuf.st_mtime;
1967
cfgfiles.custom_cfg = custom_cfg;
1969
/* Loop over all configuration options and load them */
1970
g_hash_table_foreach (type_hash, gdm_load_config_option, &cfgfiles);
1972
/* Load server-foo sections */
1973
gdm_update_xservers (cfg, custom_cfg);
1975
/* Only read the list if no_console is FALSE at this stage */
1980
/* Find static X server definitions */
1982
list = ve_config_get_keys (custom_cfg, GDM_KEY_SECTION_SERVERS);
1983
gdm_load_displays (custom_cfg, list);
1984
ve_config_free_list_of_strings (list);
1987
list = ve_config_get_keys (cfg, GDM_KEY_SECTION_SERVERS);
1988
gdm_load_displays (cfg, list);
1989
ve_config_free_list_of_strings (list);
1991
/* Free list of inactive, not needed anymore */
1992
for (li2 = displays_inactive; li2 != NULL; li2 = li2->next) {
1993
gchar *disp = li2->data;
1996
g_slist_free (displays_inactive);
1999
if G_UNLIKELY ((displays == NULL) && (! GdmXdmcp) && (!GdmDynamicXservers)) {
2000
gchar *server = NULL;
2003
* If we requested no static servers (there is no console),
2004
* then don't display errors in console messages
2007
gdm_fail (_("%s: XDMCP disabled and no static servers defined. Aborting!"), "gdm_config_parse");
2010
bin = ve_first_word (GdmStandardXserver);
2011
if G_LIKELY (g_access (bin, X_OK) == 0) {
2012
server = GdmStandardXserver;
2013
} else if (g_access ("/usr/bin/X11/X", X_OK) == 0) {
2014
server = "/usr/bin/X11/X";
2015
} else if (g_access ("/usr/X11R6/bin/X", X_OK) == 0) {
2016
server = "/usr/X11R6/bin/X";
2017
} else if (g_access ("/opt/X11R6/bin/X", X_OK) == 0) {
2018
server = "/opt/X11R6/bin/X";
2022
/* yay, we can add a backup emergency server */
2023
if (server != NULL) {
2024
int num = gdm_get_free_display (0 /* start */, 0 /* server uid */);
2025
gdm_error (_("%s: XDMCP disabled and no static servers defined. Adding %s on :%d to allow configuration!"),
2026
"gdm_config_parse", server, num);
2028
gdm_emergency_server = TRUE;
2029
displays = g_slist_append (displays, gdm_server_alloc (num, server));
2030
/* ALWAYS run the greeter and don't log anyone in,
2031
* this is just an emergency session */
2032
g_free (GdmAutomaticLogin);
2033
g_free (GdmTimedLogin);
2034
GdmAutomaticLogin = NULL;
2035
GdmTimedLogin = NULL;
2037
if (GdmConsoleNotify) {
2038
gchar *s = g_strdup_printf (C_(N_("XDMCP is disabled and GDM "
2039
"cannot find any static server "
2040
"to start. Aborting! Please "
2041
"correct the configuration "
2042
"and restart GDM.")));
2043
gdm_text_message_dialog (s);
2048
gdm_fail (_("%s: XDMCP disabled and no static servers defined. Aborting!"), "gdm_config_parse");
2052
/* If no displays were found, then obviously
2053
we're in a no console mode */
2054
if (displays == NULL)
2058
GdmConsoleNotify = FALSE;
2060
/* Lookup user and groupid for the GDM user */
2061
pwent = getpwnam (GdmUser);
2063
/* Set GdmUserId and GdmGroupId */
2064
if G_UNLIKELY (pwent == NULL) {
2066
if (GdmConsoleNotify) {
2067
gchar *s = g_strdup_printf (C_(N_("The GDM user '%s' does not exist. "
2068
"Please correct GDM configuration "
2069
"and restart GDM.")), GdmUser);
2070
gdm_text_message_dialog (s);
2075
gdm_fail (_("%s: Can't find the GDM user '%s'. Aborting!"), "gdm_config_parse", GdmUser);
2077
GdmUserId = pwent->pw_uid;
2080
if G_UNLIKELY (GdmUserId == 0) {
2081
if (GdmConsoleNotify) {
2082
gchar *s = g_strdup_printf (C_(N_("The GDM user is set to be root, but "
2083
"this is not allowed since it can "
2084
"pose a security risk. Please "
2085
"correct GDM configuration and "
2088
gdm_text_message_dialog (s);
2093
gdm_fail (_("%s: The GDM user should not be root. Aborting!"), "gdm_config_parse");
2096
grent = getgrnam (GdmGroup);
2098
if G_UNLIKELY (grent == NULL) {
2099
if (GdmConsoleNotify) {
2100
gchar *s = g_strdup_printf (C_(N_("The GDM group '%s' does not exist. "
2101
"Please correct GDM configuration "
2102
"and restart GDM.")), GdmGroup);
2103
gdm_text_message_dialog (s);
2108
gdm_fail (_("%s: Can't find the GDM group '%s'. Aborting!"), "gdm_config_parse", GdmGroup);
2110
GdmGroupId = grent->gr_gid;
2113
if G_UNLIKELY (GdmGroupId == 0) {
2114
if (GdmConsoleNotify) {
2115
gchar *s = g_strdup_printf (C_(N_("The GDM group is set to be root, but "
2116
"this is not allowed since it can "
2117
"pose a security risk. Please "
2118
"correct GDM configuration and "
2120
gdm_text_message_dialog (s);
2125
gdm_fail (_("%s: The GDM group should not be root. Aborting!"), "gdm_config_parse");
2128
/* gid remains `gdm' */
2129
NEVER_FAILS_root_set_euid_egid (GdmUserId, GdmGroupId);
2131
/* Check that the greeter can be executed */
2132
bin = ve_first_word (GdmGreeter);
2133
if G_UNLIKELY (ve_string_empty (bin) || g_access (bin, X_OK) != 0) {
2134
gdm_error (_("%s: Greeter not found or can't be executed by the GDM user"), "gdm_config_parse");
2138
bin = ve_first_word (GdmRemoteGreeter);
2139
if G_UNLIKELY (ve_string_empty (bin) || g_access (bin, X_OK) != 0) {
2140
gdm_error (_("%s: Remote greeter not found or can't be executed by the GDM user"), "gdm_config_parse");
2144
/* Check that chooser can be executed */
2145
bin = ve_first_word (GdmChooser);
2147
if G_UNLIKELY (GdmIndirect && (ve_string_empty (bin) || g_access (bin, X_OK) != 0)) {
2148
gdm_error (_("%s: Chooser not found or it can't be executed by the GDM user"), "gdm_config_parse");
2153
/* Check the serv auth and log dirs */
2154
if G_UNLIKELY (ve_string_empty (GdmServAuthDir)) {
2155
if (GdmConsoleNotify) {
2156
gdm_text_message_dialog
2157
(C_(N_("No daemon/ServAuthDir specified in the GDM configuration file")));
2160
gdm_fail (_("%s: No daemon/ServAuthDir specified."), "gdm_config_parse");
2163
if (ve_string_empty (GdmLogDir)) {
2165
GdmLogDir = g_strdup (GdmServAuthDir);
2168
/* Enter paranoia mode */
2169
check_servauthdir (&statbuf);
2171
NEVER_FAILS_root_set_euid_egid (0, 0);
2173
/* Now set things up for us as */
2174
chown (GdmServAuthDir, 0, GdmGroupId);
2175
g_chmod (GdmServAuthDir, (S_IRWXU|S_IRWXG|S_ISVTX));
2177
NEVER_FAILS_root_set_euid_egid (GdmUserId, GdmGroupId);
2179
/* Again paranoid */
2180
check_servauthdir (&statbuf);
2182
if G_UNLIKELY (statbuf.st_uid != 0 || statbuf.st_gid != GdmGroupId) {
2183
if (GdmConsoleNotify) {
2184
gchar *s = g_strdup_printf (C_(N_("Server Authorization directory "
2185
"(daemon/ServAuthDir) is set to %s "
2186
"but is not owned by user %s and group "
2187
"%s. Please correct the ownership or "
2188
"GDM configuration and restart "
2189
"GDM.")), GdmServAuthDir,
2190
gdm_root_user (), GdmGroup);
2191
gdm_text_message_dialog (s);
2196
gdm_fail (_("%s: Authdir %s is not owned by user %s, group %s. Aborting."),
2197
"gdm_config_parse", GdmServAuthDir, gdm_root_user (), GdmGroup);
2200
if G_UNLIKELY (statbuf.st_mode != (S_IFDIR|S_IRWXU|S_IRWXG|S_ISVTX)) {
2201
if (GdmConsoleNotify) {
2202
gchar *s = g_strdup_printf (C_(N_("Server Authorization directory "
2203
"(daemon/ServAuthDir) is set to %s "
2204
"but has the wrong permissions: it "
2205
"should have permissions of %o. "
2206
"Please correct the permissions or "
2207
"the GDM configuration and "
2208
"restart GDM.")), GdmServAuthDir,
2209
(S_IRWXU|S_IRWXG|S_ISVTX));
2210
gdm_text_message_dialog (s);
2215
gdm_fail (_("%s: Authdir %s has wrong permissions %o. Should be %o. Aborting."), "gdm_config_parse",
2216
GdmServAuthDir, statbuf.st_mode, (S_IRWXU|S_IRWXG|S_ISVTX));
2219
NEVER_FAILS_root_set_euid_egid (0, 0);
2223
/* Check that user authentication is properly configured */
2224
gdm_verify_check ();
2227
ve_config_destroy (custom_cfg);
2228
ve_config_destroy (cfg);
2235
* Access functions for getting the GDM user ID and group ID.
2238
gdm_get_gdmuid (void)
2244
gdm_get_gdmgid (void)
2250
* gdm_get_high_display_num
2251
* gdm_get_high_display_num
2253
* Access functions for getting the high display number.
2256
gdm_get_high_display_num (void)
2258
return high_display_num;
2262
gdm_set_high_display_num (gint val)
2264
high_display_num = val;
2270
* Returns TRUE if the key is a valid key, FALSE otherwise.
2273
gdm_is_valid_key (gchar *key)
2275
GdmConfigType *type = gdm_config_hash_lookup (type_hash, key);
2283
* gdm_signal_terminthup_was_notified
2285
* returns TRUE if signal SIGTERM, SIGINT, or SIGHUP was received.
2286
* This just hides these vicious-extensions functions from the
2290
gdm_signal_terminthup_was_notified (void)
2292
if (ve_signal_was_notified (SIGTERM) ||
2293
ve_signal_was_notified (SIGINT) ||
2294
ve_signal_was_notified (SIGHUP)) {
2304
* is_in_trusted_pic_dir
2305
* get_facefile_from_gnome2_dir_config
2307
* gdm_get_facefile_from_home
2308
* gdm_get_facefile_from_global
2310
* These functions are used for accessing the user's face image from their
2311
* home directory via vicious-extensions.
2314
check_user_file (const char *path,
2324
if (g_access (path, R_OK) != 0)
2327
dir = g_path_get_dirname (path);
2328
file = g_path_get_basename (path);
2330
is_ok = gdm_file_check ("run_pictures",
2335
gdm_get_value_int (GDM_KEY_USER_MAX_FILE),
2336
gdm_get_value_int (GDM_KEY_RELAX_PERM));
2344
check_global_file (const char *path,
2350
if (g_access (path, R_OK) != 0)
2356
/* If path starts with a "trusted" directory, don't sanity check things */
2357
/* This is really somewhat "outdated" as we now really want things in
2358
* the picture dir or in ~/.gnome2/photo */
2360
is_in_trusted_pic_dir (const char *path)
2362
/* our own pixmap dir is trusted */
2363
if (strncmp (path, PIXMAPDIR, sizeof (PIXMAPDIR)) == 0)
2370
get_facefile_from_gnome2_dir_config (const char *homedir,
2373
char *picfile = NULL;
2376
/* Sanity check on ~user/.gnome2/gdm */
2377
cfgdir = g_build_filename (homedir, ".gnome2", "gdm", NULL);
2378
if (G_LIKELY (check_user_file (cfgdir, uid))) {
2382
cfgfile = g_build_filename (homedir, ".gnome2", "gdm", NULL);
2383
cfg = ve_config_new (cfgfile);
2386
picfile = ve_config_get_string (cfg, "face/picture=");
2387
ve_config_destroy (cfg);
2389
/* must exist and be absolute (note that this check
2390
* catches empty strings)*/
2391
/* Note that these days we just set ~/.face */
2392
if G_UNLIKELY (picfile != NULL &&
2393
(picfile[0] != '/' ||
2394
/* this catches readability by user */
2395
g_access (picfile, R_OK) != 0)) {
2400
if (picfile != NULL) {
2402
if (realpath (picfile, buf) == NULL) {
2407
picfile = g_strdup (buf);
2411
if G_UNLIKELY (picfile != NULL) {
2412
if (! is_in_trusted_pic_dir (picfile)) {
2413
/* if not in trusted dir, check it out */
2415
/* Note that strict permissions checking is done
2416
* on this file. Even if it may not even be owned by the
2417
* user. This setting should ONLY point to pics in trusted
2419
if (! check_user_file (picfile, uid)) {
2431
static GHashTable *fstype_hash = NULL;
2432
extern char *filesystem_type (char *path, char *relpath, struct stat *statp);
2435
path_is_local (const char *path)
2437
gpointer local = NULL;
2442
if (fstype_hash == NULL)
2443
fstype_hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
2445
local = g_hash_table_lookup (fstype_hash, path);
2447
if (local == NULL) {
2448
struct stat statbuf;
2450
if (g_stat (path, &statbuf) == 0) {
2451
char *type = filesystem_type ((char *)path, (char *)path, &statbuf);
2452
gboolean is_local = ((strcmp (ve_sure_string (type), "nfs") != 0) &&
2453
(strcmp (ve_sure_string (type), "afs") != 0) &&
2454
(strcmp (ve_sure_string (type), "autofs") != 0) &&
2455
(strcmp (ve_sure_string (type), "unknown") != 0) &&
2456
(strcmp (ve_sure_string (type), "ncpfs") != 0));
2457
local = GINT_TO_POINTER (is_local ? 1 : -1);
2458
g_hash_table_insert (fstype_hash, g_strdup (path), local);
2462
return GPOINTER_TO_INT (local) > 0;
2466
gdm_get_facefile_from_home (const char *homedir,
2469
char *picfile = NULL;
2473
/* special case: look at parent of home to detect autofs
2474
this is so we don't try to trigger an automount */
2475
path = g_path_get_dirname (homedir);
2476
is_local = path_is_local (path);
2479
/* now check that home dir itself is local */
2481
is_local = path_is_local (homedir);
2484
/* Only look at local home directories so we don't try to
2485
read from remote (e.g. NFS) volumes */
2489
picfile = g_build_filename (homedir, ".face", NULL);
2491
if (check_user_file (picfile, uid))
2498
picfile = g_build_filename (homedir, ".face.icon", NULL);
2500
if (check_user_file (picfile, uid))
2507
picfile = get_facefile_from_gnome2_dir_config (homedir, uid);
2508
if (check_user_file (picfile, uid))
2515
/* Nothing found yet, try the old locations */
2517
picfile = g_build_filename (homedir, ".gnome2", "photo", NULL);
2518
if (check_user_file (picfile, uid))
2525
picfile = g_build_filename (homedir, ".gnome", "photo", NULL);
2526
if (check_user_file (picfile, uid))
2537
gdm_get_facefile_from_global (const char *username,
2540
char *picfile = NULL;
2541
char *facedir = gdm_get_value_string (GDM_KEY_GLOBAL_FACE_DIR);
2543
/* Try the global face directory */
2545
picfile = g_build_filename (facedir, username, NULL);
2547
if (check_global_file (picfile, uid))
2551
picfile = gdm_make_filename (facedir, username, ".png");
2553
if (check_global_file (picfile, uid))
2561
* gdm_get_session_exec
2563
* This function accesses the GDM session desktop file, via vicious
2564
* extensions and returns the execution command for starting the
2568
gdm_get_session_exec (const char *session_name, gboolean check_try_exec)
2574
static char *cached = NULL;
2578
if (session_name == NULL) {
2586
if (cached != NULL && strcmp (ve_sure_string (session_name), ve_sure_string (cached)) == 0)
2587
return g_strdup (exec);
2592
cached = g_strdup (session_name);
2594
/* Some ugly special casing for legacy "Default.desktop", oh well,
2595
* we changed to "default.desktop" */
2596
if (g_ascii_strcasecmp (session_name, "default") == 0 ||
2597
g_ascii_strcasecmp (session_name, "default.desktop") == 0) {
2598
full = ve_find_prog_in_path ("default.desktop",
2599
gdm_get_value_string (GDM_KEY_SESSION_DESKTOP_DIR));
2603
file = gdm_ensure_extension (session_name, ".desktop");
2604
full = ve_find_prog_in_path (file,
2605
gdm_get_value_string (GDM_KEY_SESSION_DESKTOP_DIR));
2609
if (ve_string_empty (full) || g_access (full, R_OK) != 0) {
2611
if (gdm_is_session_magic (session_name)) {
2612
exec = g_strdup (session_name);
2613
return g_strdup (exec);
2619
cfg = ve_config_get (full);
2621
if (ve_config_get_bool (cfg, "Desktop Entry/Hidden=false"))
2624
if (check_try_exec) {
2625
tryexec = ve_config_get_string (cfg, "Desktop Entry/TryExec");
2626
if ( ! ve_string_empty (tryexec) &&
2627
! ve_is_prog_in_path (tryexec, gdm_get_value_string (GDM_KEY_PATH)) &&
2628
! ve_is_prog_in_path (tryexec, gdm_saved_getenv ("PATH"))) {
2635
exec = ve_config_get_string (cfg, "Desktop Entry/Exec");
2636
return g_strdup (exec);
2640
* gdm_set_user_session_lang
2641
* gdm_get_user_session_lang
2643
* These functions get and set the user's language and setting in their
2644
* $HOME/.dmrc file via vicious-extensions.
2647
gdm_set_user_session_lang (gboolean savesess, gboolean savelang,
2648
const char *home_dir, const char *save_session, const char *save_language)
2650
VeConfig *dmrc = NULL;
2651
gchar *cfgstr = g_build_filename (home_dir, ".dmrc", NULL);
2654
dmrc = ve_config_new (cfgstr);
2655
ve_config_set_string (dmrc, "Desktop/Session",
2656
ve_sure_string (save_session));
2661
dmrc = ve_config_new (cfgstr);
2662
if (ve_string_empty (save_language))
2663
/* we chose the system default language so wipe the
2665
ve_config_delete_key (dmrc, "Desktop/Language");
2667
ve_config_set_string (dmrc, "Desktop/Language", save_language);
2674
oldmode = umask (077);
2675
ve_config_save (dmrc, FALSE);
2676
ve_config_destroy (dmrc);
2683
gdm_get_user_session_lang (char **usrsess, char **usrlang,
2684
const char *home_dir, gboolean *savesess)
2687
char *cfgfile = g_build_filename (home_dir, ".dmrc", NULL);
2688
VeConfig *cfg = ve_config_new (cfgfile);
2691
*usrsess = ve_config_get_string (cfg, "Desktop/Session");
2692
if (*usrsess == NULL)
2693
*usrsess = g_strdup ("");
2695
/* this is just being truly anal about what users give us, and in case
2696
* it looks like they may have included a path whack it. */
2697
p = strrchr (*usrsess, '/');
2699
char *tmp = g_strdup (p+1);
2704
/* ugly workaround for migration */
2705
if ((strcmp (ve_sure_string (*usrsess), "Default.desktop") == 0 ||
2706
strcmp (ve_sure_string (*usrsess), "Default") == 0) &&
2707
! ve_is_prog_in_path ("Default.desktop",
2708
gdm_get_value_string (GDM_KEY_SESSION_DESKTOP_DIR))) {
2710
*usrsess = g_strdup ("default");
2714
*usrlang = ve_config_get_string (cfg, "Desktop/Language");
2715
if (*usrlang == NULL)
2716
*usrlang = g_strdup ("");
2718
ve_config_destroy (cfg);