# define HELPER "/usr/local/lib/authbind/helper"
#endif
+#ifndef CONFIGDIR
+# define CONFIGDIR "/etc/authbind"
+#endif
+
#define PRELOAD_VAR "LD_PRELOAD"
#define AUTHBINDLIB_VAR "AUTHBIND_LIB"
#define AUTHBIND_LEVELS_VAR "AUTHBIND_LEVELS"
+static inline void bytes2hex(const unsigned char *in, char *out, size_t len) {
+ size_t i;
+ for (i=0; i<16; i++)
+ sprintf(out+i*2,"%02x", in[i]);
+}
+
#endif
#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);
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);