authd: add API for setting OPM listeners

This commit is contained in:
Elizabeth Myers 2016-04-01 02:43:01 -05:00
parent 7372553dd6
commit 4f6119cd40
2 changed files with 30 additions and 4 deletions

View file

@ -54,7 +54,8 @@ const char *get_provider_string(char cause);
void add_blacklist(const char *host, const char *reason, uint8_t iptype, rb_dlink_list *filters);
void del_blacklist(const char *host);
void del_blacklist_all(void);
void set_authd_timeout(const char *key, int timeout);
bool set_authd_timeout(const char *key, int timeout);
void ident_check_enable(bool enabled);
bool create_opm_listener(struct rb_sockaddr_storage *addr);
#endif

View file

@ -407,10 +407,10 @@ authd_decide_client(struct Client *client_p, const char *ident, const char *host
if(*ident != '*')
{
rb_strlcpy(client_p->username, ident, sizeof(client_p->username));
ServerStats.is_abad++; /* s_auth used to do this, stay compatible */
ServerStats.is_asuc++;
}
else
ServerStats.is_asuc++;
ServerStats.is_abad++; /* s_auth used to do this, stay compatible */
if(*host != '*')
rb_strlcpy(client_p->host, host, sizeof(client_p->host));
@ -546,14 +546,39 @@ del_blacklist_all(void)
}
/* Adjust an authd timeout value */
void
bool
set_authd_timeout(const char *key, int timeout)
{
if(timeout <= 0)
return false;
rb_helper_write(authd_helper, "O %s %d", key, timeout);
return true;
}
/* Enable identd checks */
void
ident_check_enable(bool enabled)
{
rb_helper_write(authd_helper, "O ident_enabled %d", enabled ? 1 : 0);
}
/* Create an OPM listener */
bool
create_opm_listener(struct rb_sockaddr_storage *addr)
{
char addrbuf[HOSTIPLEN];
if(!rb_inet_ntop_sock((struct sockaddr *)addr, addrbuf, sizeof(addrbuf)))
return false;
if(addrbuf[0] == ':')
{
/* Reformat for authd sending */
memmove(addrbuf + 1, addrbuf, sizeof(addrbuf) - 1);
addrbuf[0] = '0';
}
rb_helper_write(authd_helper, "O opm_listener %s %hu", addrbuf, ntohs(GET_SS_PORT(addr)));
return true;
}