]> Pileus Git - ~andy/fetchmail/commitdiff
Unbreak --smtphost default, reported and different patch suggested by
authorMatthias Andree <matthias.andree@gmx.de>
Thu, 10 Nov 2005 01:35:23 +0000 (01:35 -0000)
committerMatthias Andree <matthias.andree@gmx.de>
Thu, 10 Nov 2005 01:35:23 +0000 (01:35 -0000)
Sunil Shetye. Broken since r4382 v6.2.9-rc7.

svn path=/trunk/; revision=4402

fetchmail.c

index 6104d1c8846b0434f1c34e10af5299571b11af7c..8ded6474d2b94e74819f16586ee7bb41b4d3ee06 100644 (file)
@@ -922,7 +922,7 @@ static void optmerge(struct query *h2, struct query *h1, int force)
  *         - false if servers found on the command line */
 static int load_params(int argc, char **argv, int optind)
 {
-    int        implicitmode, st;
+    int        implicitmode, st, use_kerberos;
     struct passwd *pw;
     struct query def_opts, *ctl;
     struct stat rcstat;
@@ -1070,18 +1070,20 @@ static int load_params(int argc, char **argv, int optind)
      * If we're using Kerberos for authentication, we need 
      * the FQDN in order to generate capability keys.
      */
+    use_kerberos = 0;
+    /* use_kerberos is saved until later to properly set the invisible
+     * --smtphost (aka. smtphunt) default */
     for (ctl = querylist; ctl; ctl = ctl->next)
        if (ctl->active && 
                (ctl->server.protocol==P_ETRN || ctl->server.protocol==P_ODMR
                 || ctl->server.authenticate == A_KERBEROS_V4
                 || ctl->server.authenticate == A_KERBEROS_V5))
        {
-           fetchmailhost = host_fqdn(1);
+           use_kerberos = 1;
            break;
        }
 
-    if (!ctl) /* list exhausted */
-       fetchmailhost = host_fqdn(0);
+    fetchmailhost = host_fqdn(use_kerberos);
 
     /* this code enables flags to be turned off */
 #define DEFAULT(flag, dflt)    if (flag == FLAG_TRUE)\
@@ -1156,7 +1158,7 @@ static int load_params(int argc, char **argv, int optind)
             * Make sure we have a nonempty host list to forward to.
             */
            if (!ctl->smtphunt)
-               save_str(&ctl->smtphunt, fetchmailhost, FALSE);
+               save_str(&ctl->smtphunt, use_kerberos ? fetchmailhost : "localhost", FALSE);
 
            /*
             * Make sure we have a nonempty list of domains to fetch from.