Commit ab6586ae ab6586ae2602aa1bd1cf9486ae02d6e97c3a9505 by Alain Magloire

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".
1 parent e9e05f4e
2001-08-30 Alain Magloire
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".
2001-08-30 Sergey Poznyakoff
More changes to better integrate mysql support. Introduced
......
......@@ -66,8 +66,8 @@ extern size_t util_cpystr __P ((char *dst, const char *src, size_t size));
struct passwd;
void mu_register_getpwnam __P((struct passwd *(*fun) __P((char *))));
struct password * mu_getpwnam __P((const char *name));
extern void mu_register_getpwnam __P ((struct passwd *(*fun) __P((const char *))));
extern struct passwd * mu_getpwnam __P ((const char *name));
#ifdef __cplusplus
......@@ -75,4 +75,3 @@ struct password * mu_getpwnam __P((const char *name));
#endif
#endif /* _MAILUTILS_MUTIL_H */
......
......@@ -325,22 +325,21 @@ util_cpystr (char *dst, const char *src, size_t size)
return len;
}
static struct passwd *(*_app_getpwnam) __P((char *)) = NULL;
static struct passwd *(*_app_getpwnam) __P((const char *)) = NULL;
void
mu_register_getpwnam (struct passwd *(*fun) __P((char *)))
mu_register_getpwnam (struct passwd *(*fun) __P((const char *)))
{
_app_getpwnam = fun;
}
struct password *
struct passwd *
mu_getpwnam (const char *name)
{
struct password *p;
struct passwd *p;
p = getpwnam (name);
if (!p && _app_getpwnam)
p = (*_app_getpwnam)(name);
return p;
}
......
......@@ -104,6 +104,7 @@
#include <mailutils/header.h>
#include <mailutils/body.h>
#include <mailutils/registrar.h>
#include <mailutils/mutil.h>
#include <mailutils/error.h>
/* For Berkley DB2 APOP password file */
......
......@@ -23,6 +23,7 @@ pop3d_sigchld (int signo)
{
pid_t pid;
int status;
(void)signo;
while ( (pid = waitpid(-1, &status, WNOHANG)) > 0)
--children;
......
......@@ -25,12 +25,16 @@ static int is_virtual = 0;
#ifdef USE_VIRTUAL_DOMAINS
/* XXX: Should not this be configurable somehow?? */
#define VIRTUAL_PWDDIR "/etc/domains"
static struct passwd *
pop3d_virtual (const char *u)
{
struct passwd *pw;
char *filename;
FILE *pfile;
int i = 0, len = strlen (u), delim = 0;
size_t i = 0, len = strlen (u), delim = 0;
for (i = 0; i < len && delim == 0; i++)
if (u[i] == '!' || u[i] == ':' || u[i] == '@')
......@@ -39,17 +43,22 @@ pop3d_virtual (const char *u)
if (delim == 0)
return NULL;
chdir ("/etc/domains");
pfile = fopen (&u[delim+1], "r");
filename = malloc (strlen (VIRTUAL_PWDDIR) + strlen (&u[delim + 1]) + 1);
if (filename == NULL)
pop3d_abquit (ERR_NO_MEM);
sprintf (filename, "%s/%s", VIRTUAL_PWDDIR, &u[delim + 1]);
pfile = fopen (filename, "r");
free (filename);
while (pfile != NULL && (pw = fgetpwent (pfile)) != NULL)
{
if (strlen (pw->pw_name) == delim && !strncmp (u, pw->pw_name, delim))
if (strlen (pw->pw_name) == delim
&& !strncmp (u, pw->pw_name, delim))
{
is_virtual = 1;
return pw;
}
}
return NULL;
}
......@@ -71,6 +80,7 @@ PAM_gnupop3d_conv (int num_msg, const struct pam_message **msg,
{
int replies = 0;
struct pam_response *reply = NULL;
(void)appdata_ptr;
reply = malloc (sizeof (*reply) * num_msg);
if (!reply)
......@@ -122,7 +132,7 @@ pop3d_user (const char *arg)
struct passwd *pw;
int status;
int lockit = 1;
char *mailbox_name;
char *mailbox_name = NULL;
if (state != AUTHORIZATION)
return ERR_WRONG_STATE;
......