- Renaming repocopied cached to nscd

Approved by:	re (kensmith), brooks (mentor)
This commit is contained in:
Michael Bushkov 2007-08-09 13:06:12 +00:00
parent 4ced8fb56a
commit db1bdf2b02
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=171795
23 changed files with 116 additions and 116 deletions

View File

@ -3,30 +3,30 @@
# $FreeBSD$
#
# PROVIDE: cached
# PROVIDE: nscd
# REQUIRE: DAEMON
# BEFORE: LOGIN
#
# Add the following lines to /etc/rc.conf to enable cached:
#
# cached_enable="YES"
# nscd_enable="YES"
#
# See cached(8) for flags
# See nscd(8) for flags
#
. /etc/rc.subr
name=cached
name=nscd
rcvar=`set_rcvar`
command=/usr/sbin/cached
command=/usr/sbin/nscd
extra_commands="flush"
flush_cmd="${command} -I all"
cached_enable=${cached_enable:-"NO"}
cached_pidfile=${cached_pidfile:-"/var/run/cached.pid"}
cached_flags=${cached_flags:-""}
nscd_enable=${nscd_enable:-"NO"}
nscd_pidfile=${nscd_pidfile:-"/var/run/nscd.pid"}
nscd_flags=${nscd_flags:-""}
load_rc_config $name
run_rc_command "$1"

View File

@ -1,13 +1,13 @@
# $FreeBSD$
PROG= cached
MAN= cached.conf.5 cached.8
PROG= nscd
MAN= nscd.conf.5 nscd.8
WARNS?= 2
SRCS= agent.c cached.c cachedcli.c cachelib.c cacheplcs.c debug.c log.c \
SRCS= agent.c nscd.c nscdcli.c cachelib.c cacheplcs.c debug.c log.c \
config.c query.c mp_ws_query.c mp_rs_query.c singletons.c protocol.c \
parser.c
CFLAGS+= -DCONFIG_PATH="\"${PREFIX}/etc/cached.conf\""
CFLAGS+= -DCONFIG_PATH="\"${PREFIX}/etc/nscd.conf\""
DPADD= ${LIBM} ${LIBPTHREAD} ${LIBUTIL}
LDADD= -lm -lpthread -lutil

View File

@ -26,8 +26,8 @@
* $FreeBSD$
*/
#ifndef __CACHED_AGENT_H__
#define __CACHED_AGENT_H__
#ifndef __NSCD_AGENT_H__
#define __NSCD_AGENT_H__
/*
* Agents are used to perform the actual lookups from the caching daemon.

View File

@ -26,8 +26,8 @@
* $FreeBSD$
*/
#ifndef __CACHED_CACHELIB_H__
#define __CACHED_CACHELIB_H__
#ifndef __NSCD_CACHELIB_H__
#define __NSCD_CACHELIB_H__
#include <sys/queue.h>
#include <sys/time.h>

View File

@ -26,8 +26,8 @@
* $FreeBSD$
*/
#ifndef __CACHED_CACHEPLCS_H__
#define __CACHED_CACHEPLCS_H__
#ifndef __NSCD_CACHEPLCS_H__
#define __NSCD_CACHEPLCS_H__
#include <sys/queue.h>
#include <sys/time.h>

View File

@ -26,8 +26,8 @@
* $FreeBSD$
*/
#ifndef __CACHED_CONFIG_H__
#define __CACHED_CONFIG_H__
#ifndef __NSCD_CONFIG_H__
#define __NSCD_CONFIG_H__
#include <sys/stat.h>
#include <sys/types.h>
@ -44,8 +44,8 @@
#define DEFAULT_CACHE_HT_SIZE 257
#define INITIAL_ENTRIES_CAPACITY 8
#define DEFAULT_SOCKET_PATH "/var/run/cached"
#define DEFAULT_PIDFILE_PATH "/var/run/cached.pid"
#define DEFAULT_SOCKET_PATH "/var/run/nscd"
#define DEFAULT_PIDFILE_PATH "/var/run/nscd.pid"
#define DEFAULT_POSITIVE_ELEMENTS_SIZE (2048)
#define DEFAULT_POSITIVE_LIFETIME (3600)

View File

@ -26,8 +26,8 @@
* $FreeBSD$
*/
#ifndef __CACHED_DEBUG_H__
#define __CACHED_DEBUG_H__
#ifndef __NSCD_DEBUG_H__
#define __NSCD_DEBUG_H__
#define TRACE_WANTED 32

View File

