fam
[Top] [All Lists]

[fam] [Patch] Fam leaving .fam files in /tmp

To: <fam@xxxxxxxxxxx>
Subject: [fam] [Patch] Fam leaving .fam files in /tmp
From: Alex Larsson <alexl@xxxxxxxxxx>
Date: Tue, 15 Jan 2002 12:00:59 -0500 (EST)
Sender: owner-fam@xxxxxxxxxxx
I've gotten bugreports (and noticed myself) that fam leaves lots of 
.famXXX type files in /tmp. These should have been removed by the 
LocalClient destructor, but perhaps they didn't due to fam abruptly 
quiting or something.

Anyway, here is a patch that should fix this problem. We don't really need 
the name of the socket after the client has connected. I applied it to the 
current Red Hat RPM.

/ Alex

--- fam-2.6.7/fam/Listener.c++.cleanup  Mon Dec 17 20:03:37 2001
+++ fam-2.6.7/fam/Listener.c++  Tue Jan 15 11:44:45 2002
@@ -287,10 +287,18 @@
     //  Keep the scheduler from helpfully cleaning this up.
     Scheduler::remove_onetime_task(cleanup_negotiation, nc);
 
+    //  Remove the temp file
+    uid_t preveuid = geteuid();
+    if (preveuid) seteuid(0);
+    seteuid(nc->uid);
+    unlink(nc->sun.sun_path);
+    if (nc->uid) seteuid(0);
+    seteuid(preveuid);
+
     Log::debug("client fd %d is local/trusted (socket %s, uid %d).",
                client_fd, nc->sun.sun_path, nc->uid);
     Cred cred(nc->uid, client_fd);
-    new LocalClient(client_fd, &(nc->sun), cred);
+    new LocalClient(client_fd, cred);
     // We don't need a reference to this object.  The constructor
     // takes care of registering it with the Scheduler.
 
--- fam-2.6.7/fam/LocalClient.c++.cleanup       Mon Dec 17 20:03:37 2001
+++ fam-2.6.7/fam/LocalClient.c++       Tue Jan 15 11:43:04 2002
@@ -29,17 +29,12 @@
 #include "Log.h"
 #include "Cred.h"
 
-LocalClient::LocalClient(int fd, const struct sockaddr_un *addr, Cred &cred)
+LocalClient::LocalClient(int fd, Cred &cred)
 : TCP_Client(LOCALHOST(), fd, cred)
 {
     assert(cred.is_valid());
-    sun.sun_family = AF_UNIX;
-    strncpy(sun.sun_path, addr->sun_path, sizeof(sun.sun_path));
-    sun.sun_path[sizeof(sun.sun_path) - 1] = '\0';
 }
 
 LocalClient::~LocalClient()
 {
-    if (geteuid() != cred.uid()) cred.become_user();
-    unlink(sun.sun_path);
 }
--- fam-2.6.7/fam/LocalClient.h.cleanup Mon Dec 17 20:03:37 2001
+++ fam-2.6.7/fam/LocalClient.h Tue Jan 15 11:43:04 2002
@@ -33,13 +33,8 @@
 
 public:
 
-    LocalClient(int fd, const struct sockaddr_un *addr, Cred &cred);
+    LocalClient(int fd, Cred &cred);
     ~LocalClient();
-
-private:
-
-    struct sockaddr_un sun;
-
 };
 
 #endif /* !RemoteClient_included */


--
Source code, list archive, and docs: http://oss.sgi.com/projects/fam/
To unsubscribe: echo unsubscribe fam | mail majordomo@xxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>
  • [fam] [Patch] Fam leaving .fam files in /tmp, Alex Larsson <=