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 */
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 *
passwd_open(const uschar * filename,uschar ** errmsg)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
passwd_find(void * handle,const uschar * filename,const uschar * keystring,int length,uschar ** result,uschar ** errmsg,uint * do_cache,const uschar * opts)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 void
passwd_version_report(FILE * f)58 passwd_version_report(FILE *f)
59 {
60 #ifdef DYNLOOKUP
61 fprintf(f, "Library version: passwd: Exim version %s\n", EXIM_VERSION_STR);
62 #endif
63 }
64
65 static lookup_info _lookup_info = {
66 .name = US"passwd", /* lookup name */
67 .type = lookup_querystyle, /* query-style lookup */
68 .open = passwd_open, /* open function */
69 .check = NULL, /* no check function */
70 .find = passwd_find, /* find function */
71 .close = NULL, /* no close function */
72 .tidy = NULL, /* no tidy function */
73 .quote = NULL, /* no quoting function */
74 .version_report = passwd_version_report /* version reporting */
75 };
76
77 #ifdef DYNLOOKUP
78 #define passwd_lookup_module_info _lookup_module_info
79 #endif
80
81 static lookup_info *_lookup_list[] = { &_lookup_info };
82 lookup_module_info passwd_lookup_module_info = { LOOKUP_MODULE_INFO_MAGIC, _lookup_list, 1 };
83
84 /* End of lookups/passwd.c */
85