diff -ur qpopper4.0.3.dist/configure.in qpopper4.0.3.uchi/configure.in --- qpopper4.0.3.dist/configure.in Tue Apr 3 19:23:08 2001 +++ qpopper4.0.3.uchi/configure.in Wed Apr 24 20:05:32 2002 @@ -882,6 +880,26 @@ fi +AC_ARG_ENABLE(inbox-var, [ --enable-inbox-var Allow $INBOX variable to override spool file ], + use_inbox_var="$enableval", use_inbox_var="no") +if test "$use_inbox_var" != "no"; then + AC_MSG_RESULT(Allowing \$INBOX to override user spool files) + OS_DEFS="$OS_DEFS -DUSE_INBOX_VAR" +fi + +AC_ARG_WITH(mailpath, [ --with-mailpath=path Allow $MAILPATH_FMT variable to override spool file ], + use_mailpath_var="$withval", use_mailpath_var="no") +if test "$use_mailpath_var" != "no"; then + AC_MSG_RESULT(Allowing \$MAILPATH_FMT to override user spool files) + if test "$withval" != "yes"; then + OS_DEFS="$OS_DEFS -I$withval/include" + LIBS="-L$withval/lib" + fi + OS_DEFS="$OS_DEFS -DUSE_MAILPATH_VAR" + LIBS="$LIBS -lmailpath" +fi + + dnl dnl ---------- Query for OS options ---------- dnl diff -ur qpopper4.0.3.dist/popper/genpath.c qpopper4.0.3.uchi/popper/genpath.c --- qpopper4.0.3.dist/popper/genpath.c Sun May 6 20:00:49 2001 +++ qpopper4.0.3.uchi/popper/genpath.c Wed Apr 24 19:56:51 2002 @@ -95,6 +95,9 @@ #include "popper.h" #include "string_util.h" +#if USE_MAILPATH_VAR +# include +#endif static char *get_hash_dir ( char *pszUser, int iMethod ); @@ -108,7 +111,9 @@ int len3 = 0; /* used with strlcat */ int iChunk = 0; /* used with Qsnprintf */ struct passwd *pw = &p->pw; - + char *inbox_dir = NULL; /* INBOX variable overrides internals */ + char *inbox_file = NULL; /* ditto */ + char *mailpath_fmt = NULL; /* MAILPATH_FMT variable also overrides */ if ( pw == NULL || pw->pw_name == NULL ) { pop_log ( p, POP_PRIORITY, HERE, "Bogus passwd struct" ); @@ -118,6 +123,33 @@ pszUser = pw->pw_name; /* + * Look up $INBOX, and use it to override anything else we can + * figure out in here. + */ +#ifdef USE_INBOX_VAR + inbox_dir = getenv("INBOX"); +#endif +#ifdef USE_MAILPATH_VAR + if (! inbox_dir) { + /* No $INBOX? Then check for $MAILPATH_FMT. */ + if (mailpath_fmt = getenv("MAILPATH_FMT")) { + inbox_dir = mailpath(mailpath_fmt, pw->pw_name, pw->pw_uid, + MP_NOLOOKUP); + if (inbox_dir) + inbox_dir = strdup(inbox_dir); + } + } +#endif /* USE_MAILPATH_VAR */ +#if defined(USE_INBOX_VAR) || defined(USE_MAILPATH_VAR) + if (inbox_dir) { + if (inbox_file = strrchr(inbox_dir, '/')) { + *inbox_file = '\0'; + ++inbox_file; + } + } +#endif /* USE_INBOX_VAR || USE_MAILPATH_VAR */ + + /* * First, the parent directory */ switch ( iWhich ) { @@ -125,7 +157,9 @@ case GNPH_TMP: /* tmpxxxx */ case GNPH_XMT: /* xmitxxxx */ case GNPH_PATH: /* Just the path, M'am */ - if ( p->pHome_dir_mail != NULL ) + if (inbox_dir) + len1 = strlcpy ( pszDrop, inbox_dir, iDropLen ); + else if ( p->pHome_dir_mail != NULL ) len1 = strlcpy ( pszDrop, pw->pw_dir, iDropLen ); else len1 = strlcpy ( pszDrop, p->pCfg_spool_dir, iDropLen ); @@ -138,7 +172,10 @@ break; case GNPH_OLDPOP: /* old .pop file (always in POP_MAILDIR) */ - len1 = strlcpy ( pszDrop, p->pCfg_spool_dir, iDropLen ); + if (inbox_dir) + len1 = strlcpy ( pszDrop, inbox_dir, iDropLen ); + else + len1 = strlcpy ( pszDrop, p->pCfg_spool_dir, iDropLen ); len2 = strlcat ( pszDrop, "/", iDropLen ); break; @@ -160,7 +197,11 @@ /* * Next, the hashed directory (if in use) */ - if ( p->hash_spool != 0 ) { + /* + * Ignore hashing if $INBOX is overriding -- too messy figuring out + * what should be done. + */ + if ( inbox_dir == NULL && p->hash_spool != 0 ) { len3 = strlcat ( pszDrop, get_hash_dir ( pszUser, p->hash_spool ), iDropLen ); DEBUG_LOG2 ( p, "...built: (%d) '%.100s'", @@ -187,7 +228,9 @@ */ switch ( iWhich ) { case GNPH_SPOOL: /* spool file */ - if ( p->pHome_dir_mail != NULL ) + if ( inbox_file ) + len1 = strlcat ( pszDrop, inbox_file, iDropLen ); + else if ( p->pHome_dir_mail != NULL ) len1 = strlcat ( pszDrop, p->pHome_dir_mail, iDropLen ); else len1 = strlcat ( pszDrop, pszUser, iDropLen );