Add a new `LISTEN' flag which says whether anyone's listening on the
socket. Maybe the listener has gone away and we can only see the
leftover connections.
#define UNUSED 0u /* No sign of anyone using it */
#define STALE 1u /* Socket exists, but is abandoned */
#define USED 16u /* Socket is in active use */
#define UNUSED 0u /* No sign of anyone using it */
#define STALE 1u /* Socket exists, but is abandoned */
#define USED 16u /* Socket is in active use */
+#define LISTEN 2u /* Socket has an active listener */
enum { DENY, ALLOW }; /* ACL verdicts */
enum { DENY, ALLOW }; /* ACL verdicts */
FILE *fp = 0;
size_t len, n;
int rc;
FILE *fp = 0;
size_t len, n;
int rc;
char buf[256];
/* If we can't find the socket node, then it's definitely not in use. If
char buf[256];
/* If we can't find the socket node, then it's definitely not in use. If
if (n >= len + 2 && buf[n - len - 2] == ' ' && buf[n - 1] == '\n' &&
memcmp(buf + n - len - 1, sun->sun_path, len) == 0) {
rc |= USED;
if (n >= len + 2 && buf[n - len - 2] == ' ' && buf[n - 1] == '\n' &&
memcmp(buf + n - len - 1, sun->sun_path, len) == 0) {
rc |= USED;
+ if (sscanf(buf, "%*s %*x %*x %lx", &f) < 0 || (f&0x00010000))
+ rc |= LISTEN;