]> arthur.barton.de Git - netatalk.git/blobdiff - etc/uams/uams_passwd.c
Remove a lot of warning, from cvs HEAD
[netatalk.git] / etc / uams / uams_passwd.c
index 37a8a219b6b2bfc3449202734fd90e0701aba8ec..b5e561fbe3fbcf5b45f95ea60ccc800a5ed5b78e 100644 (file)
@@ -1,17 +1,24 @@
 /*
- * $Id: uams_passwd.c,v 1.19.2.1.2.3 2003-10-30 00:21:47 bfernhomberg Exp $
+ * $Id: uams_passwd.c,v 1.19.2.1.2.9.2.1 2005-09-27 10:40:41 didg 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.
  */
 
-#define _XOPEN_SOURCE /* for crypt() */
-
 #ifdef HAVE_CONFIG_H
 #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 <stdio.h>
 #include <stdlib.h>
 /* STDC check */
@@ -41,16 +48,14 @@ char *strchr (), *strrchr ();
 #ifdef HAVE_TIME_H
 #include <time.h>
 #endif
-#ifdef SOLARIS
-#define SHADOWPW
-#endif /* SOLARIS */
 #ifdef SHADOWPW
 #include <shadow.h>
 #endif /* SHADOWPW */
 
-#include <atalk/logger.h>
 #include <atalk/afp.h>
+#include <atalk/logger.h>
 #include <atalk/uam.h>
+#include <atalk/util.h>
 
 #define PASSWDLEN 8
 
@@ -66,9 +71,11 @@ char *strchr (), *strrchr ();
 static char *clientname;
 #endif /* TRU64 */
 
+extern void append(void *, const char *, int);
+
 static int pwd_login(void *obj, char *username, int ulen, struct passwd **uam_pwd,
                         char *ibuf, int ibuflen,
-                        char *rbuf, int *rbuflen)
+                        char *rbuf _U_, int *rbuflen _U_)
 {
     char  *p;
     struct passwd *pwd;
@@ -277,13 +284,12 @@ struct papfile    *out;
     static const char *loginok = "0\r";
     int ulen;
 
-    data = (char *)malloc(stop - start + 2);
+    data = (char *)malloc(stop - start + 1);
     if (!data) {
        LOG(log_info, logtype_uams,"Bad Login ClearTxtUAM: malloc");
        return(-1);
     }
-    strncpy(data, start, stop - start + 1);
-    data[stop - start + 2] = 0;
+    strlcpy(data, start, stop - start + 1);
 
     /* We are looking for the following format in data:
      * (username) (password)
@@ -298,25 +304,21 @@ struct papfile    *out;
         return(-1);
     }
     p++;
-    if ((q = strstr(data, ") (" )) == NULL) {
+    if ((q = strstr(p, ") (" )) == NULL) {
         LOG(log_info, logtype_uams,"Bad Login ClearTxtUAM: username not found in string");
         free(data);
         return(-1);
     }
-    strncpy(username, p, MIN( UAM_USERNAMELEN, (q - p)) );
-    username[ UAM_USERNAMELEN+1] = '\0';
-
+    memcpy(username, p,  MIN( UAM_USERNAMELEN, q - p ));
 
     /* Parse input for password in next () */
     p = q + 3;
-    if ((q = strrchr(data, ')' )) == NULL) {
+    if ((q = strrchr(, ')' )) == NULL) {
         LOG(log_info, logtype_uams,"Bad Login ClearTxtUAM: password not found in string");
         free(data);
         return(-1);
     }
-    strncpy(password, p, MIN(PASSWDLEN, q - p) );
-    password[ PASSWDLEN+1] = '\0';
-
+    memcpy(password, p, MIN(PASSWDLEN, q - p) );
 
     /* Done copying username and password, clean up */
     free(data);