static void chanacs_ext_delete(chanacs_exttarget_t *e) { return_if_fail(e != NULL); mowgli_patricia_delete(chanacs_exttarget_tree, e->channel); strshare_unref(e->channel); strshare_unref(entity(e)->name); mowgli_heap_free(chanacs_ext_heap, e); }
static void server_ext_delete(struct this_exttarget *e) { return_if_fail(e != NULL); mowgli_patricia_delete(server_exttarget_tree, e->server); strshare_unref(e->server); strshare_unref(entity(e)->name); mowgli_heap_free(server_ext_heap, e); }
static void check_hidehost(user_t *u) { static bool warned = false; char buf[HOSTLEN + 1]; /* do they qualify? */ if (!(u->flags & UF_HIDEHOSTREQ) || u->myuser == NULL || (u->myuser->flags & MU_WAITAUTH)) return; /* don't use this if they have some other kind of vhost */ if (strcmp(u->host, u->vhost)) { slog(LG_DEBUG, "check_hidehost(): +x overruled by other vhost for %s", u->nick); return; } if (me.hidehostsuffix == NULL) { if (!warned) { wallops("Misconfiguration: serverinfo::hidehostsuffix not set"); warned = true; } return; } snprintf(buf, sizeof buf, "%s.%s", entity(u->myuser)->name, me.hidehostsuffix); strshare_unref(u->vhost); u->vhost = strshare_get(buf); slog(LG_DEBUG, "check_hidehost(): %s -> %s", u->nick, u->vhost); }
static void m_mode(sourceinfo_t *si, int parc, char *parv[]) { user_t *u; char *p; if (*parv[0] == '#') channel_mode(NULL, channel_find(parv[0]), parc - 1, &parv[1]); else { /* Yes this is a nick and not a UID -- jilles */ u = user_find_named(parv[0]); if (u == NULL) { slog(LG_DEBUG, "m_mode(): user mode for unknown user %s", parv[0]); return; } user_mode(u, parv[1]); if (strchr(parv[1], 'x')) { u->flags |= UF_HIDEHOSTREQ; check_hidehost(u); } if (strchr(parv[1], 'h')) { if (parc > 2) { /* assume +h */ p = strchr(parv[2], '@'); if (p == NULL) { strshare_unref(u->vhost); u->vhost = strshare_get(parv[2]); } else { char userbuf[USERLEN]; strshare_unref(u->vhost); u->vhost = strshare_get(p + 1); mowgli_strlcpy(userbuf, parv[2], sizeof userbuf); p = strchr(userbuf, '@'); if (p != NULL) *p = '\0'; strshare_unref(u->user); u->user = strshare_get(userbuf); } slog(LG_DEBUG, "m_mode(): user %s setting vhost %s@%s", u->nick, u->user, u->vhost); } else { /* must be -h */ /* XXX we don't know the original ident */ slog(LG_DEBUG, "m_mode(): user %s turning off vhost", u->nick); strshare_unref(u->vhost); u->vhost = strshare_get(u->host); /* revert to +x vhost if applicable */ check_hidehost(u); } } } }
static void m_nick(sourceinfo_t *si, int parc, char *parv[]) { user_t *u; char ipstring[HOSTIPLEN]; char *p; int i; /* got the right number of args for an introduction? */ if (parc >= 8) { /* -> AB N jilles 1 1137687480 jilles jaguar.test +oiwgrx jilles B]AAAB ABAAE :Jilles Tjoelker */ /* -> AB N test4 1 1137690148 jilles jaguar.test +iw B]AAAB ABAAG :Jilles Tjoelker */ slog(LG_DEBUG, "m_nick(): new user on `%s': %s", si->s->name, parv[0]); decode_p10_ip(parv[parc - 3], ipstring); u = user_add(parv[0], parv[3], parv[4], NULL, ipstring, parv[parc - 2], parv[parc - 1], si->s, atoi(parv[2])); if (u == NULL) return; if (parv[5][0] == '+') { user_mode(u, parv[5]); i = 1; if (strchr(parv[5], 'r')) { p = strchr(parv[5+i], ':'); if (p != NULL) *p++ = '\0'; handle_burstlogin(u, parv[5+i], p ? atol(p) : 0); /* killed to force logout? */ if (user_find(parv[parc - 2]) == NULL) return; i++; } if (strchr(parv[5], 'h')) { p = strchr(parv[5+i], '@'); if (p == NULL) { strshare_unref(u->vhost); u->vhost = strshare_get(parv[5 + i]); } else { char userbuf[USERLEN]; strshare_unref(u->vhost); u->vhost = strshare_get(p + 1); mowgli_strlcpy(userbuf, parv[5+i], sizeof userbuf); p = strchr(userbuf, '@'); if (p != NULL) *p = '\0'; strshare_unref(u->user); u->user = strshare_get(userbuf); } i++; } if (strchr(parv[5], 'x')) { u->flags |= UF_HIDEHOSTREQ; /* this must be after setting the account name */ check_hidehost(u); } } handle_nickchange(u); } /* if it's only 2 then it's a nickname change */ else if (parc == 2) { if (!si->su) { slog(LG_DEBUG, "m_nick(): server trying to change nick: %s", si->s != NULL ? si->s->name : "<none>"); return; } slog(LG_DEBUG, "m_nick(): nickname change from `%s': %s", si->su->nick, parv[0]); if (user_changenick(si->su, parv[0], atoi(parv[1]))) return; handle_nickchange(si->su); } else { slog(LG_DEBUG, "m_nick(): got NICK with wrong (%d) number of params", parc); for (i = 0; i < parc; i++) slog(LG_DEBUG, "m_nick(): parv[%d] = %s", i, parv[i]); } }