]> arthur.barton.de Git - netatalk.git/blobdiff - etc/uams/uams_guest.c
Remove all Appletalk stuff
[netatalk.git] / etc / uams / uams_guest.c
index 9521e362c29c18dbbb3714ba1395ea42ee746a71..00f90ece0972ee01670d5cc1eee55879d6795b35 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uams_guest.c,v 1.10 2002-09-29 23:30:20 sibaz Exp $
+ * $Id: uams_guest.c,v 1.18 2009-11-08 01:07:17 didg Exp $
  *
  * (c) 2001 (see COPYING)
  */
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.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 <pwd.h>
-#include <atalk/logger.h>
 
+#include <atalk/logger.h>
 #include <atalk/afp.h>
 #include <atalk/uam.h>
+#include <atalk/util.h>
+#include <atalk/compat.h>
 
+#ifndef MIN
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif /* MIN */
+
+/*XXX in etc/papd/file.h */
+struct papfile;
+extern UAM_MODULE_EXPORT void append(struct papfile *, const char *, int);
+
+/* login and login_ext are almost the same */
 static int noauth_login(void *obj, struct passwd **uam_pwd,
-                       char *ibuf, int ibuflen
-                       char *rbuf, int *rbuflen)
+                       char *ibuf _U_, size_t ibuflen _U_
+                       char *rbuf _U_, size_t *rbuflen)
 {
     struct passwd *pwent;
     char *guest, *username;
@@ -69,17 +65,27 @@ static int noauth_login(void *obj, struct passwd **uam_pwd,
     return( AFP_OK );
 }
 
+static int noauth_login_ext(void *obj, char *uname _U_, struct passwd **uam_pwd,
+                     char *ibuf, size_t ibuflen,
+                     char *rbuf, size_t *rbuflen)
+{
+        return ( noauth_login (obj, uam_pwd, ibuf, ibuflen, rbuf, rbuflen));
+}
+
 
 /* Printer NoAuthUAM Login */
-int noauth_printer(start, stop, username, out)
-       char    *start, *stop, *username;
-       struct papfile  *out;
+static int noauth_printer(char *start, char *stop, char *username, struct papfile *out)
 {
     char       *data, *p, *q;
     static const char *loginok = "0\r";
 
     data = (char *)malloc(stop - start + 1);
-    strncpy(data, start, stop - start + 1);
+    if (!data) {
+       LOG(log_info, logtype_uams,"Bad Login NoAuthUAM: malloc");
+       return(-1);
+    }
+
+    strlcpy(data, start, stop - start + 1);
 
     /* We are looking for the following format in data:
      * (username)
@@ -93,12 +99,12 @@ int noauth_printer(start, stop, username, out)
        return(-1);
     }
     p++;
-    if ((q = strchr(data, ')' )) == NULL) {
+    if ((q = strchr(p, ')' )) == NULL) {
        LOG(log_info, logtype_uams,"Bad Login NoAuthUAM: username not found in string");
        free(data);
        return(-1);
     }
-    strncpy(username, p, q - p);
+    memcpy(username, p,  MIN( UAM_USERNAMELEN, q - p ));
 
     /* Done copying username, clean up */
     free(data);
@@ -118,9 +124,10 @@ int noauth_printer(start, stop, username, out)
 
 static int uam_setup(const char *path)
 {
-  if (uam_register(UAM_SERVER_LOGIN, path, "No User Authent",
-              noauth_login, NULL, NULL) < 0)
-       return -1;
+  if (uam_register(UAM_SERVER_LOGIN_EXT, path, "No User Authent",
+                   noauth_login, NULL, NULL, noauth_login_ext) < 0)
+        return -1;
+
   if (uam_register(UAM_SERVER_PRINTAUTH, path, "NoAuthUAM",
                noauth_printer) < 0)
        return -1;
@@ -128,7 +135,7 @@ static int uam_setup(const char *path)
   return 0;
 }
 
-static void uam_cleanup()
+static void uam_cleanup(void)
 {
   uam_unregister(UAM_SERVER_LOGIN, "No User Authent");
   uam_unregister(UAM_SERVER_PRINTAUTH, "NoAuthUAM");