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

minor cleanups and i18n fixes

Fri Jun 15 17:27:38 2001  George Lebl <jirka@5z.com>

	* gui/gdmchooser.c: minor cleanups and i18n fixes

	* daemon/slave.c, daemon/gdm.h, daemon/xdmcp.c, daemon/choose.c: a
	  bunch of xdmcp related fixes, and actually run the greeter on
	  indirect queries, though it still doesn't actually choose the host,
	  but oh well.

	* daemon/slave.c: fix GETFD argument when doing SETFD on the pipe
parent a870ab99
Fri Jun 15 17:27:38 2001 George Lebl <jirka@5z.com>
* gui/gdmchooser.c: minor cleanups and i18n fixes
* daemon/slave.c, daemon/gdm.h, daemon/xdmcp.c, daemon/choose.c: a
bunch of xdmcp related fixes, and actually run the greeter on
indirect queries, though it still doesn't actually choose the host,
but oh well.
* daemon/slave.c: fix GETFD argument when doing SETFD on the pipe
Wed Jun 13 22:22:55 2001 George Lebl <jirka@5z.com>
* daemon/slave.c: on xterm failsafe session, instead of doing
......
......@@ -55,7 +55,7 @@ extern void gdm_debug (gchar *, ...);
GdmIndirectDisplay *gdm_choose_indirect_alloc (struct sockaddr_in *clnt_sa);
GdmIndirectDisplay *gdm_choose_indirect_lookup (struct sockaddr_in *clnt_sa);
static void gdm_choose_indirect_dispose (GdmIndirectDisplay *);
void gdm_choose_indirect_dispose (GdmIndirectDisplay *id);
gboolean gdm_choose_socket_handler (GIOChannel *source, GIOCondition cond, gint fd);
......@@ -109,11 +109,13 @@ gdm_choose_indirect_alloc (struct sockaddr_in *clnt_sa)
GdmIndirectDisplay *
gdm_choose_indirect_lookup (struct sockaddr_in *clnt_sa)
{
GSList *ilist = indirect;
GSList *li, *ilist;
GdmIndirectDisplay *id;
ilist = g_slist_copy (indirect);
while (ilist) {
id = (GdmIndirectDisplay *) ilist->data;
for (li = ilist; li != NULL; li = li->next) {
id = (GdmIndirectDisplay *) li->data;
if (id && time (NULL) > id->acctime + GdmMaxIndirectWait) {
gdm_debug ("gdm_choose_indirect_check: Disposing stale INDIRECT query from %s",
......@@ -123,9 +125,8 @@ gdm_choose_indirect_lookup (struct sockaddr_in *clnt_sa)
if (id && id->dsp_sa->sin_addr.s_addr == clnt_sa->sin_addr.s_addr)
return (id);
ilist = ilist->next;
}
g_slist_free (ilist);
gdm_debug ("gdm_choose_indirect_lookup: Host %s not found",
inet_ntoa (clnt_sa->sin_addr));
......@@ -134,17 +135,19 @@ gdm_choose_indirect_lookup (struct sockaddr_in *clnt_sa)
}
static void
void
gdm_choose_indirect_dispose (GdmIndirectDisplay *id)
{
if (!id)
return;
indirect = g_slist_remove (indirect, id);
gdm_debug ("gdm_choose_indirect_dispose: Disposing %d",
inet_ntoa (id->dsp_sa->sin_addr));
if (id->dsp_sa)
g_free (id->dsp_sa);
g_free (id->dsp_sa);
id->dsp_sa = NULL;
g_free (id);
......
......@@ -213,6 +213,7 @@ struct _GdmDisplay {
gboolean authfb;
gchar *command;
gboolean failsafe_xserver;
gboolean use_chooser;
gchar *cookie;
gchar *bcookie;
gchar *name;
......
......@@ -79,6 +79,7 @@ extern gboolean GdmConfigAvailable;
extern gboolean GdmSystemMenu;
extern gint GdmXineramaScreen;
extern gchar *GdmGreeter;
extern gchar *GdmChooser;
extern gchar *GdmDisplayInit;
extern gchar *GdmPreSession;
extern gchar *GdmPostSession;
......@@ -108,6 +109,7 @@ static gint gdm_slave_xioerror_handler (Display *disp);
static void gdm_slave_run (GdmDisplay *display);
static void gdm_slave_wait_for_login (void);
static void gdm_slave_greeter (void);
static void gdm_slave_chooser (void);
static void gdm_slave_session_start (void);
static void gdm_slave_session_stop (pid_t sesspid);
static void gdm_slave_session_cleanup (void);
......@@ -375,10 +377,12 @@ gdm_slave_run (GdmDisplay *display)
/* checkout xinerama */
gdm_screen_init (d);
if (d->type == TYPE_LOCAL &&
gdm_first_login &&
! gdm_string_empty (GdmAutomaticLogin) &&
strcmp (GdmAutomaticLogin, "root") != 0) {
if (d->use_chooser) {
gdm_slave_chooser (); /* Run the chooser */
} else if (d->type == TYPE_LOCAL &&
gdm_first_login &&
! gdm_string_empty (GdmAutomaticLogin) &&
strcmp (GdmAutomaticLogin, "root") != 0) {
gdm_first_login = FALSE;
setup_automatic_session (d, GdmAutomaticLogin);
......@@ -973,7 +977,7 @@ gdm_slave_greeter (void)
close (pipe2[1]);
fcntl(pipe1[1], F_SETFD, fcntl(pipe1[1], F_GETFD, 0) | FD_CLOEXEC);
fcntl(pipe2[0], F_SETFD, fcntl(pipe2[2], F_GETFD, 0) | FD_CLOEXEC);
fcntl(pipe2[0], F_SETFD, fcntl(pipe2[0], F_GETFD, 0) | FD_CLOEXEC);
if (pipe1[1] != STDOUT_FILENO)
dup2 (pipe1[1], STDOUT_FILENO);
......@@ -990,6 +994,124 @@ gdm_slave_greeter (void)
}
}
static void
gdm_slave_chooser (void)
{
gint pipe1[2], pipe2[2];
gchar **argv;
struct passwd *pwent;
gdm_debug ("gdm_slave_chooser: Running chooser on %s", d->name);
/* Open a pipe for chooser communications */
if (pipe (pipe1) < 0 || pipe (pipe2) < 0)
gdm_slave_exit (DISPLAY_ABORT, _("gdm_slave_chooser: Can't init pipe to gdmchooser"));
/* Run the init script. gdmslave suspends until script has terminated */
gdm_slave_exec_script (d, GdmDisplayInit, NULL, NULL);
/* Fork. Parent is gdmslave, child is greeter process. */
last_killed_pid = 0; /* race condition wrapper,
* it could be that we recieve sigchld before
* we can set greetpid. eek! */
switch (d->chooserpid = fork()) {
case 0:
sigfillset (&mask);
sigdelset (&mask, SIGINT);
sigdelset (&mask, SIGTERM);
sigdelset (&mask, SIGHUP);
sigprocmask (SIG_SETMASK, &mask, NULL);
/* Plumbing */
close (pipe1[1]);
close (pipe2[0]);
if (pipe1[0] != STDIN_FILENO)
dup2 (pipe1[0], STDIN_FILENO);
if (pipe2[1] != STDOUT_FILENO)
dup2 (pipe2[1], STDOUT_FILENO);
if (setgid (GdmGroupId) < 0)
gdm_child_exit (DISPLAY_ABORT, _("gdm_slave_chooser: Couldn't set groupid to %d"), GdmGroupId);
if (initgroups (GdmUser, GdmGroupId) < 0)
gdm_child_exit (DISPLAY_ABORT, _("gdm_slave_chooser: initgroups() failed for %s"), GdmUser);
if (setuid (GdmUserId) < 0)
gdm_child_exit (DISPLAY_ABORT, _("gdm_slave_chooser: Couldn't set userid to %d"), GdmUserId);
gdm_clearenv_no_lang ();
gdm_setenv ("XAUTHORITY", d->authfile);
gdm_setenv ("DISPLAY", d->name);
gdm_setenv ("LOGNAME", GdmUser);
gdm_setenv ("USER", GdmUser);
gdm_setenv ("USERNAME", GdmUser);
gdm_setenv ("GDM_VERSION", VERSION);
pwent = getpwnam (GdmUser);
if (pwent != NULL) {
/* Note that usually this doesn't exist */
if (g_file_exists (pwent->pw_dir))
gdm_setenv ("HOME", pwent->pw_dir);
else
gdm_setenv ("HOME", "/"); /* Hack */
gdm_setenv ("SHELL", pwent->pw_shell);
} else {
gdm_setenv ("HOME", "/"); /* Hack */
gdm_setenv ("SHELL", "/bin/sh");
}
gdm_setenv ("PATH", GdmDefaultPath);
gdm_setenv ("RUNNING_UNDER_GDM", "true");
argv = g_strsplit (GdmChooser, argdelim, MAX_ARGS);
execv (argv[0], argv);
gdm_error_box (d,
GNOME_MESSAGE_BOX_ERROR,
_("Cannot start the chooser program,\n"
"you will not be able to log in.\n"
"Please contact the system administrator.\n"));
gdm_child_exit (DISPLAY_ABORT, _("gdm_slave_chooser: Error starting chooser on display %s"), d->name);
case -1:
gdm_slave_exit (DISPLAY_ABORT, _("gdm_slave_chooser: Can't fork gdmchooser process"));
default:
if (last_killed_pid == d->chooserpid) {
/* foo, this is a bad case really. We always remanage since
* we assume that the chooser died, we should probably store
* the status. But this race is not likely to happen
* normally. */
_exit (DISPLAY_REMANAGE);
}
gdm_debug ("gdm_slave_chooser: Chooser on pid %d", d->chooserpid);
close (pipe1[0]);
close (pipe2[1]);
fcntl(pipe1[1], F_SETFD, fcntl(pipe1[1], F_GETFD, 0) | FD_CLOEXEC);
fcntl(pipe2[0], F_SETFD, fcntl(pipe2[0], F_GETFD, 0) | FD_CLOEXEC);
if (pipe1[1] != STDOUT_FILENO)
dup2 (pipe1[1], STDOUT_FILENO);
if (pipe2[0] != STDIN_FILENO)
dup2 (pipe2[0], STDIN_FILENO);
/* wait for the chooser to die */
waitpid (d->chooserpid, 0, 0);
/* FIXME: read the chosen host here and whack it onto the
* chooser fifo thingie */
break;
}
}
static void
read_sessions (FILE *fp, GString *sessions, const char *def, gboolean *got_def)
{
......
......@@ -125,7 +125,11 @@ extern gboolean GdmXdmcp; /* xdmcp enabled */
/* Local prototypes */
static gboolean gdm_xdmcp_decode_packet (void);
static void gdm_xdmcp_handle_query (struct sockaddr_in *clnt_sa, gint len, gint type);
/*
FIXME: This function is not really implemented to begin with, I dunno
what to do there anyway -George
static void gdm_xdmcp_send_forward_query (GdmIndirectDisplay *id, ARRAYofARRAY8Ptr authlist);
*/
static void gdm_xdmcp_handle_forward_query (struct sockaddr_in *clnt_sa, gint len);
static void gdm_xdmcp_handle_request (struct sockaddr_in *clnt_sa, gint len);
static void gdm_xdmcp_handle_manage (struct sockaddr_in *clnt_sa, gint len);
......@@ -167,9 +171,11 @@ static XdmAuthRec serv_authlist = {
};
/* these ought to be in some header file */
extern gboolean gdm_choose_socket_handler (GIOChannel *source, GIOCondition cond, gint fd);
extern GdmIndirectDisplay *gdm_choose_indirect_alloc (struct sockaddr_in *clnt_sa);
extern GdmIndirectDisplay *gdm_choose_indirect_lookup (struct sockaddr_in *clnt_sa);
extern void gdm_choose_indirect_dispose (GdmIndirectDisplay *id);
gboolean
......@@ -393,6 +399,7 @@ gdm_xdmcp_handle_query (struct sockaddr_in *clnt_sa, gint len, gint type)
if (len != explen) {
gdm_error (_("gdm_xdmcp_handle_query: Error in checksum"));
XdmcpDisposeARRAYofARRAY8 (&clnt_authlist);
return;
}
......@@ -402,27 +409,44 @@ gdm_xdmcp_handle_query (struct sockaddr_in *clnt_sa, gint len, gint type)
/* If this is an INDIRECT_QUERY, try to look up the display in
* the pending list. If found send a FORWARD_QUERY to the
* chosen manager. Otherwise alloc a new indirect display. */
/* EEEEEEEEK! dunno what this is suppsoed to do */
if (GdmIndirect && type==INDIRECT_QUERY) {
/* OK, now, we don't do forward query here since I have no clue
* where the fuck would we send it and the code here is bullshit,
* I suppose we really want to just send willing here and run the
* chooser
* -George */
if (GdmIndirect &&
type == INDIRECT_QUERY) {
GdmIndirectDisplay *id = gdm_choose_indirect_lookup (clnt_sa);
/* EEEEEEEEK! dunno what this is suppsoed to do */
/*
if (id) {
gdm_xdmcp_send_forward_query (id, &clnt_authlist);
} else {
}
*/
if (id == NULL) {
gdm_choose_indirect_alloc (clnt_sa);
}
gdm_debug ("Got INDIRECT query");
}
gdm_xdmcp_send_willing (clnt_sa);
} else if (type == QUERY) {
/* unwilling is ONLY sent for direct queries, never for broadcast
* nor indirects */
gdm_xdmcp_send_unwilling (clnt_sa, type);
}
else
gdm_xdmcp_send_unwilling (clnt_sa, type);
/* Dispose authlist from remote display */
/* XdmcpDisposeARRAYofARRAY8 (&clnt_authlist); */
XdmcpDisposeARRAYofARRAY8 (&clnt_authlist);
}
/* EEEEEEEEEK, this function doesn't do anything */
#if 0
static void
gdm_xdmcp_send_forward_query (GdmIndirectDisplay *id, ARRAYofARRAY8Ptr authlist)
{
......@@ -443,6 +467,7 @@ gdm_xdmcp_send_forward_query (GdmIndirectDisplay *id, ARRAYofARRAY8Ptr authlist)
XdmcpWriteARRAY8 (&buf, &status);
/* XdmcpFlush (xdmcpfd, &buf, clnt_sa, sizeof (struct sockaddr_in)); */
}
#endif
static void
......@@ -461,7 +486,6 @@ gdm_xdmcp_handle_forward_query (struct sockaddr_in *clnt_sa, gint len)
/* Read display address */
if (! XdmcpReadARRAY8 (&buf, &clnt_addr)) {
XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
gdm_error (_("gdm_xdmcp_handle_forward_query: Could not read display address"));
return;
}
......@@ -469,7 +493,6 @@ gdm_xdmcp_handle_forward_query (struct sockaddr_in *clnt_sa, gint len)
/* Read display port */
if (! XdmcpReadARRAY8 (&buf, &clnt_port)) {
XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
XdmcpDisposeARRAYofARRAY8 (&clnt_port);
gdm_error (_("gdm_xdmcp_handle_forward_query: Could not read display port number"));
return;
}
......@@ -614,24 +637,34 @@ gdm_xdmcp_handle_request (struct sockaddr_in *clnt_sa, gint len)
/* This is TCP/IP - we don't care */
if (! XdmcpReadARRAYofARRAY8 (&buf, &clnt_addr)) {
gdm_error (_("gdm_xdmcp_handle_request: Could not read Client Address"));
XdmcpDisposeARRAY16 (&clnt_conntyp);
return;
}
/* Read authentication type */
if (! XdmcpReadARRAY8 (&buf, &clnt_authname)) {
gdm_error (_("gdm_xdmcp_handle_request: Could not read Authentication Names"));
XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
XdmcpDisposeARRAY16 (&clnt_conntyp);
return;
}
/* Read authentication data */
if (! XdmcpReadARRAY8 (&buf, &clnt_authdata)) {
gdm_error (_("gdm_xdmcp_handle_request: Could not read Authentication Data"));
XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
XdmcpDisposeARRAY16 (&clnt_conntyp);
XdmcpDisposeARRAY8 (&clnt_authname);
return;
}
/* Read and select from supported authorization list */
if (! XdmcpReadARRAYofARRAY8 (&buf, &clnt_authorization)) {
gdm_error (_("gdm_xdmcp_handle_request: Could not read Authorization List"));
XdmcpDisposeARRAY8 (&clnt_authdata);
XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
XdmcpDisposeARRAY16 (&clnt_conntyp);
XdmcpDisposeARRAY8 (&clnt_authname);
return;
}
......@@ -643,6 +676,11 @@ gdm_xdmcp_handle_request (struct sockaddr_in *clnt_sa, gint len)
/* Manufacturer ID */
if (! XdmcpReadARRAY8 (&buf, &clnt_manufacturer)) {
gdm_error (_("gdm_xdmcp_handle_request: Could not read Manufacturer ID"));
XdmcpDisposeARRAY8 (&clnt_authname);
XdmcpDisposeARRAY8 (&clnt_authdata);
XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
XdmcpDisposeARRAYofARRAY8 (&clnt_authorization);
XdmcpDisposeARRAY16 (&clnt_conntyp);
return;
}
......@@ -662,6 +700,12 @@ gdm_xdmcp_handle_request (struct sockaddr_in *clnt_sa, gint len)
if (explen != len) {
gdm_error (_("gdm_xdmcp_handle_request: Failed checksum from %s"),
inet_ntoa (clnt_sa->sin_addr));
XdmcpDisposeARRAY8 (&clnt_authname);
XdmcpDisposeARRAY8 (&clnt_authdata);
XdmcpDisposeARRAY8 (&clnt_manufacturer);
XdmcpDisposeARRAYofARRAY8 (&clnt_addr);
XdmcpDisposeARRAYofARRAY8 (&clnt_authorization);
XdmcpDisposeARRAY16 (&clnt_conntyp);
return;
}
......@@ -774,6 +818,7 @@ gdm_xdmcp_handle_manage (struct sockaddr_in *clnt_sa, gint len)
CARD16 clnt_dspnum;
ARRAY8 clnt_dspclass;
GdmDisplay *d;
GdmIndirectDisplay *id;
gint logfd;
gdm_debug ("gdm_xdmcp_handle_manage: Got MANAGE from %s", inet_ntoa (clnt_sa->sin_addr));
......@@ -802,13 +847,24 @@ gdm_xdmcp_handle_manage (struct sockaddr_in *clnt_sa, gint len)
/* Display Class */
if (! XdmcpReadARRAY8 (&buf, &clnt_dspclass)) {
XdmcpDisposeARRAY8(&clnt_dspclass);
gdm_error (_("gdm_xdmcp_handle_manage: Could not read Display Class"));
return;
}
d = gdm_xdmcp_display_lookup (clnt_sessid);
id = gdm_choose_indirect_lookup (clnt_sa);
/* This was an indirect thingie, use a chooser */
if (d != NULL &&
d->dispstat == XDMCP_PENDING &&
GdmIndirect &&
id != NULL) {
gdm_choose_indirect_dispose (id);
d->use_chooser = TRUE;
} else {
d->use_chooser = FALSE;
}
if (d && d->dispstat == XDMCP_PENDING) {
gchar *logfile;
......
......@@ -67,14 +67,14 @@ static const gchar *empty_network = N_("No serving hosts were found.");
static const gchar *active_network = N_("Choose a host to connect to from the selection below.");
static gchar *glade_filename = NULL;
static GdmChooserHost *gdm_chooser_host_alloc (gchar *hostname, gchar *description);
static GdmChooserHost *gdm_chooser_host_alloc (const char *hostname, const char *description);
static void gdm_chooser_decode_packet (void);
static void gdm_chooser_abort (const gchar *format, ...);
static void gdm_chooser_browser_update (void);
static void gdm_chooser_xdmcp_init (gchar **hosts);
static void gdm_chooser_xdmcp_init (const char **hosts);
static void gdm_chooser_host_dispose (GdmChooserHost *host);
static void gdm_chooser_choose_host (gchar *hostname);
static void gdm_chooser_add_hosts (gchar **hosts);
static void gdm_chooser_choose_host (const gchar *hostname);
static void gdm_chooser_add_hosts (const char **hosts);
/* Fixetyfix */
int XdmcpReallocARRAY8 (ARRAY8Ptr array, int length);
......@@ -110,7 +110,6 @@ static GladeXML *chooser_app;
static GtkWidget *chooser, *manage, *rescan, *cancel;
static GtkWidget *status_label;
static gint maxwidth = 0;
static GIOChannel *channel;
static GList *hosts = NULL;
static GdkImlibImage *defhostimg;
......@@ -358,7 +357,7 @@ gdm_chooser_xdmcp_discover (void)
gnome_icon_list_clear (GNOME_ICON_LIST (browser));
gtk_widget_set_sensitive (GTK_WIDGET (browser), FALSE);
gtk_label_set (GTK_LABEL (status_label),
scanning_message);
_(scanning_message));
while (hl) {
gdm_chooser_host_dispose ((GdmChooserHost *) hl->data);
......@@ -379,6 +378,7 @@ gdm_chooser_xdmcp_discover (void)
bl = bl->next;
}
/* FIXME: implement GdmScanTime */
/*
tid = g_timeout_add (GdmScanTime * 1000,
(GSourceFunc) gdm_chooser_browser_update, NULL);
......@@ -395,7 +395,7 @@ gdm_chooser_xdmcp_discover (void)
static void
gdm_chooser_xdmcp_init (char **hosts)
gdm_chooser_xdmcp_init (const char **hosts)
{
static XdmcpHeader header;
gint sockopts = 1;
......@@ -575,10 +575,10 @@ gdm_chooser_browser_update (void)
if (hosts) {
gtk_label_set (GTK_LABEL (glade_xml_get_widget (chooser_app, "status_label")),
active_network);
_(active_network));
} else {
gtk_label_set (GTK_LABEL (glade_xml_get_widget (chooser_app, "status_label")),
empty_network);
_(empty_network));
}
gtk_widget_set_sensitive (GTK_WIDGET (manage), FALSE);
gtk_widget_set_sensitive (GTK_WIDGET (rescan), TRUE);
......@@ -596,7 +596,6 @@ gdm_chooser_gui_init (void)
{
GtkStyle *style;
GdkColor bbg = { 0, 0xFFFF, 0xFFFF, 0xFFFF };
struct stat statbuf;
/* Look for the glade file in $(datadir)/gdmconfig or, failing that,
......@@ -623,12 +622,10 @@ gdm_chooser_gui_init (void)
gtk_rc_parse (GdmGtkRC);
/* Load default host image */
if (stat (GdmHostDefaultIcon, &statbuf))
if (access (GdmHostDefaultIcon, R_OK) != 0)
gdm_chooser_abort (_("Can't open default host icon: %s"), GdmHostDefaultIcon);
else {
else
defhostimg = gdk_imlib_load_image (GdmHostDefaultIcon);
maxwidth = defhostimg->rgb_width;
}
/* Main window */
g_assert (glade_filename != NULL);
......@@ -672,15 +669,11 @@ gdm_chooser_gui_init (void)
style->bg[GTK_STATE_NORMAL] = bbg;
gtk_widget_push_style (style);
/* Icon list */
if (maxwidth < GdmIconMaxWidth/2)
maxwidth = (gint) GdmIconMaxWidth/2;
browser = (GnomeIconList *) glade_xml_get_widget (chooser_app,
"chooser_iconlist");
gnome_icon_list_freeze (GNOME_ICON_LIST (browser));
gnome_icon_list_set_separators (GNOME_ICON_LIST (browser), " /-_.");
gnome_icon_list_set_icon_width (GNOME_ICON_LIST (browser), maxwidth+20);
gnome_icon_list_set_icon_width (GNOME_ICON_LIST (browser), GdmIconMaxWidth + 20);
gnome_icon_list_set_icon_border (GNOME_ICON_LIST (browser), 2);
gtk_widget_pop_style();
gnome_icon_list_thaw (GNOME_ICON_LIST (browser));
......@@ -722,12 +715,11 @@ gdm_chooser_signals_init (void)
}
static GdmChooserHost *
gdm_chooser_host_alloc (gchar *hostname, gchar *description)
gdm_chooser_host_alloc (const char *hostname, const char *description)
{
GdmChooserHost *host;
GdkImlibImage *imlibimg;
gchar *hostimg;
struct stat statbuf;
host = g_malloc (sizeof (GdmChooserHost));
host->name = g_strdup (hostname);
......@@ -735,7 +727,8 @@ gdm_chooser_host_alloc (gchar *hostname, gchar *description)
hostimg = g_strconcat (GdmHostIconDir, "/", hostname, NULL);
if (!stat (hostimg, &statbuf) && (imlibimg = gdk_imlib_load_image (hostimg))) {
if (access (hostimg, R_OK) == 0 &&
(imlibimg = gdk_imlib_load_image (hostimg))) {
gint w, h;
w = imlibimg->rgb_width;
......@@ -744,20 +737,17 @@ gdm_chooser_host_alloc (gchar *hostname, gchar *description)
if (w>h && w>GdmIconMaxWidth) {
h = h * ((gfloat) GdmIconMaxWidth/w);
w = GdmIconMaxWidth;
}
else if (h>GdmIconMaxHeight) {
} else if (h>GdmIconMaxHeight) {
w = w * ((gfloat) GdmIconMaxHeight/h);
h = GdmIconMaxHeight;
}
maxwidth = MAX (maxwidth, w);
host->picture = gdk_imlib_clone_scaled_image (imlibimg, w, h);
gdk_imlib_destroy_image (imlibimg);
}
else
} else {
host->picture = defhostimg;
}
g_free (hostimg);
......@@ -773,9 +763,12 @@ gdm_chooser_host_dispose (GdmChooserHost *host)
if (host->picture != defhostimg)
gdk_imlib_destroy_image (host->picture);
host->picture = NULL;
g_free (host->name);
host->name = NULL;
g_free (host->desc);
host->desc = NULL;
g_free (host);
}
......@@ -785,9 +778,8 @@ static gint connection_type = 0;
struct poptOption xdm_options [] = {
{ "xdmaddress", '\0', POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH, &xdm_address, 0,
"setting socket for xdm communication", "xdm response socket" },
{ "clientaddress", '\0', POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH, &client_address, 0, "setting client address to return in response to xdm", "client address" },
{ "connectionType", '\0', POPT_ARG_INT|POPT_ARGFLAG_ONEDASH, &connection_type, 0, "setting connection type to return in response to xdm", "connection type" },
N_("Socket for xdm communication"), N_("SOCKET") }, { "clientaddress", '\0', POPT_ARG_STRING|POPT_ARGFLAG_ONEDASH, &client_address, 0, N_("Client address to return in response to xdm"), N_("ADDRESS") },
{ "connectionType", '\0', POPT_ARG_INT|POPT_ARGFLAG_ONEDASH, &connection_type, 0, N_("Connection type to return in response to xdm"), N_("TYPE") },
POPT_AUTOHELP
{ NULL, 0, 0, NULL, 0}
};
......@@ -798,7 +790,7 @@ struct poptOption xdm_options [] = {
#define HexChar(c) ('0' <= (c) && (c) <= '9' ? (c) - '0' : (c) - 'a' + 10)
static int
from_hex (gchar *s, gchar *d, int len)
from_hex (const char *s, char *d, int len)
{
int t;
while (len >= 2)
......@@ -819,7 +811,7 @@ from_hex (gchar *s, gchar *d, int len)
static void
gdm_chooser_choose_host (gchar *hostname)
gdm_chooser_choose_host (const char *hostname)
{
ARRAY8 tmparr;
struct hostent *hentry;
......@@ -834,8 +826,9 @@ gdm_chooser_choose_host (gchar *hostname)
char buf[1024];
XdmcpBuffer buffer;
long family, port, addr;
if (strlen (xdm_address) > 64 || from_hex (xdm_address, xdm_addr, strlen (xdm_address)) != 0)
gdm_chooser_abort ("gdm_chooser_chooser_host: Invalid xdm address.");
if (strlen (xdm_address) > 64 ||
from_hex (xdm_address, xdm_addr, strlen (xdm_address)) != 0)
gdm_chooser_abort ("gdm_chooser_chooser_host: Invalid xdm address.");
family = (xdm_addr[0] << 8) | xdm_addr[1];
port = (xdm_addr[2] << 8) | xdm_addr[3];
......@@ -844,24 +837,24 @@ gdm_chooser_choose_host (gchar *hostname)
in_addr.sin_port = htons (port);
in_addr.sin_addr.s_addr = htonl (addr);
if ((fd = socket (PF_INET, SOCK_STREAM, 0)) == -1)
gdm_chooser_abort ("gdm_chooser_chooser_host: Couldn't create response socket.");
gdm_chooser_abort ("gdm_chooser_chooser_host: Couldn't create response socket.");
if (connect (fd, (struct sockaddr_in *) &in_addr, sizeof (in_addr)) == -1)
gdm_chooser_abort ("gdm_chooser_chooser_host: Couldn't connect to xdm.");
gdm_chooser_abort ("gdm_chooser_chooser_host: Couldn't connect to xdm.");
buffer.data = (BYTE *) buf;
buffer.size = sizeof (buf);
buffer.pointer = 0;
buffer.count = 0;
if (strlen (client_address) > 64 || from_hex (client_address, client_addr, strlen (client_address)) != 0)
gdm_chooser_abort ("gdm_chooser_chooser_host: Invalid client address.");
gdm_chooser_abort ("gdm_chooser_chooser_host: Invalid client address.");
tmparr.data = (BYTE *) client_addr;
tmparr.length = strlen (client_address) / 2;
XdmcpWriteARRAY8 (&buffer, &tmparr);
XdmcpWriteCARD16 (&buffer, (CARD16) connection_type);
hentry = gethostbyname (hostname);
if (!hentry)
gdm_chooser_abort ("gdm_chooser_chooser_host: Couldn't get host entry for %s", hostname);
gdm_chooser_abort ("gdm_chooser_chooser_host: Couldn't get host entry for %s", hostname);
tmparr.data = (BYTE *) hentry->h_addr_list[0]; /* XXX */
tmparr.length = 4;
......@@ -873,7 +866,7 @@ gdm_chooser_choose_host (gchar *hostname)
}
static void
gdm_chooser_add_hosts (gchar **hosts)
gdm_chooser_add_hosts (const char **hosts)
{
struct hostent *hostent;
struct sockaddr_in qa;
......@@ -881,7 +874,7 @@ gdm_chooser_add_hosts (gchar **hosts)
int i;
for (i = 0; hosts != NULL && hosts[i] != NULL; i++) {
char *name = hosts[i];
const char *name = hosts[i];
if (strcmp (name, "BROADCAST") == 0) {
gdm_chooser_find_bcaddr ();
......@@ -914,9 +907,9 @@ gdm_chooser_add_hosts (gchar **hosts)
int
main (int argc, char *argv[])
{
gchar **fixedargv;
gint fixedargc, i;
gchar **hosts;
char **fixedargv;
int fixedargc, i;
const char **hosts;
poptContext ctx;
if (g_getenv ("DOING_GDM_DEVELOPMENT") != NULL)
......@@ -947,7 +940,7 @@ main (int argc, char *argv[])
gdm_chooser_gui_init();
gdm_chooser_signals_init();
hosts = (gchar **) poptGetArgs (ctx);
hosts = poptGetArgs (ctx);
gdm_chooser_xdmcp_init (hosts);
poptFreeContext (ctx);
......
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