36 #ifdef STRCASECMP_IN_STRINGS_H
42 #include <rpcsvc/ypclnt.h>
47 #define YPERR_ACCESS 15
72 static char dict_nis_disabled[1];
73 static char *dict_nis_domain;
77 static void dict_nis_init(
void)
79 const char *myname =
"dict_nis_init";
81 if (yp_get_default_domain(&dict_nis_domain) != 0
82 || dict_nis_domain == 0 || *dict_nis_domain == 0
83 ||
strcasecmp(dict_nis_domain,
"(none)") == 0) {
84 dict_nis_domain = dict_nis_disabled;
85 msg_warn(
"%s: NIS domain name not set - NIS lookups disabled", myname);
88 msg_info(
"%s: NIS domain %s", myname, dict_nis_domain);
93 static char *dict_nis_strerror(
int err)
101 return (
"args to function are bad");
103 return (
"RPC failure - domain has been unbound");
105 return (
"can't bind to server on this domain");
107 return (
"no such map in server's domain");
109 return (
"no such key in map");
111 return (
"internal yp server or client error");
113 return (
"resource allocation failure");
115 return (
"no more records in map database");
117 return (
"can't communicate with portmapper");
119 return (
"can't communicate with ypbind");
121 return (
"can't communicate with ypserv");
123 return (
"local domain name not set");
125 return (
"yp database is bad");
127 return (
"yp version mismatch");
129 return (
"access violation");
131 return (
"database busy");
133 return (
"unknown NIS lookup error");
139 static const char *dict_nis_lookup(
DICT *dict,
const char *key)
141 DICT_NIS *dict_nis = (DICT_NIS *) dict;
153 msg_panic(
"dict_nis_lookup: no DICT_FLAG_TRY1NULL | DICT_FLAG_TRY0NULL flag");
155 if (dict_nis_domain == dict_nis_disabled)
173 err = yp_match(dict_nis_domain, dict_nis->dict.name,
174 (
void *) key, strlen(key) + 1,
175 &result, &result_len);
187 err = yp_match(dict_nis_domain, dict_nis->dict.name,
188 (
void *) key, strlen(key),
189 &result, &result_len);
204 if (err != YPERR_KEY) {
205 msg_warn(
"lookup %s, NIS domain %s, map %s: %s",
206 key, dict_nis_domain, dict_nis->dict.name,
207 dict_nis_strerror(err));
215 static void dict_nis_close(
DICT *dict)
228 if (open_flags != O_RDONLY)
230 "%s:%s map requires O_RDONLY access mode",
234 dict_nis->dict.
lookup = dict_nis_lookup;
235 dict_nis->dict.close = dict_nis_close;
241 if (dict_nis_domain == 0)
NORETURN msg_panic(const char *fmt,...)
DICT * dict_nis_open(const char *, int, int)
#define DICT_FLAG_FOLD_FIX
VSTRING * vstring_strcpy(VSTRING *vp, const char *src)
#define DICT_OWNER_TRUSTED
#define DICT_FLAG_TRY1NULL
void msg_warn(const char *fmt,...)
VSTRING * vstring_alloc(ssize_t len)
char * lowercase(char *string)
const char *(* lookup)(struct DICT *, const char *)
int strcasecmp(const char *s1, const char *s2)
VSTRING * vstring_free(VSTRING *vp)
DICT * dict_alloc(const char *, const char *, ssize_t)
VSTRING * vstring_strncpy(VSTRING *vp, const char *src, ssize_t len)
#define DICT_FLAG_TRY0NULL
DICT * dict_surrogate(const char *dict_type, const char *dict_name, int open_flags, int dict_flags, const char *fmt,...)
void msg_info(const char *fmt,...)