void AddJupe(char *name, char *reason, char *who) { struct Jupe *tempjupe; unsigned int ii; int nickjupe = 1; for (ii = 0; ii < strlen(name); ++ii) { if (IsKWildChar(name[ii])) { nickjupe = 0; break; } } tempjupe = (struct Jupe *) MyMalloc(sizeof(struct Jupe)); memset(tempjupe, 0, sizeof(struct Jupe)); tempjupe->name = MyStrdup(name); tempjupe->reason = MyStrdup(reason); tempjupe->who = MyStrdup(who); tempjupe->isnick = nickjupe; tempjupe->prev = NULL; tempjupe->next = JupeList; if (tempjupe->next) tempjupe->next->prev = tempjupe; JupeList = tempjupe; ++Network->TotalJupes; } /* AddJupe() */
static void mo_spoof(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { char *host, *spoof, *password; const char *tmp = NULL; const char *user = NULL; const char *flags = NULL; int i = 0; #ifdef SPOOF_FILE int class_opers; FBFILE *f; char buffer[1024]; struct AddressRec *arec; #endif if (MyConnect(source_p) && !IsOperAdmin(source_p)) { sendto_one(source_p, form_str(ERR_NOPRIVS), me.name, source_p->name, "SPOOF"); return; } /* check the user@host mask */ if (strchr(parv[1], '!') != NULL) { syntax: if (MyConnect(source_p)) sendto_one(source_p, ":%s NOTICE %s :Syntax: SPOOF <umask@hmask> " "<spoof/-> [flags/- [password]]", me.name, source_p->name); return; } (void) collapse(parv[1]); for (tmp = parv[1]; *tmp; tmp++) if (!IsKWildChar(*tmp)) if (++i >= ConfigFileEntry.min_nonwildcard) break; if (i < ConfigFileEntry.min_nonwildcard) { if (MyConnect(source_p)) sendto_one(source_p, ":%s NOTICE %s :Not enough non-wildcard characters " "in user@host mask", me.name, source_p->name); return; } host = strchr(parv[1], '@'); if (host) { user = parv[1]; *host = '\0'; host++; } else { user = "******"; host = parv[1]; } /* check the spoof field */ spoof = parv[2]; if (spoof == NULL || !*spoof) goto syntax; if (spoof[0] != '-' || spoof[1] != '\0') { for (tmp = spoof; *tmp; tmp++) if (!IsHostChar(*tmp)) { if (MyConnect(source_p)) sendto_one(source_p, ":%s NOTICE %s :The spoof [%s] is invalid", me.name, source_p->name, spoof); return; } if (strlen(spoof) >= HOSTLEN) { if (MyConnect(source_p)) sendto_one(source_p, ":%s NOTICE %s :Spoofs must be less than %d.." "ignoring it", me.name, source_p->name, HOSTLEN); return; } } flags = (parc > 3) ? parv[3] : "-"; password = (parc > 4 && parv[4][0]) ? parv[4] : NULL; #ifdef PROPAGATE_SPOOF sendto_server(client_p, source_p, NULL, NOCAPS, NOCAPS, LL_ICLIENT, ":%s SPOOF %s@%s %s %s :%s", source_p->name, user, host, spoof, flags, password ? password : ""); #endif #ifdef SPOOF_FILE /* Walk through auth {} items and check if we have another auth block * for this hostname */ for (i = 0; i < ATABLE_SIZE; i++) for (arec = atable[i]; arec; arec = arec->next) if (arec->type == CONF_CLIENT && !irccmp(arec->aconf->host, host) && !irccmp(arec->aconf->user, user)) { /* auth entry already exists */ if (MyConnect(source_p)) sendto_one(source_p, ":%s NOTICE %s :auth for %s@%s already exists, you need " "to use /DELSPOOF first", me.name, source_p->name, user, host); #ifdef LOG_SPOOF sendto_realops_flags(UMODE_ALL, L_ALL, "%s attemped to re-add auth for %s@%s " "[spoof: %s, flags: %s]", source_p->name, user, host, spoof, flags); #endif return; } /* Add the spoof to the the spoof file */ if ((f = fbopen(SPOOF_FILE, "a")) == NULL) { sendto_realops_flags(UMODE_ALL, L_ALL, "Could not open %s file, auth for %s@%s " "[spoof: %s, flags: %s, requested by %s] not added", SPOOF_FILE, user, host, spoof, flags, source_p->name); return; } /* write the auth {} block */ fbputs("auth {\n", f, 7); i = ircsprintf(buffer, "\tuser = \"%s@%s\";\n", user, host); fbputs(buffer, f, i); if (spoof[0] != '-' || spoof[1] != '\0') { i = ircsprintf(buffer, "\tspoof = \"%s\";\n", spoof); fbputs(buffer, f, i); } if (password) { i = ircsprintf(buffer, "\tpassword = \"%s\";\n", password); fbputs(buffer, f, i); } /* process given flags */ i = class_opers = 0; for (tmp = flags; *tmp; ++tmp) switch (*tmp) { case 't': i |= CONF_FLAGS_NO_TILDE; /* no_tilde = yes; */ break; case 'i': i |= CONF_FLAGS_NEED_IDENTD; /* need_ident = yes; */ break; case 'k': i |= CONF_FLAGS_EXEMPTKLINE; /* kline_exempt = yes; */ break; case 'g': i |= CONF_FLAGS_EXEMPTGLINE; /* gline_exempt = yes; */ break; case 'l': i |= CONF_FLAGS_NOLIMIT; /* exceed_limit = yes; */ break; case 'o': class_opers = 1; /* class = "opers"; */ break; case 'f': i |= CONF_FLAGS_CAN_FLOOD; /* can_flood = yes; */ break; case 'p': i|= CONF_FLAGS_NEED_PASSWORD; /* need_password = yes; */ } if (i) { fbputs("\tflags = ", f, 9); try_flag(f, &i, CONF_FLAGS_NO_TILDE, "no_tilde"); try_flag(f, &i, CONF_FLAGS_NEED_IDENTD, "need_ident"); try_flag(f, &i, CONF_FLAGS_EXEMPTKLINE, "kline_exempt"); try_flag(f, &i, CONF_FLAGS_EXEMPTGLINE, "gline_exempt"); try_flag(f, &i, CONF_FLAGS_NOLIMIT, "exceed_limit"); try_flag(f, &i, CONF_FLAGS_CAN_FLOOD, "can_flood"); try_flag(f, &i, CONF_FLAGS_NEED_PASSWORD, "need_password"); } if (class_opers) fbputs("\tclass = \"opers\";\n", f, 18); else fbputs("\tclass = \"users\";\n", f, 18); fbputs("};\n\n", f, 4); fbclose(f); rehash(0); #endif #ifdef LOG_SPOOF sendto_realops_flags(UMODE_ALL, L_ALL, "%s added auth for %s@%s [spoof: %s, flags: %s]", source_p->name, user, host, spoof, flags); ilog(L_TRACE, "%s added auth for %s@%s [spoof: %s, flags: %s]", source_p->name, user, host, spoof, flags); #endif }