summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTest_User <hax@andrewyu.org>2024-03-19 07:42:33 -0400
committerTest_User <hax@andrewyu.org>2024-03-19 07:42:33 -0400
commit44831804778fc0da07cb918dccc9474174d1304a (patch)
tree5aa6de2ba6fb057667f982099738e092670433f1
parent659f0d647ca27d03815e799f74e1023fa5f3bc25 (diff)
downloadcoupserv-44831804778fc0da07cb918dccc9474174d1304a.tar.gz
coupserv-44831804778fc0da07cb918dccc9474174d1304a.zip
make local_only work properly, ensure +k doesn't cause squits
-rw-r--r--client_network.c26
-rw-r--r--commands.c2
-rw-r--r--server_network.c10
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;
}