Skip to content

feat: add sudo loop#1803

Merged
GideonBear merged 5 commits intotopgrade-rs:mainfrom
uwuclxdy:sudo-loop
Apr 5, 2026
Merged

feat: add sudo loop#1803
GideonBear merged 5 commits intotopgrade-rs:mainfrom
uwuclxdy:sudo-loop

Conversation

@uwuclxdy
Copy link
Copy Markdown
Contributor

@uwuclxdy uwuclxdy commented Feb 27, 2026

What does this PR do

Implements sudo loop in a background thread to avoid password re-prompts. Optionally enabled with --sudoloop and --sudoloop-interval [SECONDS] or via config.toml:

sudo_loop = true
sudo_loop_interval = 240

Standards checklist

  • The PR title is descriptive
  • I have read CONTRIBUTING.md
  • Optional: I have tested the code myself
  • If this PR introduces new user-facing messages they are translated

Fixes #1471

Comment thread src/sudo.rs
// going through a shell (which could be powershell) first.
// See: https://gerardog.github.io/gsudo/docs/usage
cmd.args(["-d", "cmd.exe", "/c", "rem"]);
// TODO: `gsudo cache on` starts a session with cached credentials and could replace the dummy `rem` invocation here when sudo_loop is enabled...

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
@uwuclxdy uwuclxdy changed the title draft: implement sudo loop feat: implement sudo loop Feb 27, 2026
barkleesanders added a commit to barkleesanders/topgrade that referenced this pull request Mar 8, 2026
From PR topgrade-rs#1803 by uwuclxdy.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Member

@GideonBear GideonBear left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits, looks great!

Comment thread src/execution_context.rs
Comment thread src/main.rs Outdated
Comment thread config.example.toml Outdated
@GideonBear
Copy link
Copy Markdown
Member

GideonBear commented Apr 5, 2026

I tested it with:

[commands]
"one" = "sudo echo start"
"two" = "sleep 960"
"three" = "sudo echo done"
cargo run -- --only custom_commands --custom-commands one --custom-commands two --custom-commands three
  • Without sudo-loop enabled: three asked for sudo password again
  • With sudo_loop = true: three didn't ask for sudo password 🎉

So it works

@uwuclxdy uwuclxdy marked this pull request as ready for review April 5, 2026 16:01
Comment thread config.example.toml
@GideonBear GideonBear changed the title feat: implement sudo loop feat: add sudo loop Apr 5, 2026
@GideonBear GideonBear merged commit 5b2a785 into topgrade-rs:main Apr 5, 2026
20 checks passed
@github-actions github-actions Bot mentioned this pull request Apr 5, 2026
@uwuclxdy uwuclxdy deleted the sudo-loop branch April 5, 2026 16:41
@github-actions github-actions Bot mentioned this pull request Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a "sudo loop"

3 participants