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