"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/webaccess.c" between
xymon-4.3.28.tar.gz and xymon-4.3.29.tar.gz

About: Xymon is a system for monitoring servers, applications and networks (like Big Brother; former name "hobbit").

webaccess.c  (xymon-4.3.28):webaccess.c  (xymon-4.3.29)
skipping to change at line 37 skipping to change at line 37
if (acctree) return 0; if (acctree) return 0;
acctree = xtreeNew(strcasecmp); acctree = xtreeNew(strcasecmp);
fd = stackfopen(accessfn, "r", NULL); fd = stackfopen(accessfn, "r", NULL);
if (fd == NULL) return NULL; if (fd == NULL) return NULL;
buf = newstrbuffer(0); buf = newstrbuffer(0);
while (stackfgets(buf, NULL)) { while (stackfgets(buf, NULL)) {
char *group, *member; char *group, *member;
char *key; SBUF_DEFINE(key);
group = strtok(STRBUF(buf), ": \n"); group = strtok(STRBUF(buf), ": \n");
if (!group) continue; if (!group) continue;
member = strtok(NULL, ", \n"); member = strtok(NULL, ", \n");
while (member) { while (member) {
key = (char *)malloc(strlen(group) + strlen(member) + 2); SBUF_MALLOC(key, strlen(group) + strlen(member) + 2);
sprintf(key, "%s %s", group, member); snprintf(key, key_buflen, "%s %s", group, member);
xtreeAdd(acctree, key, NULL); xtreeAdd(acctree, key, NULL);
member = strtok(NULL, ", \n"); member = strtok(NULL, ", \n");
} }
} }
stackfclose(fd); stackfclose(fd);
return acctree; return acctree;
} }
int web_access_allowed(char *username, char *hostname, char *testname, web_acces s_type_t acc) int web_access_allowed(char *username, char *hostname, char *testname, web_acces s_type_t acc)
{ {
void *hinfo; void *hinfo;
char *pages, *onepg, *key; char *pages, *onepg;
SBUF_DEFINE(key);
hinfo = hostinfo(hostname); hinfo = hostinfo(hostname);
if (!hinfo || !acctree || !username) return 0; if (!hinfo || !acctree || !username) return 0;
/* Check for "root" access first */ /* Check for "root" access first */
key = (char *)malloc(strlen(username) + 6); SBUF_MALLOC(key, strlen(username) + 6);
sprintf(key, "root %s", username); snprintf(key, key_buflen, "root %s", username);
if (xtreeFind(acctree, key) != xtreeEnd(acctree)) { if (xtreeFind(acctree, key) != xtreeEnd(acctree)) {
xfree(key); xfree(key);
return 1; return 1;
} }
xfree(key); xfree(key);
pages = strdup(xmh_item(hinfo, XMH_ALLPAGEPATHS)); pages = strdup(xmh_item(hinfo, XMH_ALLPAGEPATHS));
onepg = strtok(pages, ","); onepg = strtok(pages, ",");
while (onepg) { while (onepg) {
char *p; char *p;
p = strchr(onepg, '/'); if (p) *p = '\0'; /* Will only look at th e top-level path element */ p = strchr(onepg, '/'); if (p) *p = '\0'; /* Will only look at th e top-level path element */
key = (char *)malloc(strlen(onepg) + strlen(username) + 2); SBUF_MALLOC(key, strlen(onepg) + strlen(username) + 2);
sprintf(key, "%s %s", onepg, username); snprintf(key, key_buflen, "%s %s", onepg, username);
if (xtreeFind(acctree, key) != xtreeEnd(acctree)) { if (xtreeFind(acctree, key) != xtreeEnd(acctree)) {
xfree(key); xfree(key);
xfree(pages); xfree(pages);
return 1; return 1;
} }
xfree(key); xfree(key);
onepg = strtok(NULL, ","); onepg = strtok(NULL, ",");
} }
xfree(pages); xfree(pages);
if (hostname) { if (hostname) {
/* See if user is a member of a group named by the hostname */ /* See if user is a member of a group named by the hostname */
key = (char *)malloc(strlen(hostname) + strlen(username) + 2); SBUF_MALLOC(key, strlen(hostname) + strlen(username) + 2);
sprintf(key, "%s %s", hostname, username); snprintf(key, key_buflen, "%s %s", hostname, username);
if (xtreeFind(acctree, key) != xtreeEnd(acctree)) { if (xtreeFind(acctree, key) != xtreeEnd(acctree)) {
xfree(key); xfree(key);
return 1; return 1;
} }
xfree(key); xfree(key);
} }
if (testname) { if (testname) {
/* See if user is a member of a group named by the testname */ /* See if user is a member of a group named by the testname */
key = (char *)malloc(strlen(testname) + strlen(username) + 2); SBUF_MALLOC(key, strlen(testname) + strlen(username) + 2);
sprintf(key, "%s %s", testname, username); snprintf(key, key_buflen, "%s %s", testname, username);
if (xtreeFind(acctree, key) != xtreeEnd(acctree)) { if (xtreeFind(acctree, key) != xtreeEnd(acctree)) {
xfree(key); xfree(key);
return 1; return 1;
} }
xfree(key); xfree(key);
} }
return 0; return 0;
} }
 End of changes. 7 change blocks. 
12 lines changed or deleted 13 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)