~ubuntu-branches/debian/sid/alpine/sid

« back to all changes in this revision

Viewing changes to alpine/imap.c

  • Committer: Package Import Robot
  • Author(s): Unit 193
  • Date: 2015-05-01 19:52:36 UTC
  • mfrom: (1.1.12)
  • Revision ID: package-import@ubuntu.com-20150501195236-e2xjytpbb7ik352w
Tags: 2.20+dfsg1-1
* Imported Upstream version 2.20+dfsg1
  - Drop patches applied upstream.
  - Refresh remaining patches.
  - d/rules: Update SHA256 for alpine 2.20.
* Update Standards-Version to 3.9.6.
* d/watch: Narrow the regex to only match source tarballs.
* d/alpine-doc.docs: tech-notes.txt moved to under the tech-notes/ dir.
* d/control: Update Vcs-Browser for cgit.
* d/p/10_alpine_1.10_spooldir.patch: Fix a few more references.
* d/p/40_fix_browser_hardcoded_paths.patch:
  - Fix hardcoded paths to specific browsers.
* d/p/40_fix_tech_notes_hardcoded_paths.patch, d/rules:
  - Drop patch in favor of changing paths after the build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 
5
5
/*
6
6
 * ========================================================================
 
7
 * Copyright 2013-2015 Eduardo Chappa
7
8
 * Copyright 2006-2009 University of Washington
8
 
 * Copyright 2013 Eduardo Chappa
9
9
 *
10
10
 * Licensed under the Apache License, Version 2.0 (the "License");
11
11
 * you may not use this file except in compliance with the License.
1010
1010
                      (mb->sslflag||mb->tlsflag), 0, 0);
1011
1011
#ifdef  LOCAL_PASSWD_CACHE
1012
1012
    /* if requested, remember it on disk for next session */
1013
 
    if(save_password)
 
1013
      if(save_password && F_OFF(F_DISABLE_PASSWORD_FILE_SAVING,ps_global))
1014
1014
      set_passfile_passwd(ps_global->pinerc, pwd,
1015
1015
                        altuserforcache ? altuserforcache : user, hostlist,
1016
1016
                        (mb->sslflag||mb->tlsflag),
1246
1246
 
1247
1247
    ps_global->tcptimeout = 1;
1248
1248
#ifdef  DEBUG
1249
 
    dprint((1, "tcptimeout: waited %s seconds\n",
1250
 
               long2string(elapsed)));
 
1249
    dprint((1, "tcptimeout: waited %s seconds, server: %s\n",
 
1250
               long2string(elapsed), host));
1251
1251
    if(debugfile)
1252
1252
      fflush(debugfile);
1253
1253
#endif
1842
1842
        break;
1843
1843
 
1844
1844
      default:
1845
 
        panic("Unexpected command in answer_cert_failure");
 
1845
        alpine_panic("Unexpected command in answer_cert_failure");
1846
1846
        break;
1847
1847
    }
1848
1848
 
2041
2041
        return(NULL);
2042
2042
#endif
2043
2043
}
2044
 
 
2045
2044
#endif  /* PASSFILE */
2046
2045
 
2047
2046
 
2051
2050
int 
2052
2051
line_get(char *tmp, size_t len, char **textp)
2053
2052
{
2054
 
  char *s, c;
 
2053
  char *s;
2055
2054
 
2056
2055
  tmp[0] = '\0';
2057
 
  if (*textp == NULL)
 
2056
  if (*textp == NULL || strlen(*textp) >= len - 1
 
2057
        || (s = strchr(*textp, '\n')) == NULL)
2058
2058
    return 0;
2059
 
  s = strchr(*textp, '\n');
2060
 
  if(s != NULL){
2061
 
     *s = '\0';
2062
 
     if(*(s-1) == '\r')
2063
 
        *(s-1) = '\0';
2064
 
     if(strlen(*textp) < len - 1)
2065
 
        strcpy(tmp, *textp);
2066
 
     else
2067
 
        return 0;
2068
 
     strcat(tmp, "\n");
2069
 
     *textp = s+1;
2070
 
  }
2071
 
  else
2072
 
     return 0;
 
2059
 
 
2060
  *s = '\0';
 
2061
  if(*(s-1) == '\r')
 
2062
    *(s-1) = '\0';
 
2063
 
 
2064
  snprintf(tmp, len, "%s\n", *textp);
 
2065
  tmp[len-1] = '\0';
 
2066
  *textp = s+1;
2073
2067
 
2074
2068
  return 1;
2075
2069
}
2379
2373
    };
