2 * Copyright (c) 1990,1993 Regents of The University of Michigan.
3 * All Rights Reserved. See COPYRIGHT.
10 #include <sys/param.h>
12 #include <netatalk/endian.h>
13 #include <atalk/afp.h>
14 #include <atalk/compat.h>
15 #include <atalk/util.h>
25 static struct uam_mod uam_modules = {NULL, NULL, &uam_modules, &uam_modules};
26 static struct uam_obj uam_login = {"", "", 0, {{NULL}}, &uam_login,
28 static struct uam_obj uam_changepw = {"", "", 0, {{NULL}}, &uam_changepw,
30 static struct uam_obj uam_printer = {"", "", 0, {{NULL}}, &uam_printer,
35 * Return a list of names for loaded uams
37 int getuamnames(const int type, char *uamnames)
39 struct uam_obj *prev, *start;
41 if (!(start = UAM_LIST(type)))
46 while((prev = prev->uam_prev) != start) {
47 strcat(uamnames, prev->uam_name);
48 strcat(uamnames, "\n");
51 strcat(uamnames, "*\n");
56 /* just do a linked list search. this could be sped up with a hashed
57 * list, but i doubt anyone's going to have enough uams to matter. */
58 struct uam_obj *auth_uamfind(const int type, const char *name,
61 struct uam_obj *prev, *start;
63 if (!name || !(start = UAM_LIST(type)))
67 while ((prev = prev->uam_prev) != start)
68 if (strndiacasecmp(prev->uam_name, name, len) == 0)
74 int auth_register(const int type, struct uam_obj *uam)
76 struct uam_obj *start;
78 if (!uam || !uam->uam_name || (*uam->uam_name == '\0'))
81 if (!(start = UAM_LIST(type)))
82 return 0; /* silently fail */
84 uam_attach(start, uam);
88 /* load all of the modules */
89 int auth_load(const char *path, const char *list)
91 char name[MAXPATHLEN + 1], buf[MAXPATHLEN + 1], *p;
96 if (!path || !list || (len = strlen(path)) > sizeof(name) - 2)
99 strncpy(buf, list, sizeof(buf));
100 if ((p = strtok(buf, ",")) == NULL)
104 if (name[len - 1] != '/') {
110 strncpy(name + len, p, sizeof(name) - len);
111 if ((stat(name, &st) == 0) && (mod = uam_load(name, p))) {
112 uam_attach(&uam_modules, mod);
113 syslog(LOG_INFO, "uam: %s loaded", p);
115 p = strtok(NULL, ",");
119 /* get rid of all of the uams */
122 struct uam_mod *mod, *prev, *start = &uam_modules;
124 prev = start->uam_prev;
125 while ((mod = prev) != start) {
126 prev = prev->uam_prev;