void dotrustdenydel(long unum, char *tail) { int res; char tmps2[TMPSSIZE], tmps3[TMPSSIZE]; long i; trustdeny * td; unsigned long snet, smask; res=sscanf(tail,"%s %s",tmps2,tmps3); if (res<2) { msgtouser(unum,"Syntax: trustdenydel subnet/[netmask]"); msgtouser(unum,"if netmask is omitted, then /32 (a single IP) is assumed."); return; } if (!ischarinstr('/',tmps3)) { smask=32; snet=parseipv4(tmps3); } else { char h1[TMPSSIZE]; char h2[TMPSSIZE]; char dumc; int r2; r2=sscanf(tmps3,"%[0-9.]%c%[0-9]",h1,&dumc,h2); if (r2!=3) { msgtouser(unum,"Invalid subnetmask."); return; } snet=parseipv4(h1); smask=strtoul(h2,NULL,10); if (smask>32) { msgtouser(unum,"Invalid subnetmask."); return; } } td=(trustdeny *)deniedtrusts.content; for (i=0;i<deniedtrusts.cursi;i++) { if ((td[i].v4net==snet) && (td[i].v4mask==smask)) { array_delslot(&deniedtrusts,i); msgtouser(unum,"trustdeny removed."); return; } } msgtouser(unum,"No such trustdeny"); }
int rmmod(char *modulename, int close) { int i,j; module *mods; struct module_dep *mdp; char modulebuf[1024]; strlcpy(modulebuf, modulename, sizeof(modulebuf)); delchars(modulebuf,"./\\;"); i=getindex(modulebuf); if (i<0) return 1; if ((mdp=getmoduledep(modulebuf))) { for (j=0;j<mdp->numchildren;j++) { if (isloaded(mdp->children[j]->name->content)) { if (rmmod(mdp->children[j]->name->content, close)) { Error("core",ERR_WARNING,"Unable to remove child module %s (depends on %s)", mdp->children[j]->name->content, modulebuf); return 1; } } } /* We may have removed other modules - reaquire the index number in case it has changed. */ i=getindex(modulebuf); if (i<0) return 1; } else { Error("core",ERR_WARNING,"Removing module %s without dependency information",modulebuf); } mods=(module *)(modules.content); if (!close #ifdef BROKEN_DLCLOSE || 1 #endif ) { void (*fini)(); fini = dlsym(mods[i].handle, "__fini"); if(!dlerror()) fini(); } else dlclose(mods[i].handle); freesstring(mods[i].name); array_delslot(&modules,i); Error("core",ERR_INFO,"Removed module %s.",modulebuf); return 0; }
void sp_deletesplit(const char *name) { int i; if (splitlist.cursi == 0) return; for (i = splitlist.cursi - 1; i >= 0; i--) { if (strcmp(name, ((splitserver*)splitlist.content)[i].name->content) == 0) { freesstring(((splitserver*)splitlist.content)[i].name); array_delslot(&splitlist, i); } } }
int insmod(char *modulename) { int i; module *mods; char buf[1024], modulebuf[1024]; const char *(*verinfo)(const char **); struct module_dep *mdp; strlcpy(modulebuf, modulename, sizeof(modulebuf)); delchars(modulebuf,"./\\;"); if (isloaded(modulebuf)) { Error("core",ERR_DEBUG,"Tried to load already loaded module: %s",modulebuf); return 1; } if (strlen(modulebuf)>100) { Error("core",ERR_WARNING,"Module name too long: %s",modulebuf); return 1; } if ((mdp=getmoduledep(modulebuf))) { for (i=0;i<mdp->numparents;i++) { if (!isloaded(mdp->parents[i]->name->content)) { if (insmod(mdp->parents[i]->name->content)) { Error("core",ERR_WARNING,"Error loading dependant module %s (needed by %s)", mdp->parents[i]->name->content,modulebuf); return 1; } } } } else { Error("core",ERR_WARNING,"Loading module %s without dependency information.",modulebuf); } i=array_getfreeslot(&modules); mods=(module *)(modules.content); sprintf(buf,"%s/%s%s",moddir->content,modulebuf,modsuffix->content); mods[i].handle=dlopen(buf,RTLD_NOW|RTLD_GLOBAL); if(mods[i].handle==NULL) { Error("core",ERR_ERROR,"Loading module %s failed: %s",modulebuf,dlerror()); array_delslot(&modules,i); return -1; } mods[i].name=getsstring(modulebuf,MODULENAMELEN); verinfo=dlsym(mods[i].handle,"_version"); if(verinfo) { mods[i].buildid=verinfo(&mods[i].version); } else { mods[i].version=NULL; mods[i].buildid=NULL; } mods[i].loadedsince = time(NULL); Error("core",ERR_INFO,"Loaded module %s OK.",modulebuf); return 0; }