1 /*************************************************
2 * Exim - an Internet mail transport agent *
3 *************************************************/
5 /* Copyright (c) University of Cambridge 1995 - 2015 */
6 /* Copyright (c) The Exim Maintainers 2020 */
7 /* See the file NOTICE for conditions of use and distribution. */
10 #include "lf_functions.h"
12 #include <rpcsvc/ypclnt.h>
15 /*************************************************
17 *************************************************/
19 /* See local README for interface description. This serves for both
20 the "nis" and "nis0" lookup types. */
23 nis_open(const uschar * filename, uschar ** errmsg)
26 if (yp_get_default_domain(&nis_domain) != 0)
28 *errmsg = US"failed to get default NIS domain";
36 /*************************************************
37 * Find entry point for nis *
38 *************************************************/
40 /* See local README for interface description. A separate function is used
41 for nis0 because they are so short it isn't worth trying to use any common
45 nis_find(void * handle, const uschar * filename, const uschar * keystring,
46 int length, uschar ** result, uschar ** errmsg, uint * do_cache,
52 do_cache = do_cache; /* Placate picky compilers */
53 if ((rc = yp_match(CCS handle, CCS filename, CCS keystring, length,
54 CSS &nis_data, &nis_data_length)) == 0)
56 *result = string_copy(nis_data);
57 (*result)[nis_data_length] = 0; /* remove final '\n' */
60 return (rc == YPERR_KEY || rc == YPERR_MAP)? FAIL : DEFER;
65 /*************************************************
66 * Find entry point for nis0 *
67 *************************************************/
69 /* See local README for interface description. */
72 nis0_find(void * handle, const uschar * filename, const uschar * keystring,
73 int length, uschar ** result, uschar ** errmsg, uint * do_cache,
79 do_cache = do_cache; /* Placate picky compilers */
80 if ((rc = yp_match(CCS handle, CCS filename, CCS keystring, length + 1,
81 CSS &nis_data, &nis_data_length)) == 0)
83 *result = string_copy(nis_data);
84 (*result)[nis_data_length] = 0; /* remove final '\n' */
87 return (rc == YPERR_KEY || rc == YPERR_MAP)? FAIL : DEFER;
92 /*************************************************
93 * Version reporting entry point *
94 *************************************************/
96 /* See local README for interface description. */
98 #include "../version.h"
101 nis_version_report(FILE *f)
104 fprintf(f, "Library version: NIS: Exim version %s\n", EXIM_VERSION_STR);
109 static lookup_info nis_lookup_info = {
110 .name = US"nis", /* lookup name */
111 .type = 0, /* not abs file, not query style*/
112 .open = nis_open, /* open function */
113 .check = NULL, /* check function */
114 .find = nis_find, /* find function */
115 .close = NULL, /* no close function */
116 .tidy = NULL, /* no tidy function */
117 .quote = NULL, /* no quoting function */
118 .version_report = nis_version_report /* version reporting */
121 static lookup_info nis0_lookup_info = {
122 .name = US"nis0", /* lookup name */
123 .type = 0, /* not absfile, not query style */
124 .open = nis_open, /* sic */ /* open function */
125 .check = NULL, /* check function */
126 .find = nis0_find, /* find function */
127 .close = NULL, /* no close function */
128 .tidy = NULL, /* no tidy function */
129 .quote = NULL, /* no quoting function */
130 .version_report = NULL /* no version reporting (redundant) */
134 #define nis_lookup_module_info _lookup_module_info
137 static lookup_info *_lookup_list[] = { &nis_lookup_info, &nis0_lookup_info };
138 lookup_module_info nis_lookup_module_info = { LOOKUP_MODULE_INFO_MAGIC, _lookup_list, 2 };
140 /* End of lookups/nis.c */