Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nadezhda Ivanova
OpenLDAP
Commits
eb41333e
Commit
eb41333e
authored
Dec 04, 2002
by
Kurt Zeilenga
Browse files
Use getpeereid(3) where available else use *_PEERCRED replacment function
parent
68658061
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
configure
View file @
eb41333e
This diff is collapsed.
Click to expand it.
configure.in
View file @
eb41333e
...
...
@@ -834,6 +834,7 @@ AC_CHECK_HEADERS( \
sys/syslog.h \
sys/time.h \
sys/types.h \
sys/ucred.h \
syslog.h \
termios.h \
unistd.h \
...
...
@@ -2478,11 +2479,14 @@ AC_CHECK_FUNCS( \
)
dnl We actually may need to replace more than this.
AC_REPLACE_FUNCS(getopt)
AC_REPLACE_FUNCS(getopt
getpeereid
)
if test "$ac_cv_func_getopt" != yes; then
LIBSRCS="$LIBSRCS getopt.c"
fi
if test "$ac_cv_func_getpeereid" != yes; then
LIBSRCS="$LIBSRCS getpeereid.c"
fi
if test "$ac_cv_func_snprintf" != yes -o "$ac_cv_func_vsnprintf" != yes; then
if test "$ac_cv_func_snprintf" != yes; then
AC_DEFINE(snprintf, ber_pvt_snprintf, [define to snprintf routine])
...
...
include/ac/assert.h
View file @
eb41333e
...
...
@@ -32,7 +32,7 @@
* create a replacement and hope it works
*/
LIB
LBER_F
(
void
)
ber_pvt_assert
LDAP_P
((
const
char
*
file
,
int
line
,
LBER_F
(
void
)
ber_pvt_assert
LDAP_P
((
const
char
*
file
,
int
line
,
const
char
*
test
));
/* Can't use LDAP_STRING(test), that'd expand to "test" */
...
...
include/ac/socket.h
View file @
eb41333e
...
...
@@ -197,8 +197,12 @@ LDAP_F (int) ldap_pvt_inet_aton LDAP_P(( const char *, struct in_addr * ));
# define AC_GAI_STRERROR(x) (gai_strerror((x)))
# else
# define AC_GAI_STRERROR(x) (ldap_pvt_gai_strerror((x)))
char
*
ldap_pvt_gai_strerror
(
int
);
LDAP_F
(
char
*
)
ldap_pvt_gai_strerror
(
int
);
# endif
#endif
#ifndef HAVE_GETPEEREID
LDAP_LUTIL_F
(
int
)
getpeereid
(
int
s
,
uid_t
*
,
gid_t
*
);
#endif
#endif
/* _AC_SOCKET_H_ */
include/portable.h.in
View file @
eb41333e
...
...
@@ -164,6 +164,9 @@
/* Define if you have the getpassphrase function. */
#undef HAVE_GETPASSPHRASE
/* Define if you have the getpeereid function. */
#undef HAVE_GETPEEREID
/* Define if you have the getpwnam function. */
#undef HAVE_GETPWNAM
...
...
@@ -542,6 +545,9 @@
/* Define if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define if you have the <sys/ucred.h> header file. */
#undef HAVE_SYS_UCRED_H
/* Define if you have the <sys/un.h> header file. */
#undef HAVE_SYS_UN_H
...
...
libraries/liblutil/getpeereid.c
0 → 100644
View file @
eb41333e
/* getpeereid.c */
/* $OpenLDAP$ */
/*
* Copyright 1998-2002 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
#include "portable.h"
#ifndef HAVE_GETPEEREID
#include <sys/types.h>
#include <ac/unistd.h>
#include <ac/socket.h>
#if HAVE_SYS_UCRED_H
#include <sys/ucred.h>
#endif
int
getpeereid
(
int
s
,
uid_t
*
euid
,
gid_t
*
egid
)
{
#ifdef LDAP_PF_LOCAL
#if defined( SO_PEERCRED )
struct
ucred
peercred
;
size_t
peercredlen
=
sizeof
peercred
;
if
((
getsockopt
(
s
,
SOL_SOCKET
,
SO_PEERCRED
,
(
void
*
)
&
peercred
,
&
peercredlen
)
==
0
)
&&
(
peercredlen
==
sizeof
peercred
))
{
*
euid
=
peercred
.
uid
;
*
egid
=
peercred
.
gid
;
return
0
;
}
#elif defined( LOCAL_PEERCRED )
struct
xucred
peercred
;
socklen_t
peercredlen
=
sizeof
peercred
;
if
((
getsockopt
(
s
,
LOCAL_PEERCRED
,
1
,
(
void
*
)
&
peercred
,
&
peercredlen
)
==
0
)
&&
(
peercred
.
cr_version
==
XUCRED_VERSION
))
{
*
euid
=
peercred
.
cr_uid
;
*
egid
=
peercred
.
cr_gid
;
return
0
;
}
#endif
#endif
return
-
1
;
}
#endif
servers/slapd/daemon.c
View file @
eb41333e
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment