/*
- * $Id: uam.c,v 1.26 2007-12-03 14:50:39 didg Exp $
+ * $Id: uam.c,v 1.32 2009-11-05 14:38:07 franklahm Exp $
*
* Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu)
* All Rights Reserved. See COPYRIGHT.
}
/* -- client-side uam functions -- */
-#ifndef ATACC
/* set up stuff for this uam. */
int uam_register(const int type, const char *path, const char *name, ...)
{
return ret;
}
-#endif
-
-#ifdef ATACC
-int uam_register_fn(const int type, const char *path, const char *name, void *fn1, void *fn2,
- void *fn3, void *fn4)
-{
- va_list ap;
- struct uam_obj *uam;
-
- if (!name)
- return -1;
-
- /* see if it already exists. */
- if ((uam = auth_uamfind(type, name, strlen(name)))) {
- if (strcmp(uam->uam_path, path)) {
- /* it exists, but it's not the same module. */
- LOG(log_error, logtype_afpd, "uam_register: \"%s\" already loaded by %s",
- name, path);
- return -1;
- }
- uam->uam_count++;
- return 0;
- }
-
- /* allocate space for uam */
- if ((uam = calloc(1, sizeof(struct uam_obj))) == NULL)
- return -1;
-
- uam->uam_name = name;
- uam->uam_path = strdup(path);
- uam->uam_count++;
-
- switch (type) {
- case UAM_SERVER_LOGIN_EXT: /* expect four arguments */
- uam->u.uam_login.login_ext = fn4;
- uam->u.uam_login.login = fn1;
- uam->u.uam_login.logincont = fn2;
- uam->u.uam_login.logout = fn3;
- break;
- case UAM_SERVER_LOGIN: /* expect three arguments */
- uam->u.uam_login.login_ext = NULL;
- uam->u.uam_login.login = fn1;
- uam->u.uam_login.logincont = fn2;
- uam->u.uam_login.logout = fn3;
- break;
- case UAM_SERVER_CHANGEPW: /* one argument */
- uam->u.uam_changepw = fn1;
- break;
- case UAM_SERVER_PRINTAUTH: /* x arguments */
- default:
- break;
- }
-
- /* attach to other uams */
- if (auth_register(type, uam) < 0) {
- free(uam->uam_path);
- free(uam);
- return -1;
- }
-
- return 0;
-}
-#endif
void uam_unregister(const int type, const char *name)
{
#ifndef NO_REAL_USER_NAME
if ( (size_t) -1 == (namelen = convert_string((utf8_encoding())?CH_UTF8_MAC:obj->options.maccharset,
- CH_UCS2, name, strlen(name), username, sizeof(username))))
+ CH_UCS2, name, -1, username, sizeof(username))))
return NULL;
setpwent();
*p = '\0';
if ((size_t)-1 == ( gecoslen = convert_string(obj->options.unixcharset, CH_UCS2,
- pwent->pw_gecos, strlen(pwent->pw_gecos), user, sizeof(username))) )
+ pwent->pw_gecos, -1, user, sizeof(username))) )
continue;
if ((size_t)-1 == ( pwnamelen = convert_string(obj->options.unixcharset, CH_UCS2,
- pwent->pw_name, strlen(pwent->pw_name), pwname, sizeof(username))) )
+ pwent->pw_name, -1, pwname, sizeof(username))) )
continue;
/* afp-specific functions */
int uam_afpserver_option(void *private, const int what, void *option,
- int *len)
+ size_t *len)
{
-AFPObj *obj = private;
- char **buf = (char **) option; /* most of the options are this */
+ AFPObj *obj = private;
+ const char **buf = (const char **) option; /* most of the options are this */
struct session_info **sinfo = (struct session_info **) option;
if (!obj || !option)
break;
case UAM_OPTION_CLIENTNAME:
- {
- struct DSI *dsi = obj->handle;
- struct hostent *hp;
-
- hp = gethostbyaddr( (char *) &dsi->client.sin_addr,
- sizeof( struct in_addr ),
- dsi->client.sin_family );
- if( hp )
- *buf = hp->h_name;
- else
- *buf = inet_ntoa( dsi->client.sin_addr );
- }
+ {
+ struct DSI *dsi = obj->handle;
+ const struct sockaddr *sa;
+ char hbuf[NI_MAXHOST];
+
+ sa = (struct sockaddr *)&dsi->client;
+ if (getnameinfo(sa, sizeof(dsi->client), hbuf, sizeof(hbuf), NULL, 0, 0) == 0)
+ *buf = hbuf;
+ else
+ *buf = getip_string((struct sockaddr *)&dsi->client);
+
break;
+ }
case UAM_OPTION_COOKIE:
/* it's up to the uam to actually store something useful here.
* this just passes back a handle to the cookie. the uam side
/* if we need to maintain a connection, this is how we do it.
* because an action pointer gets passed in, we can stream
* DSI connections */
-int uam_afp_read(void *handle, char *buf, int *buflen,
+int uam_afp_read(void *handle, char *buf, size_t *buflen,
int (*action)(void *, void *, const int))
{
AFPObj *obj = handle;