Move hcoop changes to quilt patch
[hcoop/debian/courier-authlib.git] / debian / patches / 0006-hcoop-openafs-changes.patch
diff --git a/debian/patches/0006-hcoop-openafs-changes.patch b/debian/patches/0006-hcoop-openafs-changes.patch
new file mode 100644 (file)
index 0000000..650cdea
--- /dev/null
@@ -0,0 +1,82 @@
+--- a/authpam.c
++++ b/authpam.c
+@@ -128,19 +128,20 @@
+               }
+       }
+-#if 0
+ #if   HAVE_PAM_SETCRED
++      fprintf(stderr, "pam_setcred...\n");
+       if (retval == PAM_SUCCESS)
+       {
+               retval=pam_setcred(*pamh, PAM_ESTABLISH_CRED);
+               if (retval != PAM_SUCCESS)
+               {
+-                      DPRINTF("pam_setcred failed, result %d", retval);
++                      fprintf(stderr, "pam_setcred failed, result %d\n", retval);
+               }
++      fprintf(stderr, "pam_setcred done\n");
+       }
+ #endif
+-#endif
++
+       if (retval == PAM_SUCCESS)
+       {
+--- a/courier_auth_config.h
++++ b/courier_auth_config.h
+@@ -256,7 +256,7 @@
+ #define STDC_HEADERS 1
+ /* Location of the userdb database */
+-#define USERDB "/usr/local/etc/authlib/userdb"
++#define USERDB "/etc/courier/userdb"
+ /* Version number of package */
+ /* #undef VERSION */
+--- a/preauthuserdbcommon.c
++++ b/preauthuserdbcommon.c
+@@ -14,11 +14,13 @@
+ #if   HAVE_UNISTD_H
+ #include      <unistd.h>
+ #endif
++#include <sys/types.h>
++#include <sys/wait.h>
+ #include      "auth.h"
+ #include      "courierauthdebug.h"
+ #include      "userdb/userdb.h"
+-
++#include      "numlib/numlib.h"
+ int auth_userdb_pre_common(const char *userid, const char *service,
+       int needpass,
+@@ -105,6 +107,27 @@
+       auth.maildir=udb->udb_mailbox;
+       auth.quota=udb->udb_quota;
++        /* Get tokens for AFS */
++       {
++          if (auth.sysuserid)
++          {
++          pid_t pid = fork ();
++
++          if (pid == 0)
++          {
++            char uidstr[32] = "<null>";
++            snprintf(uidstr, sizeof(uidstr), "%ld", (long)*auth.sysuserid);
++
++            libmail_changeuidgid (*auth.sysuserid, auth.sysgroupid);
++            execl ("/etc/courier/get-token", "get-token", uidstr, NULL);
++          }
++          else
++          {
++              waitpid (pid, NULL, 0);
++          }
++        }
++        }
++
+       courier_authdebug_authinfo("DEBUG: authuserdb: ", &auth, 0, passwords);
+       rc= (*callback)(&auth, arg);
+       if (passwords)  free(passwords);