summaryrefslogtreecommitdiff
path: root/src/libstddjb/getpeereid.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-12-21 11:18:28 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-12-21 11:18:28 +0000
commit2990ce9b390ec1e2bfa1c043c406878e8aff86dd (patch)
tree270e5e2bfa3cdb2fc795039fc45901d93290567e /src/libstddjb/getpeereid.c
parent933e986a9207d2b61c5119e18603b44b924e7226 (diff)
downloadskalibs-2990ce9b390ec1e2bfa1c043c406878e8aff86dd.tar.xz
Big 2.6.3.0 reorganization
- Add libposixplz, update headers - Add memmem and friends - Add textmessage to libunixonacid - Update some sysdeps tests
Diffstat (limited to 'src/libstddjb/getpeereid.c')
-rw-r--r--src/libstddjb/getpeereid.c66
1 files changed, 0 insertions, 66 deletions
diff --git a/src/libstddjb/getpeereid.c b/src/libstddjb/getpeereid.c
deleted file mode 100644
index 0d36abb..0000000
--- a/src/libstddjb/getpeereid.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/* ISC license. */
-
-#include <skalibs/sysdeps.h>
-
-#ifdef SKALIBS_HASGETPEEREID
-/* syscall exists - do nothing */
-
-#else
-
-#ifdef SKALIBS_HASSOPEERCRED
-/* implementation with SO_PEERCRED */
-
-#include <skalibs/nonposix.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <skalibs/getpeereid.h>
-
-int getpeereid (int s, uid_t *u, gid_t *g)
-{
- struct ucred blah ;
- socklen_t len = sizeof(blah) ;
-
- if (getsockopt(s, SOL_SOCKET, SO_PEERCRED, &blah, &len) == -1)
- return -1 ;
- *u = blah.uid ;
- *g = blah.gid ;
- return 0 ;
-}
-
-#else
-
-#ifdef SKALIBS_HASGETPEERUCRED
-/* implementation with getpeerucred() */
-
-#include <skalibs/nonposix.h>
-#include <ucred.h>
-#include <skalibs/getpeereid.h>
-
-int getpeereid (int s, uid_t *u, gid_t *g)
-{
- ucred_t *cred ;
- if (getpeerucred(s, &cred) == -1) return -1 ;
- *u = ucred_geteuid(cred) ;
- *g = ucred_getegid(cred) ;
- ucred_free(cred) ;
- return 0 ;
-}
-
-#else
-
-/* can't find a real implementation, make a stub */
-
-#include <errno.h>
-#include <skalibs/getpeereid.h>
-
-int getpeereid (int s, uid_t *uid, gid_t *gid)
-{
- (void)s ;
- *uid = *gid = -1 ;
- errno = ENOSYS ;
- return -1 ;
-}
-
-#endif
-#endif
-#endif