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
mu_getpwnam function. The function first calls system getpwnam,
if it fails, it calls application-defined getpwnam function.
mu_register_getpwnam can be used to register such a function.
* configure.in: Add -lm to AUTHLIBS when configured with
--enable-mysql.
When checking for PAM: Append to AUTHLIBS instead of just
......@@ -21,7 +42,7 @@
* mailbox/mbx_default.c: use mu_getpwnam. Removed inclusion
of MySql.h.
* mailbox/mutil.c: new functions: mu_getpwnam() and
mu_register_getpwnam().
mu_register_getpwnam().
Removed inclusion of MySql.h
* include/mailbox/mutil.h: Prototypes for the new functions.
......@@ -47,8 +68,8 @@
2001-08-29 Jakob 'sparky' Kaivo <jkaivo@elijah.nodomainname.net>
* imap4d/select.c (imap4d_select0):
* imap4d/copy.c (imap4d_copy0):
* imap4d/select.c (imap4d_select0):
* imap4d/copy.c (imap4d_copy0):
* imap4d/status.c (imap4d_status): treat INBOX differently if virtual
* 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));
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
}
#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;
......@@ -235,7 +245,7 @@ pop3d_user (const char *arg)
if (pw->pw_uid > 0 && !is_virtual)
{
setuid (pw->pw_uid);
mailbox_name = calloc (strlen (_PATH_MAILDIR) + 1
+ strlen (pw->pw_name) + 1, 1);
sprintf (mailbox_name, "%s/%s", _PATH_MAILDIR, pw->pw_name);
......