Commit 417d4307 417d4307c6a76d178a13eb29a16c8972b3b7ee8f by Sergey Poznyakoff

Use MU_PATH_MAILDIR.

1 parent 02c6f21a
......@@ -16,13 +16,6 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "guimb.h"
#ifdef HAVE_PATHS_H
# include <paths.h>
#endif
#ifndef _PATH_MAILDIR
# define _PATH_MAILDIR "/var/spool/mail"
#endif
char *temp_filename;
FILE *temp_file;
......@@ -32,7 +25,16 @@ void
collect_open_default ()
{
size_t nmesg;
if (!default_mailbox)
{
asprintf (&default_mailbox, "%s%s", maildir, user_name);
if (!default_mailbox)
{
util_error ("not enough memory");
exit (1);
}
}
if (mailbox_create (&mbox, default_mailbox) != 0
|| mailbox_open (mbox, MU_STREAM_RDWR) != 0)
{
......@@ -137,18 +139,6 @@ collect_output ()
return 0;
}
if (!default_mailbox)
{
if (!user_name)
return 0;
asprintf (&default_mailbox, "%s/%s", _PATH_MAILDIR, user_name);
if (!default_mailbox)
{
fprintf (stderr, "guimb: not enough memory\n");
return 1;
}
}
if (user_name)
saved_umask = umask (077);
......@@ -197,3 +187,18 @@ collect_drop_mailbox ()
free (temp_filename);
}
}
int
guimb_catch_handler (void *unused, SCM tag, SCM throw_args)
{
collect_drop_mailbox ();
return scm_handle_by_message ("guimb", tag, throw_args);
}
int
guimb_exit (void *unused1, mailbox_t unused2)
{
int rc = collect_output ();
collect_drop_mailbox ();
return rc;
}
......
......@@ -25,7 +25,7 @@ FILE *ofile;
unsigned int timeout = 1800; /* RFC2060: 30 minutes, if enable. */
mailbox_t mbox;
char *homedir;
char *maildir = _PATH_MAILDIR;
char *maildir = MU_PATH_MAILDIR;
int state = STATE_NONAUTH;
/* Number of child processes. */
......
......@@ -34,10 +34,6 @@
#include <mailutils/mutil.h>
#include <mailutils/error.h>
#ifndef _PATH_MAILDIR
# define _PATH_MAILDIR "/usr/spool/mail"
#endif
/* Is this a security risk? */
#define USE_ENVIRON 1
......@@ -281,6 +277,7 @@ mailbox_create_default (mailbox_t *pmbox, const char *mail)
if (mbox == NULL)
{
const char *user = NULL;
int len;
#ifdef USE_ENVIRON
user = (getenv ("LOGNAME")) ? getenv ("LOGNAME") : getenv ("USER");
#endif
......@@ -296,10 +293,10 @@ mailbox_create_default (mailbox_t *pmbox, const char *mail)
return EINVAL;
}
}
mbox = malloc (strlen (user) + strlen (_PATH_MAILDIR) + 2);
mbox = malloc (strlen (user) + strlen (MU_PATH_MAILDIR) + 2);
if (mbox == NULL)
return ENOMEM;
sprintf (mbox, "%s/%s", _PATH_MAILDIR, user);
sprintf (mbox, "%s%s", MU_PATH_MAILDIR, user);
}
status = mailbox_create (pmbox, mbox);
free (mbox);
......
......@@ -25,7 +25,7 @@ mailbox_t mbox;
unsigned int timeout;
int state;
char *username;
char *maildir = _PATH_MAILDIR;
char *maildir = MU_PATH_MAILDIR;
FILE *ifile;
FILE *ofile;
char *md5shared;
......