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
orbea -
OpenLDAP
Commits
83c748fe
Commit
83c748fe
authored
Mar 17, 2005
by
Howard Chu
Browse files
More for loading config from database. Fix non-reentrant strtok_quote.
parent
1e5f43dd
Changes
5
Hide whitespace changes
Inline
Side-by-side
servers/slapd/back-bdb/config.c
View file @
83c748fe
...
...
@@ -240,9 +240,8 @@ int bdb_back_init_cf( BackendInfo *bi )
int
rc
;
bi
->
bi_cf_table
=
bdbcfg
;
rc
=
init_
config_
attrs
(
bdbcfg
);
rc
=
config_
register_schema
(
bdbcfg
,
bdbocs
);
if
(
rc
)
return
rc
;
bdbcfg
[
0
].
ad
=
slap_schema
.
si_ad_objectClass
;
rc
=
init_config_ocs
(
bdbocs
);
return
rc
;
return
0
;
}
servers/slapd/back-ldif/ldif.c
View file @
83c748fe
...
...
@@ -1026,9 +1026,8 @@ ldif_back_initialize(
bi
->
bi_tool_id2entry_get
=
0
;
bi
->
bi_tool_entry_modify
=
0
;
rc
=
init_
config_
attrs
(
ldifcfg
);
rc
=
config_
register_schema
(
ldifcfg
,
ldifocs
);
if
(
rc
)
return
rc
;
ldifcfg
[
0
].
ad
=
slap_schema
.
si_ad_objectClass
;
rc
=
init_config_ocs
(
ldifocs
);
return
rc
;
return
0
;
}
servers/slapd/bconfig.c
View file @
83c748fe
...
...
@@ -36,7 +36,6 @@
#include "config.h"
static
struct
berval
config_rdn
=
BER_BVC
(
"cn=config"
);
static
struct
berval
access_rdn
=
BER_BVC
(
"cn=access"
);
#ifdef SLAPD_MODULES
typedef
struct
modpath_s
{
...
...
@@ -57,10 +56,24 @@ typedef struct ConfigFile {
BerVarray
c_dseFiles
;
}
ConfigFile
;
typedef
struct
CfOcInfo
{
struct
berval
*
co_name
;
ConfigTable
*
co_table
;
}
CfOcInfo
;
typedef
enum
{
Cf_Global
=
1
,
Cf_Include
,
Cf_Backend
,
Cf_Database
,
Cf_Overlay
}
CfEtypes
;
typedef
struct
CfEntryInfo
{
struct
CfEntryInfo
*
ce_sibs
;
struct
CfEntryInfo
*
ce_kids
;
Entry
*
ce_entry
;
CfEtypes
ce_type
;
BackendInfo
*
ce_bi
;
BackendDB
*
ce_be
;
}
CfEntryInfo
;
...
...
@@ -84,14 +97,17 @@ static BerVarray authz_rewrites;
static
struct
berval
cfdir
;
/* Private state */
static
AttributeDescription
*
cfAd_backend
,
*
cfAd_database
,
*
cfAd_overlay
,
*
cfAd_include
;
static
ObjectClass
*
cfOc_global
,
*
cfOc_backend
,
*
cfOc_database
,
*
cfOc_include
,
*
cfOc_overlay
,
*
cfOc_access
;
*
cfOc_include
,
*
cfOc_overlay
;
static
ConfigFile
cf_prv
,
*
cfn
=
&
cf_prv
;
static
Avlnode
*
CfOcTree
;
static
int
add_syncrepl
LDAP_P
((
Backend
*
,
char
**
,
int
));
static
int
parse_syncrepl_line
LDAP_P
((
char
**
,
int
,
syncinfo_t
*
));
static
void
syncrepl_unparse
LDAP_P
((
syncinfo_t
*
,
struct
berval
*
));
...
...
@@ -604,11 +620,6 @@ static ConfigOCs cf_ocs[] = {
"DESC 'OpenLDAP Overlay-specific options' "
"SUP olcConfig STRUCTURAL "
"MAY ( olcOverlay ) )"
,
&
cfOc_overlay
},
{
"( OLcfgOc:8 "
"NAME 'olcACL' "
"DESC 'OpenLDAP Access Control List' "
"SUP olcConfig STRUCTURAL "
"MUST ( olcAccess ) )"
,
&
cfOc_access
},
{
NULL
,
NULL
}
};
...
...
@@ -2639,6 +2650,37 @@ config_setup_ldif( BackendDB *be, const char *dir ) {
return
0
;
}
static
int
CfOcInfo_cmp
(
const
void
*
c1
,
const
void
*
c2
)
{
const
CfOcInfo
*
co1
=
c1
;
const
CfOcInfo
*
co2
=
c2
;
return
ber_bvcmp
(
co1
->
co_name
,
co2
->
co_name
);
}
int
config_register_schema
(
ConfigTable
*
ct
,
ConfigOCs
*
ocs
)
{
int
i
;
CfOcInfo
*
co
;
i
=
init_config_attrs
(
ct
);
if
(
i
)
return
i
;
/* set up the objectclasses */
i
=
init_config_ocs
(
ocs
);
if
(
i
)
return
i
;
for
(
i
=
0
;
ocs
[
i
].
def
;
i
++
)
{
if
(
ocs
[
i
].
oc
)
{
co
=
ch_malloc
(
sizeof
(
CfOcInfo
)
);
co
->
co_name
=
&
(
*
ocs
[
i
].
oc
)
->
soc_cname
;
co
->
co_table
=
ct
;
avl_insert
(
&
CfOcTree
,
co
,
CfOcInfo_cmp
,
avl_dup_error
);
}
}
return
0
;
}
int
read_config
(
const
char
*
fname
,
const
char
*
dir
)
{
BackendDB
*
be
;
...
...
@@ -2893,6 +2935,8 @@ config_build_includes( ConfigArgs *c, Entry *parent,
op
->
ora_e
=
e
;
op
->
o_bd
->
be_add
(
op
,
rs
);
ce
=
e
->
e_private
;
ce
->
ce_type
=
Cf_Include
;
ce
->
ce_bi
=
c
->
bi
;
if
(
!
ceparent
->
ce_kids
)
{
ceparent
->
ce_kids
=
ce
;
}
else
{
...
...
@@ -2951,6 +2995,8 @@ config_back_db_open( BackendDB *be )
config_build_entry
(
&
c
,
e
,
cfOc_global
,
&
rdn
,
ct
,
NO_TABLE
);
op
->
ora_e
=
e
;
op
->
o_bd
->
be_add
(
op
,
&
rs
);
ce
->
ce_type
=
Cf_Global
;
ce
->
ce_bi
=
c
.
bi
;
parent
=
e
;
ceparent
=
ce
;
...
...
@@ -2975,6 +3021,7 @@ config_back_db_open( BackendDB *be )
rdn
.
bv_len
=
sprintf
(
rdn
.
bv_val
,
"%s=%s"
,
cfAd_backend
->
ad_cname
.
bv_val
,
bi
->
bi_type
);
e
=
config_alloc_entry
(
&
parent
->
e_nname
,
&
rdn
);
ce
=
e
->
e_private
;
ce
->
ce_type
=
Cf_Backend
;
ce
->
ce_bi
=
bi
;
c
.
bi
=
bi
;
config_build_entry
(
&
c
,
e
,
cfOc_backend
,
&
rdn
,
ct
,
BI_TABLE
);
...
...
@@ -3009,6 +3056,7 @@ config_back_db_open( BackendDB *be )
ce
=
e
->
e_private
;
c
.
be
=
bptr
;
c
.
bi
=
bi
;
ce
->
ce_type
=
Cf_Database
;
ce
->
ce_be
=
c
.
be
;
ce
->
ce_bi
=
c
.
bi
;
config_build_entry
(
&
c
,
e
,
cfOc_database
,
&
rdn
,
ct
,
BE_TABLE
);
...
...
@@ -3035,6 +3083,7 @@ config_back_db_open( BackendDB *be )
ce
=
oe
->
e_private
;
c
.
be
=
bptr
;
c
.
bi
=
&
on
->
on_bi
;
ce
->
ce_type
=
Cf_Overlay
;
ce
->
ce_be
=
c
.
be
;
ce
->
ce_bi
=
c
.
bi
;
config_build_entry
(
&
c
,
oe
,
cfOc_overlay
,
&
rdn
,
ct
,
BI_TABLE
);
...
...
@@ -3140,7 +3189,9 @@ config_back_initialize( BackendInfo *bi )
parse_oidm
(
"slapd"
,
i
,
3
,
argv
);
}
i
=
init_config_attrs
(
ct
);
bi
->
bi_cf_table
=
ct
;
i
=
config_register_schema
(
ct
,
cf_ocs
);
if
(
i
)
return
i
;
/* set up the notable AttributeDescriptions */
...
...
@@ -3148,8 +3199,6 @@ config_back_initialize( BackendInfo *bi )
ads
[
3
].
sub
=
slap_schema
.
si_ad_ditContentRules
;
ads
[
5
].
sub
=
slap_schema
.
si_ad_objectClasses
;
bi
->
bi_cf_table
=
ct
;
i
=
0
;
for
(;
ct
->
name
;
ct
++
)
{
if
(
strcmp
(
ct
->
name
,
ads
[
i
].
name
))
continue
;
...
...
@@ -3162,9 +3211,6 @@ config_back_initialize( BackendInfo *bi )
if
(
!
ads
[
i
].
name
)
break
;
}
/* set up the objectclasses */
i
=
init_config_ocs
(
cf_ocs
);
return
i
;
return
0
;
}
servers/slapd/config.c
View file @
83c748fe
...
...
@@ -72,8 +72,6 @@ int slap_conn_max_pending_auth = SLAP_CONN_MAX_PENDING_AUTH;
char
*
slapd_pid_file
=
NULL
;
char
*
slapd_args_file
=
NULL
;
char
*
strtok_quote_ptr
;
int
use_reverse_lookup
=
0
;
#ifdef LDAP_SLAPI
...
...
@@ -84,7 +82,7 @@ static int fp_getline(FILE *fp, ConfigArgs *c);
static
void
fp_getline_init
(
ConfigArgs
*
c
);
static
int
fp_parse_line
(
ConfigArgs
*
c
);
static
char
*
strtok_quote
(
char
*
line
,
char
*
sep
);
static
char
*
strtok_quote
(
char
*
line
,
char
*
sep
,
char
**
quote_ptr
);
int
read_config_file
(
const
char
*
fname
,
int
depth
,
ConfigArgs
*
cf
);
...
...
@@ -458,6 +456,7 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf)
snprintf
(
c
->
log
,
sizeof
(
c
->
log
),
"%s: line %lu"
,
c
->
fname
,
c
->
lineno
);
c
->
argc
=
0
;
if
(
fp_parse_line
(
c
)
)
{
goto
badline
;
}
...
...
@@ -748,13 +747,13 @@ void bindconf_free( slap_bindconf *bc ) {
static
char
*
strtok_quote
(
char
*
line
,
char
*
sep
)
strtok_quote
(
char
*
line
,
char
*
sep
,
char
**
quote_ptr
)
{
int
inquote
;
char
*
tmp
;
static
char
*
next
;
strtok_
quote_ptr
=
NULL
;
*
quote_ptr
=
NULL
;
if
(
line
!=
NULL
)
{
next
=
line
;
}
...
...
@@ -789,7 +788,7 @@ strtok_quote( char *line, char *sep )
default:
if
(
!
inquote
)
{
if
(
strchr
(
sep
,
*
next
)
!=
NULL
)
{
strtok_
quote_ptr
=
next
;
*
quote_ptr
=
next
;
*
next
++
=
'\0'
;
return
(
tmp
);
}
...
...
@@ -877,17 +876,18 @@ fp_parse_line(ConfigArgs *c)
char
*
token
;
char
*
tline
=
ch_strdup
(
c
->
line
);
char
*
hide
[]
=
{
"rootpw"
,
"replica"
,
"bindpw"
,
"pseudorootpw"
,
"dbpasswd"
,
'\0'
};
char
*
quote_ptr
;
int
i
;
c
->
argc
=
0
;
token
=
strtok_quote
(
tline
,
"
\t
"
);
token
=
strtok_quote
(
tline
,
"
\t
"
,
&
quote_ptr
);
if
(
token
)
for
(
i
=
0
;
hide
[
i
];
i
++
)
if
(
!
strcasecmp
(
token
,
hide
[
i
]))
break
;
if
(
strtok_quote_ptr
)
*
strtok_quote_ptr
=
' '
;
Debug
(
LDAP_DEBUG_CONFIG
,
"line %lu (%s%s)
\n
"
,
c
->
lineno
,
hide
[
i
]
?
hide
[
i
]
:
c
->
line
,
hide
[
i
]
?
" ***"
:
""
);
if
(
strtok_quote_ptr
)
*
strtok_quote_ptr
=
'\0'
;
if
(
quote_ptr
)
*
quote_ptr
=
' '
;
Debug
(
LDAP_DEBUG_CONFIG
,
"line %lu (%s%s)
\n
"
,
c
->
lineno
,
hide
[
i
]
?
hide
[
i
]
:
c
->
line
,
hide
[
i
]
?
" ***"
:
""
);
if
(
quote_ptr
)
*
quote_ptr
=
'\0'
;
for
(;
token
;
token
=
strtok_quote
(
NULL
,
"
\t
"
))
{
for
(;
token
;
token
=
strtok_quote
(
NULL
,
"
\t
"
,
&
quote_ptr
))
{
if
(
c
->
argc
==
c
->
argv_size
-
1
)
{
char
**
tmp
;
tmp
=
ch_realloc
(
c
->
argv
,
(
c
->
argv_size
+
ARGS_STEP
)
*
sizeof
(
*
c
->
argv
));
...
...
servers/slapd/config.h
View file @
83c748fe
...
...
@@ -103,6 +103,7 @@ typedef struct config_args_s {
typedef
int
(
ConfigDriver
)(
ConfigArgs
*
c
);
int
config_register_schema
(
ConfigTable
*
ct
,
ConfigOCs
*
co
);
int
config_get_vals
(
ConfigTable
*
ct
,
ConfigArgs
*
c
);
int
config_add_vals
(
ConfigTable
*
ct
,
ConfigArgs
*
c
);
ConfigTable
*
config_find_keyword
(
ConfigTable
*
ct
,
ConfigArgs
*
c
);
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