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

Fix #125064 by correctly reading out the chooser output and ignoring all


Tue Jan 06 11:49:29 2004  George Lebl <jirka@5z.com>

	* daemon/display.c, daemon/gdm.h, daemon/server.c, daemon/slave.c,
 	  daemon/xdmcp.c:  Fix #125064 by correctly reading out the chooser
	  output and ignoring all but the last line.

	* gui/gdmchooser.c: Send a newline BEFORE the chosen host as well
	  as after.  Also fix reading the address on hosts that have IPV6,
	  but that don't use it.

	* gui/greeter/greeter_action_language.c: Get rid of evil 'foo == FALSE'
	  kind of test

	* gui/modules/Makefile.am, gui/modules/dwellmouselistener.c,
	  gui/modules/keymouselistener.c:  Link with ve so that we can use it
	  and ensure that our BINDIR is in the PATH.
parent e7fffc35
Tue Jan 06 11:49:29 2004 George Lebl <jirka@5z.com>
* daemon/display.c, daemon/gdm.h, daemon/server.c, daemon/slave.c,
daemon/xdmcp.c: Fix #125064 by correctly reading out the chooser
output and ignoring all but the last line.
* gui/gdmchooser.c: Send a newline BEFORE the chosen host as well
as after. Also fix reading the address on hosts that have IPV6,
but that don't use it.
* gui/greeter/greeter_action_language.c: Get rid of evil 'foo == FALSE'
kind of test
* gui/modules/Makefile.am, gui/modules/dwellmouselistener.c,
gui/modules/keymouselistener.c: Link with ve so that we can use it
and ensure that our BINDIR is in the PATH.
Tue Jan 06 10:17:41 2004 George Lebl <jirka@5z.com>
* daemon/slave.c: small leak fix
......
......@@ -508,6 +508,24 @@ gdm_display_dispose (GdmDisplay *d)
g_free (d->xsession_errors_filename);
d->xsession_errors_filename = NULL;
if (d->session_output_fd >= 0) {
VE_IGNORE_EINTR (close (d->session_output_fd));
d->session_output_fd = -1;
}
if (d->xsession_errors_fd >= 0) {
VE_IGNORE_EINTR (close (d->xsession_errors_fd));
d->xsession_errors_fd = -1;
}
g_free (d->chooser_last_line);
d->chooser_last_line = NULL;
if (d->chooser_output_fd >= 0) {
VE_IGNORE_EINTR (close (d->chooser_output_fd));
d->chooser_output_fd = -1;
}
g_free (d);
}
......
......@@ -408,6 +408,9 @@ struct _GdmDisplay {
char *xsession_errors_filename; /* if NULL then there is no .xsession-errors
file */
int chooser_output_fd; /* from the chooser */
char *chooser_last_line;
/* Only set in the main daemon as that's the only place that cares */
GdmLogoutAction logout_action;
};
......
......@@ -1329,6 +1329,9 @@ gdm_server_alloc (gint id, const gchar *command)
d->xsession_errors_bytes = 0;
d->xsession_errors_fd = -1;
d->session_output_fd = -1;
d->chooser_output_fd = -1;
d->chooser_last_line = NULL;
return d;
}
......
......@@ -379,6 +379,24 @@ run_session_output (gboolean read_until_eof)
NEVER_FAILS_root_set_euid_egid (old, oldg);
}
static void
run_chooser_output (void)
{
char *bf;
if G_UNLIKELY (d->chooser_output_fd < 0)
return;
/* the fd is non-blocking */
do {
bf = gdm_fdgets (d->chooser_output_fd);
if (bf != NULL) {
g_free (d->chooser_last_line);
d->chooser_last_line = bf;
}
} while (bf != NULL);
}
#define TIME_UNSET_P(tv) ((tv)->tv_sec == 0 && (tv)->tv_usec == 0)
/* Try to touch an authfb auth file every 12 hours. That way if it's
......@@ -478,6 +496,8 @@ slave_waitpid (GdmWaitPid *wp)
if (d->session_output_fd >= 0)
run_session_output (FALSE /* read_until_eof */);
if (d->chooser_output_fd >= 0)
run_chooser_output ();
check_notifies_now ();
}
check_notifies_now ();
......@@ -489,18 +509,23 @@ slave_waitpid (GdmWaitPid *wp)
fd_set rfds;
int ret;
struct timeval tv;
int maxfd;
FD_ZERO (&rfds);
FD_SET (slave_waitpid_r, &rfds);
if (read_session_output &&
d->session_output_fd >= 0)
FD_SET (d->session_output_fd, &rfds);
if (d->chooser_output_fd >= 0)
FD_SET (d->chooser_output_fd, &rfds);
/* unset time */
tv.tv_sec = 0;
tv.tv_usec = 0;
maxfd = MAX (slave_waitpid_r, d->session_output_fd);
maxfd = MAX (maxfd, d->chooser_output_fd);
ret = select (MAX (slave_waitpid_r, d->session_output_fd)+1, &rfds, NULL, NULL, min_time_to_wait (&tv));
ret = select (maxfd + 1, &rfds, NULL, NULL, min_time_to_wait (&tv));
/* try to touch an fb auth file */
try_to_touch_fb_userauth ();
......@@ -513,6 +538,10 @@ slave_waitpid (GdmWaitPid *wp)
FD_ISSET (d->session_output_fd, &rfds)) {
run_session_output (FALSE /* read_until_eof */);
}
if (d->chooser_output_fd >= 0 &&
FD_ISSET (d->chooser_output_fd, &rfds)) {
run_chooser_output ();
}
} else if (errno == EBADF) {
read_session_output = FALSE;
}
......@@ -2887,7 +2916,7 @@ gdm_slave_chooser (void)
{
gint p[2];
struct passwd *pwent;
char buf[1024];
char *buf;
size_t bytes;
pid_t pid;
GdmWaitPid *wp;
......@@ -3007,6 +3036,12 @@ gdm_slave_chooser (void)
VE_IGNORE_EINTR (close (p[1]));
g_free (d->chooser_last_line);
d->chooser_last_line = NULL;
d->chooser_output_fd = p[0];
/* make the output read fd non-blocking */
fcntl (d->chooser_output_fd, F_SETFL, O_NONBLOCK);
/* wait for the chooser to die */
gdm_sigchld_block_push ();
......@@ -3019,28 +3054,26 @@ gdm_slave_chooser (void)
gdm_slave_send_num (GDM_SOP_CHOOSERPID, 0);
/* Note: Nothing affecting the chooser needs update
* from notifies */
* from notifies, plus we are exitting right now */
VE_IGNORE_EINTR (bytes = read (p[0], buf, sizeof(buf)-1));
if (bytes > 0) {
VE_IGNORE_EINTR (close (p[0]));
run_chooser_output ();
VE_IGNORE_EINTR (close (d->chooser_output_fd));
d->chooser_output_fd = -1;
if (d->chooser_last_line != NULL) {
char *host = d->chooser_last_line;
d->chooser_last_line = NULL;
if (buf[bytes-1] == '\n')
buf[bytes-1] ='\0';
else
buf[bytes] ='\0';
if (d->type == TYPE_XDMCP) {
send_chosen_host (d, buf);
send_chosen_host (d, host);
gdm_slave_quick_exit (DISPLAY_CHOSEN);
} else {
gdm_debug ("Sending locally chosen host %s", buf);
gdm_slave_send_string (GDM_SOP_CHOSEN_LOCAL, buf);
gdm_slave_send_string (GDM_SOP_CHOSEN_LOCAL, host);
gdm_slave_quick_exit (DISPLAY_REMANAGE);
}
}
VE_IGNORE_EINTR (close (p[0]));
gdm_slave_quick_exit (DISPLAY_REMANAGE);
break;
}
......
......@@ -2579,6 +2579,9 @@ gdm_xdmcp_display_alloc (
d->xsession_errors_bytes = 0;
d->xsession_errors_fd = -1;
d->session_output_fd = -1;
d->chooser_output_fd = -1;
d->chooser_last_line = NULL;
/* Secure display with cookie */
if G_UNLIKELY (! gdm_auth_secure_display (d))
......
......@@ -474,13 +474,17 @@ gdm_chooser_decode_packet (GIOChannel *source,
return TRUE;
#ifdef ENABLE_IPV6
sa_len = sizeof (struct sockaddr_in6);
if (! XdmcpFill (sockfd, &buf, (XdmcpNetaddr) &clnt6_sa, &sa_len))
#else
sa_len = sizeof (struct sockaddr_in);
if (! XdmcpFill (sockfd, &buf, (XdmcpNetaddr) &clnt_sa, &sa_len))
if (have_ipv6) {
sa_len = sizeof (struct sockaddr_in6);
if (! XdmcpFill (sockfd, &buf, (XdmcpNetaddr) &clnt6_sa, &sa_len))
return TRUE;
} else
#endif
return TRUE;
{
sa_len = sizeof (struct sockaddr_in);
if (! XdmcpFill (sockfd, &buf, (XdmcpNetaddr) &clnt_sa, &sa_len))
return TRUE;
}
if (! XdmcpReadHeader (&buf, &header))
return TRUE;
......@@ -508,7 +512,8 @@ gdm_chooser_decode_packet (GIOChannel *source,
#ifdef ENABLE_IPV6
/*Since, IPv4 addresses will get extracted as V4 mapped IPv6 address*/
if (IN6_IS_ADDR_V4MAPPED (&(clnt6_sa.sin6_addr))) {
if (have_ipv6 &&
IN6_IS_ADDR_V4MAPPED (&(clnt6_sa.sin6_addr))) {
memset (&clnt_sa, 0, sizeof (clnt_sa));
memcpy (&(clnt_sa.sin_addr), &(clnt6_sa.sin6_addr.s6_addr[12]), 4);
clnt_sa.sin_family = AF_INET;
......@@ -516,7 +521,8 @@ gdm_chooser_decode_packet (GIOChannel *source,
clnt6_sa.sin6_family = AF_INET;
}
if (((struct sockaddr *) &clnt6_sa)->sa_family == AF_INET6) {
if (have_ipv6 &&
((struct sockaddr *) &clnt6_sa)->sa_family == AF_INET6) {
if ( ! is_loopback_addr ((gchar *) &clnt6_sa.sin6_addr, AF_INET6)) {
clnt6_sa.sin6_scope_id = 0;
......@@ -575,7 +581,7 @@ gdm_chooser_decode_packet (GIOChannel *source,
}
#ifdef ENABLE_IPV6
if (((struct sockaddr *) &clnt6_sa)->sa_family == AF_INET6) {
if (have_ipv6 && ((struct sockaddr *) &clnt6_sa)->sa_family == AF_INET6) {
gh = gdm_host_known ((char *)&clnt6_sa.sin6_addr, AF_INET6);
if (gh == NULL) {
gh = gdm_chooser_host_alloc (hostname, status, (char *)&clnt6_sa.sin6_addr, AF_INET6, header.opcode == WILLING);
......@@ -602,9 +608,11 @@ gdm_chooser_decode_packet (GIOChannel *source,
servers really */
}
#ifdef ENABLE_IPV6
if (((struct sockaddr *) &clnt6_sa)->sa_family == AF_INET6 &&
! gh->willing && added6_addr != NULL &&
memcmp (&gh->ia6, added6_addr, sizeof (struct in6_addr)) == 0) {
if (have_ipv6 &&
((struct sockaddr *) &clnt6_sa)->sa_family == AF_INET6 &&
! gh->willing &&
added6_addr != NULL &&
memcmp (&gh->ia6, added6_addr, sizeof (struct in6_addr)) == 0) {
added6_addr = NULL;
host_not_willing = TRUE;
......@@ -612,10 +620,9 @@ gdm_chooser_decode_packet (GIOChannel *source,
else
#endif
if (clnt_sa.sin_family == AF_INET &&
! gh->willing &&
! gh->willing &&
added_addr != NULL &&
memcmp (&gh->ia, added_addr,
sizeof (struct in_addr)) == 0) {
memcmp (&gh->ia, added_addr, sizeof (struct in_addr)) == 0) {
added_addr = NULL;
host_not_willing = TRUE;
......@@ -1105,7 +1112,7 @@ gdm_chooser_xdmcp_init (char **hosts)
else
have_ipv6 = TRUE;
#endif
if (have_ipv6 == FALSE) {
if ( ! have_ipv6) {
if ((sockfd = socket (AF_INET, SOCK_DGRAM, 0)) == -1) {
gdm_chooser_abort ("Could not create socket()!");
}
......@@ -1150,7 +1157,7 @@ gdm_chooser_choose_host (const char *hostname)
struct hostent *hentry;
#endif
printf ("%s\n", curhost->name);
printf ("\n%s\n", curhost->name);
fflush (stdout);
if (xdm_address != NULL) {
#ifdef ENABLE_IPV6
......@@ -1240,7 +1247,7 @@ gdm_chooser_choose_host (const char *hostname)
static gboolean
add_check (gpointer data)
{
gboolean check = FALSE;
gboolean check = FALSE;
#ifdef ENABLE_IPV6
if (have_ipv6 && added6_addr != NULL)
......@@ -1386,7 +1393,7 @@ gdm_chooser_add_host (void)
sock6.sin6_family = AF_INET6;
sock6.sin6_port = htons (XDM_UDP_PORT);
status = gdm_addr_known ((char *)&qa6->sin6_addr, AF_INET6);
if (status == FALSE) {
if ( ! status) {
queryaddr = g_slist_append (queryaddr, qa6);
}
if (IN6_IS_ADDR_V4MAPPED (&qa6->sin6_addr)) {
......@@ -1402,7 +1409,7 @@ gdm_chooser_add_host (void)
sock.sin_family = AF_INET;
sock.sin_port = htons (XDM_UDP_PORT);
status = gdm_addr_known ((char *)&qa->sin_addr, AF_INET);
if (status == FALSE) {
if ( ! status) {
queryaddr = g_slist_append (queryaddr, qa);
}
host = gdm_host_known ((char *) &qa->sin_addr, AF_INET);
......
......@@ -91,7 +91,7 @@ greeter_language_init (void)
{
static gboolean initted = FALSE;
g_assert (initted == FALSE);
g_assert ( ! initted);
greeter_langauge_initialize_model ();
......
......@@ -3,6 +3,7 @@
INCLUDES = \
-I. \
-I.. \
-I$(top_srcdir)/vicious-extensions \
-DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
$(GUI_CFLAGS)
......@@ -20,7 +21,9 @@ libkeymouselistener_la_SOURCES = \
libkeymouselistener_la_LDFLAGS = \
-rpath $(moduledir) -module -avoid-version \
$(GUI_LIBS) \
$(X_LIBS)
$(X_LIBS) \
-L$(top_builddir)/vicious-extensions \
-lviciousui
libdwellmouselistener_la_SOURCES = \
dwellmouselistener.c
......@@ -28,7 +31,9 @@ libdwellmouselistener_la_SOURCES = \
libdwellmouselistener_la_LDFLAGS = \
-rpath $(moduledir) -module -avoid-version \
$(GUI_LIBS) \
$(X_LIBS)
$(X_LIBS) \
-L$(top_builddir)/vicious-extensions \
-lviciousui
moduledir = $(libdir)/gtk-2.0/modules
......
......@@ -31,6 +31,8 @@
#include <config.h>
#include <vicious.h>
/*
* Note that CONFIGFILE will have to be changed to something more generic
* if this module is ever moved outside of gdm.
......@@ -539,6 +541,7 @@ leave_enter_emission_hook (GSignalInvocationHint *ihint,
for (act_li = curr_binding->actions; act_li != NULL; act_li = act_li->next)
{
gchar *action = (gchar *)act_li->data;
char *oldpath, *newpath;
g_return_val_if_fail (action != NULL, TRUE);
if (!g_shell_parse_argv (action, NULL, &argv, NULL))
......@@ -546,6 +549,18 @@ leave_enter_emission_hook (GSignalInvocationHint *ihint,
envp = get_exec_environment (gtk_window_get_screen(window));
/* add our BINDIR to the path */
oldpath = g_strdup (g_getenv ("PATH"));
if (ve_string_empty (oldpath))
newpath = g_strdup (EXPANDED_BINDIR);
else
newpath = g_strconcat (oldpath,
":",
EXPANDED_BINDIR,
NULL);
ve_setenv ("PATH", newpath, TRUE);
g_free (newpath);
retval = g_spawn_async (NULL,
argv,
envp,
......@@ -554,10 +569,17 @@ leave_enter_emission_hook (GSignalInvocationHint *ihint,
NULL,
NULL,
NULL);
if (ve_string_empty (oldpath))
ve_unsetenv ("PATH");
else
ve_setenv ("PATH", oldpath, TRUE);
g_free (oldpath);
g_strfreev (argv);
g_strfreev (envp);
if (!retval)
if ( ! retval)
{
GtkWidget *dialog =
gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR,
......
......@@ -37,6 +37,8 @@
#include <config.h>
#include <vicious.h>
/*
* Note that CONFIGFILE will have to be changed to something more generic
* if this module is ever moved outside of gdm.
......@@ -624,24 +626,44 @@ gestures_filter (GdkXEvent *gdk_xevent,
seq_count = 0;
for (act_li = curr_gesture->actions; act_li != NULL; act_li = act_li->next) {
gchar *action = (gchar *)act_li->data;
char *oldpath, *newpath;
g_return_val_if_fail (action != NULL, GDK_FILTER_CONTINUE);
if (!g_shell_parse_argv (action, NULL, &argv, NULL))
continue;
envp = get_exec_environment (xevent);
/* add our BINDIR to the path */
oldpath = g_strdup (g_getenv ("PATH"));
if (ve_string_empty (oldpath))
newpath = g_strdup (EXPANDED_BINDIR);
else
newpath = g_strconcat (oldpath,
":",
EXPANDED_BINDIR,
NULL);
ve_setenv ("PATH", newpath, TRUE);
g_free (newpath);
retval = g_spawn_async (NULL,
argv,
envp,
G_SPAWN_SEARCH_PATH,
NULL,
NULL,
NULL,
NULL);
argv,
envp,
G_SPAWN_SEARCH_PATH,
NULL,
NULL,
NULL,
NULL);
if (ve_string_empty (oldpath))
ve_unsetenv ("PATH");
else
ve_setenv ("PATH", oldpath, TRUE);
g_free (oldpath);
g_strfreev (argv);
g_strfreev (envp);
if (!retval) {
if ( ! retval) {
GtkWidget *dialog =
gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR,
GTK_BUTTONS_OK,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment