Skip to content

Commit bf8365c

Browse files
committed
Merge branches 'main' and 'main' of github.com:allthingslinux/tux
2 parents d2e2249 + 566b2ec commit bf8365c

File tree

4 files changed

+49
-5
lines changed

4 files changed

+49
-5
lines changed

config/settings.yml.example

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,29 @@ BOT_INFO:
3434
{"type": "streaming", "name": "SuperTuxKart", "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"}
3535
]
3636

37+
# This allows sysadmins to use the eval and jsk commands which can execute arbitrary code.
38+
# Do enable if:
39+
# - Tux is dockerized
40+
# - You trust your sysadmins with anything that the docker container can do (e.g if they already can access the host system)
41+
# - You are a small server
42+
# DO NOT ENABLE IF:
43+
# - Tux is not dockerized and you do not trust your sysadmins with the host system
44+
# - You are a large server and Tux has full permissions
45+
# - You do not trust your sysadmins with anything that the docker container can do
46+
# - IF YOU ARE A MULTIPLE SERVER INSTANCE, DO NOT ENABLE IT FOR THE LOVE OF GOD
47+
# If you are not sure, do not enable this.
48+
ALLOW_SYSADMINS_EVAL: false
3749

3850
USER_IDS:
39-
SYSADMINS: # WARNING! This grants dangerous permissions such as eval and jsk which can be used to execute arbitrary code.
51+
# These have access to all permissions in all servers, except for $eval and $jsk commands (unless set to true).
52+
# Only give these to people you trust with the bot and who are able to handle the responsibilities that come with it.
53+
SYSADMINS:
4054
- 123456789012345679
4155
- 123456789012345679
42-
BOT_OWNER: 123456789012345679 # This is the user who has the highest level of control over the bot. Only one user can be the bot owner.
56+
57+
# This should be the person who owns the bot and nobody else unless you ABSOLUTELY know what you are doing.
58+
# This person has access to all permissions in all servers, including $eval and $jsk commands.
59+
BOT_OWNER: 123456789012345679
4360

4461
# This adds a temporary voice channel feature to the bot, you can join the channel to create a channel called /tmp/<username> and move to it.
4562
# Channels are deleted when the last person leaves them.

tux/app.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,24 @@ async def start(self) -> None:
105105
if not self.validate_config():
106106
return
107107

108+
owner_ids = {CONFIG.BOT_OWNER_ID}
109+
if CONFIG.ALLOW_SYSADMINS_EVAL:
110+
logger.warning(
111+
"Sysadmins are allowed to use eval commands. This can be potentially dangerous if you have not fully read the comments about this in settings.yml.",
112+
)
113+
owner_ids.update(CONFIG.SYSADMIN_IDS)
114+
else:
115+
logger.warning(
116+
"Sysadmins are not allowed to use eval commands. Read settings.yml for more info on this. You can safely ignore this warning if you are not a sysadmin.",
117+
)
118+
108119
self.bot = Tux(
109120
command_prefix=get_prefix,
110121
strip_after_prefix=True,
111122
case_insensitive=True,
112123
intents=discord.Intents.all(),
113-
owner_ids={CONFIG.BOT_OWNER_ID, *CONFIG.SYSADMIN_IDS},
124+
# owner_ids={CONFIG.BOT_OWNER_ID, *CONFIG.SYSADMIN_IDS},
125+
owner_ids=owner_ids,
114126
allowed_mentions=discord.AllowedMentions(everyone=False),
115127
help_command=TuxHelp(),
116128
activity=None,

tux/cogs/admin/eval.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from tux.bot import Tux
88
from tux.ui.embeds import EmbedCreator
99
from tux.utils import checks
10+
from tux.utils.config import CONFIG
1011
from tux.utils.functions import generate_usage
1112

1213

@@ -70,10 +71,23 @@ async def eval(self, ctx: commands.Context[Tux], *, expression: str) -> None:
7071
return
7172

7273
if ctx.author.id not in self.bot.owner_ids:
74+
if not CONFIG.ALLOW_SYSADMINS_EVAL and ctx.author.id in CONFIG.SYSADMIN_IDS:
75+
logger.warning(
76+
f"{ctx.author} tried to run eval but is not the bot owner. (User ID: {ctx.author.id})",
77+
)
78+
await ctx.send(
79+
"You are not the bot owner and sysadmins are not allowed to use eval. Please contact your bot owner if you need assistance.",
80+
delete_after=30,
81+
)
82+
return
83+
7384
logger.warning(
74-
f"{ctx.author} tried to run eval but is not the bot owner. (User ID: {ctx.author.id})",
85+
f"{ctx.author} tried to run eval but is not the bot owner or sysadmin. (User ID: {ctx.author.id})",
86+
)
87+
await ctx.send(
88+
"You are not the bot owner. Better luck next time! (hint: if you are looking for the regular run command its $run)",
89+
delete_after=30,
7590
)
76-
await ctx.send("You are not the bot owner. Better luck next time!", ephemeral=True, delete_after=30)
7791
return
7892

7993
try:

tux/utils/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class Config:
4040
# Permissions
4141
BOT_OWNER_ID: Final[int] = config["USER_IDS"]["BOT_OWNER"]
4242
SYSADMIN_IDS: Final[list[int]] = config["USER_IDS"]["SYSADMINS"]
43+
ALLOW_SYSADMINS_EVAL: Final[bool] = config["ALLOW_SYSADMINS_EVAL"]
4344

4445
# Production env
4546
DEFAULT_PROD_PREFIX: Final[str] = config["BOT_INFO"]["PROD_PREFIX"]

0 commit comments

Comments
 (0)