Package: xfstt
Version: 1.2.1
Author: Guillem Jover <guillem@hadrons.org>
Status: applied
Description:
 Fix unix socket handling.

diff -Nurd xfstt-1.2.1/xfstt.cpp xfstt-1.2.1-patched/xfstt.cpp
--- xfstt-1.2.1/xfstt.cpp	Fri Mar 23 03:35:27 2001
+++ xfstt-1.2.1-patched/xfstt.cpp	Sun Jul 21 01:23:46 2002
@@ -78,6 +78,7 @@
 gid_t newgid = (uid_t)(-2);
 
 char *sockname;
+char *sockdir = "/tmp/.font-unix";
 
 #define MAXENC 16 /* Maximum number of encodings */
 Encoding *encodings[ MAXENC];
@@ -639,16 +640,15 @@
 
 	if( !sd_unix) {
 		// prepare unix connection
-		sd_unix = socket( AF_UNIX, SOCK_STREAM, 0);
+		sd_unix = socket( PF_UNIX, SOCK_STREAM, 0);
 
-		s_unix.sa_family = PF_UNIX;
-		sprintf( s_unix.sa_data, "fs%d", portno);
+		s_unix.sa_family = AF_UNIX;
+		sprintf( s_unix.sa_data, "%s/fs%d", sockdir, portno);
 		sockname =  s_unix.sa_data;
-		mkdir( "/tmp/.font-unix", 0766);
-		chdir( "/tmp/.font-unix");
+		mkdir( sockdir, 01777);
 		unlink( s_unix.sa_data);
 		if( bind( sd_unix, (struct sockaddr*)&s_unix, sizeof(s_unix))) {
-			fputs( "Couldn't write to /tmp/.font-unix/\n", stderr);
+			fprintf(stderr, "Couldn't write to %s/\n", sockdir);
 			fputs( "Please check permissions.\n", stderr);
 		}
 		listen( sd_unix, 1);	// only one connection
@@ -1531,11 +1531,9 @@
 {
 	unlink(PIDFILE);
 	if (sockname) {
-		chdir("/tmp/.font-unix"); 
 		unlink(sockname);
 		// delete the dir to if its empty
-		chdir("/tmp");
-		rmdir(".font-unix"); 
+		rmdir(sockdir);
 	}
 	exit(0);
 }
@@ -1693,18 +1691,11 @@
 		}
 		close( sd);
 	} while( multiConnection);
-	
-	/* - it seemed like a good idea at the time. How else can we handle
-		the case where a user runs xfstt for a single x session and
-		then another user wants to use it later?
- 
+
 	if (sockname) {
-		chdir( "/tmp/.font-unix");
 		unlink(sockname);
-		chdir("/tmp");
-		rmdir(".font-unix");
+		rmdir(sockdir);
 	}
-	*/
 
 	dprintf0( "xfstt: closing a connection\n");
 	cleanupMem();