2380
2374
 
2381
2375
#ifdef SMIME
 
2376
    /* the next call initializes the key/certificate pair used to
 
2377
     * encrypt and decrypt a password file. The details of how this is
 
2378
     * done is in the file pith/smime.c. During this setup we might call
 
2379
     * smime_init(), but no matter what happens we must call smime_deinit()
 
2380
     * there. The reason why this is so is because we can not assume that 
 
2381
     * the .pinerc file has been read by this time, so this code might not
 
2382
     * know about the ps_global->smime structure or any of its components,
 
2383
     * and it shouldn't because it only needs ps_global->pwdcert, so 
 
2384
     * do not init smime here, because the .pinerc might not have been
 
2385
     * read and we do not really know where the keys and certificates really
 
2386
     * are.
 
2387
     */
 
2388
    if(ps_global->pwdcert == NULL)
 
2389
       setup_pwdcert(&ps_global->pwdcert);
2382
2390
    tmp2[0] = '\0';
2383
2391
    fgets(tmp2, sizeof(tmp2), fp);
 
2392
    fclose(fp);
2384
2393
    if(strcmp(tmp2, "-----BEGIN PKCS7-----\n")){
2385
 
       fclose(fp);
2386
 
       if(encrypt_file(tmp, NULL))
 
2394
       if(encrypt_file((char *)tmp, NULL, (PERSONAL_CERT *)ps_global->pwdcert))
2387
2395
          encrypted++;
2388
2396
    }
2389
 
    else{
2390
 
       fclose(fp);
 
2397
    else
2391
2398
       encrypted++;
2392
 
    }
2393
2399
 
2394
2400
    /* 
2395
2401
     * if password file is encrypted we attemtp to decrypt. We ask the 
2404
2410
     * unencrypted and rewritten again.
2405
2411
     */
2406
2412
    if(encrypted){
2407
 
        text = text2 = decrypt_file(tmp, &i);
 
2413
        text = text2 = decrypt_file((char *)tmp, &i, (PERSONAL_CERT *)ps_global->pwdcert);
2408
2414
        switch(i){
2409
2415
           case 1 : save_password = 1;
2410
2416
                    break;
2602
2608
    }
2603
2609
 
2604
2610
#ifdef SMIME
2605
 
    strcpy(tmp2, tmp);
 
2611
   strncpy(tmp2, tmp, sizeof(tmp2)-1);
 
2612
   tmp2[sizeof(tmp2)-1] = '\0';
2606
2613
#endif /* SMIME */
2607
2614
 
2608
2615
    for(n = 0; l; l = l->next, n++){
2627
2634
           len = strlen(text) + strlen(tmp) + 1;
2628
2635
           fs_resize((void **)&text, len*sizeof(char));
2629
2636
        }
2630
 
        strcat(text, tmp);
 
2637
        strncat(text, tmp, strlen(tmp));
2631
2638
#else /* SMIME */
2632
2639
        fputs(tmp, fp);
2633
2640
#endif /* SMIME */
2635
2642
 
2636
2643
    fclose(fp);
2637
2644
#ifdef SMIME
2638
 
    if(encrypt_file(tmp2, text) == 0){
2639
 
        if((fp = our_fopen(tmp2, "wb")) != NULL){
 
2645
    if(text != NULL){
 
2646
       if(encrypt_file((char *)tmp2, text, ps_global->pwdcert) == 0){
 
2647
         if((fp = our_fopen(tmp2, "wb")) != NULL){
2640
2648
           fputs(text, fp);
2641
2649
           fclose(fp);
2642
 
        }
 
2650
         }
 
2651
       }
 
2652
       fs_give((void **)&text);
2643
2653
    }
2644
 
    fs_give((void **)&text);
2645
2654
#endif /* SMIME */
2646
2655
#endif /* PASSFILE */
2647
2656
}
2773
2782
    }
2774
2783
    return(0);
2775
2784
#else /* PASSFILE */
 
2785
if(F_OFF(F_DISABLE_PASSWORD_FILE_SAVING,ps_global))
2776
2786
    return(want_to(_("Preserve password on DISK for next login"), 
2777
2787
                   'y', 'x', NO_HELP, WT_NORM)
2778
2788
           == 'y');
2944
2954
    return;
2945
2955
#else /* !WINCRED */
2946
2956
    MMLOGIN_S *l;
2947
 
    STRLIST_S *h1, *h2;
2948
2957
    
2949
2958
    for(l = passfile_cache; l; l = l->next)
2950
2959
      if(imap_same_host(l->hosts, hostlist)