removed ckcpro.c: autogenerated
[ckermit.git] / debian / patches / 040_pam-password-prompting.patch
1 Make IKSD authentication (using PAM) ask for a password when an
2 invalid username has been given, to avoid disclosing which account
3 names are valid. See #417247.
4 --- ckermit-211.orig/ckufio.c
5 +++ ckermit-211/ckufio.c
6 @@ -490,6 +490,9 @@
7  static char guestpass[GUESTPASS] = { NUL, NUL }; /* Anonymous "password" */
8  static int logged_in = 0;               /* Set when user is logged in */
9  static int askpasswd = 0;               /* Have OK user, must ask for passwd */
10 +#ifdef CK_PAM
11 +extern int gotemptypasswd;
12 +#endif /* CK_PAM */
13  #endif /* CK_LOGIN */
14  
15  #ifdef CKROOT
16 @@ -8043,8 +8046,12 @@
17              }
18          }
19          debug(F110,"zvpass","calling pam_authenticate",0);
20 -        if (*p)
21 -         pam_pw = p;
22 +        if (*p
23 +#ifdef CK_LOGIN
24 +           || gotemptypasswd
25 +#endif /* CK_LOGIN */
26 +           )
27 +           pam_pw = p;
28          if ((pam_status = pam_authenticate(pamh, 0)) != PAM_SUCCESS) {
29              reply = pam_strerror(pamh, pam_status);
30              debug(F110,"zvpass PAM failure",reply,0);
31 --- ckermit-211.orig/ckuus7.c
32 +++ ckermit-211/ckuus7.c
33 @@ -98,6 +98,12 @@
34  
35  extern char * k_info_dir;
36  
37 +#ifdef CK_LOGIN
38 +#ifdef CK_PAM
39 +int gotemptypasswd = 0;   /* distinguish empty passwd from none given */
40 +#endif /* CK_PAM */
41 +#endif /* CK_LOGIN */
42 +
43  #ifndef NOSPL
44  extern int nmac;
45  extern struct mtab *mactab;
46 @@ -14656,9 +14662,9 @@
47  #ifdef CK_RECALL
48      extern int on_recall;               /* around Password prompting */
49  #endif /* CK_RECALL */
50 -#ifdef CK_PAM
51 +#ifdef COMMENT
52      extern int guest;
53 -#endif /* CK_PAM */
54 +#endif /* COMMENT */
55      int rprompt = 0;                    /* Restore prompt */
56  #ifdef CKSYSLOG
57      int savlog;
58 @@ -14774,9 +14780,9 @@
59      debug(F111,"ckxlogin zvuser",userid,ok);
60  
61      if (!*passwd && promptok
62 -#ifdef CK_PAM
63 +#ifdef COMMENT
64          && guest
65 -#endif /* CK_PAM */
66 +#endif /* COMMENT */
67          ) {
68          char prmpt[80];
69  
70 @@ -14852,6 +14858,9 @@
71          if (pflag) prompt(xxstring);    /* Issue prompt if at top level */
72          cmres();                        /* Reset the parser */
73          for (x = -1; x < 0;) {          /* Prompt till they answer */
74 +#ifdef CK_PAM
75 +           gotemptypasswd=0;
76 +#endif /* CK_PAM */
77              x = cmtxt("","",&s,NULL);   /* Get a literal line of text */
78              if (x == -4 || x == -10) {
79                  printf("\r\n%sLogin cancelled\n",
80 @@ -14861,6 +14870,10 @@
81  #endif /* CKSYSLOG */
82                  doexit(GOOD_EXIT,0);
83              }
84 +#ifdef CK_PAM
85 +           if(!*s)
86 +               gotemptypasswd=1;
87 +#endif /* CK_PAM */
88              if (sstate)                 /* In case of a Kermit packet */
89                goto XCKXLOG;
90              cmres();                    /* Reset the parser again */
91 @@ -14895,6 +14908,12 @@
92      if (ok) {
93          ok = zvpass((char *)passwd);    /* Check password */
94          debug(F101,"ckxlogin zvpass","",ok);
95 +#ifdef CK_PAM
96 +    } else {
97 +       /* Fake pam password failure for nonexistent users */
98 +       sleep(1);
99 +       printf("Authentication failure\n");
100 +#endif
101      }
102  
103      if (ok > 0 && isguest) {