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