From b3137da39f141aeed36a9f94d05af617645c8461 Mon Sep 17 00:00:00 2001
From: Gerrit Pape <pape@innominate.com>
Date: Tue, 11 Dec 2007 10:11:38 +0000
Subject: bug#304737: default 'Maildir' may be overridden through the env variable $MAILDIR

---
 checkapoppw.c |    7 +++++--
 checkpw.c     |    7 +++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/checkapoppw.c b/checkapoppw.c
index 4243652..1533028 100644
--- a/checkapoppw.c
+++ b/checkapoppw.c
@@ -43,6 +43,7 @@ main(int argc,char **argv)
   char *dash;
   char *ext;
   char *password;
+  char *maildir;
   char *timestamp;
   struct stat st;
   int r;
@@ -55,7 +56,9 @@ main(int argc,char **argv)
  
   if (!argv[1]) _exit(2);
   dash = env_get("DASH");
- 
+  maildir = env_get("MAILDIR");
+  if (!maildir) maildir = auto_maildir;
+
   uplen = 0;
   for (;;) {
     do
@@ -94,7 +97,7 @@ main(int argc,char **argv)
   }
   if (chdir(pw->pw_dir) == -1) die(111);
 
-  if (!stralloc_copys(&pwfile, auto_maildir)) die(111);
+  if (!stralloc_copys(&pwfile, maildir)) die(111);
   if (dash && *ext) {
     if (!stralloc_cats(&pwfile, dash)) die(111);
     if (!stralloc_cats(&pwfile, ext)) die(111);
diff --git a/checkpw.c b/checkpw.c
index 957691a..796745e 100644
--- a/checkpw.c
+++ b/checkpw.c
@@ -38,13 +38,16 @@ main(int argc,char **argv)
   char *dash;
   char *ext;
   char *password;
+  char *maildir;
   struct stat st;
   int r;
   int i;
  
   if (!argv[1]) _exit(2);
   dash = env_get("DASH");
- 
+  maildir = env_get("MAILDIR");
+  if (!maildir) maildir = auto_maildir;
+
   uplen = 0;
   for (;;) {
     do
@@ -80,7 +83,7 @@ main(int argc,char **argv)
   }
   if (chdir(pw->pw_dir) == -1) die(111);
 
-  if (!stralloc_copys(&pwfile, auto_maildir)) die(111);
+  if (!stralloc_copys(&pwfile, maildir)) die(111);
   if (dash && *ext) {
     if (!stralloc_cats(&pwfile, dash)) die(111);
     if (!stralloc_cats(&pwfile, ext)) die(111);
