A couple of bugfixes. Introduced
--virtual-passwd-dir switch to override the default placement of virtual domain password files.
Showing
1 changed file
with
45 additions
and
4 deletions
... | @@ -40,6 +40,12 @@ | ... | @@ -40,6 +40,12 @@ |
40 | # include <crypt.h> | 40 | # include <crypt.h> |
41 | #endif | 41 | #endif |
42 | 42 | ||
43 | #include <sys/types.h> | ||
44 | #include <sys/socket.h> | ||
45 | #include <netdb.h> | ||
46 | #include <netinet/in.h> | ||
47 | #include <arpa/inet.h> /*FIXME!*/ | ||
48 | |||
43 | #include <mailutils/list.h> | 49 | #include <mailutils/list.h> |
44 | #include <mailutils/iterator.h> | 50 | #include <mailutils/iterator.h> |
45 | #include <mailutils/mailbox.h> | 51 | #include <mailutils/mailbox.h> |
... | @@ -47,6 +53,9 @@ | ... | @@ -47,6 +53,9 @@ |
47 | #include <mailutils/mu_auth.h> | 53 | #include <mailutils/mu_auth.h> |
48 | 54 | ||
49 | #ifdef USE_VIRTUAL_DOMAINS | 55 | #ifdef USE_VIRTUAL_DOMAINS |
56 | |||
57 | static char *site_virtual_pwddir = SITE_VIRTUAL_PWDDIR; | ||
58 | |||
50 | static struct passwd * | 59 | static struct passwd * |
51 | getpwnam_virtual (char *u) | 60 | getpwnam_virtual (char *u) |
52 | { | 61 | { |
... | @@ -62,12 +71,12 @@ getpwnam_virtual (char *u) | ... | @@ -62,12 +71,12 @@ getpwnam_virtual (char *u) |
62 | if (delim == 0) | 71 | if (delim == 0) |
63 | return NULL; | 72 | return NULL; |
64 | 73 | ||
65 | filename = malloc (strlen (SITE_VIRTUAL_PWDDIR) + | 74 | filename = malloc (strlen (site_virtual_pwddir) + |
66 | strlen (&u[delim + 1]) + 2 /* slash and null byte */); | 75 | strlen (&u[delim + 1]) + 2 /* slash and null byte */); |
67 | if (filename == NULL) | 76 | if (filename == NULL) |
68 | return NULL; | 77 | return NULL; |
69 | 78 | ||
70 | sprintf (filename, "%s/%s", SITE_VIRTUAL_PWDDIR, &u[delim + 1]); | 79 | sprintf (filename, "%s/%s", site_virtual_pwddir, &u[delim + 1]); |
71 | pfile = fopen (filename, "r"); | 80 | pfile = fopen (filename, "r"); |
72 | free (filename); | 81 | free (filename); |
73 | 82 | ||
... | @@ -87,9 +96,8 @@ getpwnam_ip_virtual (const char *u) | ... | @@ -87,9 +96,8 @@ getpwnam_ip_virtual (const char *u) |
87 | struct sockaddr_in addr; | 96 | struct sockaddr_in addr; |
88 | struct passwd *pw = NULL; | 97 | struct passwd *pw = NULL; |
89 | int len = sizeof (addr); | 98 | int len = sizeof (addr); |
90 | char *user = NULL; | ||
91 | 99 | ||
92 | if (getsockname (fileno (ifile), (struct sockaddr *)&addr, &len) == 0) | 100 | if (getsockname (0, (struct sockaddr *)&addr, &len) == 0) |
93 | { | 101 | { |
94 | char *ip; | 102 | char *ip; |
95 | char *user; | 103 | char *user; |
... | @@ -162,6 +170,35 @@ mu_auth_virt_domain_by_name (void *return_data, void *key, | ... | @@ -162,6 +170,35 @@ mu_auth_virt_domain_by_name (void *return_data, void *key, |
162 | free (mailbox_name); | 170 | free (mailbox_name); |
163 | return rc; | 171 | return rc; |
164 | } | 172 | } |
173 | |||
174 | #define ARG_PWDDIR 1 | ||
175 | |||
176 | static error_t | ||
177 | mu_virt_argp_parser (int key, char *arg, struct argp_state *state) | ||
178 | { | ||
179 | switch (key) | ||
180 | { | ||
181 | case ARG_PWDDIR: | ||
182 | site_virtual_pwddir = arg; | ||
183 | break; | ||
184 | |||
185 | default: | ||
186 | return ARGP_ERR_UNKNOWN; | ||
187 | } | ||
188 | return 0; | ||
189 | } | ||
190 | |||
191 | static struct argp_option mu_virt_argp_option[] = { | ||
192 | { "virtual-passwd-dir", ARG_PWDDIR, "DIR", 0, | ||
193 | "Search for virtual passwd file in DIR", 0}, | ||
194 | { NULL, 0, NULL, 0, NULL, 0 } | ||
195 | }; | ||
196 | |||
197 | struct argp mu_virt_argp = { | ||
198 | mu_virt_argp_option, | ||
199 | mu_virt_argp_parser, | ||
200 | }; | ||
201 | |||
165 | #else | 202 | #else |
166 | static int | 203 | static int |
167 | mu_auth_virt_domain_by_name (void *return_data, void *key, | 204 | mu_auth_virt_domain_by_name (void *return_data, void *key, |
... | @@ -174,7 +211,11 @@ mu_auth_virt_domain_by_name (void *return_data, void *key, | ... | @@ -174,7 +211,11 @@ mu_auth_virt_domain_by_name (void *return_data, void *key, |
174 | 211 | ||
175 | struct mu_auth_module mu_auth_virtual_module = { | 212 | struct mu_auth_module mu_auth_virtual_module = { |
176 | "virtdomain", | 213 | "virtdomain", |
214 | #ifdef USE_VIRTUAL_DOMAINS | ||
215 | &mu_virt_argp, | ||
216 | #else | ||
177 | NULL, | 217 | NULL, |
218 | #endif | ||
178 | mu_auth_nosupport, | 219 | mu_auth_nosupport, |
179 | NULL, | 220 | NULL, |
180 | mu_auth_virt_domain_by_name, | 221 | mu_auth_virt_domain_by_name, | ... | ... |
-
Please register or sign in to post a comment