]> arthur.barton.de Git - netatalk.git/blobdiff - etc/papd/uam.c
Wrong path from 2-1
[netatalk.git] / etc / papd / uam.c
index d164e0efc4b83f8a95046d83508257de86487231..2962fad0b10194d0cf9ae1a7d19a47c41bebcabb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uam.c,v 1.5 2001-06-25 20:13:45 rufustfirefly Exp $
+ * $Id: uam.c,v 1.11 2009-10-15 11:39:48 didg Exp $
  *
  * Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu)
  * All Rights Reserved.  See COPYRIGHT.
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.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 */
 #include <fcntl.h>
 #include <ctype.h>
-#include <syslog.h>
+#include <atalk/logger.h>
 #include <sys/param.h>
 #include <sys/time.h>
 
@@ -39,17 +55,16 @@ struct uam_mod *uam_load(const char *path, const char *name)
   void *module;
 
   if ((module = mod_open(path)) == NULL) {
-    syslog(LOG_ERR, "uam_load(%s): failed to load.", name);
-    syslog(LOG_ERR, dlerror());
+    LOG(log_error, logtype_papd, "uam_load(%s): failed to load: %s", name, mod_error());
     return NULL;
   }
 
   if ((mod = (struct uam_mod *) malloc(sizeof(struct uam_mod))) == NULL) {
-    syslog(LOG_ERR, "uam_load(%s): malloc failed", name);
+    LOG(log_error, logtype_papd, "uam_load(%s): malloc failed", name);
     goto uam_load_fail;
   }
 
-  strncpy(buf, name, sizeof(buf));
+  strlcpy(buf, name, sizeof(buf));
   if ((p = strchr(buf, '.')))
     *p = '\0';
   if ((mod->uam_fcn = mod_symbol(module, buf)) == NULL) {
@@ -57,7 +72,7 @@ struct uam_mod *uam_load(const char *path, const char *name)
   }
 
   if (mod->uam_fcn->uam_type != UAM_MODULE_SERVER) {
-    syslog(LOG_ERR, "uam_load(%s): attempted to load a non-server module",
+    LOG(log_error, logtype_papd, "uam_load(%s): attempted to load a non-server module",
           name);
     goto uam_load_err;
   }
@@ -66,7 +81,7 @@ struct uam_mod *uam_load(const char *path, const char *name)
 
   if (!mod->uam_fcn->uam_setup || 
       ((*mod->uam_fcn->uam_setup)(name) < 0)) {
-    syslog(LOG_ERR, "uam_load(%s): uam_setup failed", name);
+    LOG(log_error, logtype_papd, "uam_load(%s): uam_setup failed", name);
     goto uam_load_err;
   }
 
@@ -98,6 +113,7 @@ int uam_register(const int type, const char *path, const char *name, ...)
 {
   va_list ap;
   struct uam_obj *uam;
+  int ret;
 
   if (!name)
     return -1;
@@ -106,7 +122,7 @@ int uam_register(const int type, const char *path, const char *name, ...)
   if ((uam = auth_uamfind(type, name, strlen(name)))) {
     if (strcmp(uam->uam_path, path)) {
       /* it exists, but it's not the same module. */
-      syslog(LOG_ERR, "uam_register: \"%s\" already loaded by %s",
+      LOG(log_error, logtype_papd, "uam_register: \"%s\" already loaded by %s",
             name, path);
       return -1;
     }
@@ -141,13 +157,13 @@ int uam_register(const int type, const char *path, const char *name, ...)
   va_end(ap);
 
   /* attach to other uams */
-  if (auth_register(type, uam) < 0) {
+  ret = auth_register(type, uam);
+  if (ret) {
     free(uam->uam_path);
     free(uam);
-    return -1;
   }
 
-  return 0;
+  return ret;
 }
 
 void uam_unregister(const int type, const char *name)
@@ -167,15 +183,15 @@ void uam_unregister(const int type, const char *name)
 }
 
 /* Crap to support uams which call this afpd function */
-int uam_afpserver_option(void *private, const int what, void *option,
-                         int *len)
+int uam_afpserver_option(void *private _U_, const int what _U_, void *option _U_,
+                         size_t *len _U_)
 {
        return(0);
 }
 
 /* --- helper functions for plugin uams --- */
 
-struct passwd *uam_getname(char *name, const int len)
+struct passwd *uam_getname(void *dummy _U_, char *name, const int len)
 {
   struct passwd *pwent;
   char *user;
@@ -224,7 +240,7 @@ int uam_checkuser(const struct passwd *pwd)
 
 #ifndef DISABLE_SHELLCHECK
   if (!p) {
-    syslog( LOG_INFO, "illegal shell %s for %s",pwd->pw_shell,pwd->pw_name);
+    LOG(log_info, logtype_papd, "illegal shell %s for %s",pwd->pw_shell,pwd->pw_name);
     return -1;
   }
 #endif /* DISABLE_SHELLCHECK */