File cleanup.patch of Package fam
diff -uNrb fam-2.7.0/src/Listener.c++ fam-2.7.0.cleanup/src/Listener.c++
--- fam-2.7.0/src/Listener.c++ 2003-04-15 06:52:40.000000000 +0200
+++ fam-2.7.0.cleanup/src/Listener.c++ 2003-11-17 11:09:36.000000000 +0100
@@ -299,10 +299,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.
diff -uNrb fam-2.7.0/src/LocalClient.c++ fam-2.7.0.cleanup/src/LocalClient.c++
--- fam-2.7.0/src/LocalClient.c++ 2003-04-15 06:21:35.000000000 +0200
+++ fam-2.7.0.cleanup/src/LocalClient.c++ 2003-11-17 11:09:36.000000000 +0100
@@ -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);
}
diff -uNrb fam-2.7.0/src/LocalClient.h fam-2.7.0.cleanup/src/LocalClient.h
--- fam-2.7.0/src/LocalClient.h 2003-04-15 06:21:35.000000000 +0200
+++ fam-2.7.0.cleanup/src/LocalClient.h 2003-11-17 11:09:36.000000000 +0100
@@ -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 */