Commit ce169514 authored by Jiri (George) Lebl's avatar Jiri (George) Lebl Committed by George Lebl

Fix some typos pointed out by Ali Akcaagac <aliakc@web.de>

Wed Jun 25 15:38:29 2003  George Lebl <jirka@5z.com>

	* configure.in, config/gdm.conf.in: Fix some typos pointed out by Ali
	  Akcaagac <aliakc@web.de>

	* daemon/errorgui.[ch]: fix a bug with yes/no dialog return and add
	  several button dialog type.  run the dialogs with gdm privilages
	  and not root.  All except the full error with details file.

	* daemon/display.c: turn some info's back into debugs

	* daemon/getvt.[ch], daemon/gdm.c: push the vt changing stuff into
	  getvt, though it's still a hack

	* daemon/slave.c, daemon/gdm.[ch], config/gdm.conf.in,
	  daemon/verify-*.c: add a double login warning question.  This asks
	  if the user still wants to log in.  If on console and there is
	  another login on a console the user can return to a previous login.
	  Can be turned off by daemon/DoubleLoginWarning=false.  For this
	  we needed notify ack response and a QUERYLOGIN SOP protocol entry.

	* daemon/slave.c: set DESKTOP_SESSION as well as GDMSESSION

	* daemon/verify-pam.c: don't refer to the /etc/pam.d/ dir since
	  that's linux-pam specific
