4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
38 #include "ns_internal.h"
39 #include "ns_cache_door.h"
40 #include "cachemgr_door.h"
42 #define LOGFILE "/var/ldap/cachemgr.log"
43 #define KILLCACHEMGR "/var/lib/ldap/ldap_cachemgr -K"
45 #define MAXDEBUG DBG_ALL
46 #define DEFAULTTTL 3600 /* 1 hour */
50 char space
[BUFFERSIZE
];
54 * In ldap_cachemgr, it return -99 for some case, start with -100 here
56 typedef enum chg_error
{
59 CHG_INVALID_PARAM
= -101,
60 CHG_NOT_FOUND_IN_WAITING_LIST
= -102,
61 CHG_EXCEED_MAX_THREADS
= -103,
62 CHG_NSCD_REPEATED_CALL
= -104
65 typedef struct waiting_list
{
66 pid_t pid
; /* pid of the door client */
67 thread_t tid
; /* thread id of the server */
69 int cleanup
; /* 1: the thread will be */
71 struct waiting_list
*prev
; /* previous node in the */
73 struct waiting_list
*next
; /* next node in the linked */
78 * This structure contains the buffer for the chang data and a wating list to
79 * regester all the threads that handle GETSTATUSCHANGE START call and are
80 * waiting for the change notification.
81 * The notification threads save the data in the buffer then send broadcast
82 * to wake up the GETSTATUSCHANGE START threads to copy data to the stack and
85 typedef struct chg_info
{
86 mutex_t chg_lock
; /* mutex for this data structure */
87 cond_t chg_cv
; /* cond var for synchronization */
88 int chg_wakeup
; /* flag used with chg_cv for */
90 waiting_list_t
*chg_w_first
; /* the head of the linked list */
91 waiting_list_t
*chg_w_last
; /* the tail of the linked list */
92 char *chg_data
; /* the buffer for the change data */
93 int chg_data_size
; /* the size of the change data */
96 extern char *getcacheopt(char *s
);
97 extern void logit(char *format
, ...);
98 extern int load_admin_defaults(admin_t
*ptr
, int will_become_server
);
99 extern int getldap_init(void);
100 extern void getldap_revalidate(void);
101 extern int getldap_uidkeepalive(int keep
, int interval
);
102 extern int getldap_invalidate(void);
103 extern void getldap_lookup(LineBuf
*config_info
, ldap_call_t
*in
);
104 extern void getldap_admincred(LineBuf
*config_info
, ldap_call_t
*in
);
105 extern void getldap_refresh(void);
106 extern int cachemgr_set_dl(admin_t
*ptr
, int value
);
107 extern int cachemgr_set_ttl(ldap_stat_t
*cache
, char *name
, int value
);
108 extern int get_clearance(int callnumber
);
109 extern int release_clearance(int callnumber
);
111 extern void discover();
113 extern void getldap_serverInfo_refresh(void);
114 extern void getldap_getserver(LineBuf
*config_info
, ldap_call_t
*in
);
115 extern void getldap_get_cacheData(LineBuf
*config_info
, ldap_call_t
*in
);
116 extern int getldap_set_cacheData(ldap_call_t
*in
);
117 extern void getldap_get_cacheStat(LineBuf
*stat_info
);
118 extern int is_called_from_nscd(pid_t pid
); /* in cachemgr.c */
119 extern int chg_is_called_from_nscd_or_peruser_nscd(char *dc_str
, pid_t
*pidp
);
120 extern void *chg_cleanup_waiting_threads(void *arg
);
121 extern int chg_get_statusChange(LineBuf
*config_info
, ldap_call_t
*in
,
123 extern int chg_notify_statusChange(char *str
);
124 extern void chg_test_config_change(ns_config_t
*new, int *change_status
);
125 extern void chg_config_cookie_set(ldap_get_chg_cookie_t
*cookie
);
126 extern ldap_get_chg_cookie_t
chg_config_cookie_get(void);
131 #endif /* _CACHEMGR_H */