2 * Copyright (c) 2005 Michael Bushkov <bushman@rsu.ru>
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * $FreeBSD: src/usr.sbin/nscd/config.h,v 1.3 2007/09/27 12:30:11 bushman Exp $
29 #ifndef __NSCD_CONFIG_H__
30 #define __NSCD_CONFIG_H__
33 #include <sys/types.h>
39 #define DEFAULT_QUERY_TIMEOUT 8
40 #define DEFAULT_THREADS_NUM 8
42 #define DEFAULT_COMMON_ENTRY_TIMEOUT 10
43 #define DEFAULT_MP_ENTRY_TIMEOUT 60
44 #define DEFAULT_CACHE_HT_SIZE 257
46 #define INITIAL_ENTRIES_CAPACITY 8
47 #define DEFAULT_SOCKET_PATH "/var/run/nscd"
48 #define DEFAULT_PIDFILE_PATH "/var/run/nscd.pid"
50 #define DEFAULT_POSITIVE_ELEMENTS_SIZE (2048)
51 #define DEFAULT_POSITIVE_LIFETIME (3600)
53 #define DEFAULT_NEGATIVE_ELEMENTS_SIZE (2048)
54 #define DEFAULT_NEGATIVE_LIFETIME (60)
56 #define DEFAULT_MULTIPART_ELEMENTS_SIZE (1024 * 8)
57 #define DEFAULT_MULITPART_SESSIONS_SIZE (1024)
58 #define DEFAULT_MULITPART_LIFETIME (3600)
60 extern const char *c_default_entries
[6];
63 * Configuration entry represents the details of each cache entry in the
64 * config file (i.e. passwd or group). Its purpose also is to acquire locks
65 * of three different types (for usual read/write caching, for multipart
66 * caching and for caching of the negative results) for that cache entry.
68 struct configuration_entry
{
69 struct common_cache_entry_params positive_cache_params
;
70 struct common_cache_entry_params negative_cache_params
;
71 struct mp_cache_entry_params mp_cache_params
;
74 * configuration_entry holds pointers for all actual cache_entries,
75 * which are used for it. There is one for positive caching, one for
76 * for negative caching, and several (one per each euid/egid) for
79 cache_entry positive_cache_entry
;
80 cache_entry negative_cache_entry
;
82 cache_entry
*mp_cache_entries
;
83 size_t mp_cache_entries_size
;
85 struct timeval common_query_timeout
;
86 struct timeval mp_query_timeout
;
89 pthread_mutex_t positive_cache_lock
;
90 pthread_mutex_t negative_cache_lock
;
91 pthread_mutex_t mp_cache_lock
;
93 int perform_actual_lookups
;
98 * Contains global configuration options and array of all configuration entries
100 struct configuration
{
104 struct configuration_entry
**entries
;
105 size_t entries_capacity
;
108 pthread_rwlock_t rwlock
;
117 enum config_entry_lock_type
{
123 extern struct configuration
*init_configuration(void);
124 extern void destroy_configuration(struct configuration
*);
125 extern void fill_configuration_defaults(struct configuration
*);
127 extern int add_configuration_entry(struct configuration
*,
128 struct configuration_entry
*);
129 extern struct configuration_entry
*create_def_configuration_entry(
131 extern void destroy_configuration_entry(struct configuration_entry
*);
132 extern size_t configuration_get_entries_size(struct configuration
*);
133 extern struct configuration_entry
*configuration_get_entry(
134 struct configuration
*, size_t);
135 extern struct configuration_entry
*configuration_find_entry(
136 struct configuration
*, const char *);
138 extern int configuration_entry_add_mp_cache_entry(struct configuration_entry
*,
140 extern cache_entry
configuration_entry_find_mp_cache_entry(
141 struct configuration_entry
*,
143 extern int configuration_entry_find_mp_cache_entries(
144 struct configuration_entry
*, const char *, cache_entry
**,
147 extern void configuration_lock_rdlock(struct configuration
*config
);
148 extern void configuration_lock_wrlock(struct configuration
*config
);
149 extern void configuration_unlock(struct configuration
*config
);
151 extern void configuration_lock_entry(struct configuration_entry
*,
152 enum config_entry_lock_type
);
153 extern void configuration_unlock_entry(struct configuration_entry
*,
154 enum config_entry_lock_type
);