From 44831804778fc0da07cb918dccc9474174d1304a Mon Sep 17 00:00:00 2001 From: Test_User Date: Tue, 19 Mar 2024 07:42:33 -0400 Subject: make local_only work properly, ensure +k doesn't cause squits --- client_network.c | 26 +++++++++++--------------- commands.c | 2 +- server_network.c | 10 +++++++++- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/client_network.c b/client_network.c index f786ac6..90a406a 100644 --- a/client_network.c +++ b/client_network.c @@ -134,6 +134,8 @@ int add_local_client(struct string uid, struct string nick_arg, struct string vh set_table_index(&user_list, uid, user); + SEND(STRING("GLOADMODULE m_servprotect\n")); // required for the +k we're about to use + char string_time[21]; snprintf(string_time, 21, "%ld", timestamp); SEND(STRING("UID ")); @@ -462,23 +464,17 @@ int client_privmsg_handler(uint64_t argc, struct string *argv) { argv[1].len -= old_offset; struct command_def *cmd = get_table_index(user_commands, command_argv[0]); if (cmd) { - if (!cmd->local_only) { - struct string message[] = { - STRING("Local user "), - client_nick, - STRING(" executes `"), - argv[1], - STRING("'\n"), - }; + struct string message[] = { + STRING("Local user "), + client_nick, + STRING(" executes `"), + argv[1], + STRING("'\n"), + }; - privmsg(STRING("1HC000000"), log_channel, sizeof(message)/sizeof(*message), message); + privmsg(STRING("1HC000000"), log_channel, sizeof(message)/sizeof(*message), message); - return cmd->func(STRING("1HC000001"), argv[1], argv[0], command_argc, command_argv, 1); - } else { - // TODO: complain about remote access - WRITES(1, STRING("Not executing local-only command from a remote source!\n")); - return 0; - } + return cmd->func(STRING("1HC000001"), argv[1], argv[0], command_argc, command_argv, 1); } else { if (argv[0].data[0] == '#') { SEND(STRING(":1HC000000 NOTICE ")); diff --git a/commands.c b/commands.c index 4ac9b98..0266b0b 100644 --- a/commands.c +++ b/commands.c @@ -303,7 +303,7 @@ int sh_command(struct string sender, struct string original_message, struct stri static struct command_def sh_command_def = { .func = sh_command, .privs = STRING("NetAdmin"), - .local_only = 0, + .local_only = 1, .summary = STRING("Executes a command locally"), }; diff --git a/server_network.c b/server_network.c index c04bb22..062c9d5 100644 --- a/server_network.c +++ b/server_network.c @@ -375,6 +375,8 @@ int kill_handler(struct string sender, uint64_t argc, struct string *argv) { return 0; // TODO: Currently not all local users are considered; fix that, then make this give an error if (STRING_EQ(user->server, STRING("1HC"))) { + SEND(STRING("GLOADMODULE m_servprotect\n")); // required for the +k we're about to use + char user_time[21]; snprintf(user_time, 21, "%ld", user->user_ts); char nick_time[21]; @@ -776,7 +778,13 @@ int privmsg_handler(struct string sender, uint64_t argc, struct string *argv) { return cmd->func(sender, argv[1], argv[0], command_argc, command_argv, 0); } else { - // TODO: complain about remote access + SEND(STRING(":1HC000000 NOTICE ")); + if (argv[0].data[0] == '#') + SEND(argv[0]); + else + SEND(sender); + SEND(STRING(" :You are not authorized to execute this command.\n")); + WRITES(1, STRING("Not executing local-only command from a remote source!\n")); return 0; } -- cgit v1.2.3