parent 9024b702
Wed Jun 25 15:38:29 2003 George Lebl <jirka@5z.com>
* configure.in, config/gdm.conf.in: Fix some typos pointed out by Ali
Akcaagac <aliakc@web.de>
* daemon/errorgui.[ch]: fix a bug with yes/no dialog return and add
several button dialog type. run the dialogs with gdm privilages
and not root. All except the full error with details file.
* daemon/display.c: turn some info's back into debugs
* daemon/getvt.[ch], daemon/gdm.c: push the vt changing stuff into
getvt, though it's still a hack
* daemon/slave.c, daemon/gdm.[ch], config/gdm.conf.in,
daemon/verify-*.c: add a double login warning question. This asks
if the user still wants to log in. If on console and there is
another login on a console the user can return to a previous login.
Can be turned off by daemon/DoubleLoginWarning=false. For this
we needed notify ack response and a QUERYLOGIN SOP protocol entry.
* daemon/slave.c: set DESKTOP_SESSION as well as GDMSESSION
* daemon/verify-pam.c: don't refer to the /etc/pam.d/ dir since
that's linux-pam specific
2003-06-16 Frederic Crozat <fcrozat@mandrakesoft.com>
* gui/greeter/greeter_session.c: (greeter_session_init):
......
......@@ -53,7 +53,7 @@ RemoteGreeter=@EXPANDED_BINDIR@/gdmlogin
# be allowed to minimise security holes
AddGtkModules=false
# By default these are the accessibility modules
GtkModulesList=gail:at-bridge:dwellmouselistener:keymouselistener
GtkModulesList=gail:atk-bridge:dwellmouselistener:keymouselistener
# User and group that gdm should run as. Probably should be gdm and gdm and
# you should create these user and group. Anyone found running this as
# someone too privilaged will get a kick in the ass. This should have
......@@ -111,6 +111,9 @@ Xnest=@X_SERVER_PATH@/Xnest -name Xnest
# is causing problems.
FirstVT=7
VTAllocation=true
# Should double login be treated with a warning (and possibility to change
# vts on linux systems for console logins)
DoubleLoginWarning=true
[security]
# If any distributions ship with this one off, they should be shot
......
......@@ -474,7 +474,7 @@ if test -x /usr/X11R6/bin/X; then
X_PATH="/usr/bin/X11:/usr/X11R6/bin:/opt/X11R6/bin"
X_SERVER_PATH="/usr/X11R6/bin"
X_SERVER="/usr/X11R6/bin/X"
X_CONF_PATH="/usr/bin/X11:usr/X11R6/bin:/usr/local/bin"
X_CONF_PATH="/usr/bin/X11:/usr/X11R6/bin:/usr/local/bin"
elif test -x /usr/openwin/bin/Xsun; then
X_PATH="/usr/openwin/bin"
X_SERVER_PATH="/usr/openwin/bin"
......@@ -486,7 +486,7 @@ else
X_PATH="/usr/bin/X11:/usr/X11R6/bin:/opt/X11R6/bin"
X_SERVER_PATH="/usr/X11R6/bin"
X_SERVER="/usr/X11R6/bin/X"
X_CONF_PATH="/usr/bin/X11:usr/X11R6/bin:/usr/local/bin"
X_CONF_PATH="/usr/bin/X11:/usr/X11R6/bin:/usr/local/bin"
fi
AC_SUBST(X_PATH)
AC_SUBST(X_SERVER)
......
......@@ -59,7 +59,7 @@ gdm_display_check_loop (GdmDisplay *disp)
if (disp->disabled)
return FALSE;
gdm_info ("loop check: last_start %ld, last_loop %ld, now: %ld, retry_count: %d", (long)disp->last_start_time, (long) disp->last_loop_start_time, (long) now, disp->retry_count);
gdm_debug ("loop check: last_start %ld, last_loop %ld, now: %ld, retry_count: %d", (long)disp->last_start_time, (long) disp->last_loop_start_time, (long) now, disp->retry_count);
if (disp->last_loop_start_time > now || disp->last_loop_start_time == 0)
{
......@@ -70,7 +70,7 @@ gdm_display_check_loop (GdmDisplay *disp)
disp->last_start_time = now;
disp->retry_count = 1;
gdm_info ("Resetting counts for loop of death detection");
gdm_debug ("Resetting counts for loop of death detection");
return TRUE;
}
......@@ -89,7 +89,7 @@ gdm_display_check_loop (GdmDisplay *disp)
disp->last_start_time = now;
disp->retry_count = 1;
gdm_info ("Resetting counts for loop of death detection, 90 seconds elapsed since loop started or session lasted more then 30 seconds.");
gdm_debug ("Resetting counts for loop of death detection, 90 seconds elapsed since loop started or session lasted more then 30 seconds.");
return TRUE;
}
......@@ -141,7 +141,7 @@ gdm_display_check_loop (GdmDisplay *disp)
*/
if (disp->retry_count > 2 && since_last < 8)
{
gdm_info ("Will sleep %ld seconds before next X server restart attempt",
gdm_debug ("Will sleep %ld seconds before next X server restart attempt",
(long)(8 - since_last));
now = time (NULL) + 8 - since_last;
disp->sleep_before_run = 8 - since_last;
......
......@@ -25,6 +25,7 @@
#include <gdk/gdkx.h>
#include <unistd.h>
#include <syslog.h>
#include <grp.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <fcntl.h>
......@@ -40,6 +41,11 @@ extern char **stored_argv;
extern int stored_argc;
extern char *stored_path;
/* Configuration option variables */
extern gchar *GdmUser;
extern uid_t GdmUserId;
extern gid_t GdmGroupId;
static int screenx = 0;
static int screeny = 0;
static int screenwidth = 0;
......@@ -189,6 +195,15 @@ gdm_error_box_full (GdmDisplay *d, GtkMessageType type, const char *error,
gdm_open_dev_null (O_RDWR); /* open stdout - fd 1 */
gdm_open_dev_null (O_RDWR); /* open stderr - fd 2 */
/* because details_file may not be readable, we must run as root */
/* FIXME: we should read in the details file here so that we don't
have to touch the disk again */
if (details_file == NULL) {
setgid (GdmGroupId);
initgroups (GdmUser, GdmGroupId);
setuid (GdmUserId);
}
gdm_desetuid ();
display = g_strdup (g_getenv ("DISPLAY"));
......@@ -330,6 +345,10 @@ gdm_failsafe_question (GdmDisplay *d,
gdm_open_dev_null (O_RDWR); /* open stdout - fd 1 */
gdm_open_dev_null (O_RDWR); /* open stderr - fd 2 */
setgid (GdmGroupId);
initgroups (GdmUser, GdmGroupId);
setuid (GdmUserId);
gdm_desetuid ();
display = g_strdup (g_getenv ("DISPLAY"));
......@@ -471,6 +490,10 @@ gdm_failsafe_yesno (GdmDisplay *d,
gdm_open_dev_null (O_RDWR); /* open stdout - fd 1 */
gdm_open_dev_null (O_RDWR); /* open stderr - fd 2 */
setgid (GdmGroupId);
initgroups (GdmUser, GdmGroupId);
setuid (GdmUserId);
gdm_desetuid ();
display = g_strdup (g_getenv ("DISPLAY"));
......@@ -531,9 +554,9 @@ gdm_failsafe_yesno (GdmDisplay *d,
setup_cursor (GDK_LEFT_PTR);
if (gtk_dialog_run (GTK_DIALOG (dlg)) == GTK_RESPONSE_YES)
gdm_fdprintf (STDOUT_FILENO, "yes\n");
gdm_fdprintf (p[1], "yes\n");
else
gdm_fdprintf (STDOUT_FILENO, "no\n");
gdm_fdprintf (p[1], "no\n");
XSetInputFocus (GDK_DISPLAY (),
PointerRoot,
......@@ -560,9 +583,147 @@ gdm_failsafe_yesno (GdmDisplay *d,
close (p[0]);
} else {
gdm_error (_("%s: Cannot fork to display error/info box"),
"gdm_failsafe_question");
"gdm_failsafe_yesno");
}
return FALSE;
}
int
gdm_failsafe_ask_buttons (GdmDisplay *d,
const char *question,
char **but)
{
pid_t pid;
int p[2];
if (pipe (p) < 0)
return -1;
pid = gdm_fork_extra ();
if (pid == 0) {
int i;
guint sid;
int argc = 1;
char **argv;
GtkWidget *dlg;
char *loc;
char *display;
char *xauthority;
closelog ();
gdm_close_all_descriptors (0 /* from */, p[1] /* except */);
/* No error checking here - if it's messed the best response
* is to ignore & try to continue */
gdm_open_dev_null (O_RDONLY); /* open stdin - fd 0 */
gdm_open_dev_null (O_RDWR); /* open stdout - fd 1 */
gdm_open_dev_null (O_RDWR); /* open stderr - fd 2 */
setgid (GdmGroupId);
initgroups (GdmUser, GdmGroupId);
setuid (GdmUserId);
gdm_desetuid ();
display = g_strdup (g_getenv ("DISPLAY"));
xauthority = g_strdup (g_getenv ("XAUTHORITY"));
/* restore initial environment */
gdm_restoreenv ();
if (display != NULL)
gnome_setenv ("DISPLAY", display, TRUE);
if (xauthority != NULL)
gnome_setenv ("XAUTHORITY", xauthority, TRUE);
/* sanity env stuff */
gnome_setenv ("SHELL", "/bin/bash", TRUE);
gnome_setenv ("HOME", "/", TRUE);
openlog ("gdm", LOG_PID, LOG_DAEMON);
argv = g_new0 (char *, 2);
argv[0] = "gtk-failsafe-ask-buttons";
gtk_init (&argc, &argv);
get_screen_size (d);
loc = gdm_locale_to_utf8 (question);
dlg = gtk_message_dialog_new (NULL /* parent */,
0 /* flags */,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_NONE,
"%s",
loc);
g_free (loc);
for (i = 0; but[i] != NULL; i++) {
loc = gdm_locale_to_utf8 (but[i]);
gtk_dialog_add_button (GTK_DIALOG (dlg),
loc, i);
g_free (loc);
}
gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
sid = g_signal_lookup ("event",
GTK_TYPE_WIDGET);
g_signal_add_emission_hook (sid,
0 /* detail */,
gdm_event,
NULL /* data */,
NULL /* destroy_notify */);
center_window (dlg);
gtk_widget_show_now (dlg);
if (dlg->window != NULL) {
gdk_error_trap_push ();
XSetInputFocus (GDK_DISPLAY (),
GDK_WINDOW_XWINDOW (dlg->window),
RevertToPointerRoot,
CurrentTime);
gdk_flush ();
gdk_error_trap_pop ();
}
setup_cursor (GDK_LEFT_PTR);
i = gtk_dialog_run (GTK_DIALOG (dlg));
gdm_fdprintf (p[1], "%d\n", i);
XSetInputFocus (GDK_DISPLAY (),
PointerRoot,
RevertToPointerRoot,
CurrentTime);
_exit (0);
} else if (pid > 0) {
char buf[BUFSIZ];
int bytes;
close (p[1]);
gdm_wait_for_extra (NULL);
bytes = read (p[0], buf, BUFSIZ-1);
if (bytes > 0) {
int i;
close (p[0]);
buf[bytes] = '\0';
if (sscanf (buf, "%d", &i) == 1)
return i;
else
return -1;
}
close (p[0]);
} else {
gdm_error (_("%s: Cannot fork to display error/info box"),
"gdm_failsafe_ask_buttons");
}
return -1;
}
/* EOF */
......@@ -38,6 +38,9 @@ char * gdm_failsafe_question (GdmDisplay *d,
gboolean gdm_failsafe_yesno (GdmDisplay *d,
const char *question);
int gdm_failsafe_ask_buttons (GdmDisplay *d,
const char *question,
char **but);
#endif /* GDM_ERRORGUI_H */
......
......@@ -50,6 +50,7 @@
#include "verify.h"
#include "display.h"
#include "choose.h"
#include "getvt.h"
#include "gdm-net.h"
/* Local functions */
......@@ -117,6 +118,7 @@ gboolean GdmSystemMenu = FALSE;
gboolean GdmChooserButton = FALSE;
gboolean GdmBrowser = FALSE;
gboolean GdmAddGtkModules = FALSE;
gboolean GdmDoubleLoginWarning = TRUE;
gchar *GdmGlobalFaceDir = NULL;
gint GdmXineramaScreen = 0;
gchar *GdmGreeter = NULL;
......@@ -250,6 +252,7 @@ gdm_config_parse (void)
GdmGreeter = gnome_config_get_string (GDM_KEY_GREETER);
GdmRemoteGreeter = gnome_config_get_string (GDM_KEY_REMOTEGREETER);
GdmAddGtkModules = gnome_config_get_bool (GDM_KEY_ADD_GTK_MODULES);
GdmDoubleLoginWarning = gnome_config_get_bool (GDM_KEY_DOUBLELOGINWARNING);
GdmGtkModulesList = gnome_config_get_string (GDM_KEY_GTK_MODULES_LIST);
GdmGroup = gnome_config_get_string (GDM_KEY_GROUP);
GdmHalt = gnome_config_get_string (GDM_KEY_HALT);
......@@ -1037,13 +1040,7 @@ suspend_machine (void)
static void
change_to_first_and_clear (gboolean reboot)
{
/* kind of hack, we could do it ourselves if we weren't lazy */
if (access ("/usr/bin/chvt", X_OK) == 0)
system ("/usr/bin/chvt 1");
else if (access ("/bin/chvt", X_OK) == 0)
system ("/bin/chvt 1");
else
return;
gdm_change_vt (1);
close (1);
close (2);
open ("/dev/tty1", O_WRONLY);
......@@ -1778,13 +1775,21 @@ write_x_servers (GdmDisplay *d)
}
static void
send_slave_ack (GdmDisplay *d)
send_slave_ack (GdmDisplay *d, const char *resp)
{
if (d->master_notify_fd >= 0) {
char not[2];
not[0] = GDM_SLAVE_NOTIFY_ACK;
not[1] = '\n';
write (d->master_notify_fd, not, 2);
if (resp == NULL) {
char not[2];
not[0] = GDM_SLAVE_NOTIFY_ACK;
not[1] = '\n';
write (d->master_notify_fd, not, 2);
} else {
char *not = g_strdup_printf ("%c%s\n",
GDM_SLAVE_NOTIFY_ACK,
resp);
write (d->master_notify_fd, not, strlen (not));
g_free (not);
}
}
gdm_sigchld_block_push ();
if (d->slavepid > 1) {
......@@ -1859,7 +1864,7 @@ gdm_handle_message (GdmConnection *conn, const char *msg, gpointer data)
d->chosen_hostname = g_strdup (p);
gdm_debug ("Got CHOSEN_LOCAL == %s", p);
/* send ack */
send_slave_ack (d);
send_slave_ack (d, NULL);
}
} else if (strncmp (msg, GDM_SOP_XPID " ",
strlen (GDM_SOP_XPID " ")) == 0) {
......@@ -1877,7 +1882,7 @@ gdm_handle_message (GdmConnection *conn, const char *msg, gpointer data)
d->servpid = pid;
gdm_debug ("Got XPID == %ld", (long)pid);
/* send ack */
send_slave_ack (d);
send_slave_ack (d, NULL);
}
} else if (strncmp (msg, GDM_SOP_SESSPID " ",
strlen (GDM_SOP_SESSPID " ")) == 0) {
......@@ -1895,7 +1900,7 @@ gdm_handle_message (GdmConnection *conn, const char *msg, gpointer data)
d->sesspid = pid;
gdm_debug ("Got SESSPID == %ld", (long)pid);
/* send ack */
send_slave_ack (d);
send_slave_ack (d, NULL);
}
} else if (strncmp (msg, GDM_SOP_GREETPID " ",
strlen (GDM_SOP_GREETPID " ")) == 0) {
......@@ -1913,7 +1918,7 @@ gdm_handle_message (GdmConnection *conn, const char *msg, gpointer data)
d->greetpid = pid;
gdm_debug ("Got GREETPID == %ld", (long)pid);
/* send ack */
send_slave_ack (d);
send_slave_ack (d, NULL);
}
} else if (strncmp (msg, GDM_SOP_CHOOSERPID " ",
strlen (GDM_SOP_CHOOSERPID " ")) == 0) {
......@@ -1931,7 +1936,7 @@ gdm_handle_message (GdmConnection *conn, const char *msg, gpointer data)
d->chooserpid = pid;
gdm_debug ("Got CHOOSERPID == %ld", (long)pid);
/* send ack */
send_slave_ack (d);
send_slave_ack (d, NULL);
}
} else if (strncmp (msg, GDM_SOP_LOGGED_IN " ",
strlen (GDM_SOP_LOGGED_IN " ")) == 0) {
......@@ -1957,7 +1962,7 @@ gdm_handle_message (GdmConnection *conn, const char *msg, gpointer data)
gdm_safe_restart ();
/* send ack */
send_slave_ack (d);
send_slave_ack (d, NULL);
}
} else if (strncmp (msg, GDM_SOP_DISP_NUM " ",
strlen (GDM_SOP_DISP_NUM " ")) == 0) {
......@@ -1978,7 +1983,7 @@ gdm_handle_message (GdmConnection *conn, const char *msg, gpointer data)
d->dispnum = disp_num;
gdm_debug ("Got DISP_NUM == %d", disp_num);
/* send ack */
send_slave_ack (d);
send_slave_ack (d, NULL);
}
} else if (strncmp (msg, GDM_SOP_VT_NUM " ",
strlen (GDM_SOP_VT_NUM " ")) == 0) {
......@@ -1997,7 +2002,7 @@ gdm_handle_message (GdmConnection *conn, const char *msg, gpointer data)
d->vt = vt_num;
gdm_debug ("Got VT_NUM == %d", vt_num);
/* send ack */
send_slave_ack (d);
send_slave_ack (d, NULL);
}
} else if (strncmp (msg, GDM_SOP_LOGIN " ",
strlen (GDM_SOP_LOGIN " ")) == 0) {
......@@ -2024,7 +2029,53 @@ gdm_handle_message (GdmConnection *conn, const char *msg, gpointer data)
d->login = g_strdup (p);
gdm_debug ("Got LOGIN == %s", p);
/* send ack */
send_slave_ack (d);
send_slave_ack (d, NULL);
}
} else if (strncmp (msg, GDM_SOP_QUERYLOGIN " ",
strlen (GDM_SOP_QUERYLOGIN " ")) == 0) {
GdmDisplay *d;
long slave_pid;
char *p;
if (sscanf (msg, GDM_SOP_QUERYLOGIN " %ld",
&slave_pid) != 1)
return;
p = strchr (msg, ' ');
if (p != NULL)
p = strchr (p+1, ' ');
if (p == NULL)
return;
p++;
/* Find out who this slave belongs to */
d = gdm_display_lookup (slave_pid);
if (d != NULL) {
GString *resp = NULL;
GSList *li;
gdm_debug ("Got QUERYLOGIN %s", p);
for (li = displays; li != NULL; li = li->next) {
GdmDisplay *di = li->data;
if (di->login != NULL &&
strcmp (di->login, p) == 0) {
if (resp == NULL) {
resp = g_string_new (di->name);
g_string_append_printf (resp, ",%d", di->vt);
} else {
g_string_append_printf (resp, ",%s,%d",
di->name, di->vt);
}
}
}
/* send ack */
if (resp != NULL) {
send_slave_ack (d, resp->str);
g_string_free (resp, TRUE);
} else {
send_slave_ack (d, NULL);
}
}
} else if (strncmp (msg, GDM_SOP_COOKIE " ",
strlen (GDM_SOP_COOKIE " ")) == 0) {
......@@ -2051,7 +2102,7 @@ gdm_handle_message (GdmConnection *conn, const char *msg, gpointer data)
d->cookie = g_strdup (p);
gdm_debug ("Got COOKIE == <secret>");
/* send ack */
send_slave_ack (d);
send_slave_ack (d, NULL);
}
} else if (strncmp (msg, GDM_SOP_FLEXI_ERR " ",
strlen (GDM_SOP_FLEXI_ERR " ")) == 0) {
......@@ -2088,7 +2139,7 @@ gdm_handle_message (GdmConnection *conn, const char *msg, gpointer data)
gdm_debug ("Got FLEXI_ERR == %d", err);
/* send ack */
send_slave_ack (d);
send_slave_ack (d, NULL);
}
} else if (strncmp (msg, GDM_SOP_FLEXI_OK " ",
strlen (GDM_SOP_FLEXI_OK " ")) == 0) {
......@@ -2118,7 +2169,7 @@ gdm_handle_message (GdmConnection *conn, const char *msg, gpointer data)
gdm_debug ("Got FLEXI_OK");
/* send ack */
send_slave_ack (d);
send_slave_ack (d, NULL);
}
} else if (strcmp (msg, GDM_SOP_SOFT_RESTART) == 0) {
gdm_restart_mode = TRUE;
......@@ -2187,7 +2238,7 @@ gdm_handle_message (GdmConnection *conn, const char *msg, gpointer data)
write_x_servers (d);
/* send ack */
send_slave_ack (d);
send_slave_ack (d, NULL);
}
} else if (strcmp (msg, GDM_SOP_SUSPEND_MACHINE) == 0) {
gdm_info (_("Master suspending..."));
......@@ -2939,6 +2990,20 @@ gdm_handle_user_message (GdmConnection *conn, const char *msg, gpointer data)
}
}
gdm_connection_write (conn, "\n");
} else if (strcmp (msg, GDM_SUP_ALL_SERVERS) == 0) {
GSList *li;
const char *sep = " ";
gdm_connection_write (conn, "OK");
for (li = displays; li != NULL; li = li->next) {
GdmDisplay *disp = li->data;
gdm_connection_printf (conn,
"%s%s,%s",
sep,
ve_sure_string (disp->name),
ve_sure_string (disp->login));
sep = ";";
}
gdm_connection_write (conn, "\n");
} else if (strcmp (msg, GDM_SUP_GREETERPIDS) == 0) {
GSList *li;
const char *sep = " ";
......
......@@ -163,6 +163,8 @@ enum {
#define GDM_KEY_UAUTHFILE "daemon/UserAuthFile=.Xauthority"
#define GDM_KEY_USER "daemon/User=gdm"
#define GDM_KEY_DOUBLELOGINWARNING "daemon/DoubleLoginWarning=true"
/* This defaults to true for backward compatibility,
* it will not actually do timed login since the TimedLogin defaults
* to nothing */
......@@ -444,6 +446,9 @@ void gdm_final_cleanup (void);
#define GDM_SOP_LOGGED_IN "LOGGED_IN" /* <slave pid> <logged_in as int> */
#define GDM_SOP_LOGIN "LOGIN" /* <slave pid> <username> */
#define GDM_SOP_COOKIE "COOKIE" /* <slave pid> <cookie> */
#define GDM_SOP_QUERYLOGIN "QUERYLOGIN" /* <slave pid> <username> */
/* if user already logged in somewhere, the ack response will be
<display>,<vt>,<display>,<vt>,... */
#define GDM_SOP_DISP_NUM "DISP_NUM" /* <slave pid> <display as int> */
/* For linux only currently */
#define GDM_SOP_VT_NUM "VT_NUM" /* <slave pid> <vt as int> */
......@@ -494,6 +499,7 @@ void gdm_final_cleanup (void);
#define GDM_NOTIFY_SOFT_RESTART_SERVERS "SOFT_RESTART_SERVERS"
/* Ack for a slave message */
/* Note that an extra response can follow an 'ack' */
#define GDM_SLAVE_NOTIFY_ACK 'A'
/* Update this key */
#define GDM_SLAVE_NOTIFY_KEY '!'
......@@ -599,6 +605,20 @@ void gdm_final_cleanup (void);
* (that is, it is an xnest inside another console display) it is listed
* and instead of vt, it lists the parent display in standard form.
*/
#define GDM_SUP_ALL_SERVERS "ALL_SERVERS" /* None */
/* ALL_SERVERS: List all servers, including console, remote, xnest. This
* Can for example be useful to figure out if the server you are on is managed
* by the gdm daemon, by seeing if it is in the list. It is also somewhat
* like the 'w' command but for graphical sessions.
* Supported since: 2.4.2.96
* Arguments: None
* Answers:
* OK <server>;<server>;...
*
* <server> is <display>,<logged in user>
*
* <logged in user> can be empty in case no one logged in yet
*/
#define GDM_SUP_UPDATE_CONFIG "UPDATE_CONFIG" /* <key> */
/* UPDATE_CONFIG: Tell the daemon to update config of some key. Any user
* can really request that values are re-read but the daemon
......
......@@ -101,6 +101,25 @@ gdm_get_empty_vt_argument (int *fd, int *vt)
return g_strdup_printf ("vt%d", *vt);
}
void
gdm_change_vt (int vt)
{
char *cmd;
if (vt < 0)
return;
/* kind of hack, we could do it ourselves if we weren't lazy */
/* FIXME: we should really do the vt thing ourselves */
if (access ("/usr/bin/chvt", X_OK) == 0)
cmd = g_strdup_printf ("/usr/bin/chvt %d", vt);
else if (access ("/bin/chvt", X_OK) == 0)
cmd = g_strdup_printf ("/bin/chvt %d", vt);
else
cmd = NULL;
if (cmd != NULL)
system (cmd);
g_free (cmd);
}
#else /* here this is just a stub, we don't know how to do this outside
of linux really */
......@@ -112,4 +131,10 @@ gdm_get_empty_vt_argument (int *fd, int *vt)
return NULL;
}
void
gdm_change_vt (int vt)
{
return;
}
#endif
......@@ -30,5 +30,6 @@
* This is to avoid race with other stuff openning this vt.
* It can be set to -1 if nothing could be opened. */
char * gdm_get_empty_vt_argument (int *fd, int *vt);
void gdm_change_vt (int vt);
#endif /* GETVT_H */
......@@ -238,7 +238,6 @@ gdm_server_stop (GdmDisplay *disp)
ve_waitpid_no_signal (servpid, 0, 0);
gdm_sigchld_block_pop ();
gdm_debug ("gdm_server_stop: Server pid %d dead", (int)servpid);
}
......
......@@ -63,6 +63,7 @@
#include "auth.h"
#include "server.h"
#include "choose.h"
#include "getvt.h"
#include "errorgui.h"
/* Some per slave globals */
......@@ -118,6 +119,7 @@ extern gchar *GdmAutomaticLogin;
extern gboolean GdmAllowRemoteAutoLogin;
extern gboolean GdmAlwaysRestartServer;
extern gboolean GdmAddGtkModules;
extern gboolean GdmDoubleLoginWarning;
extern gchar *GdmConfigurator;
extern gboolean GdmConfigAvailable;
extern gboolean GdmChooserButton;
......@@ -181,6 +183,7 @@ static void set_xnest_parent_stuff (void);
/* Yay thread unsafety */
static gboolean x_error_occured = FALSE;
static gboolean gdm_got_ack = FALSE;
static char * gdm_ack_response = NULL;
static GList *unhandled_notifies = NULL;
static void
......@@ -544,6 +547,104 @@ gdm_slave_whack_greeter (void)
gdm_sigchld_block_pop ();
}
gboolean
gdm_slave_check_user_wants_to_log_in (const char *user)
{
gboolean loggedin = FALSE;
int vt = -1;
int i;
char **vec;
char *msg;
int r;
char *but[4];
if ( ! GdmDoubleLoginWarning ||
/* always ignore root here, this is mostly a special case
* since a root login may not be a real login, such as the
config stuff, and people shouldn't log in as root anyway */
strcmp (user, "root") == 0)
return TRUE;
gdm_slave_send_string (GDM_SOP_QUERYLOGIN, user);
if (gdm_ack_response == NULL)
return TRUE;
vec = g_strsplit (gdm_ack_response, ",", -1);
if (vec == NULL)
return TRUE;
for (i = 0; vec[i] != NULL && vec[i+1] != NULL; i += 2) {
int ii;
loggedin = TRUE;
if (d->console && vt < 0 && sscanf (vec[i+1], "%d", &ii) == 1)
vt = ii;
}
g_strfreev (vec);
if ( ! loggedin)
return TRUE;
but[0] = _("Log in anyway");
if (vt >= 0) {
msg = _("You are already logged in. "
"You can log in anyway, return to your "
"previous login session, or abort this "
"login");
but[1] = _("Return to previous login");
but[2] = _("Abort login");
but[3] = NULL;
} else {
msg = _("You are already logged in. "
"You can log in anyway or abort this "
"login");
but[1] = _("Abort login");
but[2] = NULL;
}
if (greet)
gdm_slave_greeter_ctl_no_ret (GDM_DISABLE, "");
r = gdm_failsafe_ask_buttons (d, msg, but);