int auth_client_trust(const char *mac) { int rc = -1; LOCK_CONFIG(); if (!add_to_trusted_mac_list(mac) && !iptables_trust_mac(mac)) { rc = 0; } UNLOCK_CONFIG(); return rc; }
/* Given a pointer to a comma or whitespace delimited sequence of * MAC addresses, add each MAC address to config.trustedmaclist. */ void parse_trusted_mac_list(const char ptr[]) { char *ptrcopy = NULL, *ptrcopyptr; char *possiblemac = NULL; debug(LOG_DEBUG, "Parsing string [%s] for trusted MAC addresses", ptr); /* strsep modifies original, so let's make a copy */ ptrcopyptr = ptrcopy = safe_strdup(ptr); while ((possiblemac = strsep(&ptrcopy, ", \t"))) { if(strlen(possiblemac)>0) add_to_trusted_mac_list(possiblemac); } free(ptrcopyptr); }
static void ndsctl_trust(int fd, char *arg) { debug(LOG_DEBUG, "Entering ndsctl_trust..."); LOCK_CONFIG(); debug(LOG_DEBUG, "Argument: [%s]", arg); if (!add_to_trusted_mac_list(arg) && !iptables_trust_mac(arg)) { write(fd, "Yes", 3); } else { write(fd, "No", 2); } UNLOCK_CONFIG(); debug(LOG_DEBUG, "Exiting ndsctl_trust."); }