/* HELP <command> [params] */ static void os_cmd_help(sourceinfo_t *si, int parc, char *parv[]) { char *command = parv[0]; if (!has_any_privs(si)) { command_fail(si, fault_noprivs, _("You are not authorized to use %s."), si->service->nick); return; } if (!command) { command_success_nodata(si, _("***** \2%s Help\2 *****"), si->service->nick); command_success_nodata(si, _("\2%s\2 provides essential network management services, such as\n" "routing manipulation and access restriction. Please do not abuse\n" "your access to \2%s\2!"), si->service->nick, si->service->nick); command_success_nodata(si, " "); command_success_nodata(si, _("For information on a command, type:")); command_success_nodata(si, "\2/%s%s help <command>\2", (ircd->uses_rcommand == false) ? "msg " : "", si->service->disp); command_success_nodata(si, " "); command_help(si, si->service->commands); command_success_nodata(si, _("***** \2End of Help\2 *****")); return; } /* take the command through the hash table */ help_display(si, si->service, command, si->service->commands); }
/* HELP <command> [params] */ static void os_cmd_help(char *origin) { char *command = strtok(NULL, ""); if (!has_any_privs(user_find_named(origin))) { notice(opersvs.nick, origin, "You are not authorized to use %s.", opersvs.nick); return; } if (!command) { notice(opersvs.nick, origin, "***** \2%s Help\2 *****", opersvs.nick); notice(opersvs.nick, origin, "\2%s\2 provides essential network management services, such as", opersvs.nick); notice(opersvs.nick, origin, "routing manipulation and access restriction. Please do not abuse"); notice(opersvs.nick, origin, "your access to \2%s\2!", opersvs.nick); notice(opersvs.nick, origin, " "); notice(opersvs.nick, origin, "For information on a command, type:"); notice(opersvs.nick, origin, "\2/%s%s help <command>\2", (ircd->uses_rcommand == FALSE) ? "msg " : "", opersvs.disp); notice(opersvs.nick, origin, " "); command_help(opersvs.nick, origin, os_cmdtree); notice(opersvs.nick, origin, "***** \2End of Help\2 *****", opersvs.nick); return; } /* take the command through the hash table */ help_display(opersvs.nick, opersvs.disp, origin, command, os_helptree); }
static bool evaluate_condition(sourceinfo_t *si, const char *s) { char word[80]; char *p, *q; while (*s == ' ' || *s == '\t') s++; if (*s == '!') return !evaluate_condition(si, s + 1); mowgli_strlcpy(word, s, sizeof word); p = strchr(word, ' '); if (p != NULL) { *p++ = '\0'; while (*p == ' ' || *p == '\t') p++; } if (!strcmp(word, "halfops")) return ircd->uses_halfops; else if (!strcmp(word, "owner")) return ircd->uses_owner; else if (!strcmp(word, "protect")) return ircd->uses_protect; else if (!strcmp(word, "anyprivs")) return has_any_privs(si); else if (!strcmp(word, "priv")) { if (p != NULL && (q = strchr(p, ' ')) != NULL) *q = '\0'; return has_priv(si, p); } else if (!strcmp(word, "module")) { if (p != NULL && (q = strchr(p, ' ')) != NULL) *q = '\0'; return module_find_published(p) != NULL; } else if (!strcmp(word, "auth")) return me.auth != AUTH_NONE; else return false; }
static void os_cmd_specs(sourceinfo_t *si, int parc, char *parv[]) { user_t *tu = NULL; operclass_t *cl = NULL; const char *targettype = parv[0]; const char *target = parv[1]; unsigned int i; int j, n; if (!has_any_privs(si)) { command_fail(si, fault_noprivs, _("You are not authorized to use %s."), si->service->nick); return; } if (targettype != NULL) { if (!has_priv(si, PRIV_VIEWPRIVS)) { command_fail(si, fault_noprivs, STR_NO_PRIVILEGE, PRIV_VIEWPRIVS); return; } if (target == NULL) target = "?"; if (!strcasecmp(targettype, "USER")) { tu = user_find_named(target); if (tu == NULL) { command_fail(si, fault_nosuch_target, _("\2%s\2 is not on IRC."), target); return; } if (!has_any_privs_user(tu)) { command_success_nodata(si, _("\2%s\2 is unprivileged."), tu->nick); return; } if (is_internal_client(tu)) { command_fail(si, fault_noprivs, _("\2%s\2 is an internal client."), tu->nick); return; } } else if (!strcasecmp(targettype, "OPERCLASS") || !strcasecmp(targettype, "CLASS")) { cl = operclass_find(target); if (cl == NULL) { command_fail(si, fault_nosuch_target, _("No such oper class \2%s\2."), target); return; } } else { command_fail(si, fault_badparams, _("Valid target types: USER, OPERCLASS.")); return; } } else tu = si->su; if (targettype == NULL) command_success_nodata(si, _("Privileges for \2%s\2:"), get_source_name(si)); else if (tu) command_success_nodata(si, _("Privileges for \2%s\2:"), tu->nick); else command_success_nodata(si, _("Privileges for oper class \2%s\2:"), cl->name); for (i = 0; i < ARRAY_SIZE(priv_categories); i++) { struct priv_category *cat = priv_categories[i]; command_success_nodata(si, "\2%s\2:", _(cat->name)); for (j = n = 0; cat->privs[j].priv != NULL; j++) { if (targettype == NULL ? has_priv(si, cat->privs[j].priv) : (tu ? has_priv_user(tu, cat->privs[j].priv) : has_priv_operclass(cl, cat->privs[j].priv))) { command_success_nodata(si, " %s (%s)", cat->privs[j].priv, _(cat->privs[j].desc)); ++n; } } if (!n) command_success_nodata(si, " %s", _("(no privileges held)")); } command_success_nodata(si, _("End of privileges")); if (targettype == NULL) logcommand(si, CMDLOG_ADMIN, "SPECS"); else if (tu) logcommand(si, CMDLOG_ADMIN, "SPECS:USER: \2%s!%s@%s\2", tu->nick, tu->user, tu->vhost); else logcommand(si, CMDLOG_ADMIN, "SPECS:OPERCLASS: \2%s\2", cl->name); }
static void os_cmd_specs(char *origin) { user_t *u = user_find_named(origin), *tu = NULL; operclass_t *cl = NULL; char *targettype = strtok(NULL, " "); char *target = strtok(NULL, " "); char nprivs[BUFSIZE], cprivs[BUFSIZE], gprivs[BUFSIZE], oprivs[BUFSIZE]; int i; if (!has_any_privs(u)) { notice(opersvs.nick, origin, "You are not authorized to use %s.", opersvs.nick); return; } if (targettype != NULL) { if (!has_priv(u, PRIV_VIEWPRIVS)) { notice(opersvs.nick, origin, "You do not have %s privilege.", PRIV_VIEWPRIVS); return; } if (target == NULL) target = "?"; if (!strcasecmp(targettype, "USER")) { tu = user_find_named(target); if (tu == NULL) { notice(opersvs.nick, origin, "\2%s\2 is not on IRC.", target); return; } if (!has_any_privs(tu)) { notice(opersvs.nick, origin, "\2%s\2 is unprivileged.", tu->nick); return; } if (is_internal_client(tu)) { notice(opersvs.nick, origin, "\2%s\2 is an internal client.", tu->nick); return; } } else if (!strcasecmp(targettype, "OPERCLASS") || !strcasecmp(targettype, "CLASS")) { cl = operclass_find(target); if (cl == NULL) { notice(opersvs.nick, origin, "No such oper class \2%s\2.", target); return; } } else { notice(opersvs.nick, origin, "Valid target types: USER, OPERCLASS."); return; } } else tu = u; i = 0; *nprivs = *cprivs = *gprivs = *oprivs = '\0'; while (privnames[i].priv != NULL) { if (tu ? has_priv(tu, privnames[i].priv) : has_priv_operclass(cl, privnames[i].priv)) { if (privnames[i].npriv != NULL) { if (*nprivs) strcat(nprivs, ", "); strcat(nprivs, privnames[i].npriv); } if (privnames[i].cpriv != NULL) { if (*cprivs) strcat(cprivs, ", "); strcat(cprivs, privnames[i].cpriv); } if (privnames[i].gpriv != NULL) { if (*gprivs) strcat(gprivs, ", "); strcat(gprivs, privnames[i].gpriv); } if (privnames[i].opriv != NULL) { if (*oprivs) strcat(oprivs, ", "); strcat(oprivs, privnames[i].opriv); } } i++; } if (tu) notice(opersvs.nick, origin, "Privileges for \2%s\2:", tu->nick); else notice(opersvs.nick, origin, "Privileges for oper class \2%s\2:", cl->name); if (*nprivs) notice(opersvs.nick, origin, "\2Nicknames/accounts\2: %s", nprivs); if (*cprivs) notice(opersvs.nick, origin, "\2Channels\2: %s", cprivs); if (*gprivs) notice(opersvs.nick, origin, "\2General\2: %s", gprivs); if (*oprivs) notice(opersvs.nick, origin, "\2OperServ\2: %s", oprivs); notice(opersvs.nick, origin, "End of privileges"); if (tu) logcommand(opersvs.me, user_find_named(origin), CMDLOG_ADMIN, "SPECS USER %s!%s@%s", tu->nick, tu->user, tu->vhost); else logcommand(opersvs.me, user_find_named(origin), CMDLOG_ADMIN, "SPECS OPERCLASS %s", cl->name); }