Bug: https://bugzilla.gnome.org/show_bug.cgi?id=615618
Author: Emilio Pozuelo Monfort <pochu27@gmail.com>

Use dynamic allocation rather than fixed MAXPATHLEN size buffers.
Fixes the build on GNU/Hurd where MAXPATHLEN is undefined.

diff -ruNp gnome-keyring-2.30.0/pam/gkr-pam-client.c gnome-keyring-2.30.0.new/pam/gkr-pam-client.c
--- gnome-keyring-2.30.0/pam/gkr-pam-client.c	2009-12-22 14:30:53.000000000 +0100
+++ gnome-keyring-2.30.0.new/pam/gkr-pam-client.c	2010-04-13 09:50:39.000000000 +0200
@@ -145,16 +145,17 @@ write_credentials_byte (int sock)
 static int
 connect_to_daemon (const char *control)
 {
-	char path[MAXPATHLEN];
+	char *path;
 	struct sockaddr_un addr;
 	struct stat st;
 	int sock;
 
-	/* Build up the directory name */
-	if (strlen (control) + strlen ("/control") + 1 >= MAXPATHLEN) {
-		syslog (GKR_LOG_ERR, "The gnome keyring socket directory is too long");
+	path = malloc (strlen (control) + strlen ("/control") + 1);
+	if (!path) {
+		syslog (GKR_LOG_ERR, "gkr-pam: out of memory");
 		return -1;
 	}
+
 	strcpy (path, control);
 	strcat (path, "/control");
 
@@ -162,18 +163,21 @@ connect_to_daemon (const char *control)
 	if (lstat (path, &st) < 0) {
 		syslog (GKR_LOG_ERR, "Couldn't access gnome keyring socket: %s: %s",
 		        path, strerror (errno));
+		free (path);
 		return -1;
 	}
 	
 	if (st.st_uid != geteuid ()) {
 		syslog (GKR_LOG_ERR, "The gnome keyring socket is not owned with the same "
 		        "credentials as the user login: %s", path);
+		free (path);
 		return -1;
 	}
 	
 	if (S_ISLNK(st.st_mode) || !S_ISSOCK(st.st_mode)) {
 		syslog (GKR_LOG_ERR, "The gnome keyring socket is not a valid simple "
 		        "non-linked socket");
+		free (path);
 		return -1;
 	}	
 	
@@ -185,6 +189,7 @@ connect_to_daemon (const char *control)
 	sock = socket (AF_UNIX, SOCK_STREAM, 0);
 	if (sock < 0) {
 		syslog (GKR_LOG_ERR, "couldn't create control socket: %s", strerror (errno));
+		free (path);
 		return -1;
 	}
 
@@ -195,6 +200,7 @@ connect_to_daemon (const char *control)
 		syslog (GKR_LOG_ERR, "couldn't connect to gnome-keyring-daemon socket at: %s: %s",
 		        path, strerror (errno));
 		close (sock);
+		free (path);
 		return -1;
 	}
 	
@@ -202,6 +208,7 @@ connect_to_daemon (const char *control)
 	
 	if (check_peer_same_uid (sock) <= 0) {
 		close (sock);
+		free (path);
 		return -1;
 	}
 	
@@ -209,6 +216,7 @@ connect_to_daemon (const char *control)
 	
 	if (write_credentials_byte (sock) < 0) {
 		close (sock);
+		free (path);
 		return -1;
 	}
 	
