2004-08-27 02:35:05 +08:00
|
|
|
/* Copyright (c) 1998, 1999, 2000, 2001, 2003, 2004
|
|
|
|
Free Software Foundation, Inc.
|
1998-01-31 16:39:55 +08:00
|
|
|
This file is part of the GNU C Library.
|
1999-06-12 04:58:21 +08:00
|
|
|
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1998.
|
1998-01-31 16:39:55 +08:00
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 12:58:11 +08:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
1998-01-31 16:39:55 +08:00
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2001-07-06 12:58:11 +08:00
|
|
|
Lesser General Public License for more details.
|
1998-01-31 16:39:55 +08:00
|
|
|
|
2001-07-06 12:58:11 +08:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with the GNU C Library; if not, write to the Free
|
|
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
|
|
02111-1307 USA. */
|
1998-01-31 16:39:55 +08:00
|
|
|
|
|
|
|
#ifndef _NSCD_H
|
1998-10-18 23:16:22 +08:00
|
|
|
#define _NSCD_H 1
|
|
|
|
|
|
|
|
#include <pthread.h>
|
2004-08-27 02:35:05 +08:00
|
|
|
#include <stdbool.h>
|
1998-10-18 23:16:22 +08:00
|
|
|
#include <time.h>
|
|
|
|
#include <sys/uio.h>
|
1998-01-31 16:39:55 +08:00
|
|
|
|
1998-10-19 06:02:47 +08:00
|
|
|
/* The declarations for the request and response types are in the file
|
|
|
|
"nscd-client.h", which should contain everything needed by client
|
|
|
|
functions. */
|
|
|
|
#include "nscd-client.h"
|
1998-10-18 23:16:22 +08:00
|
|
|
|
1998-01-31 16:39:55 +08:00
|
|
|
|
1998-10-18 23:16:22 +08:00
|
|
|
/* Handle databases. */
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
pwddb,
|
|
|
|
grpdb,
|
|
|
|
hstdb,
|
|
|
|
lastdb
|
|
|
|
} dbtype;
|
1998-01-31 16:39:55 +08:00
|
|
|
|
1998-10-18 23:16:22 +08:00
|
|
|
|
2004-08-27 02:35:05 +08:00
|
|
|
/* Default limit on the number of times a value gets reloaded without
|
|
|
|
being used in the meantime. NSCD does not throw a value out as
|
|
|
|
soon as it times out. It tries to reload the value from the
|
|
|
|
server. Only if the value has not been used for so many rounds it
|
|
|
|
is removed. */
|
|
|
|
#define DEFAULT_RELOAD_LIMIT 5
|
|
|
|
|
|
|
|
|
|
|
|
/* Structure describing dynamic part of one database. */
|
|
|
|
struct database_dyn
|
1998-10-18 23:16:22 +08:00
|
|
|
{
|
|
|
|
pthread_rwlock_t lock;
|
|
|
|
|
|
|
|
int enabled;
|
|
|
|
int check_file;
|
2004-08-27 02:35:05 +08:00
|
|
|
int persistent;
|
2004-09-08 23:46:42 +08:00
|
|
|
int shared;
|
1998-10-18 23:16:22 +08:00
|
|
|
const char *filename;
|
2004-08-27 02:35:05 +08:00
|
|
|
const char *db_filename;
|
1998-10-18 23:16:22 +08:00
|
|
|
time_t file_mtime;
|
2004-08-27 02:35:05 +08:00
|
|
|
size_t suggested_module;
|
|
|
|
int secure;
|
1998-10-18 23:16:22 +08:00
|
|
|
|
2004-08-27 02:35:05 +08:00
|
|
|
unsigned long int postimeout; /* In seconds. */
|
|
|
|
unsigned long int negtimeout; /* In seconds. */
|
1998-10-18 23:16:22 +08:00
|
|
|
|
2004-08-27 02:35:05 +08:00
|
|
|
int wr_fd; /* Writable file descriptor. */
|
|
|
|
int ro_fd; /* Unwritable file descriptor. */
|
1998-10-18 23:16:22 +08:00
|
|
|
|
2004-08-27 02:35:05 +08:00
|
|
|
const struct iovec *disabled_iov;
|
1998-10-18 23:16:22 +08:00
|
|
|
|
2004-08-27 02:35:05 +08:00
|
|
|
struct database_pers_head *head;
|
|
|
|
char *data;
|
|
|
|
size_t memsize;
|
|
|
|
pthread_mutex_t memlock;
|
|
|
|
bool mmap_used;
|
|
|
|
bool last_alloc_failed;
|
|
|
|
};
|
2003-04-26 12:15:50 +08:00
|
|
|
|
|
|
|
|
2004-08-27 02:35:05 +08:00
|
|
|
/* Paths of the file for the persistent storage. */
|
|
|
|
#define _PATH_NSCD_PASSWD_DB "/var/run/nscd/passwd"
|
|
|
|
#define _PATH_NSCD_GROUP_DB "/var/run/nscd/group"
|
|
|
|
#define _PATH_NSCD_HOSTS_DB "/var/run/nscd/hosts"
|
1998-10-18 23:16:22 +08:00
|
|
|
|
|
|
|
|
|
|
|
/* Global variables. */
|
2004-08-27 02:35:05 +08:00
|
|
|
extern struct database_dyn dbs[lastdb];
|
1998-10-18 23:16:22 +08:00
|
|
|
extern const char *dbnames[lastdb];
|
|
|
|
extern const char *serv2str[LASTREQ];
|
|
|
|
|
|
|
|
extern const struct iovec pwd_iov_disabled;
|
|
|
|
extern const struct iovec grp_iov_disabled;
|
|
|
|
extern const struct iovec hst_iov_disabled;
|
|
|
|
|
2004-08-27 02:35:05 +08:00
|
|
|
|
1998-10-18 23:16:22 +08:00
|
|
|
/* Number of threads to run. */
|
|
|
|
extern int nthreads;
|
|
|
|
|
2003-05-04 15:00:44 +08:00
|
|
|
/* Tables for which we cache data with uid. */
|
|
|
|
extern int secure_in_use; /* Is one of the above 1? */
|
1998-10-18 23:16:22 +08:00
|
|
|
|
2003-05-04 15:00:44 +08:00
|
|
|
/* User name to run server processes as. */
|
2000-04-30 14:52:59 +08:00
|
|
|
extern const char *server_user;
|
|
|
|
|
2003-05-04 15:00:44 +08:00
|
|
|
/* Name and UID of user who is allowed to request statistics. */
|
|
|
|
extern const char *stat_user;
|
|
|
|
extern uid_t stat_uid;
|
|
|
|
|
2003-04-26 12:15:50 +08:00
|
|
|
/* Time the server was started. */
|
|
|
|
extern time_t start_time;
|
|
|
|
|
2003-04-28 11:40:26 +08:00
|
|
|
/* Number of times clients had to wait. */
|
|
|
|
extern unsigned long int client_queued;
|
|
|
|
|
2004-08-27 02:35:05 +08:00
|
|
|
/* Maximum needed alignment. */
|
|
|
|
extern const size_t block_align;
|
|
|
|
|
|
|
|
/* Number of times a value is reloaded without being used. UINT_MAX
|
|
|
|
means unlimited. */
|
|
|
|
extern unsigned int reload_count;
|
|
|
|
|
2004-09-11 07:56:29 +08:00
|
|
|
/* Pagesize minus one. */
|
|
|
|
extern uintptr_t pagesize_m1;
|
|
|
|
|
1998-10-18 23:16:22 +08:00
|
|
|
/* Prototypes for global functions. */
|
|
|
|
|
|
|
|
/* nscd.c */
|
2000-11-21 01:40:29 +08:00
|
|
|
extern void termination_handler (int signum) __attribute__ ((__noreturn__));
|
1998-10-18 23:16:22 +08:00
|
|
|
extern int nscd_open_socket (void);
|
|
|
|
|
|
|
|
/* connections.c */
|
2003-05-04 15:00:44 +08:00
|
|
|
extern void nscd_init (void);
|
1998-10-18 23:16:22 +08:00
|
|
|
extern void close_sockets (void);
|
2001-04-23 14:04:16 +08:00
|
|
|
extern void start_threads (void) __attribute__ ((__noreturn__));
|
1998-10-18 23:16:22 +08:00
|
|
|
|
|
|
|
/* nscd_conf.c */
|
2004-08-27 02:35:05 +08:00
|
|
|
extern int nscd_parse_file (const char *fname,
|
|
|
|
struct database_dyn dbs[lastdb]);
|
1998-10-18 23:16:22 +08:00
|
|
|
|
|
|
|
/* nscd_stat.c */
|
2004-08-27 02:35:05 +08:00
|
|
|
extern void send_stats (int fd, struct database_dyn dbs[lastdb]);
|
2000-11-21 01:40:29 +08:00
|
|
|
extern int receive_print_stats (void) __attribute__ ((__noreturn__));
|
1998-10-18 23:16:22 +08:00
|
|
|
|
|
|
|
/* cache.c */
|
2004-08-27 02:35:05 +08:00
|
|
|
extern struct datahead *cache_search (request_type, void *key, size_t len,
|
|
|
|
struct database_dyn *table,
|
|
|
|
uid_t owner);
|
|
|
|
extern int cache_add (int type, const void *key, size_t len,
|
|
|
|
struct datahead *packet, bool first,
|
|
|
|
struct database_dyn *table, uid_t owner);
|
|
|
|
extern void prune_cache (struct database_dyn *table, time_t now);
|
1998-10-18 23:16:22 +08:00
|
|
|
|
|
|
|
/* pwdcache.c */
|
2004-08-27 02:35:05 +08:00
|
|
|
extern void addpwbyname (struct database_dyn *db, int fd, request_header *req,
|
1999-06-12 04:58:21 +08:00
|
|
|
void *key, uid_t uid);
|
2004-08-27 02:35:05 +08:00
|
|
|
extern void addpwbyuid (struct database_dyn *db, int fd, request_header *req,
|
1999-06-12 04:58:21 +08:00
|
|
|
void *key, uid_t uid);
|
2004-08-27 02:35:05 +08:00
|
|
|
extern void readdpwbyname (struct database_dyn *db, struct hashentry *he,
|
|
|
|
struct datahead *dh);
|
|
|
|
extern void readdpwbyuid (struct database_dyn *db, struct hashentry *he,
|
|
|
|
struct datahead *dh);
|
1998-10-18 23:16:22 +08:00
|
|
|
|
|
|
|
/* grpcache.c */
|
2004-08-27 02:35:05 +08:00
|
|
|
extern void addgrbyname (struct database_dyn *db, int fd, request_header *req,
|
1999-06-12 04:58:21 +08:00
|
|
|
void *key, uid_t uid);
|
2004-08-27 02:35:05 +08:00
|
|
|
extern void addgrbygid (struct database_dyn *db, int fd, request_header *req,
|
1999-06-12 04:58:21 +08:00
|
|
|
void *key, uid_t uid);
|
2004-08-27 02:35:05 +08:00
|
|
|
extern void readdgrbyname (struct database_dyn *db, struct hashentry *he,
|
|
|
|
struct datahead *dh);
|
|
|
|
extern void readdgrbygid (struct database_dyn *db, struct hashentry *he,
|
|
|
|
struct datahead *dh);
|
1998-10-18 23:16:22 +08:00
|
|
|
|
|
|
|
/* hstcache.c */
|
2004-08-27 02:35:05 +08:00
|
|
|
extern void addhstbyname (struct database_dyn *db, int fd, request_header *req,
|
1999-06-12 04:58:21 +08:00
|
|
|
void *key, uid_t uid);
|
2004-08-27 02:35:05 +08:00
|
|
|
extern void addhstbyaddr (struct database_dyn *db, int fd, request_header *req,
|
1999-06-12 04:58:21 +08:00
|
|
|
void *key, uid_t uid);
|
2004-08-27 02:35:05 +08:00
|
|
|
extern void addhstbynamev6 (struct database_dyn *db, int fd,
|
|
|
|
request_header *req, void *key, uid_t uid);
|
|
|
|
extern void addhstbyaddrv6 (struct database_dyn *db, int fd,
|
|
|
|
request_header *req, void *key, uid_t uid);
|
|
|
|
extern void readdhstbyname (struct database_dyn *db, struct hashentry *he,
|
|
|
|
struct datahead *dh);
|
|
|
|
extern void readdhstbyaddr (struct database_dyn *db, struct hashentry *he,
|
|
|
|
struct datahead *dh);
|
|
|
|
extern void readdhstbynamev6 (struct database_dyn *db, struct hashentry *he,
|
|
|
|
struct datahead *dh);
|
|
|
|
extern void readdhstbyaddrv6 (struct database_dyn *db, struct hashentry *he,
|
|
|
|
struct datahead *dh);
|
|
|
|
|
2004-09-15 16:25:49 +08:00
|
|
|
/* aicache.c */
|
|
|
|
extern void addhstai (struct database_dyn *db, int fd, request_header *req,
|
|
|
|
void *key, uid_t uid);
|
|
|
|
extern void readdhstai (struct database_dyn *db, struct hashentry *he,
|
|
|
|
struct datahead *dh);
|
2004-08-27 02:35:05 +08:00
|
|
|
|
|
|
|
/* mem.c */
|
|
|
|
extern void *mempool_alloc (struct database_dyn *db, size_t len);
|
|
|
|
extern void gc (struct database_dyn *db);
|
1998-10-19 06:02:47 +08:00
|
|
|
|
2004-09-09 01:56:46 +08:00
|
|
|
|
|
|
|
/* nscd_setup_thread.c */
|
|
|
|
extern void setup_thread (struct database_dyn *db);
|
|
|
|
|
1998-10-18 23:16:22 +08:00
|
|
|
#endif /* nscd.h */
|