X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=usermap.c;h=e2fa5bdcecb9ff421cc9881d1cc29351ee757adb;hb=78fd5267a0533ca82c2c7733f24ed62f13023f9c;hp=7cf012f9cb69bddb31d1219effffb6b585d0d5ce;hpb=56de5b8f09f14f10955ac105d77a15ea7321c92a;p=cascardo%2Frnetproxy.git diff --git a/usermap.c b/usermap.c index 7cf012f..e2fa5bd 100644 --- a/usermap.c +++ b/usermap.c @@ -19,10 +19,47 @@ */ #include +#include #include "usermap.h" int usermap_perm (char *user) { + DEPOT* allow_dp = NULL; + DEPOT* deny_dp = NULL; + char* allow = NULL; + char* deny = NULL; + int allow_users = 0; + allow_dp = dpopen ("/var/lib/popproxy/allow.db", DP_OREADER, 0); + deny_dp = dpopen ("/var/lib/popproxy/deny.db", DP_OREADER, 0); + if (allow_dp) + { + allow = dpget (allow_dp, user, -1, 0, -1, NULL); + allow_users = dprnum (allow_dp); + dpclose (allow_dp); + } + if (deny_dp) + { + deny = dpget (deny_dp, user, -1, 0, -1, NULL); + dpclose (deny_dp); + } + if (allow && deny) + { + free (allow); + free (deny); + return ACCESS_DENY; + } + if (allow) + { + free (allow); + return ACCESS_ALLOW; + } + if (deny) + { + free (deny); + return ACCESS_DENY; + } + if (allow_users == 0) + return ACCESS_ALLOW; return ACCESS_DENY; }