Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Joe Martin
OpenLDAP
Commits
45d87c22
Commit
45d87c22
authored
Aug 26, 2009
by
Quanah Gibson-Mount
Browse files
More for ITS#5178
parent
560ea8e4
Changes
4
Hide whitespace changes
Inline
Side-by-side
servers/slapd/back-monitor/back-monitor.h
View file @
45d87c22
...
...
@@ -289,9 +289,9 @@ typedef struct monitor_extra_t {
int
(
*
register_subsys
)(
monitor_subsys_t
*
ms
);
int
(
*
register_backend
)(
BackendInfo
*
bi
);
int
(
*
register_database
)(
BackendDB
*
be
,
struct
berval
*
ndn
);
int
(
*
register_database
)(
BackendDB
*
be
,
struct
berval
*
ndn
_out
);
int
(
*
register_overlay_info
)(
slap_overinst
*
on
);
int
(
*
register_overlay
)(
BackendDB
*
be
);
int
(
*
register_overlay
)(
BackendDB
*
be
,
slap_overinst
*
on
,
struct
berval
*
ndn_out
);
int
(
*
register_entry
)(
Entry
*
e
,
monitor_callback_t
*
cb
,
monitor_subsys_t
*
ms
,
unsigned
long
flags
);
int
(
*
register_entry_parent
)(
Entry
*
e
,
monitor_callback_t
*
cb
,
...
...
servers/slapd/back-monitor/database.c
View file @
45d87c22
...
...
@@ -99,6 +99,101 @@ init_restrictedOperation( monitor_info_t *mi, Entry *e, slap_mask_t restrictops
return
LDAP_SUCCESS
;
}
static
int
monitor_subsys_overlay_init_one
(
monitor_info_t
*
mi
,
BackendDB
*
be
,
monitor_subsys_t
*
ms
,
monitor_subsys_t
*
ms_overlay
,
slap_overinst
*
on
,
Entry
*
e_database
,
Entry
**
ep_overlay
)
{
char
buf
[
BACKMONITOR_BUFSIZE
];
int
j
,
o
;
Entry
*
e_overlay
;
slap_overinst
*
on2
;
slap_overinfo
*
oi
=
NULL
;
BackendInfo
*
bi
;
monitor_entry_t
*
mp_overlay
;
struct
berval
bv
;
assert
(
overlay_is_over
(
be
)
);
oi
=
(
slap_overinfo
*
)
be
->
bd_info
->
bi_private
;
bi
=
oi
->
oi_orig
;
/* find the overlay number, o */
for
(
o
=
0
,
on2
=
oi
->
oi_list
;
on2
&&
on2
!=
on
;
on2
=
on2
->
on_next
,
o
++
)
;
if
(
on2
==
NULL
)
{
return
-
1
;
}
/* find the overlay type number, j */
for
(
on2
=
overlay_next
(
NULL
),
j
=
0
;
on2
;
on2
=
overlay_next
(
on2
),
j
++
)
{
if
(
on2
->
on_bi
.
bi_type
==
on
->
on_bi
.
bi_type
)
{
break
;
}
}
assert
(
on2
!=
NULL
);
bv
.
bv_len
=
snprintf
(
buf
,
sizeof
(
buf
),
"cn=Overlay %d"
,
o
);
bv
.
bv_val
=
buf
;
e_overlay
=
monitor_entry_stub
(
&
e_database
->
e_name
,
&
e_database
->
e_nname
,
&
bv
,
mi
->
mi_oc_monitoredObject
,
mi
,
NULL
,
NULL
);
if
(
e_overlay
==
NULL
)
{
Debug
(
LDAP_DEBUG_ANY
,
"monitor_subsys_overlay_init_one: "
"unable to create entry "
"
\"
cn=Overlay %d,%s
\"\n
"
,
o
,
e_database
->
e_name
.
bv_val
,
0
);
return
(
-
1
);
}
ber_str2bv
(
on
->
on_bi
.
bi_type
,
0
,
0
,
&
bv
);
attr_merge_normalize_one
(
e_overlay
,
mi
->
mi_ad_monitoredInfo
,
&
bv
,
NULL
);
bv
.
bv_len
=
snprintf
(
buf
,
sizeof
(
buf
),
"cn=Overlay %d,%s"
,
j
,
ms_overlay
->
mss_dn
.
bv_val
);
bv
.
bv_val
=
buf
;
attr_merge_normalize_one
(
e_overlay
,
slap_schema
.
si_ad_seeAlso
,
&
bv
,
NULL
);
if
(
SLAP_MONITOR
(
be
)
)
{
attr_merge
(
e_overlay
,
slap_schema
.
si_ad_monitorContext
,
be
->
be_suffix
,
be
->
be_nsuffix
);
}
else
{
attr_merge
(
e_overlay
,
slap_schema
.
si_ad_namingContexts
,
be
->
be_suffix
,
NULL
);
}
mp_overlay
=
monitor_entrypriv_create
();
if
(
mp_overlay
==
NULL
)
{
return
-
1
;
}
e_overlay
->
e_private
=
(
void
*
)
mp_overlay
;
mp_overlay
->
mp_info
=
ms
;
mp_overlay
->
mp_flags
=
ms
->
mss_flags
|
MONITOR_F_SUB
;
if
(
monitor_cache_add
(
mi
,
e_overlay
)
)
{
Debug
(
LDAP_DEBUG_ANY
,
"monitor_subsys_overlay_init_one: "
"unable to add entry "
"
\"
cn=Overlay %d,%s
\"\n
"
,
o
,
e_database
->
e_name
.
bv_val
,
0
);
return
-
1
;
}
*
ep_overlay
=
e_overlay
;
ep_overlay
=
&
mp_overlay
->
mp_next
;
return
0
;
}
static
int
monitor_subsys_database_init_one
(
monitor_info_t
*
mi
,
...
...
@@ -131,7 +226,7 @@ monitor_subsys_database_init_one(
if
(
e
==
NULL
)
{
Debug
(
LDAP_DEBUG_ANY
,
"monitor_subsys_database_init: "
"monitor_subsys_database_init
_one
: "
"unable to create entry
\"
%s,%s
\"\n
"
,
rdn
->
bv_val
,
ms
->
mss_dn
.
bv_val
,
0
);
return
(
-
1
);
...
...
@@ -152,7 +247,7 @@ monitor_subsys_database_init_one(
}
else
{
if
(
be
->
be_suffix
==
NULL
)
{
Debug
(
LDAP_DEBUG_ANY
,
"monitor_subsys_database_init: "
"monitor_subsys_database_init
_one
: "
"missing suffix for %s
\n
"
,
rdnval
,
0
,
0
);
}
else
{
...
...
@@ -253,7 +348,7 @@ monitor_subsys_database_init_one(
if
(
monitor_cache_add
(
mi
,
e
)
)
{
Debug
(
LDAP_DEBUG_ANY
,
"monitor_subsys_database_init: "
"monitor_subsys_database_init
_one
: "
"unable to add entry
\"
%s,%s
\"\n
"
,
rdn
->
bv_val
,
ms
->
mss_dn
.
bv_val
,
0
);
return
(
-
1
);
...
...
@@ -265,74 +360,11 @@ monitor_subsys_database_init_one(
if
(
oi
!=
NULL
)
{
Entry
**
ep_overlay
=
&
mp
->
mp_children
;
monitor_entry_t
*
mp_overlay
;
slap_overinst
*
on
=
oi
->
oi_list
;
int
o
;
for
(
o
=
0
;
on
;
o
++
,
on
=
on
->
on_next
)
{
Entry
*
e_overlay
;
slap_overinst
*
on2
;
/* find the overlay number, j */
for
(
on2
=
overlay_next
(
NULL
),
j
=
0
;
on2
;
on2
=
overlay_next
(
on2
),
j
++
)
{
if
(
on2
->
on_bi
.
bi_type
==
on
->
on_bi
.
bi_type
)
{
break
;
}
}
assert
(
on2
!=
NULL
);
bv
.
bv_len
=
snprintf
(
buf
,
sizeof
(
buf
),
"cn=Overlay %d"
,
o
);
bv
.
bv_val
=
buf
;
e_overlay
=
monitor_entry_stub
(
&
e
->
e_name
,
&
e
->
e_nname
,
&
bv
,
mi
->
mi_oc_monitoredObject
,
mi
,
NULL
,
NULL
);
if
(
e_overlay
==
NULL
)
{
Debug
(
LDAP_DEBUG_ANY
,
"monitor_subsys_database_init: "
"unable to create entry "
"
\"
cn=Overlay %d,%s,%s
\"\n
"
,
o
,
rdn
->
bv_val
,
ms
->
mss_dn
.
bv_val
);
return
(
-
1
);
}
ber_str2bv
(
on
->
on_bi
.
bi_type
,
0
,
0
,
&
bv
);
attr_merge_normalize_one
(
e_overlay
,
mi
->
mi_ad_monitoredInfo
,
&
bv
,
NULL
);
bv
.
bv_len
=
snprintf
(
buf
,
sizeof
(
buf
),
"cn=Overlay %d,%s"
,
j
,
ms_overlay
->
mss_dn
.
bv_val
);
bv
.
bv_val
=
buf
;
attr_merge_normalize_one
(
e_overlay
,
slap_schema
.
si_ad_seeAlso
,
&
bv
,
NULL
);
if
(
SLAP_MONITOR
(
be
)
)
{
attr_merge
(
e_overlay
,
slap_schema
.
si_ad_monitorContext
,
be
->
be_suffix
,
be
->
be_nsuffix
);
}
else
{
attr_merge
(
e_overlay
,
slap_schema
.
si_ad_namingContexts
,
be
->
be_suffix
,
NULL
);
}
mp_overlay
=
monitor_entrypriv_create
();
if
(
mp_overlay
==
NULL
)
{
return
-
1
;
}
e_overlay
->
e_private
=
(
void
*
)
mp_overlay
;
mp_overlay
->
mp_info
=
ms
;
mp_overlay
->
mp_flags
=
ms
->
mss_flags
|
MONITOR_F_SUB
;
if
(
monitor_cache_add
(
mi
,
e_overlay
)
)
{
Debug
(
LDAP_DEBUG_ANY
,
"monitor_subsys_database_init: "
"unable to add entry "
"
\"
cn=Overlay %d,%s,%s
\"\n
"
,
o
,
rdn
->
bv_val
,
ms
->
mss_dn
.
bv_val
);
return
(
-
1
);
}
*
ep_overlay
=
e_overlay
;
ep_overlay
=
&
mp_overlay
->
mp_next
;
for
(
;
on
;
on
=
on
->
on_next
)
{
monitor_subsys_overlay_init_one
(
mi
,
be
,
ms
,
ms_overlay
,
on
,
e
,
ep_overlay
);
}
}
...
...
@@ -342,10 +374,11 @@ monitor_subsys_database_init_one(
return
0
;
}
int
monitor_back_register_database
(
static
int
monitor_back_register_database
_and_overlay
(
BackendDB
*
be
,
struct
berval
*
ndn
)
struct
slap_overinst
*
on
,
struct
berval
*
ndn_out
)
{
monitor_info_t
*
mi
;
Entry
*
e_database
,
**
ep
;
...
...
@@ -360,7 +393,12 @@ monitor_back_register_database(
assert
(
be_monitor
!=
NULL
);
if
(
!
monitor_subsys_is_opened
()
)
{
return
monitor_back_register_database_limbo
(
be
,
ndn
);
if
(
on
)
{
return
monitor_back_register_overlay_limbo
(
be
,
on
,
ndn_out
);
}
else
{
return
monitor_back_register_database_limbo
(
be
,
ndn_out
);
}
}
mi
=
(
monitor_info_t
*
)
be_monitor
->
be_private
;
...
...
@@ -455,13 +493,51 @@ monitor_back_register_database(
done:
;
monitor_cache_release
(
mi
,
e_database
);
if
(
rc
==
0
&&
ndn
&&
ep
&&
*
ep
)
{
*
ndn
=
(
*
ep
)
->
e_nname
;
if
(
rc
==
0
&&
ndn_out
&&
ep
&&
*
ep
)
{
if
(
on
)
{
Entry
*
e_ov
;
struct
berval
ov_type
;
ber_str2bv
(
on
->
on_bi
.
bi_type
,
0
,
0
,
&
ov_type
);
mp
=
(
monitor_entry_t
*
)
(
*
ep
)
->
e_private
;
for
(
e_ov
=
mp
->
mp_children
;
e_ov
;
)
{
Attribute
*
a
=
attr_find
(
e_ov
->
e_attrs
,
mi
->
mi_ad_monitoredInfo
);
if
(
a
!=
NULL
&&
bvmatch
(
&
a
->
a_nvals
[
0
],
&
ov_type
)
)
{
*
ndn_out
=
e_ov
->
e_nname
;
break
;
}
mp
=
(
monitor_entry_t
*
)
e_ov
->
e_private
;
e_ov
=
mp
->
mp_next
;
}
}
else
{
*
ndn_out
=
(
*
ep
)
->
e_nname
;
}
}
return
rc
;
}
int
monitor_back_register_database
(
BackendDB
*
be
,
struct
berval
*
ndn_out
)
{
return
monitor_back_register_database_and_overlay
(
be
,
NULL
,
ndn_out
);
}
int
monitor_back_register_overlay
(
BackendDB
*
be
,
struct
slap_overinst
*
on
,
struct
berval
*
ndn_out
)
{
return
monitor_back_register_database_and_overlay
(
be
,
on
,
ndn_out
);
}
int
monitor_subsys_database_init
(
BackendDB
*
be
,
...
...
servers/slapd/back-monitor/init.c
View file @
45d87c22
...
...
@@ -321,13 +321,6 @@ monitor_back_register_overlay_info(
return
-
1
;
}
int
monitor_back_register_overlay
(
BackendDB
*
be
)
{
return
-
1
;
}
int
monitor_back_register_backend_limbo
(
BackendInfo
*
bi
)
...
...
@@ -338,7 +331,7 @@ monitor_back_register_backend_limbo(
int
monitor_back_register_database_limbo
(
BackendDB
*
be
,
struct
berval
*
ndn
)
struct
berval
*
ndn
_out
)
{
entry_limbo_t
**
elpp
,
el
=
{
0
};
monitor_info_t
*
mi
;
...
...
@@ -357,7 +350,7 @@ monitor_back_register_database_limbo(
el
.
el_type
=
LIMBO_DATABASE
;
el
.
el_be
=
be
->
bd_self
;
el
.
el_ndn
=
ndn
;
el
.
el_ndn
=
ndn
_out
;
for
(
elpp
=
&
mi
->
mi_entry_limbo
;
*
elpp
;
...
...
@@ -381,9 +374,41 @@ monitor_back_register_overlay_info_limbo(
int
monitor_back_register_overlay_limbo
(
BackendDB
*
be
)
BackendDB
*
be
,
struct
slap_overinst
*
on
,
struct
berval
*
ndn_out
)
{
return
-
1
;
entry_limbo_t
**
elpp
,
el
=
{
0
};
monitor_info_t
*
mi
;
if
(
be_monitor
==
NULL
)
{
Debug
(
LDAP_DEBUG_ANY
,
"monitor_back_register_overlay_limbo: "
"monitor database not configured.
\n
"
,
0
,
0
,
0
);
return
-
1
;
}
mi
=
(
monitor_info_t
*
)
be_monitor
->
be_private
;
el
.
el_type
=
LIMBO_OVERLAY
;
el
.
el_be
=
be
->
bd_self
;
el
.
el_on
=
on
;
el
.
el_ndn
=
ndn_out
;
for
(
elpp
=
&
mi
->
mi_entry_limbo
;
*
elpp
;
elpp
=
&
(
*
elpp
)
->
el_next
)
/* go to last */
;
*
elpp
=
(
entry_limbo_t
*
)
ch_malloc
(
sizeof
(
entry_limbo_t
)
);
el
.
el_next
=
NULL
;
**
elpp
=
el
;
return
0
;
}
int
...
...
@@ -2365,8 +2390,7 @@ monitor_back_db_open(
* opens the monitor backend subsystems
*/
for
(
ms
=
monitor_subsys
;
ms
[
0
]
!=
NULL
;
ms
++
)
{
if
(
ms
[
0
]
->
mss_open
&&
(
*
ms
[
0
]
->
mss_open
)(
be
,
ms
[
0
]
)
)
{
if
(
ms
[
0
]
->
mss_open
&&
ms
[
0
]
->
mss_open
(
be
,
ms
[
0
]
)
)
{
return
(
-
1
);
}
ms
[
0
]
->
mss_flags
|=
MONITOR_F_OPENED
;
...
...
@@ -2434,7 +2458,7 @@ monitor_back_db_open(
break
;
case
LIMBO_OVERLAY
:
rc
=
monitor_back_register_overlay
(
el
->
el_be
);
rc
=
monitor_back_register_overlay
(
el
->
el_be
,
el
->
el_on
,
el
->
el_ndn
);
break
;
default:
...
...
servers/slapd/back-monitor/proto-back-monitor.h
View file @
45d87c22
...
...
@@ -152,20 +152,24 @@ monitor_back_register_overlay_info LDAP_P((
slap_overinst
*
on
));
extern
int
monitor_back_register_overlay
LDAP_P
((
BackendDB
*
be
));
BackendDB
*
be
,
struct
slap_overinst
*
on
,
struct
berval
*
ndn_out
));
extern
int
monitor_back_register_backend_limbo
LDAP_P
((
BackendInfo
*
bi
));
extern
int
monitor_back_register_database_limbo
LDAP_P
((
BackendDB
*
be
,
struct
berval
*
ndn
));
struct
berval
*
ndn
_out
));
extern
int
monitor_back_register_overlay_info_limbo
LDAP_P
((
slap_overinst
*
on
));
extern
int
monitor_back_register_overlay_limbo
LDAP_P
((
BackendDB
*
be
));
BackendDB
*
be
,
struct
slap_overinst
*
on
,
struct
berval
*
ndn_out
));
extern
monitor_subsys_t
*
monitor_back_get_subsys
LDAP_P
((
const
char
*
name
));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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