summaryrefslogtreecommitdiff
path: root/helper.c
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2012-06-02 01:23:02 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2012-06-02 01:23:02 +0100
commit97c1bc1b3cb16224315db59268f64025cc00d172 (patch)
tree8d6aa534cdde4d3966a4179a9c3fcfdb6a175ab5 /helper.c
parentf62c5e576fd26e4e56f0304fe40b6a9f4ec86537 (diff)
wip about to undo
Diffstat (limited to 'helper.c')
-rw-r--r--helper.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/helper.c b/helper.c
index cc4efe2..9e8ab86 100644
--- a/helper.c
+++ b/helper.c
@@ -30,9 +30,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>
-#ifndef CONFIGDIR
-# define CONFIGDIR "/etc/authbind"
-#endif
+#include "authbind.h"
static void exiterrno(int e) {
exit(e>0 && e<128 ? e : ENOSYS);
@@ -138,15 +136,21 @@ int main(int argc, const char *const *argv) {
assert(np);
if (af == AF_INET) {
- snprintf(fnbuf,sizeof(fnbuf)-1,"byaddr/%s%s:%u",np,tophalfchar,hport);
+ snprintf(fnbuf,sizeof(fnbuf)-1,"byaddr/%s%s:%u",tophalfchar,np,hport);
if (!access(fnbuf,X_OK)) authorised();
if (errno != ENOENT) exiterrno(errno);
}
- snprintf(fnbuf,sizeof(fnbuf)-1,"byaddr/%s%s,%u",np,tophalfchar,hport);
+ snprintf(fnbuf,sizeof(fnbuf)-1,"byaddr/%s%s,%u",tophalfchar,np,hport);
if (!access(fnbuf,X_OK)) authorised();
if (errno != ENOENT) exiterrno(errno);
+ if (af == AF_INET6) {
+ char sbuf[addrlen_any*2+1];
+ bytes2hex(addr_any,sbuf,addrlen_any);
+ snprintf(fnbuf,sizeof(fnbuf)-1,"byaddr/%s%s,%u",tophalfchar,sbuf,hport);
+ }
+
uid= getuid(); if (uid==(uid_t)-1) perrorfail("getuid");
snprintf(fnbuf,sizeof(fnbuf)-1,"byuid/%s%lu",tophalfchar,(unsigned long)uid);