]> Pileus Git - ~andy/fetchmail/blobdiff - env.c
More patches by Sunil.
[~andy/fetchmail] / env.c
diff --git a/env.c b/env.c
index 7aad7d5206a33d7a88bc7923484ece2745bf6dc2..8fe2103d6548a1b271b1f06e94691b7eaffabe64 100644 (file)
--- a/env.c
+++ b/env.c
 #include "fetchmail.h"
 
 #include "i18n.h"
+#if defined(HAVE_SETLOCALE) && defined(ENABLE_NLS) && defined(HAVE_STRFTIME)
+#include <time.h>
+#include <locale.h>
+#endif
 
 extern char *getenv(); /* needed on sysV68 R3V7.1. */
 
@@ -37,14 +41,47 @@ void envquery(int argc, char **argv)
 {
     struct passwd by_name, by_uid, *pwp;
 
-    (user = getenv("FETCHMAILUSER"))
-       || (user = getenv("LOGNAME"))
-       || (user = getenv("USER"));
+    if (!(user = getenv("FETCHMAILUSER")))
+    {
+       if (!(user = getenv("LOGNAME")))
+       {
+           user = getenv("USER");
+       }
+    }
+
+    if ((program_name = strrchr(argv[0], '/')) != NULL)
+       ++program_name;
+    else
+       program_name = argv[0];
+
+    if (getenv("QMAILINJECT") && strcmp(getenv("QMAILINJECT"), ""))
+    {
+       fprintf(stderr,
+               GT_("%s: The QMAILINJECT environment variable is set.\n"
+                   "This is dangerous as it can make qmail-inject or qmail's sendmail wrapper\n"  
+                   "tamper with your From: or Message-ID: headers.\n"
+                   "Try \"env QMAILINJECT= %s YOUR ARGUMENTS HERE\"\n"
+                   "%s: Abort.\n"), 
+               program_name, program_name, program_name);
+       exit(PS_UNDEFINED);
+    }
+
+    if (getenv("NULLMAILER_FLAGS") && strcmp(getenv("NULLMAILER_FLAGS"), ""))
+    {
+       fprintf(stderr,
+               GT_("%s: The NULLMAILER_FLAGS environment variable is set.\n"
+                   "This is dangerous as it can make nullmailer-inject or nullmailer's\n" 
+                   "sendmail wrapper tamper with your From:, Message-ID: or Return-Path: headers.\n"
+                   "Try \"env NULLMAILER_FLAGS= %s YOUR ARGUMENTS HERE\"\n"
+                   "%s: Abort.\n"), 
+               program_name, program_name, program_name);
+       exit(PS_UNDEFINED);
+    }
 
     if (!(pwp = getpwuid(getuid())))
     {
        fprintf(stderr,
-               _("%s: You don't exist.  Go away.\n"),
+               GT_("%s: You don't exist.  Go away.\n"),
                program_name);
        exit(PS_UNDEFINED);
     }
@@ -77,11 +114,6 @@ void envquery(int argc, char **argv)
     if (!(fmhome = getenv("FETCHMAILHOME")))
        fmhome = home;
 
-    if ((program_name = strrchr(argv[0], '/')) != NULL)
-       ++program_name;
-    else
-       program_name = argv[0];
-
 #define RCFILE_NAME    "fetchmailrc"
     /*
      * The (fmhome==home) leaves an extra character for a . at the
@@ -110,7 +142,7 @@ char *host_fqdn(void)
 
     if (gethostname(tmpbuf, sizeof(tmpbuf)))
     {
-       fprintf(stderr, _("%s: can't determine your host!"),
+       fprintf(stderr, GT_("%s: can't determine your host!"),
                program_name);
        exit(PS_DNS);
     }
@@ -126,7 +158,7 @@ char *host_fqdn(void)
        {
            /* exit with error message */
            fprintf(stderr,
-                   _("gethostbyname failed for %s\n"), tmpbuf);
+                   GT_("gethostbyname failed for %s\n"), tmpbuf);
            exit(PS_DNS);
        }
        return(xstrdup(hp->h_name));
@@ -177,10 +209,18 @@ char *rfc822timestamp(void)
      * Conform to RFC822.  We generate a 4-digit year here, avoiding
      * Y2K hassles.  Max length of this timestamp in an English locale
      * should be 29 chars.  The only things that should vary by locale
-     * are the day and month abbreviations.
+     * are the day and month abbreviations.  The set_locale calls prevent
+     * weird multibyte i18n characters (such as kanji) from showing up
+     * in your Received headers.
      */
+#if defined(HAVE_SETLOCALE) && defined(ENABLE_NLS)
+    setlocale (LC_TIME, "C");
+#endif
     strftime(buf, sizeof(buf)-1, 
             "%a, %d %b %Y %H:%M:%S XXXXX (%Z)", localtime(&now));
+#if defined(HAVE_SETLOCALE) && defined(ENABLE_NLS)
+    setlocale (LC_TIME, "");
+#endif
     strncpy(strstr(buf, "XXXXX"), tzoffset(&now), 5);
 #else
     /*
@@ -204,17 +244,17 @@ const char *showproto(int proto)
 #ifdef POP2_ENABLE
     case P_POP2: return("POP2");
 #endif /* POP2_ENABLE */
+#ifdef POP3_ENABLE
     case P_POP3: return("POP3");
-    case P_IMAP: return("IMAP");
-    case P_IMAP_K4: return("IMAP-K4");
-#ifdef GSSAPI
-    case P_IMAP_GSS: return("IMAP-GSS");
-#endif /* GSSAPI */
-    case P_IMAP_CRAM_MD5: return("IMAP-LOGIN");
-    case P_IMAP_LOGIN: return("IMAP-LOGIN");
     case P_APOP: return("APOP");
     case P_RPOP: return("RPOP");
+#endif /* POP3_ENABLE */
+#ifdef IMAP_ENABLE
+    case P_IMAP: return("IMAP");
+#endif /* IMAP_ENABLE */
+#ifdef ETRN_ENABLE
     case P_ETRN: return("ETRN");
+#endif /* ETRN_ENABLE */
 #ifdef ODMR_ENABLE
     case P_ODMR: return("ODMR");
 #endif /* ODMR_ENABLE */