mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-10 06:03:13 +02:00
Add warning when rpc-user::rpc-class is missing. Add default 'full' and 'read-only'.
The reason for the warning is that in some future UnrealIRCd version I want the
rpc-user::rpc-class to become a required item.
This commit also adds rpc-class.default.conf which is by default
included from rpc.modules.default.conf.
This also completes the TODO list from b9de933378
(the rpc.add_timer was never a loophole and i kept rpc.info as-is)
This commit is contained in:
+33
-1
@@ -371,7 +371,7 @@ static int valid_rpc_user_name(const char *str)
|
||||
int rpc_config_test_rpc_user(ConfigFile *cf, ConfigEntry *ce, int type, int *errs)
|
||||
{
|
||||
int errors = 0;
|
||||
char has_match = 1, has_password = 1;
|
||||
char has_match = 0, has_password = 0, has_rpc_class = 0;
|
||||
ConfigEntry *cep;
|
||||
|
||||
/* We are only interested in rpc-user { } */
|
||||
@@ -409,6 +409,7 @@ int rpc_config_test_rpc_user(ConfigFile *cf, ConfigEntry *ce, int type, int *err
|
||||
} else
|
||||
if (!strcmp(cep->name, "rpc-class"))
|
||||
{
|
||||
has_rpc_class = 1;
|
||||
if (!cep->value)
|
||||
{
|
||||
config_error_empty(cep->file->filename,
|
||||
@@ -423,6 +424,30 @@ int rpc_config_test_rpc_user(ConfigFile *cf, ConfigEntry *ce, int type, int *err
|
||||
}
|
||||
}
|
||||
|
||||
if (!has_match)
|
||||
{
|
||||
config_error_missing(ce->file->filename, ce->line_number,
|
||||
"rpc-user::mask");
|
||||
errors++;
|
||||
}
|
||||
|
||||
if (!has_password)
|
||||
{
|
||||
config_error_missing(ce->file->filename, ce->line_number,
|
||||
"rpc-user::password");
|
||||
errors++;
|
||||
}
|
||||
|
||||
if (!has_rpc_class)
|
||||
{
|
||||
config_warn("%s:%d: rpc-user block should have a ::rpc-class item to indicate "
|
||||
"the permissions, like: rpc-user %s { rpc-class full; ....etc.... }",
|
||||
ce->file->filename, ce->line_number, ce->value);
|
||||
config_warn("See https://www.unrealircd.org/docs/Rpc-user_block. For now, this "
|
||||
"is a warning and we assume you want rpc-class 'full', but in later "
|
||||
"versions this will become an error.");
|
||||
}
|
||||
|
||||
*errs = errors;
|
||||
return errors ? -1 : 1;
|
||||
}
|
||||
@@ -606,6 +631,13 @@ OperPermission ValidatePermissionsForJSONRPC(const char *path, Client *client)
|
||||
if (r->rpc_class == NULL)
|
||||
return OPER_ALLOW;
|
||||
|
||||
/* The 'full' is a virtual rpc-class, actually. So we can do a shortcut.
|
||||
* We have a clear (triple) warning about this in operclass.default.conf
|
||||
* that you should not fiddle with build-in classes so this should be OK.
|
||||
*/
|
||||
if (!strcmp(r->rpc_class, "full"))
|
||||
return OPER_ALLOW;
|
||||
|
||||
ce_operClass = find_rpc_class(r->rpc_class);
|
||||
if (!ce_operClass)
|
||||
return OPER_DENY;
|
||||
|
||||
Reference in New Issue
Block a user