]> arthur.barton.de Git - netatalk.git/blobdiff - etc/uams/uams_passwd.c
Try using Tracker 0.15 from OpenCSW
[netatalk.git] / etc / uams / uams_passwd.c
index e94539c83c6dc99ff09aa408d05d00c264125f95..bec45a360813bd502affc3a9ac5eed8902f6fae3 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: uams_passwd.c,v 1.23 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) 
  * All Rights Reserved.  See COPYRIGHT.
 #include <config.h>
 #endif /* HAVE_CONFIG_H */
 
-#include <sys/types.h>
-/* crypt needs _XOPEN_SOURCE (500) at least on BSD, but that breaks Solaris compile */
-#ifdef NETBSD
-#define _XOPEN_SOURCE 500 /* for crypt() */
-#endif
-#ifdef FREEBSD
-#define _XOPEN_SOURCE /* for crypt() */
-#endif
+#include <atalk/standards.h>
 
+#include <sys/types.h>
 #include <stdio.h>
 #include <stdlib.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 */
-#ifdef HAVE_UNISTD_H
 #include <unistd.h>
-#endif /* HAVE_UNISTD_H */
 #ifdef HAVE_CRYPT_H
 #include <crypt.h>
 #endif /* ! HAVE_CRYPT_H */
 #include <pwd.h>
-#ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
-#endif
-#ifdef HAVE_TIME_H
 #include <time.h>
-#endif
 #ifdef SHADOWPW
 #include <shadow.h>
 #endif /* SHADOWPW */
+#include <arpa/inet.h>
 
 #include <atalk/afp.h>
 #include <atalk/logger.h>
 #include <atalk/uam.h>
 #include <atalk/util.h>
+#include <atalk/compat.h>
 
 #define PASSWDLEN 8
 
@@ -68,14 +43,16 @@ char *strchr (), *strrchr ();
 #include <sia.h>
 #include <siad.h>
 
-static char *clientname;
+static const char *clientname;
 #endif /* TRU64 */
 
-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);
 
 static int pwd_login(void *obj, char *username, int ulen, struct passwd **uam_pwd,
-                        char *ibuf, int ibuflen,
-                        char *rbuf _U_, int *rbuflen _U_)
+                        char *ibuf, size_t ibuflen,
+                        char *rbuf _U_, size_t *rbuflen _U_)
 {
     char  *p;
     struct passwd *pwd;
@@ -96,7 +73,7 @@ static int pwd_login(void *obj, char *username, int ulen, struct passwd **uam_pw
     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);
@@ -113,7 +90,7 @@ static int pwd_login(void *obj, char *username, int ulen, struct passwd **uam_pw
     }
     pwd->pw_passwd = sp->sp_pwdp;
 
-    if (sp && sp->sp_max != -1 && sp->sp_lstchg) {
+    if (sp->sp_max != -1 && sp->sp_lstchg) {
         time_t now = time(NULL) / (60*60*24);
         int32_t expire_days = sp->sp_lstchg - now + sp->sp_max;
         if ( expire_days < 0 ) {
@@ -156,11 +133,11 @@ static int pwd_login(void *obj, char *username, int ulen, struct passwd **uam_pw
 
 /* cleartxt login */
 static int passwd_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;
 
@@ -168,7 +145,7 @@ static int passwd_login(void *obj, struct passwd **uam_pwd,
                              (void *) &username, &ulen) < 0)
         return AFPERR_MISC;
 
-    if (ibuflen <= 1) {
+    if (ibuflen < 2) {
         return( AFPERR_PARAM );
     }
 
@@ -197,12 +174,12 @@ static int passwd_login(void *obj, struct passwd **uam_pwd,
     len bytes unicode name
 */
 static int passwd_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;
 
@@ -228,7 +205,7 @@ static int passwd_login_ext(void *obj, char *uname, struct passwd **uam_pwd,
 /* change passwd */
 static int passwd_changepw(void *obj, char *username,
                            struct passwd *pwd, char *ibuf,
-                           int ibuflen, char *rbuf, int *rbuflen)
+                           size_t ibuflen, char *rbuf, size_t *rbuflen)
 {
 #ifdef SHADOWPW
     struct spwd *sp;
@@ -271,9 +248,7 @@ static int passwd_changepw(void *obj, char *username,
 
 
 /* Printer ClearTxtUAM login */
-static int passwd_printer(start, stop, username, out)
-char   *start, *stop, *username;
-struct papfile *out;
+static int passwd_printer(char *start, char *stop, char *username, struct papfile *out)
 {
     struct passwd *pwd;
 #ifdef SHADOWPW
@@ -344,7 +319,7 @@ struct papfile      *out;
     }
     pwd->pw_passwd = sp->sp_pwdp;
 
-    if (sp && sp->sp_max != -1 && sp->sp_lstchg) {
+    if (sp->sp_max != -1 && sp->sp_lstchg) {
         time_t now = time(NULL) / (60*60*24);
         int32_t expire_days = sp->sp_lstchg - now + sp->sp_max;
         if ( expire_days < 0 ) {
@@ -378,19 +353,6 @@ struct papfile     *out;
     return(0);
 }
 
-#ifdef ATACC
-int uam_setup(const char *path)
-{
-    if (uam_register_fn(UAM_SERVER_LOGIN_EXT, path, "Cleartxt Passwrd",
-                     passwd_login, NULL, NULL, passwd_login_ext) < 0)
-        return -1;
-    if (uam_register_fn(UAM_SERVER_PRINTAUTH, path, "ClearTxtUAM",
-                     passwd_printer) < 0)
-        return -1;
-
-    return 0;
-}
-#else 
 static int uam_setup(const char *path)
 {
     if (uam_register(UAM_SERVER_LOGIN_EXT, path, "Cleartxt Passwrd",
@@ -403,8 +365,6 @@ static int uam_setup(const char *path)
     return 0;
 }
 
-#endif
-
 static void uam_cleanup(void)
 {
     uam_unregister(UAM_SERVER_LOGIN, "Cleartxt Passwrd");
@@ -416,3 +376,9 @@ UAM_MODULE_EXPORT struct uam_export uams_clrtxt = {
             UAM_MODULE_VERSION,
             uam_setup, uam_cleanup
         };
+
+UAM_MODULE_EXPORT struct uam_export uams_passwd = {
+            UAM_MODULE_SERVER,
+            UAM_MODULE_VERSION,
+            uam_setup, uam_cleanup
+        };