]> arthur.barton.de Git - netatalk.git/blobdiff - etc/uams/uams_pam.c
Writing metadata xattr on directories with sticky bit set, FR#94
[netatalk.git] / etc / uams / uams_pam.c
index 0870968cb4f34e1dfe3c011b5c40722f5e5e8114..da5be62132a0dd073f53abdc880c6f4e2e06faf6 100644 (file)
@@ -1,5 +1,4 @@
 /*
- * $Id: uams_pam.c,v 1.17 2005-04-28 20:49:50 bfernhomberg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu) 
 #include "config.h"
 #endif /* HAVE_CONFIG_H */
 
-#ifndef ATACC
 #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 <atalk/logger.h>
-
 #ifdef HAVE_SECURITY_PAM_APPL_H
 #include <security/pam_appl.h>
 #endif
 #ifdef HAVE_PAM_PAM_APPL_H
 #include <pam/pam_appl.h>
 #endif
+#include <arpa/inet.h>
 
 #include <atalk/afp.h>
 #include <atalk/uam.h>
 #include <atalk/util.h>
+#include <atalk/logger.h>
+#include <atalk/compat.h>
 
 #define PASSWDLEN 8
 
@@ -56,18 +40,24 @@ char *strchr (), *strrchr ();
  * and the server_login function
  */
 static pam_handle_t *pamh = NULL; 
-static char *hostname;
+static const char *hostname;
 static char *PAM_username;
 static char *PAM_password;
 
-extern void append(void *, const char *, int);
+/*XXX in etc/papd/file.h */
+struct papfile;
+extern UAM_MODULE_EXPORT void append(struct papfile *, const char *, int);
 
 /* PAM conversation function
  * Here we assume (for now, at least) that echo on means login name, and
  * echo off means password.
  */
 static int PAM_conv (int num_msg,
+#ifdef LINUX
                      const struct pam_message **msg,
+#else
+                     struct pam_message **msg,
+#endif
                      struct pam_response **resp,
                      void *appdata_ptr _U_) 
 {
@@ -139,8 +129,8 @@ static struct pam_conv PAM_conversation = {
 };
 
 static int login(void *obj, char *username, int ulen,  struct passwd **uam_pwd,
-                    char *ibuf, int ibuflen _U_,
-                    char *rbuf _U_, int *rbuflen _U_)
+                    char *ibuf, size_t ibuflen _U_,
+                    char *rbuf _U_, size_t *rbuflen _U_)
 {
     struct passwd *pwd;
     int err, PAM_error;
@@ -155,7 +145,7 @@ static int login(void *obj, char *username, int ulen,  struct passwd **uam_pwd,
     ibuf[ PASSWDLEN ] = '\0';
 
     if (( pwd = uam_getname(obj, username, ulen)) == NULL ) {
-       return AFPERR_PARAM;
+       return AFPERR_NOTAUTH;
     }
 
     LOG(log_info, logtype_uams, "cleartext login: %s", username);
@@ -218,11 +208,11 @@ login_err:
    cleartxt login 
 */
 static int pam_login(void *obj, struct passwd **uam_pwd,
-                    char *ibuf, int ibuflen,
-                    char *rbuf, int *rbuflen)
+                    char *ibuf, size_t ibuflen,
+                    char *rbuf, size_t *rbuflen)
 {
     char *username; 
-    int  len, ulen;
+    size_t  len, ulen;
 
     *rbuflen = 0;
 
@@ -247,12 +237,12 @@ static int pam_login(void *obj, struct passwd **uam_pwd,
 
 /* ----------------------------- */
 static int pam_login_ext(void *obj, char *uname, struct passwd **uam_pwd,
-                    char *ibuf, int ibuflen,
-                    char *rbuf, int *rbuflen)
+                    char *ibuf, size_t ibuflen,
+                    char *rbuf, size_t *rbuflen)
 {
     char *username; 
-    int  len, ulen;
-    u_int16_t  temp16;
+    size_t  len, ulen;
+    uint16_t  temp16;
 
     *rbuflen = 0;
 
@@ -275,7 +265,7 @@ static int pam_login_ext(void *obj, char *uname, struct passwd **uam_pwd,
 }
 
 /* logout */
-static void pam_logout() {
+static void pam_logout(void) {
     pam_close_session(pamh, 0);
     pam_end(pamh, 0);
     pamh = NULL;
@@ -283,8 +273,8 @@ static void pam_logout() {
 
 /* change passwd */
 static int pam_changepw(void *obj _U_, char *username,
-                       struct passwd *pwd _U_, char *ibuf, int ibuflen _U_,
-                       char *rbuf _U_, int *rbuflen _U_)
+                       struct passwd *pwd _U_, char *ibuf, size_t ibuflen _U_,
+                       char *rbuf _U_, size_t *rbuflen _U_)
 {
     char pw[PASSWDLEN + 1];
     pam_handle_t *lpamh;
@@ -342,9 +332,7 @@ static int pam_changepw(void *obj _U_, char *username,
 
 
 /* Printer ClearTxtUAM login */
-int pam_printer(start, stop, username, out)
-        char    *start, *stop, *username;
-       struct papfile  *out;
+static int pam_printer(char *start, char *stop, char *username, struct papfile *out)
 {
     int PAM_error;
     char       *data, *p, *q;
@@ -457,7 +445,7 @@ int pam_printer(start, stop, username, out)
 }
 
 
-static int uam_setup(const char *path)
+static int uam_setup(void *obj, const char *path)
 {
   if (uam_register(UAM_SERVER_LOGIN_EXT, path, "Cleartxt Passwrd", 
                   pam_login, NULL, pam_logout, pam_login_ext) < 0)
@@ -495,4 +483,3 @@ UAM_MODULE_EXPORT struct uam_export uams_pam = {
   UAM_MODULE_VERSION,
   uam_setup, uam_cleanup
 };
-#endif