summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog22
-rw-r--r--NEWS2
-rw-r--r--TODO3
-rw-r--r--daemon/auth.c11
-rw-r--r--daemon/choose.c2
-rw-r--r--daemon/cookie.c3
-rw-r--r--daemon/display.c1
-rw-r--r--daemon/gdm.c33
-rw-r--r--daemon/gdm.h2
-rw-r--r--daemon/server.c10
-rw-r--r--daemon/slave.c2
-rw-r--r--daemon/verify-pam.c9
-rw-r--r--daemon/xdmcp.c55
-rw-r--r--docs/C/gdm.sgml6
-rw-r--r--gui/gdmflexiserver.c6
-rw-r--r--gui/gdmlogin.c21
16 files changed, 155 insertions, 33 deletions
diff --git a/ChangeLog b/ChangeLog
index efbe2b86..cdcbdaf1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+Sat Sep 01 00:47:36 2001 George Lebl <jirka@5z.com>
+
+ * daemon/xdmcp.c, daemon/gdm.[ch], daemon/server.c: Implement
+ DisplaysPerHost which was documented so it should have worked
+ in the first place
+
+ * daemon/xdmcp.c, daemon/server.c, daemon/auth.c, daemon/gdm.c,
+ daemon/choose.c, daemon/cookie.c, daemon/display.c, daemon/slave.c,
+ gui/gdmlogin.c: fix some memleaks, none really dangerous
+
+ * daemon/xdmcp.c: messages such as status information shouldn't be
+ translated. Because they go over a wire with no specification of
+ charset or language.
+
+ * gui/gdmlogin.c: Fix broken "session don't exist wanna save new one"
+ message
+
+ * daemon/gdm.c: Make sure static display numbers are unique.
+ and fix a possible crash in flexible server code
+
+ * docs/C/gdm.sgml: a small update
+
Fri Aug 31 20:22:33 2001 George Lebl <jirka@5z.com>
* docs/C/gdm.sgml: Update for all the server def stuff.
diff --git a/NEWS b/NEWS
index 1486ac6e..9d3d6355 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,8 @@ Ahh news...
- The reference doc updated a tad, still somewhat out of date,
the configurator documentation has not been updated however.
+- Many, many fixes mostly leaks, some minor some bigger
+
2.2.4.0 stuff:
- New unix socket protocol for controlling the daemon from outside.
diff --git a/TODO b/TODO
index 4a855b5a..8e35f54d 100644
--- a/TODO
+++ b/TODO
@@ -21,7 +21,4 @@ handle all the XFree86 Xserver error thingies, such as
No "Display" subsection for
etc...
-Implement DisplaysPerHost (GdmDispPerHost), it's documented,
-and just isn't used.
-
Exclude below PID
diff --git a/daemon/auth.c b/daemon/auth.c
index dcbe667c..f6cdaa99 100644
--- a/daemon/auth.c
+++ b/daemon/auth.c
@@ -67,8 +67,10 @@ add_auth_entry (GdmDisplay *d, FILE *af,
xa->family = family;
xa->address = malloc (addrlen);
- if (xa->address == NULL)
+ if (xa->address == NULL) {
+ free (xa);
return FALSE;
+ }
memcpy (xa->address, addr, addrlen);
xa->address_length = addrlen;
xa->number = strdup (dispnum);
@@ -76,8 +78,13 @@ add_auth_entry (GdmDisplay *d, FILE *af,
xa->name = strdup ("MIT-MAGIC-COOKIE-1");
xa->name_length = strlen ("MIT-MAGIC-COOKIE-1");
xa->data = malloc (16);
- if (xa->data == NULL)
+ if (xa->data == NULL) {
+ free (xa->number);
+ free (xa->name);
+ free (xa->address);
+ free (xa);
return FALSE;
+ }
memcpy (xa->data, d->bcookie, 16);
xa->data_length = 16;
diff --git a/daemon/choose.c b/daemon/choose.c
index 7b73521e..1f8701e7 100644
--- a/daemon/choose.c
+++ b/daemon/choose.c
@@ -105,6 +105,8 @@ gdm_choose_data (const char *data)
return FALSE;
}
+ g_free (msg);
+
gdm_debug ("gdm_choose_data: got indirect id: %d address: %s",
id, inet_ntoa (addr));
diff --git a/daemon/cookie.c b/daemon/cookie.c
index 7c322ff1..7a440a12 100644
--- a/daemon/cookie.c
+++ b/daemon/cookie.c
@@ -24,6 +24,7 @@
*
*/
+#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
@@ -102,7 +103,9 @@ gdm_cookie_generate (GdmDisplay *d)
strcat (cookie, sub);
}
+ g_free (d->cookie);
d->cookie = g_strdup (cookie);
+ g_free (d->bcookie);
d->bcookie = g_new (char, 16);
memcpy (d->bcookie, digest, 16);
}
diff --git a/daemon/display.c b/daemon/display.c
index becf1003..40be93bd 100644
--- a/daemon/display.c
+++ b/daemon/display.c
@@ -305,6 +305,7 @@ gdm_display_dispose (GdmDisplay *d)
while (tmpauth && tmpauth->data) {
XauDisposeAuth ((Xauth *) tmpauth->data);
+ tmpauth->data = NULL;
tmpauth = tmpauth->next;
}
diff --git a/daemon/gdm.c b/daemon/gdm.c
index e5866760..1ce5aa3d 100644
--- a/daemon/gdm.c
+++ b/daemon/gdm.c
@@ -157,6 +157,19 @@ char *stored_path = NULL;
static gboolean gdm_restart_mode = FALSE;
+static gboolean
+display_exists (int num)
+{
+ GSList *li;
+
+ for (li = displays; li != NULL; li = li->next) {
+ GdmDisplay *disp = li->data;
+ if (disp->dispnum == num)
+ return TRUE;
+ }
+ return FALSE;
+}
+
/**
* gdm_config_parse:
@@ -246,8 +259,10 @@ gdm_config_parse (void)
GdmWilling = gnome_config_get_string (GDM_KEY_WILLING);
GdmStandardXServer = gnome_config_get_string (GDM_KEY_STANDARD_XSERVER);
- if (ve_string_empty (GdmStandardXServer))
+ if (ve_string_empty (GdmStandardXServer)) {
+ g_free (GdmStandardXServer);
GdmStandardXServer = g_strdup ("/usr/bin/X11/X");
+ }
GdmFlexibleXServers = gnome_config_get_int (GDM_KEY_FLEXIBLE_XSERVERS);
GdmXnest = gnome_config_get_string (GDM_KEY_XNEST);
if (ve_string_empty (GdmXnest))
@@ -375,7 +390,18 @@ gdm_config_parse (void)
while (iter) {
if (isdigit (*k)) {
int disp_num = atoi (k);
- GdmDisplay *disp = gdm_server_alloc (disp_num, v);
+ GdmDisplay *disp;
+
+ while (display_exists (disp_num)) {
+ disp_num++;
+ }
+
+ if (disp_num != atoi (k)) {
+ gdm_error (_("%s: Display number %d in use! I will use %d"),
+ "gdm_config_parse", atoi (k), disp_num);
+ }
+
+ disp = gdm_server_alloc (disp_num, v);
if (disp == NULL) {
g_free (k);
g_free (v);
@@ -1705,6 +1731,7 @@ gdm_handle_message (GdmConnection *conn, const char *msg, gpointer data)
NULL, NULL);
if ( ! gdm_connection_write (conn, msg))
gdm_display_unmanage (d);
+ g_free (msg);
}
gdm_debug ("Got FLEXI_OK");
@@ -1925,7 +1952,6 @@ gdm_handle_user_message (GdmConnection *conn, const char *msg, gpointer data)
}
svr = gdm_find_x_server (name);
- g_free (name);
if (svr == NULL) {
/* Don't print the name to syslog as it might be
* long and dangerous */
@@ -1940,6 +1966,7 @@ gdm_handle_user_message (GdmConnection *conn, const char *msg, gpointer data)
} else {
command = svr->command;
}
+ g_free (name);
handle_flexi_server (conn, TYPE_FLEXI, command, NULL, NULL);
} else if (strncmp (msg, GDM_SUP_FLEXI_XNEST " ",
diff --git a/daemon/gdm.h b/daemon/gdm.h
index f58d8b03..94c215ba 100644
--- a/daemon/gdm.h
+++ b/daemon/gdm.h
@@ -23,6 +23,7 @@
#include <X11/Xlib.h>
#include <X11/Xmd.h>
#include <X11/Xauth.h>
+#include <netinet/in.h>
#define STX 0x2 /* Start of txt */
#define BEL 0x7 /* Bell, used to interrupt login for
@@ -254,6 +255,7 @@ struct _GdmDisplay {
gchar *bcookie;
gchar *name;
gchar *hostname;
+ struct in_addr addr;
guint8 dispstat;
guint16 dispnum;
guint8 servstat;
diff --git a/daemon/server.c b/daemon/server.c
index 960bd180..f560f7c9 100644
--- a/daemon/server.c
+++ b/daemon/server.c
@@ -730,12 +730,14 @@ gdm_server_child_handler (gint signal)
GdmDisplay *
gdm_server_alloc (gint id, const gchar *command)
{
- gchar *hostname = g_new0 (gchar, 1024);
- GdmDisplay *d = g_new0 (GdmDisplay, 1);
+ gchar hostname[1024];
+ GdmDisplay *d;
if (gethostname (hostname, 1023) == -1)
return NULL;
+ d = g_new0 (GdmDisplay, 1);
+
d->authfile = NULL;
d->auths = NULL;
d->userauth = NULL;
@@ -745,6 +747,8 @@ gdm_server_alloc (gint id, const gchar *command)
d->greetpid = 0;
d->name = g_strdup_printf (":%d", id);
d->hostname = g_strdup (hostname);
+ /* Not really used for not XDMCP */
+ memset (&(d->addr), 0, sizeof (struct in_addr));
d->dispnum = id;
d->servpid = 0;
d->servstat = SERVER_DEAD;
@@ -771,8 +775,6 @@ gdm_server_alloc (gint id, const gchar *command)
d->timed_login_ok = FALSE;
- g_free (hostname);
-
return d;
}
diff --git a/daemon/slave.c b/daemon/slave.c
index 316c7787..72882976 100644
--- a/daemon/slave.c
+++ b/daemon/slave.c
@@ -1557,6 +1557,8 @@ gdm_get_sessions (struct passwd *pwent)
g_string_append (sessions, def);
}
+ g_free (def);
+
seteuid (0);
setegid (GdmGroupId);
diff --git a/daemon/verify-pam.c b/daemon/verify-pam.c
index 137662b9..eed98d01 100644
--- a/daemon/verify-pam.c
+++ b/daemon/verify-pam.c
@@ -77,7 +77,7 @@ gdm_verify_pam_conv (int num_msg, const struct pam_message **msg,
return PAM_CONV_ERR;
}
reply[replies].resp_retcode = PAM_SUCCESS;
- reply[replies].resp = strdup (s != NULL ? s : "");
+ reply[replies].resp = strdup (ve_sure_string (s));
g_free (s);
break;
@@ -90,7 +90,7 @@ gdm_verify_pam_conv (int num_msg, const struct pam_message **msg,
return PAM_CONV_ERR;
}
reply[replies].resp_retcode = PAM_SUCCESS;
- reply[replies].resp = strdup (s != NULL ? s : "");
+ reply[replies].resp = strdup (ve_sure_string (s));
g_free (s);
break;
@@ -295,7 +295,7 @@ gdm_verify_user (const char *username,
}
/*sleep (3);
- gdm_slave_greeter_ctl_no_ret (GDM_MSGERR, _("Please enter your login"));*/
+ gdm_slave_greeter_ctl_no_ret (GDM_MSGERR, _("Please enter your username"));*/
}
pam_end (pamh, pamerr);
@@ -308,6 +308,8 @@ gdm_verify_user (const char *username,
current_login = NULL;
g_free (current_display);
current_display = NULL;
+
+ g_free (login);
return NULL;
}
@@ -499,6 +501,7 @@ gdm_verify_open_session (void)
}
/* Migrate any PAM env. variables to the user's environment */
+ /* This leaks, oh well */
if ((pamenv = pam_getenvlist (pamh))) {
gint i;
diff --git a/daemon/xdmcp.c b/daemon/xdmcp.c
index 450d3982..0974bc52 100644
--- a/daemon/xdmcp.c
+++ b/daemon/xdmcp.c
@@ -156,10 +156,11 @@ static void gdm_xdmcp_send_failed (struct sockaddr_in *clnt_sa, CARD32 sessid);
static void gdm_xdmcp_send_alive (struct sockaddr_in *clnt_sa, CARD32 sessid);
static void gdm_xdmcp_send_managed_forward (struct sockaddr_in *clnt_sa);
static gboolean gdm_xdmcp_host_allow (struct sockaddr_in *cnlt_sa);
-static GdmDisplay *gdm_xdmcp_display_alloc (const char *hostname, gint);
+static GdmDisplay *gdm_xdmcp_display_alloc (struct in_addr *addr, const char *hostname, gint);
static GdmDisplay *gdm_xdmcp_display_lookup (CARD32 sessid);
static void gdm_xdmcp_display_dispose_check (const gchar *name);
static void gdm_xdmcp_displays_check (void);
+static int gdm_xdmcp_displays_from_host (struct in_addr *addr);
static GdmForwardQuery * gdm_forward_query_alloc (struct sockaddr_in *mgr_sa,
struct sockaddr_in *dsp_sa);
@@ -233,6 +234,7 @@ peek_local_address_list (void)
if (ioctl (xdmcpfd, SIOCGIFCONF, &ifc) < 0) {
gdm_error (_("%s: Cannot get local addresses!"),
"peek_local_address_list");
+ g_free (buf);
return NULL;
}
@@ -289,6 +291,22 @@ peek_local_address_list (void)
return the_list;
}
+static int
+gdm_xdmcp_displays_from_host (struct in_addr *addr)
+{
+ GSList *li;
+ int count = 0;
+
+ for (li = displays; li != NULL; li = li->next) {
+ GdmDisplay *disp = li->data;
+ if (disp->type == TYPE_XDMCP &&
+ memcmp (&disp->addr, addr, sizeof (struct in_addr)) == 0)
+ count ++;
+ }
+
+ return count;
+}
+
static gboolean
is_loopback_addr (struct in_addr *ia)
@@ -863,8 +881,15 @@ gdm_xdmcp_send_willing (struct sockaddr_in *clnt_sa)
last_willing = time (NULL);
}
- status.data = last_status;
- status.length = strlen (last_status);
+ if ( ! is_local_addr (&(clnt_sa->sin_addr)) &&
+ gdm_xdmcp_displays_from_host (&(clnt_sa->sin_addr)) >= GdmDispPerHost) {
+ /* Don't translate, this goes over the wire to servers where we
+ * don't know the charset or language, so it must be ascii */
+ status.data = g_strdup_printf ("%s (Server is busy)", last_status);
+ } else {
+ status.data = g_strdup (last_status);
+ }
+ status.length = strlen (status.data);
header.opcode = (CARD16) WILLING;
header.length = 6 + serv_authlist.authentication.length;
@@ -877,6 +902,8 @@ gdm_xdmcp_send_willing (struct sockaddr_in *clnt_sa)
XdmcpWriteARRAY8 (&buf, &status);
XdmcpFlush (xdmcpfd, &buf, (XdmcpNetaddr)clnt_sa,
(int)sizeof (struct sockaddr_in));
+
+ g_free (status.data);
}
static void
@@ -889,7 +916,9 @@ gdm_xdmcp_send_unwilling (struct sockaddr_in *clnt_sa, gint type)
gdm_error (_("Denied XDMCP query from host %s"), inet_ntoa (clnt_sa->sin_addr));
- status.data = _("Display not authorized to connect");
+ /* Don't translate, this goes over the wire to servers where we
+ * don't know the charset or language, so it must be ascii */
+ status.data = "Display not authorized to connect";
status.length = strlen (status.data);
header.opcode = (CARD16) UNWILLING;
@@ -908,12 +937,12 @@ gdm_xdmcp_send_managed_forward (struct sockaddr_in *clnt_sa)
{
ARRAY8 hostname;
XdmcpHeader header;
+ char buffer[1024] = "";
gdm_debug ("gdm_xdmcp_send_managed_forward: Sending MANAGED_FORWARD to %s", inet_ntoa (clnt_sa->sin_addr));
- hostname.data = g_new0 (char, 1024);
+ hostname.data = buffer;
if (gethostname (hostname.data, 1023) != 0) {
- g_free (hostname.data);
/* eek ! */
return;
}
@@ -1063,9 +1092,12 @@ gdm_xdmcp_handle_request (struct sockaddr_in *clnt_sa, gint len)
gdm_debug ("gdm_xdmcp_handle_request: pending=%d, MaxPending=%d, sessions=%d, MaxSessions=%d",
pending, GdmMaxPending, sessions, GdmMaxSessions);
+
/* Check if ok to manage display */
if (mitauth &&
- sessions < GdmMaxSessions) {
+ sessions < GdmMaxSessions &&
+ (is_local_addr (&(clnt_sa->sin_addr)) ||
+ gdm_xdmcp_displays_from_host (&(clnt_sa->sin_addr)) < GdmDispPerHost)) {
char *disp;
char *hostname = get_host_from_addr (clnt_sa);
disp = g_strdup_printf ("%s:%d", hostname, clnt_dspnum);
@@ -1107,7 +1139,7 @@ gdm_xdmcp_send_accept (const char *hostname,
ARRAY8 authdata;
GdmDisplay *d;
- d = gdm_xdmcp_display_alloc (hostname, displaynum);
+ d = gdm_xdmcp_display_alloc (&(clnt_sa->sin_addr), hostname, displaynum);
authentype.data = (CARD8 *) 0;
authentype.length = (CARD16) 0;
@@ -1162,6 +1194,8 @@ gdm_xdmcp_send_decline (struct sockaddr_in *clnt_sa)
authendata.data = (CARD8 *) 0;
authendata.length = (CARD16) 0;
+ /* Don't translate, this goes over the wire to servers where we
+ * don't know the charset or language, so it must be ascii */
status.data = "Session refused";
status.length = strlen (status.data);
@@ -1346,6 +1380,8 @@ gdm_xdmcp_send_failed (struct sockaddr_in *clnt_sa, CARD32 sessid)
gdm_debug ("gdm_xdmcp_send_failed: Sending FAILED to %ld", (long)sessid);
+ /* Don't translate, this goes over the wire to servers where we
+ * don't know the charset or language, so it must be ascii */
status.data = "Failed to start session";
status.length = strlen (status.data);
@@ -1441,7 +1477,7 @@ gdm_xdmcp_host_allow (struct sockaddr_in *clnt_sa)
static GdmDisplay *
-gdm_xdmcp_display_alloc (const char *hostname, gint displaynum)
+gdm_xdmcp_display_alloc (struct in_addr *addr, const char *hostname, gint displaynum)
{
GdmDisplay *d = NULL;
@@ -1481,6 +1517,7 @@ gdm_xdmcp_display_alloc (const char *hostname, gint displaynum)
d->name = g_strdup_printf ("%s:%d", hostname,
displaynum);
d->hostname = g_strdup (hostname);
+ memcpy (&d->addr, addr, sizeof (struct in_addr));
/* Secure display with cookie */
if (! gdm_auth_secure_display (d))
diff --git a/docs/C/gdm.sgml b/docs/C/gdm.sgml
index bbfefb35..423334da 100644
--- a/docs/C/gdm.sgml
+++ b/docs/C/gdm.sgml
@@ -1118,6 +1118,12 @@
services to machines with more than one screen, you
should increase the DisplaysPerHost value accordingly.
</para>
+
+ <para>
+ Note that the number of connections from the local
+ machine is unlimited. Only remote connections
+ are limited by this number.
+ </para>
</listitem>
</varlistentry>
diff --git a/gui/gdmflexiserver.c b/gui/gdmflexiserver.c
index 91319a63..05f9c337 100644
--- a/gui/gdmflexiserver.c
+++ b/gui/gdmflexiserver.c
@@ -41,6 +41,7 @@
static GSList *xservers = NULL;
static gboolean got_standard = FALSE;
static gboolean use_xnest = FALSE;
+static gboolean authenticate = FALSE;
static const char *send_command = NULL;
static const char *server = NULL;
static const char *chosen_server = NULL;
@@ -414,6 +415,7 @@ struct poptOption options [] = {
{ "command", 'c', POPT_ARG_STRING, &send_command, 0, N_("Send the specified protocol command to gdm"), N_("COMMAND") },
{ "xnest", 'n', POPT_ARG_NONE, &use_xnest, 0, N_("Xnest mode"), NULL },
{ "debug", 'd', POPT_ARG_NONE, &debug, 0, N_("Debugging output"), NULL },
+ { "authenticate", 'a', POPT_ARG_NONE, &authenticate, 0, N_("Authenticate before running --command"), NULL },
POPT_AUTOHELP
{ NULL, 0, 0, NULL, 0}
};
@@ -477,7 +479,9 @@ main (int argc, char *argv[])
}
if (send_command != NULL) {
- ret = call_gdm (send_command, NULL /* auth cookie */,
+ if (authenticate)
+ auth_cookie = get_auth_cookie ();
+ ret = call_gdm (send_command, auth_cookie,
"2.2.4.0", 5);
if (ret != NULL) {
g_print ("%s\n", ret);
diff --git a/gui/gdmlogin.c b/gui/gdmlogin.c
index b3b40b1f..70ec022f 100644
--- a/gui/gdmlogin.c
+++ b/gui/gdmlogin.c
@@ -484,6 +484,8 @@ gdm_login_abort (const gchar *format, ...)
syslog (LOG_ERR, "%s", s);
closelog();
+ g_free (s);
+
kill_thingies ();
_exit (DISPLAY_ABORT);
}
@@ -494,7 +496,7 @@ static gchar *
gdm_parse_enriched_string (const gchar *s)
{
gchar cmd, *buffer;
- gchar hostbuf[256];
+ gchar hostbuf[256] = "";
gchar *hostname, *display;
struct utsname name;
GString *str;
@@ -507,12 +509,11 @@ gdm_parse_enriched_string (const gchar *s)
if (display == NULL)
return(NULL);
- gethostname (hostbuf, 255);
- hostname = g_strdup (hostbuf);
+ if (gethostname (hostbuf, sizeof (hostbuf) - 1) < 0)
+ hostname = g_strdup ("Gnome");
+ else
+ hostname = g_strdup (hostbuf);
- if (hostname == NULL)
- hostname = g_strdup ("Gnome");
-
uname (&name);
/* HAAAAAAAAAAAAAAAAAAAAAAAACK!, do not translate the next line!,
@@ -930,10 +931,13 @@ gdm_login_session_lookup (const gchar* savedsess)
g_free (session);
session = g_strdup (defsess);
- msg = g_strdup_printf (_("Your preferred session type %s is not installed on this machine.\n" \
- "Do you wish to make %s the default for future sessions?"),
+ msg = g_strdup_printf (_("Your preferred session type %s is not "
+ "installed on this machine.\n"
+ "Do you wish to make %s the default for "
+ "future sessions?"),
translate_session (savedsess),
translate_session (defsess));
+ savesess = gdm_login_query (msg);
g_free (msg);
}
}
@@ -2001,6 +2005,7 @@ gdm_login_ctrl_handler (GIOChannel *source, GIOCondition cond, gint fd)
char *newtext;
newtext = g_strdup_printf ("%s\n%s", oldtext, buf);
gtk_label_set (GTK_LABEL (msg), newtext);
+ g_free (newtext);
} else {
gtk_label_set (GTK_LABEL (msg), buf);
}