diff options
author | Karl Ramm <kcr@1ts.org> | 2013-10-26 21:14:24 -0400 |
---|---|---|
committer | Karl Ramm <kcr@1ts.org> | 2013-10-26 21:14:24 -0400 |
commit | b4f80eaccdfe16e83dd43909c10dc81c73c58a6b (patch) | |
tree | 3cd750c30c97953eb0f0ada92af91416a2640142 | |
parent | c484b28592243699c219b5275dda89a4259b4cd9 (diff) |
rearrange the function so as to have the logging work
-rw-r--r-- | server/acl_files.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/server/acl_files.c b/server/acl_files.c index f426874..346abb7 100644 --- a/server/acl_files.c +++ b/server/acl_files.c @@ -351,27 +351,32 @@ acl_check(char *acl, char *princ, struct sockaddr_in *who) { char *realm; char *name; - int result = 0; - - syslog(LOG_DEBUG, "acl_check(%s, %s, ?) = %d", acl, princ, result); + int result = -1; if (princ) { name = strdup(princ); realm = split_name(name); if (acl_match(acl, name, realm, 1)) - return 0; - if (acl_match(acl, name, realm, 0)) + result = 0; + else if (acl_match(acl, name, realm, 0)) result = 1; free(name); } - if (who) { + if (who && result != 0) { if (acl_host_match(acl, who->sin_addr.s_addr, 1)) - return 0; - if (acl_host_match(acl, who->sin_addr.s_addr, 0)) + result = 0; + else if (acl_host_match(acl, who->sin_addr.s_addr, 0)) result = 1; } + if (result == -1) + result = 0; + + syslog(LOG_DEBUG, "acl_check(%s, %s, %s) = %d", acl, + princ ? princ : "NONE", who ? inet_ntoa(who->sin_addr) : "NONE", + result); + return result; } |