summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
d5bf624)
Reading dumps from complicated multi-process systems can be tricky
otherwise.
/* Debugging */
#ifdef DEBUG
# define D(body) { if (debug) { body } }
/* Debugging */
#ifdef DEBUG
# define D(body) { if (debug) { body } }
+# define Dpid pid_t pid = debug ? getpid() : -1
#endif
/* Preservation of error status */
#endif
/* Preservation of error status */
- fprintf(stderr, "noip: %c ", a->act ? '+' : '-');
+ fprintf(stderr, "noip(%d): %c ", getpid(), a->act ? '+' : '-');
plen = common_prefix_length(a->af, &a->minaddr, &a->maxaddr);
p = inet_ntop(a->af, &a->minaddr, buf, sizeof(buf));
fprintf(stderr, strchr(p, ':') ? "[%s]" : "%s", p);
plen = common_prefix_length(a->af, &a->minaddr, &a->maxaddr);
p = inet_ntop(a->af, &a->minaddr, buf, sizeof(buf));
fprintf(stderr, strchr(p, ':') ? "[%s]" : "%s", p);
dump_aclnode(a);
act = a->act;
}
dump_aclnode(a);
act = a->act;
}
- fprintf(stderr, "noip: [default policy: %s]\n",
+ fprintf(stderr, "noip(%d): [default policy: %s]\n", getpid(),
act == ALLOW ? "DENY" : "ALLOW");
}
act == ALLOW ? "DENY" : "ALLOW");
}
{
unsigned short port = port_from_sockaddr(sa);
int act = ALLOW;
{
unsigned short port = port_from_sockaddr(sa);
int act = ALLOW;
- fprintf(stderr, "noip: check %s\n",
+ fprintf(stderr, "noip(%d): check %s\n", pid,
present_sockaddr(sa, 0, buf, sizeof(buf))); })
for (; a; a = a->next) {
D( dump_aclnode(a); )
if (sockaddr_in_range_p(sa, &a->minaddr, &a->maxaddr) &&
a->minport <= port && port <= a->maxport) {
present_sockaddr(sa, 0, buf, sizeof(buf))); })
for (; a; a = a->next) {
D( dump_aclnode(a); )
if (sockaddr_in_range_p(sa, &a->minaddr, &a->maxaddr) &&
a->minport <= port && port <= a->maxport) {
- D( fprintf(stderr, "noip: aha! %s\n", a->act ? "ALLOW" : "DENY"); )
+ D( fprintf(stderr, "noip(%d): aha! %s\n", pid,
+ a->act ? "ALLOW" : "DENY"); )
return (a->act);
}
act = a->act;
}
return (a->act);
}
act = a->act;
}
- D( fprintf(stderr, "noip: nothing found: %s\n", act ? "DENY" : "ALLOW"); )
+ D( fprintf(stderr, "noip(%d): nothing found: %s\n", pid,
+ act ? "DENY" : "ALLOW"); )
char buf[ADDRBUFSZ];
int rc;
char buf[ADDRBUFSZ];
int rc;
- D( fprintf(stderr, "noip: encode %s (%s)",
+ D( fprintf(stderr, "noip(%d): encode %s (%s)", getpid(),
present_sockaddr(sa, 0, buf, sizeof(buf)),
want == WANT_EXISTING ? "EXISTING" : "FRESH"); )
sun->sun_family = AF_UNIX;
present_sockaddr(sa, 0, buf, sizeof(buf)),
want == WANT_EXISTING ? "EXISTING" : "FRESH"); )
sun->sun_family = AF_UNIX;
if (len > sizeof(*sun)) return (-1);
((char *)sun)[len] = 0;
nn = strlen(sun->sun_path);
if (len > sizeof(*sun)) return (-1);
((char *)sun)[len] = 0;
nn = strlen(sun->sun_path);
- D( fprintf(stderr, "noip: decode `%s'", sun->sun_path); )
+ D( fprintf(stderr, "noip(%d): decode `%s'", getpid(), sun->sun_path); )
if (af_hint && !sun->sun_path[0]) {
wildcard_address(af_hint, sa);
D( fprintf(stderr, " -- unbound socket\n"); )
if (af_hint && !sun->sun_path[0]) {
wildcard_address(af_hint, sa);
D( fprintf(stderr, " -- unbound socket\n"); )
- D( fprintf(stderr, "noip: bad acl spec (ignored)\n"); )
+ D( fprintf(stderr, "noip(%d): bad acl spec (ignored)\n", getpid()); )
- D( fprintf(stderr, "bad port range (ignored)\n"); )
+ D( fprintf(stderr, "noip(%d): bad port range (ignored)\n", getpid()); )
char buf[1024];
size_t n;
char *p, *q, *cmd;
char buf[1024];
size_t n;
char *p, *q, *cmd;
parse_acl_env("NOIP_REALBIND_BEFORE", &bind_tail);
parse_acl_env("NOIP_REALCONNECT_BEFORE", &connect_tail);
parse_acl_env("NOIP_REALBIND_BEFORE", &bind_tail);
parse_acl_env("NOIP_REALCONNECT_BEFORE", &connect_tail);
}
if ((p = getenv("NOIP_CONFIG")) == 0)
snprintf(p = buf, sizeof(buf), "%s/.noip", home());
}
if ((p = getenv("NOIP_CONFIG")) == 0)
snprintf(p = buf, sizeof(buf), "%s/.noip", home());
- D( fprintf(stderr, "noip: config file: %s\n", p); )
+ D( fprintf(stderr, "noip(%d): config file: %s\n", pid, p); )
if ((fp = fopen(p, "r")) == 0) {
if ((fp = fopen(p, "r")) == 0) {
- D( fprintf(stderr, "noip: couldn't read config: %s\n",
- strerror(errno)); )
+ D( fprintf(stderr, "noip(%d): couldn't read config: %s\n",
+ pid, strerror(errno)); )
goto done;
}
while (fgets(buf, sizeof(buf), fp)) {
goto done;
}
while (fgets(buf, sizeof(buf), fp)) {
snprintf(buf, sizeof(buf), "%s/noip-%s", tmpdir(), user());
sockdir = xstrdup(buf);
}
snprintf(buf, sizeof(buf), "%s/noip-%s", tmpdir(), user());
sockdir = xstrdup(buf);
}
- D( fprintf(stderr, "noip: socketdir: %s\n", sockdir);
- fprintf(stderr, "noip: autoports: %u-%u\n",
- minautoport, maxautoport);
- fprintf(stderr, "noip: realbind acl:\n");
+ D( fprintf(stderr, "noip(%d): socketdir: %s\n", pid, sockdir);
+ fprintf(stderr, "noip(%d): autoports: %u-%u\n",
+ pid, minautoport, maxautoport);
+ fprintf(stderr, "noip(%d): realbind acl:\n", pid);
- fprintf(stderr, "noip: realconnect acl:\n");
+ fprintf(stderr, "noip(%d): realconnect acl:\n", pid);
dump_acl(connect_real); )
}
dump_acl(connect_real); )
}
address addr;
struct sockaddr_un sun;
struct stat st;
address addr;
struct sockaddr_un sun;
struct stat st;
if ((dir = opendir(sockdir)) == 0) return;
sun.sun_family = AF_UNIX;
if ((dir = opendir(sockdir)) == 0) return;
sun.sun_family = AF_UNIX;
if (decode_inet_addr(&addr.sa, 0, &sun, SUN_LEN(&sun)) ||
stat(sun.sun_path, &st) ||
!S_ISSOCK(st.st_mode)) {
if (decode_inet_addr(&addr.sa, 0, &sun, SUN_LEN(&sun)) ||
stat(sun.sun_path, &st) ||
!S_ISSOCK(st.st_mode)) {
- D( fprintf(stderr, "noip: ignoring unknown socketdir entry `%s'\n",
- sun.sun_path); )
+ D( fprintf(stderr, "noip(%d): ignoring unknown socketdir entry `%s'\n",
+ pid, sun.sun_path); )
continue;
}
if (unix_socket_status(&sun, 0) == STALE) {
continue;
}
if (unix_socket_status(&sun, 0) == STALE) {
- D( fprintf(stderr, "noip: clearing away stale socket %s\n",
- d->d_name); )
+ D( fprintf(stderr, "noip(%d): clearing away stale socket %s\n",
+ pid, d->d_name); )
unlink(sun.sun_path);
}
}
unlink(sun.sun_path);
}
}
struct ifaddrs *ifa_head, *ifa;
ipaddr a;
int i;
struct ifaddrs *ifa_head, *ifa;
ipaddr a;
int i;
+ D( fprintf(stderr, "noip(%d): fetching local addresses...\n", pid); )
if (getifaddrs(&ifa_head)) { perror("getifaddrs"); return; }
for (n_local_ipaddrs = 0, ifa = ifa_head;
n_local_ipaddrs < MAX_LOCAL_IPADDRS && ifa;
if (getifaddrs(&ifa_head)) { perror("getifaddrs"); return; }
for (n_local_ipaddrs = 0, ifa = ifa_head;
n_local_ipaddrs < MAX_LOCAL_IPADDRS && ifa;
continue;
ipaddr_from_sockaddr(&a, ifa->ifa_addr);
D({ char buf[ADDRBUFSZ];
continue;
ipaddr_from_sockaddr(&a, ifa->ifa_addr);
D({ char buf[ADDRBUFSZ];
- fprintf(stderr, "noip: local addr %s = %s", ifa->ifa_name,
+ fprintf(stderr, "noip(%d): local addr %s = %s", pid,
+ ifa->ifa_name,
inet_ntop(ifa->ifa_addr->sa_family, &a,
buf, sizeof(buf))); })
for (i = 0; i < n_local_ipaddrs; i++) {
inet_ntop(ifa->ifa_addr->sa_family, &a,
buf, sizeof(buf))); })
for (i = 0; i < n_local_ipaddrs; i++) {