diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 4aed2c8219774f5d797760606b8489a92ddc5163 (patch) | |
tree | 3f8c130f7d269626bf6a9447407ef6c35954426a /kdesu/kdesud/secure.h | |
download | tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdesu/kdesud/secure.h')
-rw-r--r-- | kdesu/kdesud/secure.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/kdesu/kdesud/secure.h b/kdesu/kdesud/secure.h new file mode 100644 index 000000000..8e122fac3 --- /dev/null +++ b/kdesu/kdesud/secure.h @@ -0,0 +1,52 @@ +/* vi: ts=8 sts=4 sw=4 + * + * This file is part of the KDE project, module kdesu. + * Copyright (C) 1999,2000 Geert Jansen <jansen@kde.org> + */ + +#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 |