2 * Copyright (c) 1990,1993 Regents of The University of Michigan.
3 * All Rights Reserved. See COPYRIGHT.
13 #include <sys/types.h>
14 #include <sys/param.h>
16 #include <netatalk/endian.h>
17 #include <atalk/afp.h>
18 #include <atalk/compat.h>
19 #include <atalk/util.h>
29 static struct uam_mod uam_modules = {NULL, NULL, &uam_modules, &uam_modules};
30 static struct uam_obj uam_login = {"", "", 0, {{NULL}}, &uam_login,
32 static struct uam_obj uam_changepw = {"", "", 0, {{NULL}}, &uam_changepw,
34 static struct uam_obj uam_printer = {"", "", 0, {{NULL}}, &uam_printer,
39 * Return a list of names for loaded uams
41 int getuamnames(const int type, char *uamnames)
43 struct uam_obj *prev, *start;
45 if (!(start = UAM_LIST(type)))
50 while((prev = prev->uam_prev) != start) {
51 strcat(uamnames, prev->uam_name);
52 strcat(uamnames, "\n");
55 strcat(uamnames, "*\n");
60 /* just do a linked list search. this could be sped up with a hashed
61 * list, but i doubt anyone's going to have enough uams to matter. */
62 struct uam_obj *auth_uamfind(const int type, const char *name,
65 struct uam_obj *prev, *start;
67 if (!name || !(start = UAM_LIST(type)))
71 while ((prev = prev->uam_prev) != start)
72 if (strndiacasecmp(prev->uam_name, name, len) == 0)
78 int auth_register(const int type, struct uam_obj *uam)
80 struct uam_obj *start;
82 if (!uam || !uam->uam_name || (*uam->uam_name == '\0'))
85 if (!(start = UAM_LIST(type)))
86 return 0; /* silently fail */
88 uam_attach(start, uam);
92 /* load all of the modules */
93 int auth_load(const char *path, const char *list)
95 char name[MAXPATHLEN + 1], buf[MAXPATHLEN + 1], *p;
100 if (!path || !list || (len = strlen(path)) > sizeof(name) - 2)
103 strncpy(buf, list, sizeof(buf));
104 if ((p = strtok(buf, ",")) == NULL)
108 if (name[len - 1] != '/') {
114 strncpy(name + len, p, sizeof(name) - len);
115 if ((stat(name, &st) == 0) && (mod = uam_load(name, p))) {
116 uam_attach(&uam_modules, mod);
117 syslog(LOG_INFO, "uam: %s loaded", p);
119 p = strtok(NULL, ",");
123 /* get rid of all of the uams */
126 struct uam_mod *mod, *prev, *start = &uam_modules;
128 prev = start->uam_prev;
129 while ((mod = prev) != start) {
130 prev = prev->uam_prev;