1 /* Copyright (c) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@suse.de>, 1998.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27 /* The declarations for the request and response types are in the file
28 "nscd-client.h", which should contain everything needed by client
30 #include "nscd-client.h"
33 /* Handle databases. */
43 /* Structure for one hash table entry. */
46 request_type type
; /* Which type of dataset. */
47 size_t len
; /* Length of key. */
48 void *key
; /* Pointer to key. */
49 uid_t owner
; /* If secure table, this is the owner. */
50 struct hashentry
*next
; /* Next entry in this hash bucket list. */
51 time_t timeout
; /* Time when this entry becomes invalid. */
52 ssize_t total
; /* Number of bytes in PACKET. */
53 const void *packet
; /* Records for the result. */
54 void *data
; /* The malloc()ed respond record. */
55 int last
; /* Nonzero if DATA should be free()d. */
56 struct hashentry
*dellist
; /* Next record to be deleted. */
59 /* Structure describing one database. */
62 pthread_rwlock_t lock
;
70 const struct iovec
*disabled_iov
;
72 unsigned long int postimeout
;
73 unsigned long int negtimeout
;
75 unsigned long int poshit
;
76 unsigned long int neghit
;
77 unsigned long int posmiss
;
78 unsigned long int negmiss
;
80 unsigned long int nentries
;
81 unsigned long int maxnentries
;
82 unsigned long int maxnsearched
;
84 unsigned long int rdlockdelayed
;
85 unsigned long int wrlockdelayed
;
87 struct hashentry
**array
;
91 /* Global variables. */
92 extern struct database dbs
[lastdb
];
93 extern const char *dbnames
[lastdb
];
94 extern const char *serv2str
[LASTREQ
];
96 extern const struct iovec pwd_iov_disabled
;
97 extern const struct iovec grp_iov_disabled
;
98 extern const struct iovec hst_iov_disabled
;
100 /* Number of threads to run. */
103 /* Tables for which we cache data with uid. */
104 extern int secure
[lastdb
];
105 extern int secure_in_use
; /* Is one of the above 1? */
107 /* User name to run server processes as. */
108 extern const char *server_user
;
110 /* Name and UID of user who is allowed to request statistics. */
111 extern const char *stat_user
;
112 extern uid_t stat_uid
;
114 /* Time the server was started. */
115 extern time_t start_time
;
117 /* Number of times clients had to wait. */
118 extern unsigned long int client_queued
;
120 /* Prototypes for global functions. */
123 extern void termination_handler (int signum
) __attribute__ ((__noreturn__
));
124 extern int nscd_open_socket (void);
127 extern void nscd_init (void);
128 extern void close_sockets (void);
129 extern void start_threads (void) __attribute__ ((__noreturn__
));
132 extern int nscd_parse_file (const char *fname
, struct database dbs
[lastdb
]);
135 extern void send_stats (int fd
, struct database dbs
[lastdb
]);
136 extern int receive_print_stats (void) __attribute__ ((__noreturn__
));
139 extern struct hashentry
*cache_search (request_type
, void *key
, size_t len
,
140 struct database
*table
, uid_t owner
);
141 extern void cache_add (int type
, void *key
, size_t len
,
142 const void *packet
, size_t iovtotal
, void *data
,
143 int last
, time_t t
, struct database
*table
,
145 extern void prune_cache (struct database
*table
, time_t now
);
148 extern void addpwbyname (struct database
*db
, int fd
, request_header
*req
,
149 void *key
, uid_t uid
);
150 extern void addpwbyuid (struct database
*db
, int fd
, request_header
*req
,
151 void *key
, uid_t uid
);
154 extern void addgrbyname (struct database
*db
, int fd
, request_header
*req
,
155 void *key
, uid_t uid
);
156 extern void addgrbygid (struct database
*db
, int fd
, request_header
*req
,
157 void *key
, uid_t uid
);
160 extern void addhstbyname (struct database
*db
, int fd
, request_header
*req
,
161 void *key
, uid_t uid
);
162 extern void addhstbyaddr (struct database
*db
, int fd
, request_header
*req
,
163 void *key
, uid_t uid
);
164 extern void addhstbynamev6 (struct database
*db
, int fd
, request_header
*req
,
165 void *key
, uid_t uid
);
166 extern void addhstbyaddrv6 (struct database
*db
, int fd
, request_header
*req
,
167 void *key
, uid_t uid
);