@ -50,7 +50,7 @@ __log_msg(int level, const char *sender, const char *message, ...)
printf("M%d from %s: %s\n", level, sender, fmessage);
#ifndef NO_SYSLOG
if (level == 0)
syslog(LOG_INFO, "cached message (from %s): %s", sender,
syslog(LOG_INFO, "nscd message (from %s): %s", sender,
fmessage);
#endif
free(fmessage);
@ -72,7 +72,7 @@ __log_err(int level, const char *sender, const char *error, ...)
#ifndef NO_SYSLOG
if (level == 0)
syslog(LOG_ERR, "cached error (from %s): %s", sender, ferror);
syslog(LOG_ERR, "nscd error (from %s): %s", sender, ferror);
#endif
free(ferror);
}

View File

@ -26,8 +26,8 @@
* $FreeBSD$
*/
#ifndef __CACHED_LOG_H__
#define __CACHED_LOG_H__
#ifndef __NSCD_LOG_H__
#define __NSCD_LOG_H__
#define LOG_MSG_1(sender, msg, ...) __log_msg(1, sender, msg, ##__VA_ARGS__)
#define LOG_MSG_2(sender, msg, ...) __log_msg(2, sender, msg, ##__VA_ARGS__)

View File

@ -200,7 +200,7 @@ on_mp_read_session_request_process(struct query_state *qstate)
dec_cache_entry_name = strdup(
qstate->config_entry->mp_cache_params.entry_name);
else {
#ifdef NS_CACHED_EID_CHECKING
#ifdef NS_NSCD_EID_CHECKING
if (check_query_eids(qstate) != 0) {
c_mp_rs_response->error_code = EPERM;
goto fin;

View File

@ -26,8 +26,8 @@
* $FreeBSD$
*/
#ifndef __CACHED_MP_RS_QUERY_H__
#define __CACHED_MP_RS_QUERY_H__
#ifndef __NSCD_MP_RS_QUERY_H__
#define __NSCD_MP_RS_QUERY_H__
extern int on_mp_read_session_request_read1(struct query_state *);

View File

@ -203,7 +203,7 @@ on_mp_write_session_request_process(struct query_state *qstate)
"can't write to it", c_mp_ws_request->entry);
goto fin;
} else {
#ifdef NS_CACHED_EID_CHECKING
#ifdef NS_NSCD_EID_CHECKING
if (check_query_eids(qstate) != 0) {
c_mp_ws_response->error_code = EPERM;
goto fin;

View File

@ -26,8 +26,8 @@
* $FreeBSD$
*/
#ifndef __CACHED_MP_WS_QUERY_H__
#define __CACHED_MP_WS_QUERY_H__
#ifndef __NSCD_MP_WS_QUERY_H__
#define __NSCD_MP_WS_QUERY_H__
extern int on_mp_write_session_request_read1(struct query_state *);
extern cache_entry register_new_mp_cache_entry(struct query_state *,

View File

@ -25,11 +25,11 @@
.\" $FreeBSD$
.\"
.Dd October 20, 2005
.Dt CACHED 8
.Dt NSCD 8
.Os
.Sh NAME
.Nm cached
.Nd "caching server daemon"
.Nm nscd
.Nd "name service caching daemon"
.Sh SYNOPSIS
.Nm
.Op Fl dnst
@ -82,7 +82,7 @@ lookups by itself.
To enable this feature, use the
.Va perform-actual-lookups
parameter in
.Xr cached.conf 5 .
.Xr nscd.conf 5 .
.Pp
The
.Nm
@ -100,7 +100,7 @@ Forces using only one thread for all processing purposes (it overrides
the
.Va threads
parameter in the
.Xr cached.conf 5
.Xr nscd.conf 5
file).
.It Fl t
Trace mode.
@ -150,16 +150,16 @@ to invalidate the whole cache.
Only the root can use this option.
.El
.Sh FILES
.Bl -tag -width ".Pa /etc/cached.conf" -compact
.It Pa /etc/cached.conf
.Bl -tag -width ".Pa /etc/nscd.conf" -compact
.It Pa /etc/nscd.conf
The default configuration file.
.El
.Sh SEE ALSO
.Xr nsdispatch 3 ,
.Xr cached.conf 5 ,
.Xr nscd.conf 5 ,
.Xr nsswitch.conf 5
.Sh AUTHORS
.An Michael Bushkov Aq bushman@rsu.ru
.An Michael Bushkov Aq bushman@freebsd.org
.Sh BUGS
Please send bug reports and suggestions to
.Aq bushman@rsu.ru .
.Aq bushman@freebsd.org .

View File

@ -49,19 +49,19 @@ __FBSDID("$FreeBSD$");
#include "agents/passwd.h"
#include "agents/group.h"
#include "agents/services.h"
#include "cachedcli.h"
#include "cachelib.h"
#include "config.h"
#include "debug.h"
#include "log.h"
#include "nscdcli.h"
#include "parser.h"
#include "query.h"
#include "singletons.h"
#ifndef CONFIG_PATH
#define CONFIG_PATH "/etc/cached.conf"
#define CONFIG_PATH "/etc/nscd.conf"
#endif
#define DEFAULT_CONFIG_PATH "cached.conf"
#define DEFAULT_CONFIG_PATH "nscd.conf"
#define MAX_SOCKET_IO_SIZE 4096
@ -93,7 +93,7 @@ static void
print_version_info(void)
{
TRACE_IN(print_version_info);
printf("cached v0.2 (20 Oct 2005)\nwas developed during SoC 2005\n");
printf("nscd v0.2 (20 Oct 2005)\nwas developed during SoC 2005\n");
TRACE_OUT(print_version_info);
}
@ -101,7 +101,7 @@ static void
usage(void)
{
fprintf(stderr,
"usage: cached [-dnst] [-i cachename] [-I cachename]\n");
"usage: nscd [-dnst] [-i cachename] [-I cachename]\n");
exit(1);
}
@ -683,8 +683,8 @@ main(int argc, char *argv[])
FILE *pidfin = fopen(DEFAULT_PIDFILE_PATH, "r");
char pidbuf[256];
struct cached_connection_params connection_params;
cached_connection connection;
struct nscd_connection_params connection_params;
nscd_connection connection;
int result;
@ -704,14 +704,14 @@ main(int argc, char *argv[])
memset(&connection_params, 0,
sizeof(struct cached_connection_params));
sizeof(struct nscd_connection_params));
connection_params.socket_path = DEFAULT_SOCKET_PATH;
connection = open_cached_connection__(&connection_params);
if (connection == INVALID_CACHED_CONNECTION)
connection = open_nscd_connection__(&connection_params);
if (connection == INVALID_NSCD_CONNECTION)
errx(EXIT_FAILURE, "Can't connect to the daemon.");
if (clear_user_cache_entries != 0) {
result = cached_transform__(connection,
result = nscd_transform__(connection,
user_config_entry_name, TT_USER);
if (result != 0)
LOG_MSG_1("main",
@ -727,7 +727,7 @@ main(int argc, char *argv[])
errx(EXIT_FAILURE, "Only root can initiate "
"global cache transformation.");
result = cached_transform__(connection,
result = nscd_transform__(connection,
global_config_entry_name, TT_ALL);
if (result != 0)
LOG_MSG_1("main",
@ -739,7 +739,7 @@ main(int argc, char *argv[])
"succeeded");
}
close_cached_connection__(connection);
close_nscd_connection__(connection);
free(user_config_entry_name);
free(global_config_entry_name);

View File

@ -25,17 +25,17 @@
.\" $FreeBSD$
.\"
.Dd April 30, 2006
.Dt CACHED.CONF 5
.Dt NSCD.CONF 5
.Os
.Sh NAME
.Nm cached.conf
.Nd "caching daemon configuration file"
.Nm nscd.conf
.Nd "nscd configuration file"
.Sh DESCRIPTION
The
.Nm
file
is used by the
.Xr cached 8
.Xr nscd 8
daemon and is read on its startup.
Its syntax is mostly similar to the
.Pa nscd.conf
@ -114,12 +114,12 @@ When it is exceeded, the policy will be applied.
The default value is 2048.
.It Va perform-actual-lookups Oo Ar cachename Oc Op Cm yes | no
If enabled, the
.Xr cached 8
.Xr nscd 8
does not simply receive and cache the NSS-requests results, but performs
all the lookups by itself and only returns the responses.
If this feature is enabled, then for the given
.Ar cachename
.Xr cached 8
.Xr nscd 8
will act similarly to the NSCD.
.Pp
.Sy NOTE :
@ -135,14 +135,14 @@ You can use the
.Ql #
symbol at the beginning of the line for comments.
.Sh FILES
.Bl -tag -width ".Pa /etc/cached.conf" -compact
.It Pa /etc/cached.conf
.Bl -tag -width ".Pa /etc/nscd.conf" -compact
.It Pa /etc/nscd.conf
.El
.Sh SEE ALSO
.Xr cached 8
.Xr nscd 8
.Sh AUTHORS
.An Michael Bushkov
.Aq bushman@rsu.ru
.Aq bushman@freebsd.org
.Sh BUGS
Please send bug reports and suggestions to
.Aq bushman@rsu.ru .
.Aq bushman@freebsd.org .

View File

@ -41,17 +41,17 @@ __FBSDID("$FreeBSD$");
#include <unistd.h>
#include "debug.h"
#include "cachedcli.h"
#include "nscdcli.h"
#include "protocol.h"
#define DEFAULT_CACHED_IO_TIMEOUT 4
#define DEFAULT_NSCD_IO_TIMEOUT 4
static int safe_write(struct cached_connection_ *, const void *, size_t);
static int safe_read(struct cached_connection_ *, void *, size_t);
static int send_credentials(struct cached_connection_ *, int);
static int safe_write(struct nscd_connection_ *, const void *, size_t);
static int safe_read(struct nscd_connection_ *, void *, size_t);
static int send_credentials(struct nscd_connection_ *, int);
static int
safe_write(struct cached_connection_ *connection, const void *data,
safe_write(struct nscd_connection_ *connection, const void *data,
size_t data_size)
{
struct kevent eventlist;
@ -63,7 +63,7 @@ safe_write(struct cached_connection_ *connection, const void *data,
if (data_size == 0)
return (0);
timeout.tv_sec = DEFAULT_CACHED_IO_TIMEOUT;
timeout.tv_sec = DEFAULT_NSCD_IO_TIMEOUT;
timeout.tv_nsec = 0;
result = 0;
do {
@ -88,7 +88,7 @@ safe_write(struct cached_connection_ *connection, const void *data,
}
static int
safe_read(struct cached_connection_ *connection, void *data, size_t data_size)
safe_read(struct nscd_connection_ *connection, void *data, size_t data_size)
{
struct kevent eventlist;
size_t result;
@ -99,7 +99,7 @@ safe_read(struct cached_connection_ *connection, void *data, size_t data_size)
if (data_size == 0)
return (0);
timeout.tv_sec = DEFAULT_CACHED_IO_TIMEOUT;
timeout.tv_sec = DEFAULT_NSCD_IO_TIMEOUT;
timeout.tv_nsec = 0;
result = 0;
do {
@ -124,7 +124,7 @@ safe_read(struct cached_connection_ *connection, void *data, size_t data_size)
}
static int
send_credentials(struct cached_connection_ *connection, int type)
send_credentials(struct nscd_connection_ *connection, int type)
{
struct kevent eventlist;
int nevents;
@ -173,16 +173,16 @@ send_credentials(struct cached_connection_ *connection, int type)
}
}
struct cached_connection_ *
open_cached_connection__(struct cached_connection_params const *params)
struct nscd_connection_ *
open_nscd_connection__(struct nscd_connection_params const *params)
{
struct cached_connection_ *retval;
struct nscd_connection_ *retval;
struct kevent eventlist;
struct sockaddr_un client_address;
int client_address_len, client_socket;
int res;
TRACE_IN(open_cached_connection);
TRACE_IN(open_nscd_connection);
assert(params != NULL);
client_socket = socket(PF_LOCAL, SOCK_STREAM, 0);
@ -196,14 +196,14 @@ open_cached_connection__(struct cached_connection_params const *params)
client_address_len);
if (res == -1) {
close(client_socket);
TRACE_OUT(open_cached_connection);
TRACE_OUT(open_nscd_connection);
return (NULL);
}
fcntl(client_socket, F_SETFL, O_NONBLOCK);
retval = malloc(sizeof(struct cached_connection_));
retval = malloc(sizeof(struct nscd_connection_));
assert(retval != NULL);
memset(retval, 0, sizeof(struct cached_connection_));
memset(retval, 0, sizeof(struct nscd_connection_));
retval->sockfd = client_socket;
@ -221,33 +221,33 @@ open_cached_connection__(struct cached_connection_params const *params)
0, 0, NULL);
res = kevent(retval->read_queue, &eventlist, 1, NULL, 0, NULL);
TRACE_OUT(open_cached_connection);
TRACE_OUT(open_nscd_connection);
return (retval);
}
void
close_cached_connection__(struct cached_connection_ *connection)
close_nscd_connection__(struct nscd_connection_ *connection)
{
TRACE_IN(close_cached_connection);
TRACE_IN(close_nscd_connection);
assert(connection != NULL);
close(connection->sockfd);
close(connection->read_queue);
close(connection->write_queue);
free(connection);
TRACE_OUT(close_cached_connection);
TRACE_OUT(close_nscd_connection);
}
int
cached_transform__(struct cached_connection_ *connection,
nscd_transform__(struct nscd_connection_ *connection,
const char *entry_name, int transformation_type)
{
size_t name_size;
int error_code;
int result;
TRACE_IN(cached_transform);
TRACE_IN(nscd_transform);
error_code = -1;
result = 0;
@ -279,6 +279,6 @@ cached_transform__(struct cached_connection_ *connection,
error_code = -1;
fin:
TRACE_OUT(cached_transform);
TRACE_OUT(nscd_transform);
return (error_code);
}

View File

@ -26,32 +26,32 @@
* $FreeBSD$
*/
#ifndef __CACHED_CACHEDCLI_H__
#define __CACHED_CACHEDCLI_H__
#ifndef __NSCD_NSCDCLI_H__
#define __NSCD_NSCDCLI_H__
struct cached_connection_params {
struct nscd_connection_params {
char *socket_path;
struct timeval timeout;
};
struct cached_connection_ {
struct nscd_connection_ {
int sockfd;
int read_queue;
int write_queue;
};
/* simple abstractions for not to write "struct" every time */
typedef struct cached_connection_ *cached_connection;
typedef struct cached_connection_ *cached_mp_write_session;
typedef struct cached_connection_ *cached_mp_read_session;
typedef struct nscd_connection_ *nscd_connection;
typedef struct nscd_connection_ *nscd_mp_write_session;
typedef struct nscd_connection_ *nscd_mp_read_session;
#define INVALID_CACHED_CONNECTION (NULL)
#define INVALID_NSCD_CONNECTION (NULL)
/* initialization/destruction routines */
extern cached_connection open_cached_connection__(
struct cached_connection_params const *);
extern void close_cached_connection__(cached_connection);
extern nscd_connection open_nscd_connection__(
struct nscd_connection_params const *);
extern void close_nscd_connection__(nscd_connection);
extern int cached_transform__(cached_connection, const char *, int);
extern int nscd_transform__(nscd_connection, const char *, int);
#endif

View File

@ -26,8 +26,8 @@
* $FreeBSD$
*/
#ifndef __CACHED_PARSER_H__
#define __CACHED_PARSER_H__
#ifndef __NSCD_PARSER_H__
#define __NSCD_PARSER_H__
extern int parse_config_file(struct configuration *,
const char *, char const **, int *);

View File

@ -26,8 +26,8 @@
* $FreeBSD$
*/
#ifndef __CACHED_PROTOCOL_H__
#define __CACHED_PROTOCOL_H__
#ifndef __NSCD_PROTOCOL_H__
#define __NSCD_PROTOCOL_H__
#include <stdlib.h>

View File

@ -191,13 +191,13 @@ on_query_startup(struct query_state *qstate)
qstate->uid = cred->cmcred_uid;
qstate->gid = cred->cmcred_gid;
#if defined(NS_CACHED_EID_CHECKING) || defined(NS_STRICT_CACHED_EID_CHECKING)
#if defined(NS_NSCD_EID_CHECKING) || defined(NS_STRICT_NSCD_EID_CHECKING)
/*
* This check is probably a bit redundant - per-user cache is always separated
* by the euid/egid pair
*/
if (check_query_eids(qstate) != 0) {
#ifdef NS_STRICT_CACHED_EID_CHECKING
#ifdef NS_STRICT_NSCD_EID_CHECKING
TRACE_OUT(on_query_startup);
return (-1);
#else
@ -511,7 +511,7 @@ on_negative_write_request_process(struct query_state *qstate)
"can't write to it", write_request->entry);
goto fin;
} else {
#ifdef NS_CACHED_EID_CHECKING
#ifdef NS_NSCD_EID_CHECKING
if (check_query_eids(qstate) != 0) {
write_response->error_code = EPERM;
goto fin;
@ -705,7 +705,7 @@ on_read_request_process(struct query_state *qstate)
if (qstate->config_entry->perform_actual_lookups != 0)
memset(read_request->cache_key, 0, qstate->eid_str_length);
else {
#ifdef NS_CACHED_EID_CHECKING
#ifdef NS_NSCD_EID_CHECKING
if (check_query_eids(qstate) != 0) {
/* if the lookup is not self-performing, we check for clients euid/egid */
read_response->error_code = EPERM;

View File

@ -26,8 +26,8 @@
* $FreeBSD$
*/
#ifndef __CACHED_QUERY_H__
#define __CACHED_QUERY_H__
#ifndef __NSCD_QUERY_H__
#define __NSCD_QUERY_H__
#include <sys/types.h>
#include <stdlib.h>

View File

@ -26,8 +26,8 @@
* $FreeBSD$
*/
#ifndef __CACHED_SINGLETONS_H__
#define __CACHED_SINGLETONS_H__
#ifndef __NSCD_SINGLETONS_H__
#define __NSCD_SINGLETONS_H__
#include "cachelib.h"
#include "config.h"