In the virtual code, change the chdir() and build the full
pathname in a buffer. For a daemon, it is better to stay in "/" the root. Moving in subdirecteris, will not permit the volume to be unmounted. But we do not follow the same rule for imap4d, it should be fix. * pop3d/signal.c: Shutup unused parameter warrning from gcc. * pop3d/user.c: Define macro VIRTUAL_PWDDIR. use sprintf() to build filename instead of chdir(). (PAM_gnupop3d_conv): Shutup unused parameter warrning from gcc. Make sure variable mailbox_name is initialized. * include/mailutils/mutil.h: Typo "struct password" instead of "struct passwd". Use const appropriately in the declaration of mu_register_getpwnam() and mu_getpwnam(). * mailbox/mutil.c: Use const appropriately in the definition of mu_register_getpwnam() and mu_getpwnam(). Typo "struct password" instead of "struct passwd".
Showing
6 changed files
with
52 additions
and
21 deletions
1 | 2001-08-30 Alain Magloire | ||
2 | |||
3 | In the virtual code, change the chdir() and build the full | ||
4 | pathname in a buffer. For a daemon, it is better to stay | ||
5 | in "/" the root. Moving in subdirecteris, will not permit | ||
6 | the volume to be unmounted. But we do not follow the | ||
7 | same rule for imap4d, it should be fix. | ||
8 | |||
9 | * pop3d/signal.c: Shutup unused parameter warrning from gcc. | ||
10 | * pop3d/user.c: Define macro VIRTUAL_PWDDIR. use sprintf() | ||
11 | to build filename instead of chdir(). | ||
12 | (PAM_gnupop3d_conv): Shutup unused parameter warrning from gcc. | ||
13 | Make sure variable mailbox_name is initialized. | ||
14 | |||
15 | * include/mailutils/mutil.h: Typo "struct password" instead of | ||
16 | "struct passwd". Use const appropriately in the declaration | ||
17 | of mu_register_getpwnam() and mu_getpwnam(). | ||
18 | * mailbox/mutil.c: Use const appropriately in the definition | ||
19 | of mu_register_getpwnam() and mu_getpwnam(). Typo "struct password" | ||
20 | instead of "struct passwd". | ||
21 | |||
1 | 2001-08-30 Sergey Poznyakoff | 22 | 2001-08-30 Sergey Poznyakoff |
2 | 23 | ||
3 | More changes to better integrate mysql support. Introduced | 24 | More changes to better integrate mysql support. Introduced |
4 | mu_getpwnam function. The function first calls system getpwnam, | 25 | mu_getpwnam function. The function first calls system getpwnam, |
5 | if it fails, it calls application-defined getpwnam function. | 26 | if it fails, it calls application-defined getpwnam function. |
6 | mu_register_getpwnam can be used to register such a function. | 27 | mu_register_getpwnam can be used to register such a function. |
7 | 28 | ||
8 | * configure.in: Add -lm to AUTHLIBS when configured with | 29 | * configure.in: Add -lm to AUTHLIBS when configured with |
9 | --enable-mysql. | 30 | --enable-mysql. |
10 | When checking for PAM: Append to AUTHLIBS instead of just | 31 | When checking for PAM: Append to AUTHLIBS instead of just |
... | @@ -21,7 +42,7 @@ | ... | @@ -21,7 +42,7 @@ |
21 | * mailbox/mbx_default.c: use mu_getpwnam. Removed inclusion | 42 | * mailbox/mbx_default.c: use mu_getpwnam. Removed inclusion |
22 | of MySql.h. | 43 | of MySql.h. |
23 | * mailbox/mutil.c: new functions: mu_getpwnam() and | 44 | * mailbox/mutil.c: new functions: mu_getpwnam() and |
24 | mu_register_getpwnam(). | 45 | mu_register_getpwnam(). |
25 | Removed inclusion of MySql.h | 46 | Removed inclusion of MySql.h |
26 | * include/mailbox/mutil.h: Prototypes for the new functions. | 47 | * include/mailbox/mutil.h: Prototypes for the new functions. |
27 | 48 | ||
... | @@ -47,8 +68,8 @@ | ... | @@ -47,8 +68,8 @@ |
47 | 68 | ||
48 | 2001-08-29 Jakob 'sparky' Kaivo <jkaivo@elijah.nodomainname.net> | 69 | 2001-08-29 Jakob 'sparky' Kaivo <jkaivo@elijah.nodomainname.net> |
49 | 70 | ||
50 | * imap4d/select.c (imap4d_select0): | 71 | * imap4d/select.c (imap4d_select0): |
51 | * imap4d/copy.c (imap4d_copy0): | 72 | * imap4d/copy.c (imap4d_copy0): |
52 | * imap4d/status.c (imap4d_status): treat INBOX differently if virtual | 73 | * imap4d/status.c (imap4d_status): treat INBOX differently if virtual |
53 | 74 | ||
54 | * imap4d/login.c (imap4d_virtual): new function | 75 | * imap4d/login.c (imap4d_virtual): new function | ... | ... |
... | @@ -66,13 +66,12 @@ extern size_t util_cpystr __P ((char *dst, const char *src, size_t size)); | ... | @@ -66,13 +66,12 @@ extern size_t util_cpystr __P ((char *dst, const char *src, size_t size)); |
66 | 66 | ||
67 | struct passwd; | 67 | struct passwd; |
68 | 68 | ||
69 | void mu_register_getpwnam __P((struct passwd *(*fun) __P((char *)))); | 69 | extern void mu_register_getpwnam __P ((struct passwd *(*fun) __P((const char *)))); |
70 | struct password * mu_getpwnam __P((const char *name)); | 70 | extern struct passwd * mu_getpwnam __P ((const char *name)); |
71 | 71 | ||
72 | 72 | ||
73 | #ifdef __cplusplus | 73 | #ifdef __cplusplus |
74 | } | 74 | } |
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | #endif /* _MAILUTILS_MUTIL_H */ | 77 | #endif /* _MAILUTILS_MUTIL_H */ |
78 | ... | ... |
... | @@ -325,22 +325,21 @@ util_cpystr (char *dst, const char *src, size_t size) | ... | @@ -325,22 +325,21 @@ util_cpystr (char *dst, const char *src, size_t size) |
325 | return len; | 325 | return len; |
326 | } | 326 | } |
327 | 327 | ||
328 | static struct passwd *(*_app_getpwnam) __P((char *)) = NULL; | 328 | static struct passwd *(*_app_getpwnam) __P((const char *)) = NULL; |
329 | 329 | ||
330 | void | 330 | void |
331 | mu_register_getpwnam (struct passwd *(*fun) __P((char *))) | 331 | mu_register_getpwnam (struct passwd *(*fun) __P((const char *))) |
332 | { | 332 | { |
333 | _app_getpwnam = fun; | 333 | _app_getpwnam = fun; |
334 | } | 334 | } |
335 | 335 | ||
336 | struct password * | 336 | struct passwd * |
337 | mu_getpwnam (const char *name) | 337 | mu_getpwnam (const char *name) |
338 | { | 338 | { |
339 | struct password *p; | 339 | struct passwd *p; |
340 | 340 | ||
341 | p = getpwnam (name); | 341 | p = getpwnam (name); |
342 | if (!p && _app_getpwnam) | 342 | if (!p && _app_getpwnam) |
343 | p = (*_app_getpwnam)(name); | 343 | p = (*_app_getpwnam)(name); |
344 | return p; | 344 | return p; |
345 | } | 345 | } |
346 | ... | ... |
... | @@ -104,6 +104,7 @@ | ... | @@ -104,6 +104,7 @@ |
104 | #include <mailutils/header.h> | 104 | #include <mailutils/header.h> |
105 | #include <mailutils/body.h> | 105 | #include <mailutils/body.h> |
106 | #include <mailutils/registrar.h> | 106 | #include <mailutils/registrar.h> |
107 | #include <mailutils/mutil.h> | ||
107 | #include <mailutils/error.h> | 108 | #include <mailutils/error.h> |
108 | 109 | ||
109 | /* For Berkley DB2 APOP password file */ | 110 | /* For Berkley DB2 APOP password file */ | ... | ... |
... | @@ -23,6 +23,7 @@ pop3d_sigchld (int signo) | ... | @@ -23,6 +23,7 @@ pop3d_sigchld (int signo) |
23 | { | 23 | { |
24 | pid_t pid; | 24 | pid_t pid; |
25 | int status; | 25 | int status; |
26 | (void)signo; | ||
26 | 27 | ||
27 | while ( (pid = waitpid(-1, &status, WNOHANG)) > 0) | 28 | while ( (pid = waitpid(-1, &status, WNOHANG)) > 0) |
28 | --children; | 29 | --children; | ... | ... |
... | @@ -25,12 +25,16 @@ static int is_virtual = 0; | ... | @@ -25,12 +25,16 @@ static int is_virtual = 0; |
25 | 25 | ||
26 | #ifdef USE_VIRTUAL_DOMAINS | 26 | #ifdef USE_VIRTUAL_DOMAINS |
27 | 27 | ||
28 | /* XXX: Should not this be configurable somehow?? */ | ||
29 | #define VIRTUAL_PWDDIR "/etc/domains" | ||
30 | |||
28 | static struct passwd * | 31 | static struct passwd * |
29 | pop3d_virtual (const char *u) | 32 | pop3d_virtual (const char *u) |
30 | { | 33 | { |
31 | struct passwd *pw; | 34 | struct passwd *pw; |
35 | char *filename; | ||
32 | FILE *pfile; | 36 | FILE *pfile; |
33 | int i = 0, len = strlen (u), delim = 0; | 37 | size_t i = 0, len = strlen (u), delim = 0; |
34 | 38 | ||
35 | for (i = 0; i < len && delim == 0; i++) | 39 | for (i = 0; i < len && delim == 0; i++) |
36 | if (u[i] == '!' || u[i] == ':' || u[i] == '@') | 40 | if (u[i] == '!' || u[i] == ':' || u[i] == '@') |
... | @@ -39,17 +43,22 @@ pop3d_virtual (const char *u) | ... | @@ -39,17 +43,22 @@ pop3d_virtual (const char *u) |
39 | if (delim == 0) | 43 | if (delim == 0) |
40 | return NULL; | 44 | return NULL; |
41 | 45 | ||
42 | chdir ("/etc/domains"); | 46 | filename = malloc (strlen (VIRTUAL_PWDDIR) + strlen (&u[delim + 1]) + 1); |
43 | pfile = fopen (&u[delim+1], "r"); | 47 | if (filename == NULL) |
48 | pop3d_abquit (ERR_NO_MEM); | ||
49 | |||
50 | sprintf (filename, "%s/%s", VIRTUAL_PWDDIR, &u[delim + 1]); | ||
51 | pfile = fopen (filename, "r"); | ||
52 | free (filename); | ||
44 | while (pfile != NULL && (pw = fgetpwent (pfile)) != NULL) | 53 | while (pfile != NULL && (pw = fgetpwent (pfile)) != NULL) |
45 | { | 54 | { |
46 | if (strlen (pw->pw_name) == delim && !strncmp (u, pw->pw_name, delim)) | 55 | if (strlen (pw->pw_name) == delim |
56 | && !strncmp (u, pw->pw_name, delim)) | ||
47 | { | 57 | { |
48 | is_virtual = 1; | 58 | is_virtual = 1; |
49 | return pw; | 59 | return pw; |
50 | } | 60 | } |
51 | } | 61 | } |
52 | |||
53 | return NULL; | 62 | return NULL; |
54 | } | 63 | } |
55 | 64 | ||
... | @@ -71,6 +80,7 @@ PAM_gnupop3d_conv (int num_msg, const struct pam_message **msg, | ... | @@ -71,6 +80,7 @@ PAM_gnupop3d_conv (int num_msg, const struct pam_message **msg, |
71 | { | 80 | { |
72 | int replies = 0; | 81 | int replies = 0; |
73 | struct pam_response *reply = NULL; | 82 | struct pam_response *reply = NULL; |
83 | (void)appdata_ptr; | ||
74 | 84 | ||
75 | reply = malloc (sizeof (*reply) * num_msg); | 85 | reply = malloc (sizeof (*reply) * num_msg); |
76 | if (!reply) | 86 | if (!reply) |
... | @@ -122,7 +132,7 @@ pop3d_user (const char *arg) | ... | @@ -122,7 +132,7 @@ pop3d_user (const char *arg) |
122 | struct passwd *pw; | 132 | struct passwd *pw; |
123 | int status; | 133 | int status; |
124 | int lockit = 1; | 134 | int lockit = 1; |
125 | char *mailbox_name; | 135 | char *mailbox_name = NULL; |
126 | 136 | ||
127 | if (state != AUTHORIZATION) | 137 | if (state != AUTHORIZATION) |
128 | return ERR_WRONG_STATE; | 138 | return ERR_WRONG_STATE; |
... | @@ -235,7 +245,7 @@ pop3d_user (const char *arg) | ... | @@ -235,7 +245,7 @@ pop3d_user (const char *arg) |
235 | if (pw->pw_uid > 0 && !is_virtual) | 245 | if (pw->pw_uid > 0 && !is_virtual) |
236 | { | 246 | { |
237 | setuid (pw->pw_uid); | 247 | setuid (pw->pw_uid); |
238 | 248 | ||
239 | mailbox_name = calloc (strlen (_PATH_MAILDIR) + 1 | 249 | mailbox_name = calloc (strlen (_PATH_MAILDIR) + 1 |
240 | + strlen (pw->pw_name) + 1, 1); | 250 | + strlen (pw->pw_name) + 1, 1); |
241 | sprintf (mailbox_name, "%s/%s", _PATH_MAILDIR, pw->pw_name); | 251 | sprintf (mailbox_name, "%s/%s", _PATH_MAILDIR, pw->pw_name); | ... | ... |
-
Please register or sign in to post a comment