1
/* GDM - The GNOME Display Manager
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
3
* GDM - The GNOME Display Manager
2
4
* Copyright (C) 1998, 1999, 2000 Martin K. Petersen <mkp@mkp.net>
4
6
* This program is free software; you can redistribute it and/or modify
16
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
/* This is the gdm slave process. gdmslave runs the chooser, greeter
20
* and the user's session scripts. */
22
21
#include "config.h"
24
24
#include <unistd.h>
27
27
#include <sys/types.h>
28
28
#include <sys/wait.h>
42
#include "gdmconfig.h"
43
42
#include "errorgui.h"
45
/* set in the main function */
46
extern char **stored_argv;
47
extern int stored_argc;
48
extern char *stored_path;
45
#include "gdm-common.h"
47
#include "gdm-daemon-config.h"
49
#include "gdm-socket-protocol.h"
50
51
static int screenx = 0;
51
52
static int screeny = 0;
203
202
gdm_open_dev_null (O_RDWR); /* open stderr - fd 2 */
205
204
if (set_gdm_ids) {
206
setgid (gdm_get_gdmgid ());
207
initgroups (gdm_get_value_string (GDM_KEY_USER), gdm_get_gdmgid ());
208
setuid (gdm_get_gdmuid ());
205
setgid (gdm_daemon_config_get_gdmgid ());
206
initgroups (gdm_daemon_config_get_value_string (GDM_KEY_USER), gdm_daemon_config_get_gdmgid ());
207
setuid (gdm_daemon_config_get_gdmuid ());
211
210
pw = getpwuid (uid);
216
215
/* restore initial environment */
217
216
gdm_restoreenv ();
219
openlog ("gdm", LOG_PID, LOG_DAEMON);
221
g_setenv ("LOGNAME", gdm_get_value_string (GDM_KEY_USER), TRUE);
222
g_setenv ("USER", gdm_get_value_string (GDM_KEY_USER), TRUE);
223
g_setenv ("USERNAME", gdm_get_value_string (GDM_KEY_USER), TRUE);
220
g_setenv ("LOGNAME", gdm_daemon_config_get_value_string (GDM_KEY_USER), TRUE);
221
g_setenv ("USER", gdm_daemon_config_get_value_string (GDM_KEY_USER), TRUE);
222
g_setenv ("USERNAME", gdm_daemon_config_get_value_string (GDM_KEY_USER), TRUE);
225
224
g_setenv ("DISPLAY", d->name, TRUE);
226
225
g_unsetenv ("XAUTHORITY");
228
gdm_auth_set_local_auth (d);
227
g_setenv ("XAUTHORITY", GDM_AUTHFILE (d), TRUE);
230
229
/* sanity env stuff */
231
230
g_setenv ("SHELL", "/bin/sh", TRUE);
232
231
/* set HOME to /, we don't need no stinking HOME anyway */
233
232
if (pw == NULL ||
234
233
ve_string_empty (pw->pw_dir))
235
g_setenv ("HOME", ve_sure_string (gdm_get_value_string (GDM_KEY_SERV_AUTHDIR)), TRUE);
234
g_setenv ("HOME", ve_sure_string (gdm_daemon_config_get_value_string (GDM_KEY_SERV_AUTHDIR)), TRUE);
237
236
g_setenv ("HOME", pw->pw_dir, TRUE);
243
242
if ( ! inhibit_gtk_modules &&
244
gdm_get_value_bool (GDM_KEY_ADD_GTK_MODULES) &&
245
! ve_string_empty (gdm_get_value_string (GDM_KEY_GTK_MODULES_LIST))) {
246
argv[1] = g_strdup_printf ("--gtk-module=%s", gdm_get_value_string (GDM_KEY_GTK_MODULES_LIST));
243
gdm_daemon_config_get_value_bool (GDM_KEY_ADD_GTK_MODULES) &&
244
! ve_string_empty (gdm_daemon_config_get_value_string (GDM_KEY_GTK_MODULES_LIST))) {
245
argv[1] = g_strdup_printf ("--gtk-module=%s", gdm_daemon_config_get_value_string (GDM_KEY_GTK_MODULES_LIST));
256
255
if ( ! inhibit_gtk_themes) {
257
256
const char *theme_name;
258
gchar *gtkrc = gdm_get_value_string (GDM_KEY_GTKRC);
257
const gchar *gtkrc = gdm_daemon_config_get_value_string (GDM_KEY_GTKRC);
260
259
if ( ! ve_string_empty (gtkrc) &&
261
260
g_access (gtkrc, R_OK) == 0)
264
263
theme_name = d->theme_name;
265
264
if (ve_string_empty (theme_name))
266
theme_name = gdm_get_value_string (GDM_KEY_GTK_THEME);
265
theme_name = gdm_daemon_config_get_value_string (GDM_KEY_GTK_THEME);
267
266
if ( ! ve_string_empty (theme_name)) {
268
267
gchar *theme_dir = gtk_rc_get_theme_dir ();
269
268
char *theme = g_strdup_printf ("%s/%s/gtk-2.0/gtkrc", theme_dir, theme_name);
303
gdm_error_box_full (GdmDisplay *d, GtkMessageType type, const char *error,
304
const char *details_label, const char *details_file,
305
uid_t uid, gid_t gid)
302
gdm_errorgui_error_box_full (GdmDisplay *d,
305
const char *details_label,
306
const char *details_file,
307
310
GdkDisplay *gdk_display;
313
gdm_debug ("Forking extra process: error dialog");
310
315
pid = gdm_fork_extra ();
324
if (details_label != NULL) {
325
if (strncmp (details_label, "NIL", 3) == 0)
326
details_label = NULL;
328
if (details_file != NULL) {
329
if (strncmp (details_file, "NIL", 3) == 0)
320
334
gid_t groups[1] = { gid };
345
359
if (S_ISREG (s.st_mode)) {
346
360
VE_IGNORE_EINTR (fp = fopen (details_file, "r"));
348
loc = gdm_locale_to_utf8 (_("%s not a regular file!\n"));
362
loc = g_locale_to_utf8 (_("%s not a regular file!\n"), -1, NULL, NULL, NULL);
349
363
g_string_printf (gs, loc, details_file);
362
376
/* cap the lines at 500, that's already
363
377
a possibility of 128k of data */
364
378
if (lines++ > 500) {
365
loc = gdm_locale_to_utf8 (_("\n... File too long to display ...\n"));
379
loc = g_locale_to_utf8 (_("\n... File too long to display ...\n"), -1, NULL, NULL, NULL);
366
380
g_string_append (gs, loc);
372
386
VE_IGNORE_EINTR (fclose (fp));
374
loc = gdm_locale_to_utf8 (_("%s could not be opened"));
388
loc = g_locale_to_utf8 (_("%s could not be opened"), -1, NULL, NULL, NULL);
375
389
g_string_append_printf (gs, loc, details_file);
379
393
details = g_string_free (gs, FALSE);
381
395
if ( ! valid_utf8) {
382
char *tmp = gdm_locale_to_utf8 (details);
396
char *tmp = g_locale_to_utf8 (details, -1, NULL, NULL, NULL);
383
397
g_free (details);
390
404
setup_dialog (d, "gtk-error-box", -1, TRUE, uid);
392
loc = gdm_locale_to_utf8 (error);
406
loc = g_locale_to_utf8 (error, -1, NULL, NULL, NULL);
394
408
dlg = gtk_message_dialog_new (NULL /* parent */,
404
418
if (details_label != NULL) {
405
419
GtkWidget *text = get_error_text_view (details);
407
loc = gdm_locale_to_utf8 (details_label);
421
loc = g_locale_to_utf8 (details_label, -1, NULL, NULL, NULL);
408
422
button = gtk_check_button_new_with_label (loc);
466
480
} else if (pid > 0) {
468
gdm_wait_for_extra (&status);
482
gdm_wait_for_extra (pid, &status);
470
484
if (dialog_failed (status)) {
471
485
if ( ! inhibit_gtk_themes) {
472
486
/* on failure try again, this time without any themes
473
487
which may be causing a crash */
474
488
inhibit_gtk_themes = TRUE;
475
gdm_error_box_full (d, type, error, details_label, details_file, uid, gid);
489
gdm_errorgui_error_box_full (d, type, error, details_label, details_file, uid, gid);
476
490
inhibit_gtk_themes = FALSE;
477
491
} else if ( ! inhibit_gtk_modules) {
478
492
/* on failure try again, this time without any modules
479
493
which may be causing a crash */
480
494
inhibit_gtk_modules = TRUE;
481
gdm_error_box_full (d, type, error, details_label, details_file, uid, gid);
495
gdm_errorgui_error_box_full (d, type, error, details_label, details_file, uid, gid);
482
496
inhibit_gtk_modules = FALSE;
486
500
gdm_error (_("%s: Cannot fork to display error/info box"),
501
"gdm_errorgui_error_box");
499
gdm_error_box (GdmDisplay *d, GtkMessageType type, const char *error)
513
gdm_errorgui_error_box (GdmDisplay *d, GtkMessageType type, const char *error)
501
gdm_error_box_full (d, type, error, NULL, NULL,
502
/* zero for uid/gid doesn't mean root, but
503
it means to use the gdm user/group */
518
msg = g_strdup_printf ("type=%d$$error=%s$$details_label=%s$$details_file=%s$$uid=%d$$gid=%d", type, error, "NIL", "NIL", id, id);
520
gdm_slave_send_string (GDM_SOP_SHOW_ERROR_DIALOG, msg);
508
gdm_failsafe_question (GdmDisplay *d,
509
const char *question,
526
gdm_errorgui_failsafe_question (GdmDisplay *d,
527
const char *question,
512
530
GdkDisplay *gdk_display;
525
545
setup_dialog (d, "gtk-failsafe-question", p[1], TRUE /* set_gdm_ids */, 0);
527
loc = gdm_locale_to_utf8 (question);
547
loc = g_locale_to_utf8 (question, -1, NULL, NULL, NULL);
529
549
dlg = gtk_dialog_new_with_buttons (loc,
530
550
NULL /* parent */,
582
602
gtk_dialog_run (GTK_DIALOG (dlg));
584
loc = gdm_locale_from_utf8 (ve_sure_string (gtk_entry_get_text (GTK_ENTRY (entry))));
604
loc = g_locale_from_utf8 (ve_sure_string (gtk_entry_get_text (GTK_ENTRY (entry))), -1, NULL, NULL, NULL);
586
606
gdm_fdprintf (p[1], "%s", ve_sure_string (loc));
599
619
VE_IGNORE_EINTR (close (p[1]));
601
gdm_wait_for_extra (&status);
621
gdm_wait_for_extra (pid, &status);
603
623
if (dialog_failed (status)) {
604
624
char *ret = NULL;
607
627
/* on failure try again, this time without any themes
608
628
which may be causing a crash */
609
629
inhibit_gtk_themes = TRUE;
610
ret = gdm_failsafe_question (d, question, echo);
630
ret = gdm_errorgui_failsafe_question (d, question, echo);
611
631
inhibit_gtk_themes = FALSE;
612
632
} else if ( ! inhibit_gtk_modules) {
613
633
/* on failure try again, this time without any modules
614
634
which may be causing a crash */
615
635
inhibit_gtk_modules = TRUE;
616
ret = gdm_failsafe_question (d, question, echo);
636
ret = gdm_errorgui_failsafe_question (d, question, echo);
617
637
inhibit_gtk_modules = FALSE;
628
648
VE_IGNORE_EINTR (close (p[0]));
630
650
gdm_error (_("%s: Cannot fork to display error/info box"),
631
"gdm_failsafe_question");
651
"gdm_errorgui_failsafe_question");
637
gdm_failsafe_yesno (GdmDisplay *d,
638
const char *question)
657
gdm_errorgui_failsafe_yesno (GdmDisplay *d,
658
const char *question)
640
660
GdkDisplay *gdk_display;
653
675
setup_dialog (d, "gtk-failsafe-yesno", p[1], TRUE /* set_gdm_ids */, 0);
655
loc = gdm_locale_to_utf8 (question);
677
loc = g_locale_to_utf8 (question, -1, NULL, NULL, NULL);
657
679
dlg = gtk_message_dialog_new (NULL /* parent */,
708
730
VE_IGNORE_EINTR (close (p[1]));
710
gdm_wait_for_extra (&status);
732
gdm_wait_for_extra (pid, &status);
712
734
if (dialog_failed (status)) {
713
735
gboolean ret = FALSE;
716
738
/* on failure try again, this time without any themes
717
739
which may be causing a crash */
718
740
inhibit_gtk_themes = TRUE;
719
ret = gdm_failsafe_yesno (d, question);
741
ret = gdm_errorgui_failsafe_yesno (d, question);
720
742
inhibit_gtk_themes = FALSE;
721
743
} else if ( ! inhibit_gtk_modules) {
722
744
/* on failure try again, this time without any modules
723
745
which may be causing a crash */
724
746
inhibit_gtk_modules = TRUE;
725
ret = gdm_failsafe_yesno (d, question);
747
ret = gdm_errorgui_failsafe_yesno (d, question);
726
748
inhibit_gtk_modules = FALSE;
739
761
VE_IGNORE_EINTR (close (p[0]));
741
763
gdm_error (_("%s: Cannot fork to display error/info box"),
742
"gdm_failsafe_yesno");
764
"gdm_errorgui_failsafe_yesno");
748
gdm_failsafe_ask_buttons (GdmDisplay *d,
749
const char *question,
770
gdm_errorgui_failsafe_ask_buttons (GdmDisplay *d,
771
const char *question,
752
774
GdkDisplay *gdk_display;
766
790
setup_dialog (d, "gtk-failsafe-ask-buttons", p[1], TRUE /* set_gdm_ids */, 0);
768
loc = gdm_locale_to_utf8 (question);
792
loc = g_locale_to_utf8 (question, -1, NULL, NULL, NULL);
770
794
dlg = gtk_message_dialog_new (NULL /* parent */,
777
801
gtk_widget_set_events (dlg, GDK_ALL_EVENTS_MASK);
778
for (i = 0; but[i] != NULL; i++) {
779
loc = gdm_locale_to_utf8 (but[i]);
802
for (i = 0; but[i] != NULL && strcmp (but[i], "NIL"); i++) {
803
loc = g_locale_to_utf8 (but[i], -1, NULL, NULL, NULL);
780
804
gtk_dialog_add_button (GTK_DIALOG (dlg),
827
851
VE_IGNORE_EINTR (close (p[1]));
829
gdm_wait_for_extra (&status);
853
gdm_wait_for_extra (pid, &status);
831
855
if (dialog_failed (status)) {
835
859
/* on failure try again, this time without any themes
836
860
which may be causing a crash */
837
861
inhibit_gtk_themes = TRUE;
838
ret = gdm_failsafe_ask_buttons (d, question, but);
862
ret = gdm_errorgui_failsafe_ask_buttons (d, question, but);
839
863
inhibit_gtk_themes = FALSE;
840
864
} else if ( ! inhibit_gtk_modules) {
841
865
/* on failure try again, this time without any modules
842
866
which may be causing a crash */
843
867
inhibit_gtk_modules = TRUE;
844
ret = gdm_failsafe_ask_buttons (d, question, but);
868
ret = gdm_errorgui_failsafe_ask_buttons (d, question, but);
845
869
inhibit_gtk_modules = FALSE;
860
884
VE_IGNORE_EINTR (close (p[0]));
862
886
gdm_error (_("%s: Cannot fork to display error/info box"),
863
"gdm_failsafe_ask_buttons");
887
"gdm_errorgui_failsafe_ask_buttons");