[gnome-keyring: 1/3] [pam] Don't use MAXPATHLEN in pam module.



commit 5845892d3596491d1d8b06525b0642a0b49ec9d7
Author: Stef Walter <stef memberwebs com>
Date:   Sat Sep 11 21:02:06 2010 +0000

    [pam] Don't use MAXPATHLEN in pam module.
    
    MAXPATHLEN has been reintroduced. This patch makes use of dynamic allocation
    rather than fixed MAXPATHLEN size buffers, fixing the build on GNU/Hurd again.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=615618

 pam/gkr-pam-client.c |   31 ++++++++++++++-----------------
 1 files changed, 14 insertions(+), 17 deletions(-)
---
diff --git a/pam/gkr-pam-client.c b/pam/gkr-pam-client.c
index f505c3f..c23c984 100644
--- a/pam/gkr-pam-client.c
+++ b/pam/gkr-pam-client.c
@@ -145,29 +145,30 @@ write_credentials_byte (int sock)
 static int
 connect_to_daemon (const char *control)
 {
-	char path[MAXPATHLEN];
 	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");
+	addr.sun_family = AF_UNIX;
+	if (strlen (control) + strlen ("/control") + 1 > sizeof (addr.sun_path)) {
+		syslog (GKR_LOG_ERR, "gkr-pam: address is too long for unix socket path: %s/control",
+		        control);
 		return -1;
 	}
-	strcpy (path, control);
-	strcat (path, "/control");
+
+	strcpy (addr.sun_path, control);
+	strcat (addr.sun_path, "/control");
 
 	/* A bunch of checks to make sure nothing funny is going on */
-	if (lstat (path, &st) < 0) {
+	if (lstat (addr.sun_path, &st) < 0) {
 		syslog (GKR_LOG_ERR, "Couldn't access gnome keyring socket: %s: %s",
-		        path, strerror (errno));
+		        addr.sun_path, strerror (errno));
 		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);
+		        "credentials as the user login: %s", addr.sun_path);
 		return -1;
 	}
 	
@@ -175,13 +176,9 @@ connect_to_daemon (const char *control)
 		syslog (GKR_LOG_ERR, "The gnome keyring socket is not a valid simple "
 		        "non-linked socket");
 		return -1;
-	}	
-	
-	/* Now we connect */
+	}
 
-	addr.sun_family = AF_UNIX;
-	strncpy (addr.sun_path, path, sizeof (addr.sun_path));
-	
+	/* Now we connect */
 	sock = socket (AF_UNIX, SOCK_STREAM, 0);
 	if (sock < 0) {
 		syslog (GKR_LOG_ERR, "couldn't create control socket: %s", strerror (errno));
@@ -193,11 +190,11 @@ connect_to_daemon (const char *control)
 
 	if (connect (sock, (struct sockaddr*) &addr, sizeof (addr)) < 0) {
 		syslog (GKR_LOG_ERR, "couldn't connect to gnome-keyring-daemon socket at: %s: %s",
-		        path, strerror (errno));
+		        addr.sun_path, strerror (errno));
 		close (sock);
 		return -1;
 	}
-	
+
 	/* Verify the server is running as the right user */
 	
 	if (check_peer_same_uid (sock) <= 0) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]