]> git.ipfire.org Git - thirdparty/glibc.git/blame - nscd/nscd.h
* sysdeps/unix/sysv/linux/Versions: Export Inotify_* syscalls.
[thirdparty/glibc.git] / nscd / nscd.h
CommitLineData
dc4bb1c2 1/* Copyright (c) 1998, 1999, 2000, 2001, 2003, 2004, 2005
a95a08b4 2 Free Software Foundation, Inc.
d67281a7 3 This file is part of the GNU C Library.
a1c542bf 4 Contributed by Thorsten Kukuk <kukuk@suse.de>, 1998.
d67281a7
UD
5
6 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
d67281a7
UD
10
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 14 Lesser General Public License for more details.
d67281a7 15
41bdb6e2
AJ
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
d67281a7
UD
20
21#ifndef _NSCD_H
67479a70
UD
22#define _NSCD_H 1
23
24#include <pthread.h>
a95a08b4 25#include <stdbool.h>
67479a70
UD
26#include <time.h>
27#include <sys/uio.h>
d67281a7 28
4f6bfa80
RM
29/* The declarations for the request and response types are in the file
30 "nscd-client.h", which should contain everything needed by client
31 functions. */
32#include "nscd-client.h"
67479a70 33
d67281a7 34
67479a70
UD
35/* Handle databases. */
36typedef enum
37{
38 pwddb,
39 grpdb,
40 hstdb,
41 lastdb
42} dbtype;
d67281a7 43
67479a70 44
a95a08b4
UD
45/* Default limit on the number of times a value gets reloaded without
46 being used in the meantime. NSCD does not throw a value out as
47 soon as it times out. It tries to reload the value from the
48 server. Only if the value has not been used for so many rounds it
49 is removed. */
50#define DEFAULT_RELOAD_LIMIT 5
51
52
4401d759
UD
53/* Time before restarting the process in paranoia mode. */
54#define RESTART_INTERVAL (60 * 60)
55
56
a95a08b4
UD
57/* Structure describing dynamic part of one database. */
58struct database_dyn
67479a70
UD
59{
60 pthread_rwlock_t lock;
61
62 int enabled;
63 int check_file;
a95a08b4 64 int persistent;
c207f23b 65 int shared;
a334319f 66 const char *filename;
a95a08b4 67 const char *db_filename;
67479a70 68 time_t file_mtime;
a95a08b4 69 size_t suggested_module;
a334319f 70 int secure;
67479a70 71
a95a08b4
UD
72 unsigned long int postimeout; /* In seconds. */
73 unsigned long int negtimeout; /* In seconds. */
67479a70 74
a95a08b4
UD
75 int wr_fd; /* Writable file descriptor. */
76 int ro_fd; /* Unwritable file descriptor. */
67479a70 77
a95a08b4 78 const struct iovec *disabled_iov;
67479a70 79
a95a08b4
UD
80 struct database_pers_head *head;
81 char *data;
82 size_t memsize;
83 pthread_mutex_t memlock;
84 bool mmap_used;
85 bool last_alloc_failed;
86};
c86e6aec 87
c86e6aec 88
a95a08b4 89/* Paths of the file for the persistent storage. */
457962e5
UD
90#define _PATH_NSCD_PASSWD_DB "/var/db/nscd/passwd"
91#define _PATH_NSCD_GROUP_DB "/var/db/nscd/group"
92#define _PATH_NSCD_HOSTS_DB "/var/db/nscd/hosts"
93
94/* Path used when not using persistent storage. */
95#define _PATH_NSCD_XYZ_DB_TMP "/var/run/nscd/dbXXXXXX"
67479a70 96
dc4bb1c2
UD
97/* Maximum alignment requirement we will encounter. */
98#define BLOCK_ALIGN_LOG 3
99#define BLOCK_ALIGN (1 << BLOCK_ALIGN_LOG)
100#define BLOCK_ALIGN_M1 (BLOCK_ALIGN - 1)
101
67479a70 102
67479a70 103/* Global variables. */
a95a08b4 104extern struct database_dyn dbs[lastdb];
67479a70
UD
105extern const char *dbnames[lastdb];
106extern const char *serv2str[LASTREQ];
107
108extern const struct iovec pwd_iov_disabled;
109extern const struct iovec grp_iov_disabled;
110extern const struct iovec hst_iov_disabled;
111
a95a08b4 112
27e82856 113/* Initial number of threads to run. */
67479a70 114extern int nthreads;
27e82856
UD
115/* Maximum number of threads to use. */
116extern int max_nthreads;
67479a70 117
a334319f
UD
118/* Tables for which we cache data with uid. */
119extern int secure_in_use; /* Is one of the above 1? */
120
a12ce44f 121/* User name to run server processes as. */
adcf0e4a
UD
122extern const char *server_user;
123
a12ce44f
UD
124/* Name and UID of user who is allowed to request statistics. */
125extern const char *stat_user;
126extern uid_t stat_uid;
127
c86e6aec
UD
128/* Time the server was started. */
129extern time_t start_time;
130
a16e3585
UD
131/* Number of times clients had to wait. */
132extern unsigned long int client_queued;
133
a95a08b4
UD
134/* Maximum needed alignment. */
135extern const size_t block_align;
136
137/* Number of times a value is reloaded without being used. UINT_MAX
138 means unlimited. */
139extern unsigned int reload_count;
140
3418007e
UD
141/* Pagesize minus one. */
142extern uintptr_t pagesize_m1;
143
4401d759
UD
144/* Nonzero if paranoia mode is enabled. */
145extern int paranoia;
146/* Time after which the process restarts. */
147extern time_t restart_time;
148/* How much time between restarts. */
149extern time_t restart_interval;
150/* Old current working directory. */
151extern const char *oldcwd;
152/* Old user and group ID. */
153extern uid_t old_uid;
154extern gid_t old_gid;
155
156
67479a70
UD
157/* Prototypes for global functions. */
158
159/* nscd.c */
59553897 160extern void termination_handler (int signum) __attribute__ ((__noreturn__));
67479a70
UD
161extern int nscd_open_socket (void);
162
163/* connections.c */
a12ce44f 164extern void nscd_init (void);
67479a70 165extern void close_sockets (void);
8f11d6f9 166extern void start_threads (void) __attribute__ ((__noreturn__));
67479a70
UD
167
168/* nscd_conf.c */
a95a08b4
UD
169extern int nscd_parse_file (const char *fname,
170 struct database_dyn dbs[lastdb]);
67479a70
UD
171
172/* nscd_stat.c */
a95a08b4 173extern void send_stats (int fd, struct database_dyn dbs[lastdb]);
59553897 174extern int receive_print_stats (void) __attribute__ ((__noreturn__));
67479a70
UD
175
176/* cache.c */
a95a08b4
UD
177extern struct datahead *cache_search (request_type, void *key, size_t len,
178 struct database_dyn *table,
179 uid_t owner);
180extern int cache_add (int type, const void *key, size_t len,
181 struct datahead *packet, bool first,
182 struct database_dyn *table, uid_t owner);
a334319f 183extern void prune_cache (struct database_dyn *table, time_t now);
67479a70
UD
184
185/* pwdcache.c */
a95a08b4 186extern void addpwbyname (struct database_dyn *db, int fd, request_header *req,
a1c542bf 187 void *key, uid_t uid);
a95a08b4 188extern void addpwbyuid (struct database_dyn *db, int fd, request_header *req,
a1c542bf 189 void *key, uid_t uid);
a95a08b4
UD
190extern void readdpwbyname (struct database_dyn *db, struct hashentry *he,
191 struct datahead *dh);
192extern void readdpwbyuid (struct database_dyn *db, struct hashentry *he,
193 struct datahead *dh);
67479a70
UD
194
195/* grpcache.c */
a95a08b4 196extern void addgrbyname (struct database_dyn *db, int fd, request_header *req,
a1c542bf 197 void *key, uid_t uid);
a95a08b4 198extern void addgrbygid (struct database_dyn *db, int fd, request_header *req,
a1c542bf 199 void *key, uid_t uid);
a95a08b4
UD
200extern void readdgrbyname (struct database_dyn *db, struct hashentry *he,
201 struct datahead *dh);
202extern void readdgrbygid (struct database_dyn *db, struct hashentry *he,
203 struct datahead *dh);
67479a70
UD
204
205/* hstcache.c */
a95a08b4 206extern void addhstbyname (struct database_dyn *db, int fd, request_header *req,
a1c542bf 207 void *key, uid_t uid);
a95a08b4 208extern void addhstbyaddr (struct database_dyn *db, int fd, request_header *req,
a1c542bf 209 void *key, uid_t uid);
a95a08b4
UD
210extern void addhstbynamev6 (struct database_dyn *db, int fd,
211 request_header *req, void *key, uid_t uid);
212extern void addhstbyaddrv6 (struct database_dyn *db, int fd,
213 request_header *req, void *key, uid_t uid);
214extern void readdhstbyname (struct database_dyn *db, struct hashentry *he,
215 struct datahead *dh);
216extern void readdhstbyaddr (struct database_dyn *db, struct hashentry *he,
217 struct datahead *dh);
218extern void readdhstbynamev6 (struct database_dyn *db, struct hashentry *he,
219 struct datahead *dh);
220extern void readdhstbyaddrv6 (struct database_dyn *db, struct hashentry *he,
221 struct datahead *dh);
222
d19687d6
UD
223/* aicache.c */
224extern void addhstai (struct database_dyn *db, int fd, request_header *req,
225 void *key, uid_t uid);
226extern void readdhstai (struct database_dyn *db, struct hashentry *he,
227 struct datahead *dh);
a95a08b4 228
26235c7c
UD
229
230/* initgrcache.c */
231extern void addinitgroups (struct database_dyn *db, int fd,
232 request_header *req, void *key, uid_t uid);
233extern void readdinitgroups (struct database_dyn *db, struct hashentry *he,
234 struct datahead *dh);
235
a95a08b4
UD
236/* mem.c */
237extern void *mempool_alloc (struct database_dyn *db, size_t len);
238extern void gc (struct database_dyn *db);
4f6bfa80 239
081fc592
UD
240
241/* nscd_setup_thread.c */
242extern void setup_thread (struct database_dyn *db);
243
67479a70 244#endif /* nscd.h */