0a4a7b4e793e66f9e0258b23dd0020c55f6f4717
[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 /* See the file NOTICE for conditions of use and distribution. */
7
8 #include "../exim.h"
9
10
11
12 /*************************************************
13 * Open entry point *
14 *************************************************/
15
16 /* See local README for interface description */
17
18 static void *
19 passwd_open(const uschar * filename, uschar ** errmsg)
20 {
21 filename = filename; /* Keep picky compilers happy */
22 errmsg = errmsg;
23 return (void *)(-1); /* Just return something non-null */
24 }
25
26
27
28
29 /*************************************************
30 * Find entry point for passwd *
31 *************************************************/
32
33 /* See local README for interface description */
34
35 static int
36 passwd_find(void * handle, const uschar * filename, const uschar * keystring,
37 int length, uschar ** result, uschar ** errmsg, uint * do_cache,
38 const uschar * opts)
39 {
40 struct passwd *pw;
41
42 handle = handle; /* Keep picky compilers happy */
43 filename = filename;
44 length = length;
45 errmsg = errmsg;
46 do_cache = do_cache;
47
48 if (!route_finduser(keystring, &pw, NULL)) return FAIL;
49 *result = string_sprintf("*:%d:%d:%s:%s:%s", (int)pw->pw_uid, (int)pw->pw_gid,
50 pw->pw_gecos, pw->pw_dir, pw->pw_shell);
51 return OK;
52 }
53
54
55
56 /*************************************************
57 * Version reporting entry point *
58 *************************************************/
59
60 /* See local README for interface description. */
61
62 #include "../version.h"
63
64 void
65 passwd_version_report(FILE *f)
66 {
67 #ifdef DYNLOOKUP
68 fprintf(f, "Library version: passwd: Exim version %s\n", EXIM_VERSION_STR);
69 #endif
70 }
71
72 static lookup_info _lookup_info = {
73 .name = US"passwd", /* lookup name */
74 .type = lookup_querystyle, /* query-style lookup */
75 .open = passwd_open, /* open function */
76 .check = NULL, /* no check function */
77 .find = passwd_find, /* find function */
78 .close = NULL, /* no close function */
79 .tidy = NULL, /* no tidy function */
80 .quote = NULL, /* no quoting function */
81 .version_report = passwd_version_report /* version reporting */
82 };
83
84 #ifdef DYNLOOKUP
85 #define passwd_lookup_module_info _lookup_module_info
86 #endif
87
88 static lookup_info *_lookup_list[] = { &_lookup_info };
89 lookup_module_info passwd_lookup_module_info = { LOOKUP_MODULE_INFO_MAGIC, _lookup_list, 1 };
90
91 /* End of lookups/passwd.c */