From: Gabriel B. <sh...@us...> - 2005-09-04 06:31:19
|
Update of /cvsroot/solidircd/solidircd-stable/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32409/src Modified Files: Makefile.in s_serv.c toys.c Removed Files: m_gline.c Log Message: updates... Index: toys.c =================================================================== RCS file: /cvsroot/solidircd/solidircd-stable/src/toys.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** toys.c 27 Jun 2005 03:02:11 -0000 1.1.1.1 --- toys.c 4 Sep 2005 06:31:10 -0000 1.2 *************** *** 41,44 **** --- 41,46 ---- #endif + #undef CHECK + #define STATES_NUM 512 *************** *** 175,178 **** --- 177,183 ---- memset(state, 0, sizeof(state)); next_free_state = 1; + #ifdef CHECK + printf("states used: %d\n", next_free_state); + #endif } *************** *** 296,297 **** --- 301,316 ---- return 0; } + + /***************************************** + * End ELMER routines + *****************************************/ + #ifdef CHECK + void main(void) { + char buffer[256], buffer2[256]; + init_chef(); + printf("Text: "); + gets(buffer); + encode_chef(buffer, buffer2, 256); + printf("Translation: %s\n",buffer2); + } + #endif --- m_gline.c DELETED --- Index: Makefile.in =================================================================== RCS file: /cvsroot/solidircd/solidircd-stable/src/Makefile.in,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Makefile.in 4 Sep 2005 05:24:13 -0000 1.4 --- Makefile.in 4 Sep 2005 06:31:10 -0000 1.5 *************** *** 21,25 **** SOURCES = blalloc.c bsd.c channel.c clientlist.c clones.c confparse.c \ fdlist.c fds.c hash.c hide.c inet_addr.c ircd.c ircsprintf.c \ ! klines.c list.c m_gline.c m_shun.c m_nick.c m_rwho.c m_server.c m_services.c \ m_stats.c m_who.c match.c memcount.c modules.c packet.c parse.c pcre.c\ probability.c res.c s_auth.c s_bsd.c s_conf.c s_debug.c s_err.c s_misc.c s_numeric.c \ --- 21,25 ---- SOURCES = blalloc.c bsd.c channel.c clientlist.c clones.c confparse.c \ fdlist.c fds.c hash.c hide.c inet_addr.c ircd.c ircsprintf.c \ ! klines.c list.c m_shun.c m_nick.c m_rwho.c m_server.c m_services.c \ m_stats.c m_who.c match.c memcount.c modules.c packet.c parse.c pcre.c\ probability.c res.c s_auth.c s_bsd.c s_conf.c s_debug.c s_err.c s_misc.c s_numeric.c \ *************** *** 148,156 **** ../include/zlink.h ../include/memcount.h ../include/throttle.h \ ../include/queue.h - m_gline.o: m_gline.c ../include/struct.h ../include/dbuf.h ../include/config.h \ - ../include/setup.h ../include/defs.h ../include/hash.h \ - ../include/h.h ../include/send.h ../include/common.h \ - ../include/ircsprintf.h ../include/msg.h ../include/sys.h \ - ../include/userban.h ../include/common.h m_shun.o: m_shun.c ../include/struct.h ../include/config.h \ ../include/setup.h ../include/defs.h ../include/hash.h \ --- 148,151 ---- Index: s_serv.c =================================================================== RCS file: /cvsroot/solidircd/solidircd-stable/src/s_serv.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** s_serv.c 4 Sep 2005 05:24:13 -0000 1.5 --- s_serv.c 4 Sep 2005 06:31:10 -0000 1.6 *************** *** 2486,2489 **** --- 2486,2813 ---- #endif /* UNKLINE */ + + + int m_gline(aClient *cptr, aClient *sptr, int parc, char *parv[]) + { + struct userBan *ban, *oban; + char buffer[1024]; + char *user, *host; + char *reason; + char *current_date; + aClient *acptr; + char tempuser[USERLEN + 2]; + char temphost[HOSTLEN + 1]; + int temporary_gline_time = 0; /* -Dianora */ + time_t temporary_gline_time_seconds = 0; + int time_specified = 0; + char *argv; + int i; + char fbuf[512]; + + + + + if (!IsAnOper(sptr) && !IsServer(sptr)) + { + sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); + return 0; + } + + if (parc < 2) + { + sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), + me.name, parv[0], "GLINE"); + return 0; + } + + argv = parv[1]; + + if ((temporary_gline_time = isnumber(argv)) >= 0) + { + if (parc < 3) + { + sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), + me.name, parv[0], "GLINE"); + return 0; + } + if (temporary_gline_time > 1080000) + temporary_gline_time = 1080000; + + temporary_gline_time_seconds = (time_t) temporary_gline_time; + + argv = parv[2]; + parc--; + time_specified = 1; + } + else + { + temporary_gline_time = 0; + } + + if(strchr(argv, ' ')) + { + sendto_one(sptr, + ":%s NOTICE %s :Poorly formatted hostname " + "(contains spaces). Be sure you are using the form: " + "/quote GLINE [time] <user@host/nick> :<reason>", + me.name, parv[0]); + return 0; + } + + + if ((host = strchr(argv, '@')) || *argv == '*') + { + + if (host) + { + user = argv; + *(host++) = '\0'; + } + else + { + user = "*"; + host = argv; + } + + if (!*host) + host = "*"; + + strncpyzt(tempuser, user, USERLEN + 2); + strncpyzt(temphost, host, HOSTLEN); + user = tempuser; + host = temphost; + } + else + { + + if (!(acptr = find_chasing(sptr, argv, NULL))) + return 0; + + if (!acptr->user) + return 0; + + if (IsServer(acptr)) + { + sendto_one(sptr, ":%s NOTICE %s :Can't GLINE a server, use @'s " + "where appropriate", me.name, parv[0]); + return 0; + } + tempuser[0] = '*'; + if (*acptr->user->username == '~') + strcpy(tempuser + 1, (char *) acptr->user->username + 1); + + else + strcpy(tempuser + 1, acptr->user->username); + user = tempuser; + host = cluster(acptr->user->host); + } + + if (time_specified) + argv = parv[3]; + else + argv = parv[2]; + + /* FIXME: Shouldnt we use our hown DEFAULT_GLINE_TIME? - Tux`*/ + #ifdef DEFAULT_KLINE_TIME + if (time_specified <= 0) + { + temporary_gline_time = 30; + temporary_gline_time_seconds = (time_t) temporary_gline_time *(time_t) 60; + } + #endif + if (parc > 2) + { + if (*argv) + reason = argv; + else + reason = "No reason"; + } + else + reason = "No reason"; + + if (!match(user, "akjhfkahfasfjd") && + !match(host, "ldksjfl.kss...kdjfd.jfklsjf")) + { + sendto_one(sptr, ":%s NOTICE %s :Can't G-Line *@*", me.name, + parv[0]); + return 0; + } + + if (temporary_gline_time == 0 && strchr(reason, ':')) + { + sendto_one(sptr, + ":%s NOTICE %s :Invalid character ':' in comment", + me.name, parv[0]); + return 0; + } + + if (temporary_gline_time == 0 && strchr(reason, '#')) + { + sendto_one(sptr,":%s NOTICE %s :Invalid character '#' in comment", + me.name, parv[0]); + return 0; + } + + ban = make_hostbased_ban(user, host); + if(!ban) + { + sendto_one(sptr, ":%s NOTICE %s :Malformed ban %s@%s", me.name, parv[0], + user, host); + return 0; + } + + if ((oban = find_userban_exact(ban, 0))) + { + if (oban->flags & UBAN_GLINE) + { + if (MyClient(sptr)) + { + sendto_one(sptr, ":%s NOTICE %s :[%s@%s] already %s for %s", + me.name, parv[0], user, host, NETWORK_GLINNED_NAME, + oban->reason ? oban->reason : "<No Reason>"); + } + else + { + /* The G-Line does not exist, and sptr is not our client. + * However, we should still send it... - Tux` */ + host = get_userban_host(ban, fbuf, 512); + sendto_serv_butone(sptr, ":%s GLINE %d %s@%s :%s", + parv[0], temporary_gline_time_seconds, user, host, reason); + + } + userban_free(ban); + return 0; + } + } + + current_date = smalldate((time_t) 0); + ban->flags |= temporary_gline_time ? (UBAN_GLINE|UBAN_TEMPORARY) : (UBAN_GLINE); + if (IsServer(sptr)) + ircsprintf(buffer, "%s", reason); + ircsprintf(buffer, "%s (%s)", reason, current_date); + ban->reason = (char *) MyMalloc(strlen(buffer) + 1); + strcpy(ban->reason, buffer); + + ban->timeset = timeofday; + ban->duration = temporary_gline_time_seconds; + + + + if(user_match_ban(sptr, ban)) + { + sendto_one(sptr, ":%s NOTICE %s :You attempted to add a gline [%s@%s] " + "which would affect yourself. Aborted.", + me.name, parv[0], user, host); + userban_free(ban); + return 0; + } + + add_hostbased_userban(ban); + + /* Check local users against it */ + for (i = 0; i <= highest_fd; i++) + { + if (!(acptr = local[i]) || IsMe(acptr) || IsLog(acptr)) + continue; + + if (IsPerson(acptr) && user_match_ban(acptr, ban)) + { + sendto_ops(NETWORK_GLINE_NAME" active for %s", + get_client_name(acptr, FALSE)); + sendto_serv_butone(sptr, ":%s GLOBOPS :%s active for %s", + NETWORK_GLINE_NAME, me.name, get_client_name(acptr, FALSE)); + + ircsprintf(fbuf, NETWORK_GLINNED_NAME": %s", reason); + exit_client(acptr, acptr, &me, fbuf); + i--; + } + } + + host = get_userban_host(ban, fbuf, 512); + + if(temporary_gline_time) + { + sendto_realops("%s added a temporary %d sec(s) "NETWORK_GLINE_NAME" for [%s@%s] [%s]", + parv[0], temporary_gline_time, user, host, reason); + sendto_serv_butone(sptr, ":%s GLINE %d %s@%s :%s", + parv[0], temporary_gline_time_seconds, user, host, reason); + return 0; + } + + sendto_realops("%s added a permanent gline for [%s@%s] [%s]", + parv[0], user, host, reason); + sendto_serv_butone(sptr, ":%s GLINE %d %s@%s :%s", + parv[0], temporary_gline_time_seconds, user, host, reason); + + return 0; + } + + int m_ungline(aClient *cptr, aClient *sptr, int parc, char *parv[]) + { + struct userBan *ban; + char *user, *host; + + if (!IsAnOper(sptr)) + { + sendto_one(sptr, err_str(ERR_NOPRIVILEGES), me.name, parv[0]); + return 0; + } + + if(parc<2) + { + sendto_one(sptr, err_str(ERR_NEEDMOREPARAMS), me.name, parv[0],"UNGLINE"); + return 0; + } + + if ((host = strchr(parv[1], '@')) || *parv[1] == '*') { + if (host) { + user = parv[1]; + *(host++) = '\0'; + } else { + user = "*"; + host = parv[1]; + } + } else { + sendto_one(sptr, ":%s NOTICE %s :Invalid parameters",me.name, parv[0]); + return 0; + } + if ((user[0] == '*') && (user[1] == '\0') && + (host[0] == '*') && (host[1] == '\0')) { + sendto_one(sptr, ":%s NOTICE %s :Cannot ungline everyone",me.name, parv[0]); + return 0; + } + + ban = make_hostbased_ban(user, host); + if(ban) { + struct userBan *oban; + ban->flags |= (UBAN_GLINE|UBAN_TEMPORARY); + + if((oban = find_userban_exact(ban, UBAN_GLINE))) { + char tmp[512]; + host = get_userban_host(oban, tmp, 512); + remove_userban(oban); + userban_free(oban); + userban_free(ban); + + if (MyClient(sptr)) + sendto_one(sptr, ":%s NOTICE %s :G-line for [%s@%s] is removed", + me.name, parv[0], user, host); + sendto_ops("%s has removed the G-line for: [%s@%s] (%d matches)", + parv[0], user, host, 1); + + sendto_serv_butone(cptr, ":%s UNGLINE %s@%s", sptr->name, user, host); + return 0; + } + userban_free(ban); + } + if (MyClient(sptr)) + sendto_one(sptr, ":%s NOTICE %s :No g-line for %s@%s was found", + me.name, parv[0], user, host); + return 0; + } + + + + /* m_rehash */ int |