summaryrefslogtreecommitdiffstats
path: root/tdesu/tdesud/secure.h
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2011-11-06 15:56:34 -0600
committerTimothy Pearson <[email protected]>2011-11-06 15:56:34 -0600
commitb529f046c9a64ac5fcfa60747af940cf972b3ebc (patch)
tree83c28cf7fa8fed1960ebd3924b579e7ed8c95cc6 /tdesu/tdesud/secure.h
parent6508fe4c40c60fd7a43bd3d9e19b762e10ea3f53 (diff)
downloadtdebase-b529f046c9a64ac5fcfa60747af940cf972b3ebc.tar.gz
tdebase-b529f046c9a64ac5fcfa60747af940cf972b3ebc.zip
Actually move the kde files that were renamed in the last commit
Diffstat (limited to 'tdesu/tdesud/secure.h')
-rw-r--r--tdesu/tdesud/secure.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/tdesu/tdesud/secure.h b/tdesu/tdesud/secure.h
new file mode 100644
index 000000000..edf58d9c6
--- /dev/null
+++ b/tdesu/tdesud/secure.h
@@ -0,0 +1,52 @@
+/* vi: ts=8 sts=4 sw=4
+ *
+ * This file is part of the KDE project, module tdesu.
+ * Copyright (C) 1999,2000 Geert Jansen <[email protected]>
+ */
+
+#ifndef __Secure_h_included__
+#define __Secure_h_included__
+
+#include "config.h"
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#ifndef HAVE_STRUCT_UCRED
+
+// `struct ucred' is not defined in glibc 2.0.
+
+struct ucred {
+ pid_t pid;
+ uid_t uid;
+ gid_t gid;
+};
+
+#endif // HAVE_STRUCT_UCRED
+
+
+/**
+ * The Socket_security class autheticates the peer for you. It provides
+ * the process-id, user-id and group-id plus the MD5 sum of the connected
+ * binary.
+ */
+
+class SocketSecurity {
+public:
+ SocketSecurity(int fd);
+
+ /** Returns the peer's process-id. */
+ int peerPid() { if (!ok) return -1; return cred.pid; }
+
+ /** Returns the peer's user-id */
+ int peerUid() { if (!ok) return -1; return cred.uid; }
+
+ /** Returns the peer's group-id */
+ int peerGid() { if (!ok) return -1; return cred.gid; }
+
+private:
+ bool ok;
+ struct ucred cred;
+};
+
+#endif