diff -cr ../ircu2.10.05/config/config-sh.in ../ircu2.10.05+/config/config-sh.in *** ../ircu2.10.05/config/config-sh.in Tue Mar 16 16:03:27 1999 --- ../ircu2.10.05+/config/config-sh.in Tue Mar 16 16:52:05 1999 *************** *** 324,329 **** --- 324,333 ---- bool 'Allow Opers to use the DIE command' OPER_DIE y bool 'Allow Opers to add local G-lines' OPER_LGLINE y bool 'Allow Opers to connect from a remote site' OPER_REMOTE y + bool 'Allow Opers to join channels using a master key - ESNET' OPER_JOIN_GOD_ESNET y + bool 'Allow Opers to became channel service - ESNET' OPER_CHANNEL_SERVICE_ESNET y + bool 'Local Channel Services has no Flood Control - ESNET' CS_NO_FLOOD_ESNET y + bool 'Allow Opers to bypass UWorld mode changes - ESNET' OPER_XMODE_ESNET y bool 'Allow local opers to use the REHASH command' LOCOP_REHASH y bool 'Allow local opers to use the RESTART command' LOCOP_RESTART bool 'Allow local opers to use the DIE command' LOCOP_DIE *************** *** 346,351 **** --- 350,357 ---- mainmenu_option next_comment comment 'Mandatory defines (you should leave these untouched)' + bool 'XMODE Networking - ESNET' XMODE_ESNET y + bool 'ESNET Distributed DataBase Support - ESNET' DB_ESNET y int 'Max auto connects per class (1!)' MAXIMUM_LINKS 1 echo '* Never define this on a production server:' bool 'Enable message logging' MSGLOG_ENABLED diff -cr ../ircu2.10.05/doc/Configure.help ../ircu2.10.05+/doc/Configure.help *** ../ircu2.10.05/doc/Configure.help Tue Mar 16 16:03:28 1999 --- ../ircu2.10.05+/doc/Configure.help Tue Mar 16 16:48:58 1999 *************** *** 836,841 **** --- 836,870 ---- the server in order to gain oper privledges. If you're not sure, just select 'y'. + Allow Opers to join channels using a master key - ESNET + OPER_JOIN_GOD_ESNET + If you choose "yes", an OPER can join any channel writing + a master key "GOD". She can join through keys, invite, bans, and so on. + Useful to run local Channel Services. + + Allow Opers to join channels using a master key - ESNET + OPER_CHANNEL_SERVICE_ESNET + If you choose "yes", an OPER can set mode "+k" on himself. That is, + nobody will can kick or deop him. Useful to run local Channel Services. + + Local Channel Services has no Flood Control - ESNET + CS_NO_FLOOD_ESNET + If you choose "yes", a local channel service (user with mode +k) won't + have flood control. Useful if you are running local bots as ChServ. + + Allow Opers to bypass UWorld mode changes - ESNET + OPER_XMODE_ESNET + If you choose "yes", an oper can make channel mode changes + without being OP in that channel. He only need to include + the "extended mode" (flag "x") in his mode command. + + ESNET Distributed DataBase Support - ESNET + DB_ESNET + If you choose "yes", your server will can manage + ESNET Distributed DataBases. A "database" file will be + created in IRCd home directory to support nick + and channel registration, etc. + Allow local opers to use the REHASH command LOCOP_REHASH Allows a local operator (defined by a lowercase o:line in ircd.conf) *************** *** 913,918 **** --- 942,952 ---- then you should specify a 'y' here. If you specify a 'n' then the idle time will be nullified on all messages except the server PING/PONG. + + XMODE Networking - ESNET + XMODE_ESNET + This mode allows the use of "extended modes" in the network. + Extended modes can change channel modes without UWorld intervention. Check clone limit (2!) CHECK_CLONE_LIMIT diff -cr ../ircu2.10.05/include/msg.h ../ircu2.10.05+/include/msg.h *** ../ircu2.10.05/include/msg.h Tue Mar 16 16:03:29 1999 --- ../ircu2.10.05+/include/msg.h Tue Mar 16 16:48:59 1999 *************** *** 40,45 **** --- 40,51 ---- /* *INDENT-OFF* */ + #ifdef DB_ESNET + #define MSG_DB "DB" /* Base de Datos ESNET */ + #define TOK_DB "DB" + #define CLASS_DB LEVEL_PROPAGATE + #endif + #define MSG_PRIVATE "PRIVMSG" /* PRIV */ #define TOK_PRIVATE "P" #define CLASS_PRIVATE LEVEL_PROPAGATE diff -cr ../ircu2.10.05/include/numeric.h ../ircu2.10.05+/include/numeric.h *** ../ircu2.10.05/include/numeric.h Tue Mar 16 16:03:29 1999 --- ../ircu2.10.05+/include/numeric.h Tue Mar 16 16:48:59 1999 *************** *** 69,74 **** --- 69,77 ---- #define ERR_NONICKNAMEGIVEN 431 #define ERR_ERRONEUSNICKNAME 432 #define ERR_NICKNAMEINUSE 433 + #ifdef DB_ESNET + #define ERR_NICKREGISTERED ERR_NICKNAMEINUSE + #endif #define ERR_NICKCOLLISION 436 #define ERR_BANNICKCHANGE 437 /* Undernet extension */ #define ERR_NICKTOOFAST 438 /* Undernet extension */ diff -cr ../ircu2.10.05/include/s_serv.h ../ircu2.10.05+/include/s_serv.h *** ../ircu2.10.05/include/s_serv.h Tue Mar 16 16:03:29 1999 --- ../ircu2.10.05+/include/s_serv.h Tue Mar 16 17:03:34 1999 *************** *** 60,67 **** StatusMask(STAT_LOG)|\ StatusMask(STAT_CONNECTING)|\ StatusMask(STAT_HANDSHAKE)|\ ! StatusMask(STAT_ME)|\ ! StatusMask(STAT_SERVER))) #ifdef DEBUGMODE /* Coredump if we miss something... */ #define IsServer(x) ( ((x)->status == STAT_SERVER) && \ (((x)->serv) ? 1 : (*((char *) NULL) = 0)) ) --- 60,77 ---- StatusMask(STAT_LOG)|\ StatusMask(STAT_CONNECTING)|\ StatusMask(STAT_HANDSHAKE)|\ ! StatusMask(STAT_ME)|\ ! StatusMask(STAT_SERVER))) ! ! #ifdef DB_ESNET ! extern unsigned long db_num_serie_local; ! extern void tea(unsigned long v[],unsigned long k[],unsigned long x[]); ! extern void reload_db(void); ! extern void initdb(void); ! struct DB_nick *find_db_nick(char *nick); ! extern int m_db(aClient *cptr, aClient *sptr, int parc, char *parv[]); ! #endif ! #ifdef DEBUGMODE /* Coredump if we miss something... */ #define IsServer(x) ( ((x)->status == STAT_SERVER) && \ (((x)->serv) ? 1 : (*((char *) NULL) = 0)) ) diff -cr ../ircu2.10.05/include/s_user.h ../ircu2.10.05+/include/s_user.h *** ../ircu2.10.05/include/s_user.h Tue Mar 16 16:03:29 1999 --- ../ircu2.10.05+/include/s_user.h Tue Mar 16 16:53:42 1999 *************** *** 65,70 **** --- 65,73 ---- extern int is_snomask(char *); extern int check_target_limit(aClient *sptr, void *target, const char *name, int created); extern void add_target(aClient *sptr, void *target); + #ifdef DB_ESNET + extern unsigned int base64toint(const char *str); + #endif extern const char *inttobase64(unsigned int i); extern struct SLink *opsarray[]; diff -cr ../ircu2.10.05/include/struct.h ../ircu2.10.05+/include/struct.h *** ../ircu2.10.05/include/struct.h Tue Mar 16 16:03:29 1999 --- ../ircu2.10.05+/include/struct.h Tue Mar 16 16:56:35 1999 *************** *** 136,141 **** --- 136,144 ---- unsigned short int nn_mask; /* [Remote] FD_SETSIZE - 1 */ unsigned char last_x1; unsigned char last_x2; + #ifdef DB_ESNET + unsigned char esnet_db; + #endif #ifdef LIST_DEBUG struct Client *bcptr; #endif *************** *** 157,162 **** --- 160,171 ---- #ifdef LIST_DEBUG struct Client *bcptr; #endif + }; + + struct DB_nick { + char nick[8*((NICKLEN+8)/8)]; /* El +8 es para que siempre sea multiplo entero de 8 */ + unsigned long clave[2]; + struct DB_nick *siguiente; }; #endif /* STRUCT_H */ diff -cr ../ircu2.10.05/ircd/channel.c ../ircu2.10.05+/ircd/channel.c *** ../ircu2.10.05/ircd/channel.c Tue Mar 16 16:03:30 1999 --- ../ircu2.10.05+/ircd/channel.c Tue Mar 16 16:40:45 1999 *************** *** 1030,1035 **** --- 1030,1041 ---- char *bmbuf = bmodebuf, *bpbuf = bparambuf, *nbpbuf = nbparambuf; time_t newtime = (time_t) 0; aConfItem *aconf; + /* + ** Si somos IRCOPs y hemos puesto el flag X, podemos + ** fijar parametros pase lo que pase. + ** jcea@argo.es - 03/Feb/98 + */ + int jcea_xmode_esnet=0; *mbuf = *pbuf = *npbuf = *bmbuf = *bpbuf = *nbpbuf = '\0'; *badop = 0; *************** *** 1251,1256 **** --- 1257,1280 ---- if (whatt == MODE_DEL) while ((lp = chptr->invites)) del_invite(lp->value.cptr, chptr); + goto def; /* Porque insertamos codigo */ + #ifdef XMODE_ESNET + case 'x': + /* + ** Si somos IRCOPs y hemos puesto el flag X, podemos + ** fijar parametros pase lo que pase. + ** jcea@argo.es - 03/Feb/98 + */ + if(IsOper(sptr) + #ifndef OPER_XMODE_ESNET + && IsServer(cptr) + #endif + ) { + if(!is_chan_op(sptr,chptr)) jcea_xmode_esnet=!0; + break; + } + #endif + def: default: for (ip = flags; *ip; ip += 2) if (*(ip + 1) == *curr) *************** *** 1340,1346 **** } /* end of while loop for MODE processing */ /* Now reject non chan ops */ ! if (!IsServer(cptr) && (!tmp || !(tmp->flags & CHFL_CHANOP))) { *badop = 0; return (opcnt || newmode != mode->mode || limitset || keychange) ? 0 : -1; --- 1364,1376 ---- } /* end of while loop for MODE processing */ /* Now reject non chan ops */ ! ! /* ! ** Si somos IRCOPs y hemos puesto el flag X, podemos ! ** fijar parametros pase lo que pase. ! ** jcea@argo.es - 03/Feb/98 ! */ ! if (!jcea_xmode_esnet && !IsServer(cptr) && (!tmp || !(tmp->flags & CHFL_CHANOP))) { *badop = 0; return (opcnt || newmode != mode->mode || limitset || keychange) ? 0 : -1; *************** *** 1355,1360 **** --- 1385,1400 ---- bounce = (*badop == 1 || *badop == 2 || is_deopped(sptr, chptr)) ? 1 : 0; + /* + ** Si somos IRCOPs y hemos puesto el flag X, podemos + ** fijar parametros pase lo que pase. + ** jcea@argo.es - 03/Feb/98 + */ + if(jcea_xmode_esnet) { + bounce=0; + *mbuf++='x'; + } + whatt = 0; for (ip = flags; *ip; ip += 2) if ((*ip & newmode) && !(*ip & oldm.mode)) *************** *** 1949,1954 **** --- 1989,2009 ---- { Reg1 Link *lp; + + /* + ** Si somos IRCOPs y hemos puesto la clave GOD, podemos + ** entrar en el canal pase lo que pase. + ** jcea@argo.es - 26/03/97 + */ + + #ifdef OPER_JOIN_GOD_ESNET + if((IsOper(sptr)) && (!BadPtr(key)) && (!compall("GOD", key))) + return 0; + #endif + /* + */ + + /* Now a banned user CAN join if invited -- Nemesi */ /* Now a user CAN escape channel limit if invited -- bfriendly */ if ((chptr->mode.mode & MODE_INVITEONLY) || (is_banned(sptr, chptr, NULL) *************** *** 2304,2310 **** sendcreate = 1; } ! if (sptr->user->joined >= MAXCHANNELSPERUSER) { sendto_one(sptr, err_str(ERR_TOOMANYCHANNELS), me.name, parv[0], name); --- 2359,2365 ---- sendcreate = 1; } ! if (!IsChannelService(sptr) && (sptr->user->joined >= MAXCHANNELSPERUSER)) { sendto_one(sptr, err_str(ERR_TOOMANYCHANNELS), me.name, parv[0], name); diff -cr ../ircu2.10.05/ircd/ircd.c ../ircu2.10.05+/ircd/ircd.c *** ../ircu2.10.05/ircd/ircd.c Tue Mar 16 16:03:30 1999 --- ../ircu2.10.05+/ircd/ircd.c Tue Mar 16 17:10:13 1999 *************** *** 934,939 **** --- 934,942 ---- #ifdef USE_SYSLOG syslog(LOG_NOTICE, "Server Ready"); #endif + #ifdef DB_ESNET + initdb(); + #endif for (;;) { diff -cr ../ircu2.10.05/ircd/parse.c ../ircu2.10.05+/ircd/parse.c *** ../ircu2.10.05/ircd/parse.c Tue Mar 16 16:03:30 1999 --- ../ircu2.10.05+/ircd/parse.c Tue Mar 16 16:54:44 1999 *************** *** 119,124 **** --- 119,127 ---- #if defined(OPER_DIE) || defined(LOCOP_DIE) {CLASS_DIE, MSG_DIE, TOK_DIE, m_die, 0, MAXPARA, MFLG_SLOW, 0L}, #endif + #ifdef DB_ESNET + {CLASS_DB, MSG_DB, TOK_DB, m_db, 0, MAXPARA, MFLG_SLOW, 0L}, + #endif {0, (char *)0, (char *)0, (int (*)(aClient *, aClient *, int, char **))0, 0, 0, 0, 0L} } ; /* *INDENT-ON* */ diff -cr ../ircu2.10.05/ircd/s_bsd.c ../ircu2.10.05+/ircd/s_bsd.c *** ../ircu2.10.05/ircd/s_bsd.c Tue Mar 16 16:03:30 1999 --- ../ircu2.10.05+/ircd/s_bsd.c Tue Mar 16 17:03:34 1999 *************** *** 989,994 **** --- 989,997 ---- sendto_one(cptr, "SERVER %s 1 %lu %lu J%s %s :%s", my_name_for_link(me.name, aconf), me.serv->timestamp, newts, MAJOR_PROTOCOL, me.yxx, me.info); + #ifdef DB_ESNET + sendto_one(cptr,"%c DB * 0 J %lu",me.yxx[0],db_num_serie_local); + #endif if (!IsDead(cptr)) start_auth(cptr); *************** *** 1554,1566 **** return exit_client(cptr, cptr, &me, "dbuf_put fail"); #ifndef NOFLOODCONTROL ! if (IsUser(cptr) && DBufLength(&cptr->recvQ) > CLIENT_FLOOD) return exit_client(cptr, cptr, &me, "Excess Flood"); #endif while (DBufLength(&cptr->recvQ) && !NoNewLine(cptr) #ifndef NOFLOODCONTROL && (IsTrusted(cptr) || cptr->since - now < 10) #endif ) { --- 1557,1576 ---- return exit_client(cptr, cptr, &me, "dbuf_put fail"); #ifndef NOFLOODCONTROL ! if (IsUser(cptr) && DBufLength(&cptr->recvQ) > CLIENT_FLOOD ! #ifdef CS_NO_FLOOD_ESNET ! && !IsChannelService(cptr) ! #endif ! ) return exit_client(cptr, cptr, &me, "Excess Flood"); #endif while (DBufLength(&cptr->recvQ) && !NoNewLine(cptr) #ifndef NOFLOODCONTROL + #ifdef CS_NO_FLOOD_ESNET + && (IsChannelService(cptr) || cptr->since - now < 10) + #else && (IsTrusted(cptr) || cptr->since - now < 10) + #endif #endif ) { diff -cr ../ircu2.10.05/ircd/s_conf.c ../ircu2.10.05+/ircd/s_conf.c *** ../ircu2.10.05/ircd/s_conf.c Tue Mar 16 16:03:30 1999 --- ../ircu2.10.05+/ircd/s_conf.c Tue Mar 16 16:48:59 1999 *************** *** 644,649 **** --- 644,653 ---- if (sig == 1) sendto_ops("Got signal SIGHUP, reloading ircd conf. file"); + #ifdef DB_ESNET + reload_db(); + #endif + for (i = 0; i <= highest_fd; i++) if ((acptr = loc_clients[i]) && !IsMe(acptr)) { diff -cr ../ircu2.10.05/ircd/s_debug.c ../ircu2.10.05+/ircd/s_debug.c *** ../ircu2.10.05/ircd/s_debug.c Tue Mar 16 16:03:30 1999 --- ../ircu2.10.05+/ircd/s_debug.c Tue Mar 16 17:11:28 1999 *************** *** 158,163 **** --- 158,196 ---- #ifdef USE_SYSLOG 'Y', #endif + '.','E','S','N','E','T','.', + 'J','G', + #ifdef OPER_JOIN_GOD_ESNET + '+', + #else + '-', + #endif + 'C','S', + #ifdef OPER_CHANNEL_SERVICE_ESNET + '+', + #else + '-', + #endif + 'C','S','F','3', + #ifdef CS_NO_FLOOD_ESNET + '+', + #else + '-', + #endif + #ifdef XMODE_ESNET + 'X','M', + #ifdef OPER_XMODE_ESNET + '+', + #else + '-', + #endif + #endif + 'D','B','6', + #ifdef DB_ESNET + '+', + #else + '-', + #endif '\0' }; diff -cr ../ircu2.10.05/ircd/s_err.c ../ircu2.10.05+/ircd/s_err.c *** ../ircu2.10.05/ircd/s_err.c Tue Mar 16 16:03:30 1999 --- ../ircu2.10.05+/ircd/s_err.c Tue Mar 16 16:48:59 1999 *************** *** 128,134 **** --- 128,139 ---- /* 432 */ {ERR_ERRONEUSNICKNAME, "%s :Erroneus Nickname"}, /* 433 */ + #ifdef DB_ESNET + {ERR_NICKNAMEINUSE, "%s :Nickname is already in use or registered " + "(missing or wrong password)"}, + #else {ERR_NICKNAMEINUSE, "%s :Nickname is already in use."}, + #endif /* 434 */ {0, (char *)NULL}, /* 435 */ diff -cr ../ircu2.10.05/ircd/s_serv.c ../ircu2.10.05+/ircd/s_serv.c *** ../ircu2.10.05/ircd/s_serv.c Tue Mar 16 16:03:30 1999 --- ../ircu2.10.05+/ircd/s_serv.c Tue Mar 16 17:11:28 1999 *************** *** 23,28 **** --- 23,34 ---- #include "sys.h" #include + #ifdef DB_ESNET + #include + #include + #include + #include "common.h" + #endif #include "h.h" #include "struct.h" #include "ircd.h" *************** *** 713,718 **** --- 719,727 ---- cptr->serv->timestamp = timestamp; cptr->serv->prot = prot; cptr->serv->ghost = ghost; + #ifdef DB_ESNET + cptr->serv->esnet_db=0; /* De momento exigimos un BURST de la base de datos */ + #endif SetServerYXX(cptr, cptr, parv[6]); if (start_timestamp > 780000000) { *************** *** 799,804 **** --- 808,816 ---- my_name_for_link(me.name, aconf), me.serv->timestamp, cptr->serv->timestamp, MAJOR_PROTOCOL, me.yxx, (me.info[0]) ? (me.info) : "IRCers United"); + #ifdef DB_ESNET + sendto_one(cptr,"%c DB * 0 J %lu",me.yxx[0],db_num_serie_local); + #endif IPcheck_connect_fail(cptr); /* Don't charge this IP# for connecting */ } *************** *** 1108,1110 **** --- 1120,1528 ---- } return 0; } + + #ifdef DB_ESNET + + /* + * TEA (cifrado) + * + * Cifra 64 bits de datos, usando clave de 64 bits (los 64 bits superiores son cero) + * Se cifra v[0]^x[0], v[1]^x[1], para poder hacer CBC facilmente. + * + */ + void tea(unsigned long v[],unsigned long k[],unsigned long x[]) + { + unsigned long y=v[0]^x[0],z=v[1]^x[1],sum=0,delta=0x9E3779B9; + unsigned long a=k[0],b=k[1],n=32; + unsigned long c=0,d=0; + + while(n-->0) + { + sum += delta; + y += (z << 4)+a ^ z+sum ^ (z >> 5)+b; + z += (y << 4)+c ^ y+sum ^ (y >> 5)+d; + } + + x[0]=y; x[1]=z; + } + + /* + * leer_db + * + * Lee un registro de la base de datos. Si hay error, cierra el handle. + * + */ + int leer_db(int handle,char *buf) + { + int cont=0; + int estado; + + do { + alarm(3); + estado=read(handle,buf,1); + alarm(0); + if(estado!=1) { + close(handle); + *buf='\0'; + return estado; + } + cont++; + } while((*buf++!='\n') && (cont<500)); + *(--buf)='\0'; + return cont; + } + + /* + * abrir_db + * + * Se mueve hasta un registro de la base de datos + * + */ + int abrir_db(unsigned long registro,char *buf) + { + int handle; + int cont; + + *buf='\0'; + alarm(3); + handle=open("database", O_RDONLY, S_IRUSR | S_IWUSR); + alarm(0); + if(handle==-1) return 0; + do { + cont=leer_db(handle,buf); + if(cont==-1) { + *buf='\0'; + return 0; + } + } while(atol(buf)<=registro); + return handle; + } + + /* + ** El 0 es nuestra base de datos local + ** El 1 son los registros que no son nuestros, para poder compactar luego la DB. + */ + static struct DB_nick *nick_db[2]={NULL,NULL}; + unsigned long db_num_serie_local=0; + + /* + * db_manage_nick + * + * Escribe un registro nuevo, modifica uno existente o lo borra + * + */ + struct DB_nick *db_manage_nick(char *nick_,int offset,int borrar) + { + struct DB_nick *n,*n2=NULL; + char nick[512],*p=nick; + + while(*p++=tolower(*nick_++)); + + n=nick_db[offset]; + /* Busca el registro */ + while(n!=NULL) { + if(!strcmp(n->nick,nick)) break; + if(*(n->nick)=='\0') n2=n; + n=n->siguiente; + } + if(n!=NULL) { + memset(n->nick,0,sizeof(n->nick)); + if(!borrar) strcpy(n->nick,nick); + return n; + } + if(borrar) return NULL; + + /* + ** No existe el registro. Busco un hueco o pido uno nuevo + */ + if(n2!=NULL) { + memset(n2->nick,0,sizeof(n2->nick)); + strcpy(n2->nick,nick); + return n2; + } + n=(struct DB_nick *)RunMalloc(sizeof(struct DB_nick)); + if(n==NULL) { + sendto_ops("No hay memoria para un nuevo registro"); + return NULL; + } + memset(n,0,sizeof(struct DB_nick)); + strcpy(n->nick,nick); + n->siguiente=nick_db[offset]; + nick_db[offset]=n; + return n; + } + + /* + * db_alta + * + * Da de alta una entrada en la base de datos en memoria + * Formato "serie destino id clave contenido" + * + */ + void db_alta(char *registro) + { + char *p,*p2,*p3; + aClient *acptr; + int offset=0; + struct DB_nick *nick; + + p=strchr(registro,' '); + if(p==NULL) return; + p2=strchr(++p,' '); + if(p2==NULL) return; + db_num_serie_local=atol(registro); + + /* + * Guardamos en memoria AUNQUE no sea para nosotros, para poder hacer + * luego la compactacion de la base de datos. + * Si no es para nosotros, los ponemos en una cola aparte. + * + */ + *p2='\0'; + if(*p=='*') p=me.name; + acptr=find_match_server(p); + if((acptr==NULL) || !IsMe(acptr)) offset=1; + *p2++=' '; + p=strchr(p2,' '); + if(p==NULL) return; + p3=strchr(++p,' '); + if(p3!=NULL) *p3++='\0'; + + switch (*p2) { + case 'N': + if(p3==NULL) { /* Borrado */ + db_manage_nick(p,offset,!0); + return; + } + if(strlen(p3)<12) return; + nick=db_manage_nick(p,offset,0); + if(nick==NULL) return; + nick->clave[0]=base64toint(p3); + nick->clave[1]=base64toint(p3+6); + break; + } + + if(p3!=NULL) *(--p3)=' '; + return; + } + + /* + * initdb + * + * Lee la base de datos de disco + * + */ + void initdb(void) + { + char buf[1024]; + int handle; + + nick_db[0]=nick_db[1]=NULL; + db_num_serie_local=0; + if(!(handle=abrir_db(0,buf))) return; + do { + db_alta(buf); + } while(leer_db(handle,buf)!=-1); + return; + } + + /* + * borrar_db + * + * Borra la base de datos en memoria + * + */ + void borrar_db(void) + { + struct DB_nick *n,*n2; + + n=nick_db[0]; + while(n!=NULL) { + n2=n->siguiente; + RunFree(n); + n=n2; + } + + n=nick_db[1]; + while(n!=NULL) { + n2=n->siguiente; + RunFree(n); + n=n2; + } + nick_db[0]=nick_db[1]=NULL; + db_num_serie_local=0; + } + + /* + * reload_db + * + * Recarga la base de datos de disco, liberando la memoria + * + */ + void reload_db(void) + { + borrar_db(); + initdb(); + sendto_ops("Releyendo la base de datos. Ultimo registro: %lu",db_num_serie_local); + } + + /* + * find_db_nick + * + * Busca un nick en la base de datos + * + */ + struct DB_nick *find_db_nick(char *nick) + { + struct DB_nick *db_nick; + char n[512],*p=n; + + while(*p++=tolower(*nick++)); + + db_nick=nick_db[0]; + while(db_nick!=NULL) { + if(!strcmp(db_nick->nick,n)) break; + db_nick=db_nick->siguiente; + } + return db_nick; + } + + /* + * m_db + * + * Gestion de la base de datos - ESNET + * 29/May/98 jcea@argo.es + * + */ + int m_db(aClient *cptr, aClient *sptr, int parc, char *parv[]) + { + unsigned long db; + aClient *acptr; + Dlink *lp; + char db_buf[1024]; + int db_file; + + if(!IsServer(sptr) || parc<5) return 0; + db=atol(parv[2]); + if(!db) { + db=atol(parv[4]); + switch(*parv[3]) { + case 'B': + sendto_one(sptr,"%c DB %s 0 J %lu",me.yxx[0],parv[0],db_num_serie_local); + return 0; + break; + + case 'J': + { + char *p,*p2,*p3,*p4; + int cont=100; + + if(db>=db_num_serie_local) { /* Se le pueden mandar registros individuales */ + sptr->serv->esnet_db=!0; + return 0; + break; + } + db_file=abrir_db(db,db_buf); + if(db_file==0) return 0; /* Problemas con la DB */ + do { + p=strchr(db_buf,' '); + if(p==NULL) continue; + *p++='\0'; + p2=strchr(p,' '); + if(p2==NULL) continue; + *p2++='\0'; + p3=strchr(p2,' '); + if(p3==NULL) continue; + *p3++='\0'; + p4=strchr(p3,' '); + if(p4==NULL) { + sendto_one(sptr,"%c DB %s %s %s %s",me.yxx[0],p,db_buf,p2,p3); + } else { + *p4++='\0'; + sendto_one(sptr,"%c DB %s %s %s %s :%s",me.yxx[0],p,db_buf,p2,p3,p4); + } + if(!(--cont)) break; + } while(leer_db(db_file,db_buf)!=-1); + close(db_file); + if(cont) sptr->serv->esnet_db=!0; + else sendto_one(sptr,"%c DB %s 0 B %lu",me.yxx[0],parv[0],db_num_serie_local); + return 0; + break; + } + + case 'q': + if((acptr=find_match_server(parv[1]))&&(!IsMe(acptr))) + sendto_one(acptr,"%c DB %s 0 q %lu %s",NumServ(sptr), + acptr->name,db,parv[5]); + return 0; + break; + + case 'Q': + if(!(acptr = find_match_server(parv[1]))) { + sendto_one(sptr, err_str(ERR_NOSUCHSERVER), me.name, parv[0], parv[1]); + return 0; + } + + if(!IsMe(acptr)) { + sendto_one(acptr,"%c DB %s 0 Q %lu\n",NumServ(sptr),acptr->name,db); + return 0; + } + if(dbdown; lp; lp = lp->next) + { + if(!(lp->value.cptr->serv->esnet_db) || (lp->value.cptr==cptr)) continue; + sendto_one(lp->value.cptr,db_buf); + } + + db_num_serie_local=db; + + alarm(3); + db_file=open("database",O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR); + alarm(0); + + if(parc==5) + sprintf_irc(db_buf,"%lu %s %s %s\n",db,parv[1],parv[3],parv[4]); + else + sprintf_irc(db_buf,"%lu %s %s %s %s\n",db,parv[1],parv[3],parv[4],parv[5]); + + alarm(3); + write(db_file,db_buf,strlen(db_buf)); + alarm(0); + + close(db_file); + + return 0; + } + + #endif /* Base de Datos ESNET */ diff -cr ../ircu2.10.05/ircd/s_user.c ../ircu2.10.05+/ircd/s_user.c *** ../ircu2.10.05/ircd/s_user.c Tue Mar 16 16:03:30 1999 --- ../ircu2.10.05+/ircd/s_user.c Tue Mar 16 17:10:48 1999 *************** *** 454,460 **** --- 454,464 ---- IPcheck_connect_fail(sptr); return exit_client(cptr, sptr, &me, "Bad Password"); } + + #ifndef DB_ESNET memset(sptr->passwd, 0, sizeof(sptr->passwd)); + #endif + /* * following block for the benefit of time-dependent K:-lines */ *************** *** 709,715 **** /* *INDENT-ON* */ ! static unsigned int base64toint(const char *str) { register unsigned int i; i = convert2n[(unsigned char)str[5]]; --- 713,719 ---- /* *INDENT-ON* */ ! unsigned int base64toint(const char *str) { register unsigned int i; i = convert2n[(unsigned char)str[5]]; *************** *** 741,746 **** --- 745,751 ---- * * parv[0] = sender prefix * parv[1] = nickname + * parv[2] = clave (opcional) * * If from server, source is client: * parv[2] = timestamp *************** *** 758,763 **** --- 763,771 ---- */ int m_nick(aClient *cptr, aClient *sptr, int parc, char *parv[]) { + #ifdef DB_ESNET + struct DB_nick *nick_db=NULL; + #endif aClient *acptr, *server = NULL; char nick[NICKLEN + 2], *s; Link *lp; *************** *** 878,883 **** --- 886,895 ---- return exit_client(cptr, sptr, &me, "Nick/Server collision"); } + #ifdef DB_ESNET + if(!IsServer(cptr)) nick_db=find_db_nick(nick); + #endif + if (!(acptr = FindClient(nick))) goto nickkilldone; /* No collisions, all clear... */ /* *************** *** 1045,1050 **** --- 1057,1099 ---- return 0; nickkilldone: + + #ifdef DB_ESNET + /* + * Comprueba si el nick esta registrado, y si lo esta que se ponga la clave correcta + * + */ + if(nick_db) { /* El nick indicado esta registrado */ + unsigned long v[2],k[2],x[2]; + int cont=(NICKLEN+8)/8; + unsigned long *p=(unsigned long *)nick_db->nick; + + k[0]=k[1]=x[0]=x[1]=0; + if((parc>=3) && (strlen(parv[2])>=12)) { + k[0]=base64toint(parv[2]); + k[1]=base64toint(parv[2]+6); + } else { + k[0]=base64toint(cptr->passwd); + k[1]=base64toint(cptr->passwd+6); + } + while(cont--) { + v[0]=ntohl(*p++); + v[1]=ntohl(*p++); + tea(v,k,x); + } + + parc=3; /* Chanchullo !!OJO!! */ + + if(x[0]!=nick_db->clave[0] || x[1]!=nick_db->clave[1]) parc=0; + + if(parc<3) { + sendto_one(cptr,err_str(ERR_NICKREGISTERED), + me.name,parv[0],nick); + return 0; + } + } + #endif + if (IsServer(sptr)) { int flag, *s; *************** *** 1266,1271 **** --- 1315,1325 ---- register u_char *p; register u_int tmp = ((u_int)target & 0xffff00) >> 8; u_char hash = (tmp * tmp) >> 12; + + #ifdef CS_NO_FLOOD_ESNET + if(IsChannelService(sptr)) return 0; + #endif + if (sptr->targets[0] == hash) /* Same target as last time ? */ return 0; for (p = sptr->targets; p < &sptr->targets[MAXTARGETS - 1];) *************** *** 1855,1868 **** return 0; } - /* if the user is +k, prevent a kill from local user */ - if (IsChannelService(acptr) && MyUser(sptr)) - { - sendto_one(sptr, err_str(ERR_ISCHANSERVICE), me.name, - parv[0], "KILL", acptr->name); - return 0; - } - #ifdef LOCAL_KILL_ONLY if (MyConnect(sptr) && !MyConnect(acptr)) { --- 1909,1914 ---- *************** *** 2611,2617 **** det_confs_butmask(sptr, CONF_CLIENT & ~CONF_OPS); /* new umode; servers can set it, local users cannot; * prevents users from /kick'ing or /mode -o'ing */ ! if (!(setflags & FLAGS_CHSERV) && !IsServer(cptr)) sptr->flags &= ~FLAGS_CHSERV; /* * Compare new flags with old flags and send string which --- 2657,2672 ---- det_confs_butmask(sptr, CONF_CLIENT & ~CONF_OPS); /* new umode; servers can set it, local users cannot; * prevents users from /kick'ing or /mode -o'ing */ ! ! /* ! ** Si somos IRCOPs y hemos puesto el flag K, lo acepta. ! ** jcea@argo.es - 16/Dic/97 ! */ ! if (!(setflags & FLAGS_CHSERV) && !IsServer(cptr) ! #ifdef OPER_CHANNEL_SERVICE_ESNET ! && !IsOper(sptr) ! #endif ! ) sptr->flags &= ~FLAGS_CHSERV; /* * Compare new flags with old flags and send string which