]> arthur.barton.de Git - netatalk.git/blobdiff - etc/uams/uams_pam.c
patch to fix checking of hostname
[netatalk.git] / etc / uams / uams_pam.c
index bb65bec1c293374039393d17fd6fe9d7c72d849e..b6222cf605ea71800ab987148a6dba92c969a299 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uams_pam.c,v 1.6 2001-02-27 17:07:43 rufustfirefly Exp $
+ * $Id: uams_pam.c,v 1.10 2001-11-13 15:01:38 rufustfirefly Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu) 
@@ -8,13 +8,29 @@
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
-#endif
+#endif /* HAVE_CONFIG_H */
 
-#ifdef USE_PAM
 #include <stdio.h>
 #include <stdlib.h>
+#ifdef HAVE_UNISTD_H
 #include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+/* STDC check */
+#if STDC_HEADERS
 #include <string.h>
+#else /* STDC_HEADERS */
+#ifndef HAVE_STRCHR
+#define strchr index
+#define strrchr index
+#endif /* HAVE_STRCHR */
+char *strchr (), *strrchr ();
+#ifndef HAVE_MEMCPY
+#define memcpy(d,s,n) bcopy ((s), (d), (n))
+#define memmove(d,s,n) bcopy ((s), (d), (n))
+#endif /* ! HAVE_MEMCPY */
+#endif /* STDC_HEADERS */
+
 #include <syslog.h>
 
 #include <security/pam_appl.h>
@@ -70,7 +86,7 @@ static int PAM_conv (int num_msg,
     case PAM_TEXT_INFO:
 #ifdef PAM_BINARY_PROMPT
     case PAM_BINARY_PROMPT:
-#endif
+#endif /* PAM_BINARY_PROMPT */
       /* ignore it... */
       break;
     case PAM_ERROR_MSG:
@@ -124,9 +140,13 @@ static int pam_login(void *obj, struct passwd **uam_pwd,
                             (void *) &username, &ulen) < 0)
       return AFPERR_MISC;
 
-    if (uam_afpserver_option(obj, UAM_OPTION_HOSTNAME,
+    if (uam_afpserver_option(obj, UAM_OPTION_CLIENTNAME,
                             (void *) &hostname, NULL) < 0)
-      return AFPERR_MISC;
+       {
+       syslog(LOG_INFO, "uams_pam.c :PAM: unable to retrieve client hostname");
+       hostname = NULL;
+       }
+
 
     len = (unsigned char) *ibuf++;
     if ( len > ulen ) {
@@ -171,13 +191,13 @@ static int pam_login(void *obj, struct passwd **uam_pwd,
 #ifdef PAM_AUTHTOKEN_REQD
       else if (PAM_error == PAM_AUTHTOKEN_REQD) 
        err = AFPERR_PWDCHNG;
-#endif
+#endif /* PAM_AUTHTOKEN_REQD */
       goto login_err;
     }
 
 #ifndef PAM_CRED_ESTABLISH
 #define PAM_CRED_ESTABLISH PAM_ESTABLISH_CRED
-#endif
+#endif /* PAM_CRED_ESTABLISH */
     PAM_error = pam_setcred(pamh, PAM_CRED_ESTABLISH);
     if (PAM_error != PAM_SUCCESS)
       goto login_err;
@@ -394,4 +414,8 @@ UAM_MODULE_EXPORT struct uam_export uams_clrtxt = {
   uam_setup, uam_cleanup
 };
 
-#endif /* USE_PAM */
+UAM_MODULE_EXPORT struct uam_export uams_pam = {
+  UAM_MODULE_SERVER,
+  UAM_MODULE_VERSION,
+  uam_setup, uam_cleanup
+};