00001
00002
00003
00004
00005
00006
00007 #ifndef __Secure_h_included__
00008 #define __Secure_h_included__
00009
00010 #include "config.h"
00011
00012 #include <sys/types.h>
00013 #include <sys/socket.h>
00014
00015 #ifndef HAVE_STRUCT_UCRED
00016
00017
00018
00019 struct ucred {
00020 pid_t pid;
00021 uid_t uid;
00022 gid_t gid;
00023 };
00024
00025 #endif // HAVE_STRUCT_UCRED
00026
00027
00034 class SocketSecurity {
00035 public:
00036 SocketSecurity(int fd);
00037
00039 int peerPid() { if (!ok) return -1; return cred.pid; }
00040
00042 int peerUid() { if (!ok) return -1; return cred.uid; }
00043
00045 int peerGid() { if (!ok) return -1; return cred.gid; }
00046
00047 private:
00048 bool ok;
00049 struct ucred cred;
00050 };
00051
00052 #endif