Giriş

Orijinalini görmek için tıklayınız : IRCServices çoklu root eklentisi..


Return
10 Şubat 2015, 22:30
Bir zamanlar çok istenen bir özellik..
16.06.2007 tarihinde yapmıştım, ve yayınlamaya karar verdim.
kodlama : orta~zor
ekleme (edit) : kolay~orta

tek dosya içerisinde işlem yapıyoruz:

Aşama #0:
cd ircservices-xxx
cd modules
cd operserv
pico main.c

Aşama #1:

char * ServicesRoot;
bu kodu bulup "hemen altına" şu kodları ekleyin:


char **Sky_Roots_Char;
static int Sky_Roots_Int;
static int Sky_Realod=0;
Aşama #2:

static int introduce_operserv(const char *nick)
bu kodu bulup "hemen üstüne" şu kodları ekleyin:


void Root_Ayir(char *ServicesRoot_);
void Root_Ayir(char *ServicesRoot_) {
char *Sky_Temp=NULL;
Sky_Realod=1;
if (ServicesRoot_) {
Sky_Roots_Int = 0;
Sky_Temp = strtok(ServicesRoot_, " ");
do {
if (Sky_Temp) {
Sky_Roots_Int++;
Sky_Roots_Char = realloc(Sky_Roots_Char, sizeof(char *) * Sky_Roots_Int);
Sky_Roots_Char[Sky_Roots_Int - 1] = sstrdup(Sky_Temp);
}
}
while ((Sky_Temp = strtok(NULL, " ")));
}
if (!Sky_Roots_Int)
config_error("operserv/main", 0, "No Root NickName(s) Defined");
}
Aşama #3:

int is_services_root(User *u)
{
NickInfo *ni;
int rootid;
static int warned_ni = 0, warned_id = 0;
if (u->flags & UF_SERVROOT)
return 1;
if (!(ni = get_nickinfo(ServicesRoot))) {
if (!warned_ni) {
wallops(s_OperServ, "Warning: Services super-user nickname %s"
" is not registered", ServicesRoot);
warned_ni = 1;
}
module_log("warning: ServicesRoot nickname not registered");
return 0;
}
warned_ni = 0;
if (!(rootid = ni->nickgroup)) {
if (!warned_id) {
wallops(s_OperServ, "Warning: Services super-user nickname %s"
" is forbidden or not properly registered", ServicesRoot);
warned_id = 1;
}
module_log("warning: ServicesRoot nickname forbidden or registered"
" data corrupt");
return 0;
}
if (!is_oper(u) || !u->ni || u->ni->nickgroup != rootid)
return 0;
if (user_identified(u))
return 1;
return 0;
}
bu kodları silip yerine şu kodları ekleyin (7~8 yerde değişim olduğu için iş karışabilir, o yüzden eskiyi silip yeniyi ekleyin diyorum)


int is_services_root(User *u)
{
int i;
int ret=0;
NickInfo *ni;
int rootid;
static int warned_ni = 0, warned_id = 0;
if (u->flags & UF_SERVROOT)
return 1;
for (i = 0; i < Sky_Roots_Int; i++) {

if (!(ni = get_nickinfo(Sky_Roots_Char[i]))) {
// if (!warned_ni) {
wallops(s_OperServ, "Warning: Services super-user nickname %s"
" is not registered", Sky_Roots_Char[i]);
warned_ni = 1;
// }
module_log("warning: ServicesRoot nickname not registered");
continue;
}
// warned_ni = 0;
if (!(rootid = ni->nickgroup)) {
// if (!warned_id) {
wallops(s_OperServ, "Warning: Services super-user nickname %s"
" is forbidden or not properly registered", Sky_Roots_Char[i]);
// warned_id = 1;
// }
module_log("warning: ServicesRoot nickname forbidden or registered"
" data corrupt");
continue;
}
}
for (i = 0; i < Sky_Roots_Int; i++) {
if (!(ni = get_nickinfo(Sky_Roots_Char[i])))
continue;
if (!(rootid = ni->nickgroup))
continue;
if (!is_oper(u) || !u->ni || u->ni->nickgroup != rootid) {
ret=0;
}
else {
ret=1;
break;
}
}
if (ret && user_identified(u))
return 1;
return 0;
}
Aşama #4:

int nick_is_services_admin(NickInfo *ni)
{
NickGroupInfo *ngi;
if (!ni || !(ngi = get_ngi(ni)))
return 0;
if (stricmp(ni->nick, ServicesRoot) == 0)
return 1;
return ngi->os_priv >= NP_SERVADMIN;
}
bu kodları silip, yerine şu kodları ekleyin;


int nick_is_services_admin(NickInfo *ni)
{
int i;
NickGroupInfo *ngi;
if (!ni || !(ngi = get_ngi(ni)))
return 0;
for (i = 0; i < Sky_Roots_Int; i++)
if (stricmp(ni->nick, Sky_Roots_Char[i]) == 0)
return 1;
//if (stricmp(ni->nick, ServicesRoot) == 0)
//return 1;
return ngi->os_priv >= NP_SERVADMIN;
}
Aşama #5:

old_clearchan_sender_set = 1;
yukarıdaki kodu bulup, hemen altına şu kodları ekleyin;


if (Sky_Realod==0)
Root_Ayir(ServicesRoot);
make & make install çekip, servislerinizi yeniden başlatınız..

kodlar biraz karışık. Bu yüzden anlayamayabilirsiniz nerde ne yapıldığını.. ama kısaca özetlemek gerekir ise;
Root satırından gelen nick verisini, aradaki boşluklara göre ayırıp, array'e aktarıp, is_service_root vs. kısmında bu arraydeki nicklerin varlığı||yokluğu şeklinde bakıyoruz.. Varsa root diyoruz. Yok ise root değil diyoruz [Only Registered Users Can See Links]

moduels.conf unuzdaki Root satırınıza bilgi girerken;
ServicesRoot Nick1 Nick2
yukarıdaki şekilde DEĞİL;
ServicesRoot "Nick1 Nick2"
şeklinde girmeniz gerekiyor..

Kod yazarı: Sky-Dancer