[Core] Add su and unsu and sudo <command> commands to bot #3999
Labels
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Mrcoolgamer11/Red-DiscordBot!3999
Loading…
Reference in a new issue
No description provided.
Delete branch "sudo"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Type
Description of the changes
This PR does a couple of things.
[p]suwhich allows a bot owner to elevate themselves to currently bot owner level.[p]unsuwhich allows a bot owner to delavate their permissions back to a standard user[p]suand[p]unsualways avaliable to bot owners.[p]suis runSo theres a couple of things that can be done/changed here.
The reasoning behind this PR is that bot owners should not have elevated permissions by default and should only elevate themselves when needed (for example a user will need to run
sudoon terminal to elevate their shell, and even here after a period of time the user will need to reelevate themselves).I would appreciate any feedback on behaviour and discussion on default behaviour introduced by this PR.
resolves #3598
I feel as if the owners should have the elevated privileges by default. A lot of users may only host for their needs and this would hinder their setup, maybe a flag to have it off by default?
Personally, if I think the default should be unelevated for Team Tokens. If the bot is being run with just a single owner, it should default to elevated. If Co-Owners are used, maybe elevate the Token owner and unelevate the co-owners by default?
The idea of being able to "unsudo" is nice though, save us from having to always test stuff with an alt
We could put a recommendation to enable this functionality somewhere in our docs, but I really don't think we should make this a default. I also think that status-quo wins by default so IMO we would need very good reasons to change the current default behavior and they imo would need to outweight the reasons for the current behavior.
For one, we have a lot of less-knowledgeable users and this is yet another obstacle thrown at them.
I personally also don't think that
[p]sudoactually necessarily has to make that much sense if your bot is in one (or few) servers. In these cases, I would be quite surprised if the person owning the bot isn't at least a very trusted mod (since mods don't have perms to add bots) and I would assume that usually they might be even admins or guild owners. Adding[p]sudoas default makes the management of the bot harder by default and considering that currently this is discussed as a cli flag, it would require the user to always put additional flags when running the bot if they want to disable this. Truth to be told, they should be running auto-restart service, but there might be some less or more valid reasons why they don't.Last but not least, while the point of what should be the default is debatable, there definitely needs to be a way that allows you to (depending on what will be chosen by default) enable/disable this functionality.
From other things:
sudodefinitely makes sense for us, but it might not be the most user-friendly for people that aren't familiar with UnixI agree with what jack said. I believe this is a cool feature but the default shouldn't be changed.
As for names of the commands...
I think a "ownermode" setting would make more sense to users that are unfamiliar with unix.
This could either be made part of
[p]setthough this time contrary to the proposed audio changes I'd agree to having them as standalone command. Maybe[p]ownermode enableand[p]ownermode disable? Potentially a book converter instead of seperate commands.I don't have anything specific against the
ownermodename in itself, but one thing to note here is that it might be a little bit long considering that owner will need to run it whenever they want to use some owner-only command (though only once within the set timeout). It is not hard to add an alias though so I guess it wouldn't necessarily be that problematic.Added
[p]sudotimerwhich will allow bot owners to set a time so that the sudo priviledges auto expire.Added the
--enable-sudocli.I think
[p]set sudotimer(or[p]set sudotimeout) would make more sense hereBy putting this here, you moved the help formatter line a little more below the comment about it
This can be enabled more elegantly with a kwarg to is_owner check based on my own use of similar in the past.
I don't know what's the view of org members on this functionality, so I wouldn't be able to approve this either way, but here's a code review.
From things not included in review comments:
sudo/unsudo? I do like these names myself, but as mentioned earlier, there could be better choices we (mostly you and I, I guess) didn't think ofnitpick,
_AlwaysAvailableMixinis an unneeded subclass here.This might make more sense as a cancellable task - currently using
[p]sudo,[p]unsudoafter 5 minutes, and[p]sudoright after will lead to "sudo time" being shorter by 5 minutes.Why remove dot here?
So in theory this is ready to merge, although @TrustyJAID asked for the sudo command to accept commands, this would make it so it runs a singular command as sudo, and then it would auto remove sudo from you after, this needs to be looked into further before it is properly implemented.
@ -193,0 +197,4 @@if "owner_id" in kwargs:raise RuntimeError("Red doesn't accept owner_id kwarg, use owner_ids instead.")So adding the optional arg is gonna be far more painful than antecipated, since this PR is not dependent on it i would suggest we leave that for a follow up PR and keep this PR as it is.
Keeping this one open as jack spent a lot of time on it already.
Pull request closed