Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Nadezhda Ivanova
OpenLDAP
Commits
b76c56ba
Commit
b76c56ba
authored
Oct 21, 1998
by
Kurt Zeilenga
Browse files
include portable.h
parent
c7fe14a9
Changes
125
Hide whitespace changes
Inline
Side-by-side
acconfig.h
View file @
b76c56ba
...
...
@@ -5,6 +5,9 @@
Leave the following blank line there!! Autoheader needs it. */
/* define this if toupper() requires tolower() check */
#undef C_UPPER_LOWER
/* define this if sys_errlist is not defined in stdio.h or errno.h */
#undef DECL_SYS_ERRLIST
...
...
aclocal.m4
View file @
b76c56ba
...
...
@@ -113,7 +113,7 @@ AC_DEFUN([OL_BERKELEY_DB2],
fi
])
if test $ol_cv_berkeley_db2 = yes ; then
AC_DEFINE(HAVE_BERKELEY_DB2)
AC_DEFINE(HAVE_BERKELEY_DB2
,1
)
fi
])dnl
dnl
...
...
@@ -179,7 +179,7 @@ AC_DEFUN([OL_BERKELEY_DB],
fi
])
if test $ol_cv_berkeley_db = yes ; then
AC_DEFINE(HAVE_BERKELEY_DB)
AC_DEFINE(HAVE_BERKELEY_DB
,1
)
fi
])dnl
dnl
...
...
@@ -224,7 +224,7 @@ AC_DEFUN([OL_GDBM],
fi
])
if test $ol_cv_gdbm = yes ; then
AC_DEFINE(HAVE_GDBM)
AC_DEFINE(HAVE_GDBM
,1
)
fi
])dnl
dnl
...
...
@@ -280,7 +280,7 @@ AC_DEFUN([OL_NDBM],
fi
])
if test $ol_cv_ndbm = yes ; then
AC_DEFINE(HAVE_NDBM)
AC_DEFINE(HAVE_NDBM
,1
)
fi
])dnl
dnl
...
...
@@ -340,6 +340,30 @@ AC_CACHE_CHECK([for LinuxThreads], [ol_cv_linux_threads], [
])
])dnl
dnl
dnl ====================================================================
dnl Check if toupper() requires islower() to be called first
AC_DEFUN([OL_C_UPPER_LOWER],
[
AC_MSG_CHECKING([if toupper() requires islower()])
AC_CACHE_VAL(ol_cv_c_upper_lower,[
AC_TRY_RUN([
#include <ctypes.h>
main()
{
if ('C' == toupper('C'))
exit 0;
else
exit 1;
}],
[ol_cv_c_upper_lower=no],
[ol_cv_c_upper_lower=yes],
[ol_cv_c_upper_lower=safe])])
AC_MSG_RESULT($ol_cv_c_upper_lower)
if test $ol_cv_c_upper_lower != no ; then
AC_DEFINE(C_UPPER_LOWER,1)
fi
])
dnl ====================================================================
dnl Check for declaration of sys_errlist in one of stdio.h and errno.h.
dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration.
...
...
@@ -359,7 +383,7 @@ AC_MSG_RESULT($ol_cv_dcl_sys_errlist)
# It's possible (for near-UNIX clones) that sys_errlist doesn't exist
if test $ol_cv_dcl_sys_errlist = no ; then
AC_DEFINE(DECL_SYS_ERRLIST)
AC_DEFINE(DECL_SYS_ERRLIST
,1
)
AC_MSG_CHECKING([existence of sys_errlist])
AC_CACHE_VAL(ol_cv_have_sys_errlist,[
AC_TRY_LINK([#include <errno.h>],
...
...
configure
View file @
b76c56ba
...
...
@@ -5430,103 +5430,58 @@ EOF
fi
echo
$ac_n
"checking whether byte ordering is bigendian""...
$ac_c
"
1>&6
echo
"configure:5435: checking whether byte ordering is bigendian"
>
&5
if
eval
"test
\"
`
echo
'$''{'
ac_cv_c_bigendian
'+set}'
`
\"
= set"
;
then
echo
$ac_n
"(cached)
$ac_c
"
1>&6
else
ac_cv_c_bigendian
=
unknown
# See if sys/param.h defines the BYTE_ORDER macro.
cat
>
conftest.
$ac_ext
<<
EOF
#line 5442 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
int main() {
#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
bogus endian macros
#endif
; return 0; }
EOF
if
{
(
eval echo
configure:5453:
\"
$ac_compile
\"
)
1>&5
;
(
eval
$ac_compile
)
2>&5
;
}
;
then
rm
-rf
conftest
*
# It does; now see whether it defined to BIG_ENDIAN or not.
cat
>
conftest.
$ac_ext
<<
EOF
#line 5457 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/param.h>
int main() {
#if BYTE_ORDER != BIG_ENDIAN
not big endian
#endif
; return 0; }
EOF
if
{
(
eval echo
configure:5468:
\"
$ac_compile
\"
)
1>&5
;
(
eval
$ac_compile
)
2>&5
;
}
;
then
rm
-rf
conftest
*
ac_cv_c_bigendian
=
yes
else
echo
"configure: failed program was:"
>
&5
cat
conftest.
$ac_ext
>
&5
rm
-rf
conftest
*
ac_cv_c_bigendian
=
no
fi
rm
-f
conftest
*
echo
$ac_n
"checking if toupper() requires islower()""...
$ac_c
"
1>&6
echo
"configure:5436: checking if toupper() requires islower()"
>
&5
if
eval
"test
\"
`
echo
'$''{'
ol_cv_c_upper_lower
'+set}'
`
\"
= set"
;
then
echo
$ac_n
"(cached)
$ac_c
"
1>&6
else
echo
"configure: failed program was:"
>
&5
cat
conftest.
$ac_ext
>
&5
fi
rm
-f
conftest
*
if
test
$ac_cv_c_bigendian
=
unknown
;
then
if
test
"
$cross_compiling
"
=
yes
;
then
{
echo
"configure: error: can not run test program while cross compiling"
1>&2
;
exit
1
;
}
if
test
"
$cross_compiling
"
=
yes
;
then
ol_cv_c_upper_lower
=
safe
else
cat
>
conftest.
$ac_ext
<<
EOF
#line 54
88
"configure"
#line 54
45
"configure"
#include "confdefs.h"
main () {
/* Are we little or big endian? From Harbison&Steele. */
union
{
long l;
char c[sizeof (long)];
} u;
u.l = 1;
exit (u.c[sizeof (long) - 1] == 1);
#include <ctypes.h>
main()
{
if ('C' == toupper('C'))
exit 0;
else
exit 1;
}
EOF
if
{
(
eval echo
configure:5
501
:
\"
$ac_link
\"
)
1>&5
;
(
eval
$ac_link
)
2>&5
;
}
&&
test
-s
conftest
&&
(
./conftest
;
exit
)
2>/dev/null
if
{
(
eval echo
configure:5
457
:
\"
$ac_link
\"
)
1>&5
;
(
eval
$ac_link
)
2>&5
;
}
&&
test
-s
conftest
&&
(
./conftest
;
exit
)
2>/dev/null
then
ac
_cv_c_
bigendian
=
no
ol
_cv_c_
upper_lower
=
no
else
echo
"configure: failed program was:"
>
&5
cat
conftest.
$ac_ext
>
&5
rm
-fr
conftest
*
ac
_cv_c_
bigendian
=
yes
ol
_cv_c_
upper_lower
=
yes
fi
rm
-fr
conftest
*
fi
fi
fi
echo
"
$ac_t
""
$
ac
_cv_c_
bigendian
"
1>&6
if
test
$
ac
_cv_c_
bigendian
=
yes
;
then
cat
>>
confdefs.h
<<
\
EOF
#define
WORDS_BIGENDIAN
1
echo
"
$ac_t
""
$
ol
_cv_c_
upper_lower
"
1>&6
if
test
$
ol
_cv_c_
upper_lower
!=
no
;
then
cat
>>
confdefs.h
<<
\
EOF
#define
C_UPPER_LOWER
1
EOF
fi
echo
$ac_n
"checking for working const""...
$ac_c
"
1>&6
echo
"configure:5
525
: checking for working const"
>
&5
echo
"configure:5
480
: checking for working const"
>
&5
if
eval
"test
\"
`
echo
'$''{'
ac_cv_c_const
'+set}'
`
\"
= set"
;
then
echo
$ac_n
"(cached)
$ac_c
"
1>&6
else
cat
>
conftest.
$ac_ext
<<
EOF
#line 5
530
"configure"
#line 5
485
"configure"
#include "confdefs.h"
int main() {
...
...
@@ -5575,7 +5530,7 @@ ccp = (char const *const *) p;
; return 0; }
EOF
if
{
(
eval echo
configure:55
79
:
\"
$ac_compile
\"
)
1>&5
;
(
eval
$ac_compile
)
2>&5
;
}
;
then
if
{
(
eval echo
configure:55
34
:
\"
$ac_compile
\"
)
1>&5
;
(
eval
$ac_compile
)
2>&5
;
}
;
then
rm
-rf
conftest
*
ac_cv_c_const
=
yes
else
...
...
@@ -5598,7 +5553,7 @@ fi
echo
$ac_n
"checking for 8-bit clean memcmp""...
$ac_c
"
1>&6
echo
"configure:5
602
: checking for 8-bit clean memcmp"
>
&5
echo
"configure:5
557
: checking for 8-bit clean memcmp"
>
&5
if
eval
"test
\"
`
echo
'$''{'
ac_cv_func_memcmp_clean
'+set}'
`
\"
= set"
;
then
echo
$ac_n
"(cached)
$ac_c
"
1>&6
else
...
...
@@ -5606,7 +5561,7 @@ else
ac_cv_func_memcmp_clean
=
no
else
cat
>
conftest.
$ac_ext
<<
EOF
#line 5
610
"configure"
#line 5
565
"configure"
#include "confdefs.h"
main()
...
...
@@ -5616,7 +5571,7 @@ main()
}
EOF
if
{
(
eval echo
configure:5
620
:
\"
$ac_link
\"
)
1>&5
;
(
eval
$ac_link
)
2>&5
;
}
&&
test
-s
conftest
&&
(
./conftest
;
exit
)
2>/dev/null
if
{
(
eval echo
configure:5
575
:
\"
$ac_link
\"
)
1>&5
;
(
eval
$ac_link
)
2>&5
;
}
&&
test
-s
conftest
&&
(
./conftest
;
exit
)
2>/dev/null
then
ac_cv_func_memcmp_clean
=
yes
else
...
...
@@ -5634,12 +5589,12 @@ echo "$ac_t""$ac_cv_func_memcmp_clean" 1>&6
test
$ac_cv_func_memcmp_clean
=
no
&&
LIBOBJS
=
"
$LIBOBJS
memcmp.o"
echo
$ac_n
"checking for strftime""...
$ac_c
"
1>&6
echo
"configure:5
638
: checking for strftime"
>
&5
echo
"configure:5
593
: checking for strftime"
>
&5
if
eval
"test
\"
`
echo
'$''{'
ac_cv_func_strftime
'+set}'
`
\"
= set"
;
then
echo
$ac_n
"(cached)
$ac_c
"
1>&6
else
cat
>
conftest.
$ac_ext
<<
EOF
#line 5
643
"configure"
#line 5
598
"configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char strftime(); below. */
...
...
@@ -5662,7 +5617,7 @@ strftime();
; return 0; }
EOF
if
{
(
eval echo
configure:56
66
:
\"
$ac_link
\"
)
1>&5
;
(
eval
$ac_link
)
2>&5
;
}
&&
test
-s
conftest
;
then
if
{
(
eval echo
configure:56
21
:
\"
$ac_link
\"
)
1>&5
;
(
eval
$ac_link
)
2>&5
;
}
&&
test
-s
conftest
;
then
rm
-rf
conftest
*
eval
"ac_cv_func_strftime=yes"
else
...
...
@@ -5684,7 +5639,7 @@ else
echo
"
$ac_t
""no"
1>&6
# strftime is in -lintl on SCO UNIX.
echo
$ac_n
"checking for strftime in -lintl""...
$ac_c
"
1>&6
echo
"configure:56
88
: checking for strftime in -lintl"
>
&5
echo
"configure:56
43
: checking for strftime in -lintl"
>
&5
ac_lib_var
=
`
echo
intl
'_'
strftime |
sed
'y%./+-%__p_%'
`
if
eval
"test
\"
`
echo
'$''{'
ac_cv_lib_
$ac_lib_var
'+set}'
`
\"
= set"
;
then
echo
$ac_n
"(cached)
$ac_c
"
1>&6
...
...
@@ -5692,7 +5647,7 @@ else
ac_save_LIBS
=
"
$LIBS
"
LIBS
=
"-lintl
$LIBS
"
cat
>
conftest.
$ac_ext
<<
EOF
#line 56
96
"configure"
#line 56
51
"configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
...
...
@@ -5703,7 +5658,7 @@ int main() {
strftime()
; return 0; }
EOF
if
{
(
eval echo
configure:5
707
:
\"
$ac_link
\"
)
1>&5
;
(
eval
$ac_link
)
2>&5
;
}
&&
test
-s
conftest
;
then
if
{
(
eval echo
configure:5
662
:
\"
$ac_link
\"
)
1>&5
;
(
eval
$ac_link
)
2>&5
;
}
&&
test
-s
conftest
;
then
rm
-rf
conftest
*
eval
"ac_cv_lib_
$ac_lib_var
=yes"
else
...
...
@@ -5730,12 +5685,12 @@ fi
fi
echo
$ac_n
"checking for vprintf""...
$ac_c
"
1>&6
echo
"configure:5
734
: checking for vprintf"
>
&5
echo
"configure:5
689
: checking for vprintf"
>
&5
if
eval
"test
\"
`
echo
'$''{'
ac_cv_func_vprintf
'+set}'
`
\"
= set"
;
then
echo
$ac_n
"(cached)
$ac_c
"
1>&6
else
cat
>
conftest.
$ac_ext
<<
EOF
#line 5
739
"configure"
#line 5
694
"configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char vprintf(); below. */
...
...
@@ -5758,7 +5713,7 @@ vprintf();
; return 0; }
EOF
if
{
(
eval echo
configure:57
62
:
\"
$ac_link
\"
)
1>&5
;
(
eval
$ac_link
)
2>&5
;
}
&&
test
-s
conftest
;
then
if
{
(
eval echo
configure:57
17
:
\"
$ac_link
\"
)
1>&5
;
(
eval
$ac_link
)
2>&5
;
}
&&
test
-s
conftest
;
then
rm
-rf
conftest
*
eval
"ac_cv_func_vprintf=yes"
else
...
...
@@ -5782,12 +5737,12 @@ fi
if
test
"
$ac_cv_func_vprintf
"
!=
yes
;
then
echo
$ac_n
"checking for _doprnt""...
$ac_c
"
1>&6
echo
"configure:57
86
: checking for _doprnt"
>
&5
echo
"configure:57
41
: checking for _doprnt"
>
&5
if
eval
"test
\"
`
echo
'$''{'
ac_cv_func__doprnt
'+set}'
`
\"
= set"
;
then
echo
$ac_n
"(cached)
$ac_c
"
1>&6
else
cat
>
conftest.
$ac_ext
<<
EOF
#line 57
91
"configure"
#line 57
46
"configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char _doprnt(); below. */
...
...
@@ -5810,7 +5765,7 @@ _doprnt();
; return 0; }
EOF
if
{
(
eval echo
configure:5
814
:
\"
$ac_link
\"
)
1>&5
;
(
eval
$ac_link
)
2>&5
;
}
&&
test
-s
conftest
;
then
if
{
(
eval echo
configure:5
769
:
\"
$ac_link
\"
)
1>&5
;
(
eval
$ac_link
)
2>&5
;
}
&&
test
-s
conftest
;
then
rm
-rf
conftest
*
eval
"ac_cv_func__doprnt=yes"
else
...
...
@@ -5835,7 +5790,7 @@ fi
fi
echo
$ac_n
"checking for wait3 that fills in rusage""...
$ac_c
"
1>&6
echo
"configure:5
839
: checking for wait3 that fills in rusage"
>
&5
echo
"configure:5
794
: checking for wait3 that fills in rusage"
>
&5
if
eval
"test
\"
`
echo
'$''{'
ac_cv_func_wait3_rusage
'+set}'
`
\"
= set"
;
then
echo
$ac_n
"(cached)
$ac_c
"
1>&6
else
...
...
@@ -5843,7 +5798,7 @@ else
ac_cv_func_wait3_rusage
=
no
else
cat
>
conftest.
$ac_ext
<<
EOF
#line 58
47
"configure"
#line 58
02
"configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/time.h>
...
...
@@ -5874,7 +5829,7 @@ main() {
}
}
EOF
if
{
(
eval echo
configure:58
78
:
\"
$ac_link
\"
)
1>&5
;
(
eval
$ac_link
)
2>&5
;
}
&&
test
-s
conftest
&&
(
./conftest
;
exit
)
2>/dev/null
if
{
(
eval echo
configure:58
33
:
\"
$ac_link
\"
)
1>&5
;
(
eval
$ac_link
)
2>&5
;
}
&&
test
-s
conftest
&&
(
./conftest
;
exit
)
2>/dev/null
then
ac_cv_func_wait3_rusage
=
yes
else
...
...
@@ -5926,12 +5881,12 @@ for ac_func in \
do
echo
$ac_n
"checking for
$ac_func
""...
$ac_c
"
1>&6
echo
"configure:5
930
: checking for
$ac_func
"
>
&5
echo
"configure:5
885
: checking for
$ac_func
"
>
&5
if
eval
"test
\"
`
echo
'$''{'
ac_cv_func_
$ac_func
'+set}'
`
\"
= set"
;
then
echo
$ac_n
"(cached)
$ac_c
"
1>&6
else
cat
>
conftest.
$ac_ext
<<
EOF
#line 5
935
"configure"
#line 5
890
"configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char
$ac_func
(); below. */
...
...
@@ -5954,7 +5909,7 @@ $ac_func();
; return 0; }
EOF
if
{
(
eval echo
configure:59
58
:
\"
$ac_link
\"
)
1>&5
;
(
eval
$ac_link
)
2>&5
;
}
&&
test
-s
conftest
;
then
if
{
(
eval echo
configure:59
13
:
\"
$ac_link
\"
)
1>&5
;
(
eval
$ac_link
)
2>&5
;
}
&&
test
-s
conftest
;
then
rm
-rf
conftest
*
eval
"ac_cv_func_
$ac_func
=yes"
else
...
...
@@ -5982,12 +5937,12 @@ done
for
ac_func
in
getopt strdup
do
echo
$ac_n
"checking for
$ac_func
""...
$ac_c
"
1>&6
echo
"configure:59
86
: checking for
$ac_func
"
>
&5
echo
"configure:59
41
: checking for
$ac_func
"
>
&5
if
eval
"test
\"
`
echo
'$''{'
ac_cv_func_
$ac_func
'+set}'
`
\"
= set"
;
then
echo
$ac_n
"(cached)
$ac_c
"
1>&6
else
cat
>
conftest.
$ac_ext
<<
EOF
#line 59
91
"configure"
#line 59
46
"configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char
$ac_func
(); below. */
...
...
@@ -6010,7 +5965,7 @@ $ac_func();
; return 0; }
EOF
if
{
(
eval echo
configure:
6014
:
\"
$ac_link
\"
)
1>&5
;
(
eval
$ac_link
)
2>&5
;
}
&&
test
-s
conftest
;
then
if
{
(
eval echo
configure:
5969
:
\"
$ac_link
\"
)
1>&5
;
(
eval
$ac_link
)
2>&5
;
}
&&
test
-s
conftest
;
then
rm
-rf
conftest
*
eval
"ac_cv_func_
$ac_func
=yes"
else
...
...
@@ -6040,13 +5995,13 @@ done
# Check Configuration
echo
$ac_n
"checking declaration of sys_errlist""...
$ac_c
"
1>&6
echo
"configure:
6044
: checking declaration of sys_errlist"
>
&5
echo
"configure:
5999
: checking declaration of sys_errlist"
>
&5
if
eval
"test
\"
`
echo
'$''{'
ol_cv_dcl_sys_errlist
'+set}'
`
\"
= set"
;
then
echo
$ac_n
"(cached)
$ac_c
"
1>&6
else
cat
>
conftest.
$ac_ext
<<
EOF
#line 60
5
0 "configure"
#line 600
5
"configure"
#include "confdefs.h"
#include <stdio.h>
...
...
@@ -6056,7 +6011,7 @@ int main() {
char *c = (char *) *sys_errlist
; return 0; }
EOF
if
{
(
eval echo
configure:60
60
:
\"
$ac_compile
\"
)
1>&5
;
(
eval
$ac_compile
)
2>&5
;
}
;
then
if
{
(
eval echo
configure:60
15
:
\"
$ac_compile
\"
)
1>&5
;
(
eval
$ac_compile
)
2>&5
;
}
;
then
rm
-rf
conftest
*
ol_cv_dcl_sys_errlist
=
yes
else
...
...
@@ -6077,20 +6032,20 @@ if test $ol_cv_dcl_sys_errlist = no ; then
EOF
echo
$ac_n
"checking existence of sys_errlist""...
$ac_c
"
1>&6
echo
"configure:60
81
: checking existence of sys_errlist"
>
&5
echo
"configure:60
36
: checking existence of sys_errlist"
>
&5
if
eval
"test
\"
`
echo
'$''{'
ol_cv_have_sys_errlist
'+set}'
`
\"
= set"
;
then
echo
$ac_n
"(cached)
$ac_c
"
1>&6
else
cat
>
conftest.
$ac_ext
<<
EOF
#line 60
87
"configure"
#line 60
42
"configure"
#include "confdefs.h"
#include <errno.h>
int main() {
char *c = (char *) *sys_errlist
; return 0; }
EOF
if
{
(
eval echo
configure:60
9
4:
\"
$ac_link
\"
)
1>&5
;
(
eval
$ac_link
)
2>&5
;
}
&&
test
-s
conftest
;
then
if
{
(
eval echo
configure:604
9
:
\"
$ac_link
\"
)
1>&5
;
(
eval
$ac_link
)
2>&5
;
}
&&
test
-s
conftest
;
then
rm
-rf
conftest
*
ol_cv_have_sys_errlist
=
yes
else
...
...
configure.in
View file @
b76c56ba
...
...
@@ -716,7 +716,7 @@ AC_STRUCT_ST_BLKSIZE
AC_HEADER_TIME
AC_STRUCT_TM
AC
_C_
BIGENDIAN
OL
_C_
UPPER_LOWER
AC_C_CONST
dnl AC_CHECK_SIZEOF(short)
...
...
include/portable.h.in
View file @
b76c56ba
...
...
@@ -104,9 +104,8 @@ is provided ``as is'' without express or implied warranty.
/* Define to `int' if <sys/types.h> doesn't define. */
#undef uid_t
/* Define if your processor stores words with the most significant
byte first (like Motorola and SPARC, unlike Intel and VAX). */
#undef WORDS_BIGENDIAN
/* define this if toupper() requires tolower() check */
#undef C_UPPER_LOWER
/* define this if sys_errlist is not defined in stdio.h or errno.h */
#undef DECL_SYS_ERRLIST
...
...
servers/slapd/abandon.c
View file @
b76c56ba
...
...
@@ -12,9 +12,11 @@
* is provided ``as is'' without express or implied warranty.
*/
#include
"portable.h"
#include
<stdio.h>
#include
<
sys/types
.h>
#include
<sys/socket.h>
#include
<
ac/socket
.h>
#include
"slap.h"
extern
Backend
*
select_backend
();
...
...
servers/slapd/acl.c
View file @
b76c56ba
/* acl.c - routines to parse and check acl's */
#include
"portable.h"
#include
<stdio.h>
#include
<string.h>
#include
<sys/types.h>
...
...
servers/slapd/aclparse.c
View file @
b76c56ba
/* acl.c - routines to parse and check acl's */
#include
"portable.h"
#include
<stdio.h>
#include
<string.h>
...
...
@@ -7,12 +8,13 @@
#include
<sys/socket.h>
#include
<netinet/in.h>
#include
<netdb.h>
#include
"regex.h"
#include
<unistd.h>
#include
<regex.h>
#include
"slap.h"
#include
"portable.h"
extern
Filter
*
str2filter
();
extern
char
*
re_comp
();
extern
struct
acl
*
global_acl
;
extern
char
**
str2charray
();
extern
char
*
dn_upcase
();
...
...
@@ -26,6 +28,62 @@ static void print_acl();
static
void
print_access
();
#endif
int
regtest
(
char
*
fname
,
int
lineno
,
char
*
pat
)
{
int
e
;
regex_t
re
;
char
buf
[
512
];
int
size
;
char
*
sp
;
char
*
dp
;
int
flag
;
sp
=
pat
;
dp
=
buf
;
size
=
0
;
buf
[
0
]
=
'\0'
;
for
(
size
=
0
,
flag
=
0
;
(
size
<
sizeof
(
buf
))
&&
*
sp
;
sp
++
)
{
if
(
flag
)
{
if
(
*
sp
==
'$'
||
(
*
sp
>=
'0'
&&
*
sp
<=
'9'
))
{
*
dp
++
=
*
sp
;
size
++
;
}
flag
=
0
;
}
else
{
if
(
*
sp
==
'$'
)
{
flag
=
1
;
}
else
{
*
dp
++
=
*
sp
;
size
++
;
}
}
}
*
dp
=
'\0'
;
if
(
size
>=
(
sizeof
(
buf
)
-
1
)
)
{
fprintf
(
stderr
,
"%s: line %d: regular expression
\"
%s
\"
too large
\n
"
,
fname
,
lineno
,
pat
,
0
);
acl_usage
();
}
if
((
e
=
regcomp
(
&
re
,
buf
,
REG_EXTENDED
|
REG_ICASE
)))
{
char
error
[
512
];
regerror
(
e
,
&
re
,
error
,
sizeof
(
error
));
fprintf
(
stderr
,
"%s: line %d: regular expression
\"
%s
\"
bad because of %s
\n
"
,
fname
,
lineno
,
pat
,
error
);
acl_usage
();
return
(
0
);
}
regfree
(
&
re
);
return
(
1
);
}
void
parse_acl
(
Backend
*
be
,
...
...
@@ -58,6 +116,17 @@ parse_acl(
}
if
(
strcasecmp
(
argv
[
i
],
"*"
)
==
0
)
{
int
e
;
if
((
e
=
regcomp
(
&
a
->
acl_dnre
,
".*"
,
REG_EXTENDED
|
REG_ICASE
)))
{
char
buf
[
512
];
regerror
(
e
,
&
a
->
acl_dnre
,
buf
,
sizeof
(
buf
));
fprintf
(
stderr
,
"%s: line %d: regular expression
\"
%s
\"
bad because of %s
\n
"
,
fname
,
lineno
,
right
,
buf
);
acl_usage
();
}
a
->
acl_dnpat
=
strdup
(
".*"
);
continue
;
}
...
...
@@ -79,14 +148,19 @@ parse_acl(
acl_usage
();
}
}
else
if
(
strcasecmp
(
left
,
"dn"
)
==
0
)
{
if
(
(
e
=
re_comp
(
right
))
!=
NULL
)
{
int
e
;
if
((
e
=
regcomp
(
&
a
->
acl_dnre
,
right
,
REG_EXTENDED
|
REG_ICASE
)))
{
char
buf
[
512
];
regerror
(
e
,
&
a
->
acl_dnre
,
buf
,
sizeof
(
buf
));
fprintf
(
stderr
,
"%s: line %d: regular expression
\"
%s
\"
bad because of %s
\n
"
,
fname
,
lineno
,
right
,
e
);
"%s: line %d: regular expression
\"
%s
\"
bad because of %s
\n
"
,
fname
,
lineno
,
right
,
buf
);
acl_usage
();
}
else
{
a
->
acl_dnpat
=
dn_upcase
(
strdup
(
right
));
}
a
->
acl_dnpat
=
dn_upcase
(
strdup
(
right
)
);
}
else
if
(
strncasecmp
(
left
,
"attr"
,
4
)
==
0
)
{
char
**
alist
;
...
...
@@ -96,7 +170,7 @@ parse_acl(