-/* Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu)
+/*
+ * $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.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
-#endif
+#endif /* HAVE_CONFIG_H */
#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>
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) {
}
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;
}
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;
}
{
va_list ap;
struct uam_obj *uam;
+ int ret;
if (!name)
return -1;
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;
}
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)
}
/* 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;
}
}
endpwent();
-#endif
+#endif /* NO_REAL_USER_NAME */
/* os x server doesn't keep anything useful if we do getpwent */
return pwent ? getpwnam(name) : NULL;
}
endusershell();
+#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 */
return 0;
}