diff options
-rw-r--r-- | src/InspIRCd.layout | 30 | ||||
-rw-r--r-- | src/commands.cpp | 1 | ||||
-rw-r--r-- | src/inspircd.cpp | 7 | ||||
-rw-r--r-- | src/users.cpp | 62 | ||||
-rwxr-xr-x | src/version.sh | 2 |
5 files changed, 85 insertions, 17 deletions
diff --git a/src/InspIRCd.layout b/src/InspIRCd.layout index 2ba69f876..06ccc0a28 100644 --- a/src/InspIRCd.layout +++ b/src/InspIRCd.layout @@ -1,5 +1,5 @@ [Editors] -Focused=-1 +Focused=6 Order=2,4,6,3,7,25,5,24,39,42,43,-1,1,46,0,49 [Editor_0] @@ -13,9 +13,9 @@ LeftChar=1 [Editor_1] Open=1 Top=0 -CursorCol=26 -CursorRow=90 -TopLine=131 +CursorCol=2 +CursorRow=211 +TopLine=180 LeftChar=1 [Editor_2] @@ -52,10 +52,10 @@ LeftChar=1 [Editor_6] Open=1 -Top=0 -CursorCol=16 -CursorRow=17 -TopLine=38 +Top=1 +CursorCol=24 +CursorRow=140 +TopLine=94 LeftChar=1 [Editor_7] @@ -181,14 +181,14 @@ LeftChar=1 [Editor_22] Open=1 Top=0 -CursorCol=34 -CursorRow=78 -TopLine=51 +CursorCol=1 +CursorRow=182 +TopLine=92 LeftChar=1 [Editor_23] Open=1 -Top=1 +Top=0 CursorCol=1 CursorRow=69 TopLine=14 @@ -330,9 +330,9 @@ LeftChar=1 [Editor_43] Open=1 Top=0 -CursorCol=34 -CursorRow=1536 -TopLine=1498 +CursorCol=1 +CursorRow=86 +TopLine=49 LeftChar=1 [Editor_44] Open=1 diff --git a/src/commands.cpp b/src/commands.cpp index a9bf10699..c280d0699 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1337,6 +1337,7 @@ void handle_oper(char **parameters, int pcnt, userrec *user) /* found this oper's opertype */ ConfValue("type","host",j,Hostname,&config_f); ChangeDisplayedHost(user,Hostname); + strncpy(user->oper,TypeName,NICKMAX); } } if (!strchr(user->modes,'o')) diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 6a8b85348..f313c64c7 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -2739,6 +2739,13 @@ void process_command(userrec *user, char* cmd) cmd_found = 1; return; } + if ((cmdlist[i].flags_needed) && (!user->HasPermission(command))) + { + log(DEBUG,"process_command: permission denied: %s %s",user->nick,command); + WriteServ(user->fd,"481 %s :Permission Denied- Oper type %s does not have access to command %s",user->nick,user->oper,command); + cmd_found = 1; + return; + } /* if the command isnt USER, PASS, or NICK, and nick is empty, * deny command! */ if ((strncmp(command,"USER",4)) && (strncmp(command,"NICK",4)) && (strncmp(command,"PASS",4))) diff --git a/src/users.cpp b/src/users.cpp index 6fb0e6a5c..b523033ba 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -1,5 +1,5 @@ /* - +Manages userrec objects */ #include "inspircd_config.h" @@ -8,6 +8,8 @@ #include "inspircd.h" #include <stdio.h> +extern std::stringstream config_f; + userrec::userrec() { // the PROPER way to do it, AVOID bzero at *ALL* costs @@ -91,3 +93,61 @@ void userrec::RemoveInvite(char* channel) } } } + +bool userrec::HasPermission(char* command) +{ + char TypeName[MAXBUF],Classes[MAXBUF],ClassName[MAXBUF],CommandList[MAXBUF]; + char* myclass; + char* mycmd; + char* savept; + char* savept2; + + // are they even an oper at all? + if (strchr(this->modes,'o')) + { + log(DEBUG,"*** HasPermission: %s is an oper",this->nick); + for (int j =0; j < ConfValueEnum("type",&config_f); j++) + { + ConfValue("type","name",j,TypeName,&config_f); + if (!strcmp(TypeName,this->oper)) + { + log(DEBUG,"*** HasPermission: %s is an oper of type '%s'",this->nick,this->oper); + ConfValue("type","classes",j,Classes,&config_f); + char* myclass = strtok_r(Classes," ",&savept); + //myclass = savept; + while (myclass) + { + log(DEBUG,"*** HasPermission: checking classtype '%s'",myclass); + for (int k =0; k < ConfValueEnum("class",&config_f); k++) + { + ConfValue("class","name",k,ClassName,&config_f); + if (!strcmp(ClassName,myclass)) + { + ConfValue("class","commands",k,CommandList,&config_f); + log(DEBUG,"*** HasPermission: found class named %s with commands: '%s'",ClassName,CommandList); + + + mycmd = strtok_r(CommandList," ",&savept2); + //mycmd = savept2; + while (mycmd) + { + if (!strcasecmp(mycmd,command)) + { + log(DEBUG,"*** Command %s found, returning true",command); + return true; + } + mycmd = strtok_r(NULL," ",&savept2); + //mycmd = savept2; + } + } + } + myclass = strtok_r(NULL," ",&savept); + //myclass = savept; + } + } + } + } + return false; +} + + diff --git a/src/version.sh b/src/version.sh index b11ea3fef..7677c1baa 100755 --- a/src/version.sh +++ b/src/version.sh @@ -1,2 +1,2 @@ #!sh -echo "InspIRCd-1.0[Alpha11]" +echo "InspIRCd-1.0[Alpha12]" |