Debug: feed startup "whats supported" info through normal debug channel
[exim.git] / src / src / lookups / passwd.c
1 /*************************************************
2 *     Exim - an Internet mail transport agent    *
3 *************************************************/
4
5 /* Copyright (c) University of Cambridge 1995 - 2015 */
6 /* Copyright (c) The Exim Maintainers 2020 - 2021 */
7 /* See the file NOTICE for conditions of use and distribution. */
8
9 #include "../exim.h"
10
11
12
13 /*************************************************
14 *              Open entry point                  *
15 *************************************************/
16
17 /* See local README for interface description */
18
19 static void *
20 passwd_open(const uschar * filename, uschar ** errmsg)
21 {
22 return (void *)(-1);     /* Just return something non-null */
23 }
24
25
26
27
28 /*************************************************
29 *         Find entry point for passwd           *
30 *************************************************/
31
32 /* See local README for interface description */
33
34 static int
35 passwd_find(void * handle, const uschar * filename, const uschar * keystring,
36   int length, uschar ** result, uschar ** errmsg, uint * do_cache,
37   const uschar * opts)
38 {
39 struct passwd *pw;
40
41 if (!route_finduser(keystring, &pw, NULL)) return FAIL;
42 *result = string_sprintf("*:%d:%d:%s:%s:%s", (int)pw->pw_uid, (int)pw->pw_gid,
43   pw->pw_gecos, pw->pw_dir, pw->pw_shell);
44 return OK;
45 }
46
47
48
49 /*************************************************
50 *         Version reporting entry point          *
51 *************************************************/
52
53 /* See local README for interface description. */
54
55 #include "../version.h"
56
57 gstring *
58 passwd_version_report(gstring * g)
59 {
60 #ifdef DYNLOOKUP
61 g = string_fmt_append(g, "Library version: passwd: Exim version %s\n", EXIM_VERSION_STR);
62 #endif
63 return g;
64 }
65
66 static lookup_info _lookup_info = {
67   .name = US"passwd",                   /* lookup name */
68   .type = lookup_querystyle,            /* query-style lookup */
69   .open = passwd_open,                  /* open function */
70   .check = NULL,                        /* no check function */
71   .find = passwd_find,                  /* find function */
72   .close = NULL,                        /* no close function */
73   .tidy = NULL,                         /* no tidy function */
74   .quote = NULL,                        /* no quoting function */
75   .version_report = passwd_version_report          /* version reporting */
76 };
77
78 #ifdef DYNLOOKUP
79 #define passwd_lookup_module_info _lookup_module_info
80 #endif
81
82 static lookup_info *_lookup_list[] = { &_lookup_info };
83 lookup_module_info passwd_lookup_module_info = { LOOKUP_MODULE_INFO_MAGIC, _lookup_list, 1 };
84
85 /* End of lookups/passwd.c */