1 /* $NetBSD: operational.c,v 1.3 2021/08/14 16:15:00 christos Exp $ */
2
3 /* operational.c - monitor backend operational attributes function */
4 /* $OpenLDAP$ */
5 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
6 *
7 * Copyright 2001-2021 The OpenLDAP Foundation.
8 * Portions Copyright 2001-2003 Pierangelo Masarati.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted only as authorized by the OpenLDAP
13 * Public License.
14 *
15 * A copy of this license is available in file LICENSE in the
16 * top-level directory of the distribution or, alternatively, at
17 * <http://www.OpenLDAP.org/license.html>.
18 */
19 /* ACKNOWLEDGEMENTS:
20 * This work was initially developed by Pierangelo Masarati for inclusion
21 * in OpenLDAP Software.
22 */
23
24 #include <sys/cdefs.h>
25 __RCSID("$NetBSD: operational.c,v 1.3 2021/08/14 16:15:00 christos Exp $");
26
27 #include "portable.h"
28
29 #include <stdio.h>
30
31 #include <ac/string.h>
32 #include <ac/socket.h>
33
34 #include "slap.h"
35 #include "back-monitor.h"
36 #include "proto-back-monitor.h"
37
38 /*
39 * sets the supported operational attributes (if required)
40 */
41
42 int
monitor_back_operational(Operation * op,SlapReply * rs)43 monitor_back_operational(
44 Operation *op,
45 SlapReply *rs )
46 {
47 Attribute **ap;
48
49 assert( rs->sr_entry != NULL );
50
51 for ( ap = &rs->sr_operational_attrs; *ap; ap = &(*ap)->a_next ) {
52 if ( (*ap)->a_desc == slap_schema.si_ad_hasSubordinates ) {
53 break;
54 }
55 }
56
57 if ( *ap == NULL &&
58 attr_find( rs->sr_entry->e_attrs, slap_schema.si_ad_hasSubordinates ) == NULL &&
59 ( SLAP_OPATTRS( rs->sr_attr_flags ) ||
60 ad_inlist( slap_schema.si_ad_hasSubordinates, rs->sr_attrs ) ) )
61 {
62 int hs;
63 monitor_entry_t *mp;
64
65 mp = ( monitor_entry_t * )rs->sr_entry->e_private;
66
67 assert( mp != NULL );
68
69 hs = MONITOR_HAS_CHILDREN( mp );
70 *ap = slap_operational_hasSubordinate( hs );
71 assert( *ap != NULL );
72 ap = &(*ap)->a_next;
73 }
74
75 return LDAP_SUCCESS;
76 }
77
78