-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Execute commands using a pseudoterminal #235
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #235 +/- ##
==========================================
- Coverage 77.37% 74.83% -2.55%
==========================================
Files 38 40 +2
Lines 4738 4903 +165
==========================================
+ Hits 3666 3669 +3
- Misses 1072 1234 +162
☔ View full report in Codecov by Sentry. |
6566386
to
29495ca
Compare
Closed
Closed
This replaces the old behavior based around `exec_nopty` and uses `exec_pty` instead. The rough logic described in `man sudo` is implemented but some details are missing: 1. Allocate a new pseudoterminal 2. Create a monitor process 3. Create a new terminal session with the monitor as the leader and the follower end of the pseudoterminal as the controlling terminal. 4. Spawn the command from the monitor. 5. Relay signals between sudo and the monitor and between the monitor and the command. 6. Propagate the exit status of the command to sudo.
(the 'wait' calls are guaranteed to exit when we get SIGCHLD)
Number of dependencies and binary size impact report
Dependencies diff └─ sudo [v0.1.0-alpha.1]
├─ sudo-cli [v0.1.0-alpha.1]
- | └─ clap [v4.2.7]
- | ├─ clap_builder [v4.2.7]
- | | ├─ anstream [v0.3.2]
- | | | ├─ anstyle [v1.0.0]
- | | | ├─ anstyle-parse [v0.2.0]
- | | | | └─ utf8parse [v0.2.1]
- | | | ├─ anstyle-query [v1.0.0]
- | | | ├─ colorchoice [v1.0.0]
- | | | ├─ is-terminal [v0.4.7]
- | | | | ├─ io-lifetimes [v1.0.10]
- | | | | | └─ libc [v0.2.144]
- | | | | └─ rustix [v0.37.19]
- | | | | ├─ bitflags [v1.3.2]
- | | | | ├─ io-lifetimes [v1.0.10]
- | | | | ├─ libc [v0.2.144]
- | | | | └─ linux-raw-sys [v0.3.7]
- | | | └─ utf8parse [v0.2.1]
- | | ├─ anstyle [v1.0.0]
-
+ | └─ clap [v4.1.14]
+ | ├─ clap_builder [v4.1.14]
+
| | ├─ bitflags [v1.3.2]
- | | ├─ clap_lex [v0.4.1]
-
+ | | ├─ clap_lex [v0.4.0]
+ | | ├─ is-terminal [v0.4.5]
+ | | | ├─ io-lifetimes [v1.0.9]
+ | | | | └─ libc [v0.2.140]
+ | | | └─ rustix [v0.36.11]
+ | | | ├─ bitflags [v1.3.2]
+ | | | ├─ io-lifetimes [v1.0.9]
+ | | | ├─ libc [v0.2.140]
+ | | | └─ linux-raw-sys [v0.1.4]
+
| | ├─ once_cell [v1.17.1]
- | | └─ strsim [v0.10.0]
- | ├─ clap_derive [v4.2.0]
-
+ | | ├─ strsim [v0.10.0]
+ | | └─ termcolor [v1.2.0]
+ | ├─ clap_derive [v4.1.14]
+
| | ├─ heck [v0.4.1]
- | | ├─ proc-macro2 [v1.0.56]
-
+ | | ├─ proc-macro2 [v1.0.54]
+
| | | └─ unicode-ident [v1.0.8]
- | | ├─ quote [v1.0.27]
- | | | └─ proc-macro2 [v1.0.56]
- | | └─ syn [v2.0.15]
- | | ├─ proc-macro2 [v1.0.56]
- | | ├─ quote [v1.0.27]
-
+ | | ├─ quote [v1.0.26]
+ | | | └─ proc-macro2 [v1.0.54]
+ | | └─ syn [v2.0.11]
+ | | ├─ proc-macro2 [v1.0.54]
+ | | ├─ quote [v1.0.26]
+
| | └─ unicode-ident [v1.0.8]
| └─ once_cell [v1.17.1]
├─ sudo-common [v0.1.0-alpha.1]
- | ├─ libc [v0.2.144]
-
+ | ├─ libc [v0.2.140]
+
| ├─ sudo-cli [v0.1.0-alpha.1]
| ├─ sudo-pam [v0.1.0-alpha.1]
- | | ├─ libc [v0.2.144]
-
+ | | ├─ libc [v0.2.140]
+
| | ├─ sudo-cutils [v0.1.0-alpha.1]
- | | | └─ libc [v0.2.144]
- | | └─ sudo-pam-sys [v0.1.0-alpha.1]
- | | ├─ libc [v0.2.144]
- | | └─ bindgen [v0.63.0]
- | | ├─ bitflags [v1.3.2]
- | | ├─ cexpr [v0.6.0]
- | | | └─ nom [v7.1.3]
- | | | ├─ memchr [v2.5.0]
- | | | └─ minimal-lexical [v0.2.1]
- | | ├─ clang-sys [v1.6.1]
- | | | ├─ glob [v0.3.1]
- | | | ├─ libc [v0.2.144]
- | | | ├─ libloading [v0.7.4]
- | | | | └─ cfg-if [v1.0.0]
- | | | └─ glob [v0.3.1]
- | | ├─ lazy_static [v1.4.0]
- | | ├─ lazycell [v1.3.0]
-
+ | | | └─ libc [v0.2.140]
+ | | ├─ sudo-pam-sys [v0.1.0-alpha.1]
+ | | | ├─ libc [v0.2.140]
+ | | | └─ bindgen [v0.63.0]
+ | | | ├─ bitflags [v1.3.2]
+ | | | ├─ cexpr [v0.6.0]
+ | | | | └─ nom [v7.1.3]
+ | | | | ├─ memchr [v2.5.0]
+ | | | | └─ minimal-lexical [v0.2.1]
+ | | | ├─ clang-sys [v1.6.0]
+ | | | | ├─ glob [v0.3.1]
+ | | | | ├─ libc [v0.2.140]
+ | | | | ├─ libloading [v0.7.4]
+ | | | | | └─ cfg-if [v1.0.0]
+ | | | | └─ glob [v0.3.1]
+ | | | ├─ lazy_static [v1.4.0]
+ | | | ├─ lazycell [v1.3.0]
+ | | | ├─ log [v0.4.17]
+ | | | | └─ cfg-if [v1.0.0]
+ | | | ├─ peeking_take_while [v0.1.2]
+ | | | ├─ proc-macro2 [v1.0.54]
+ | | | ├─ quote [v1.0.26]
+ | | | ├─ regex [v1.7.3]
+ | | | | ├─ aho-corasick [v0.7.20]
+ | | | | | └─ memchr [v2.5.0]
+ | | | | ├─ memchr [v2.5.0]
+ | | | | └─ regex-syntax [v0.6.29]
+ | | | ├─ rustc-hash [v1.1.0]
+ | | | ├─ shlex [v1.1.0]
+ | | | ├─ syn [v1.0.109]
+ | | | | ├─ proc-macro2 [v1.0.54]
+ | | | | ├─ quote [v1.0.26]
+ | | | | └─ unicode-ident [v1.0.8]
+ | | | └─ which [v4.4.0]
+ | | | ├─ either [v1.8.1]
+ | | | └─ libc [v0.2.140]
+ | | └─ thiserror [v1.0.40]
+ | | └─ thiserror-impl [v1.0.40]
+ | | ├─ proc-macro2 [v1.0.54]
+ | | ├─ quote [v1.0.26]
+ | | └─ syn [v2.0.11]
+ | ├─ sudo-system [v0.1.0-alpha.1]
+ | | ├─ libc [v0.2.140]
+ | | ├─ sudo-cutils [v0.1.0-alpha.1]
+ | | └─ sudo-log [v0.1.0-alpha.1]
+ | | ├─ env_logger [v0.9.3]
+ | | | ├─ atty [v0.2.14]
+ | | | | └─ libc [v0.2.140]
+ | | | ├─ humantime [v2.1.0]
+ | | | ├─ log [v0.4.17]
+ | | | ├─ regex [v1.7.3]
+ | | | └─ termcolor [v1.2.0]
+ | | ├─ log [v0.4.17]
+ | | └─ syslog [v6.0.1]
+ | | ├─ error-chain [v0.12.4]
+ | | | └─ version_check [v0.9.4]
+ | | ├─ hostname [v0.3.1]
+ | | | ├─ libc [v0.2.140]
+ | | | └─ match_cfg [v0.1.0]
+ | | ├─ libc [v0.2.140]
+
| | ├─ log [v0.4.17]
- | | | └─ cfg-if [v1.0.0]
- | | ├─ peeking_take_while [v0.1.2]
- | | ├─ proc-macro2 [v1.0.56]
- | | ├─ quote [v1.0.27]
- | | ├─ regex [v1.8.1]
- | | | ├─ aho-corasick [v1.0.1]
- | | | | └─ memchr [v2.5.0]
- | | | ├─ memchr [v2.5.0]
- | | | └─ regex-syntax [v0.7.1]
- | | ├─ rustc-hash [v1.1.0]
- | | ├─ shlex [v1.1.0]
- | | ├─ syn [v1.0.109]
- | | | ├─ proc-macro2 [v1.0.56]
- | | | ├─ quote [v1.0.27]
- | | | └─ unicode-ident [v1.0.8]
- | | └─ which [v4.4.0]
- | | ├─ either [v1.8.1]
- | | └─ libc [v0.2.144]
- | └─ sudo-system [v0.1.0-alpha.1]
- | ├─ libc [v0.2.144]
- | ├─ sudo-cutils [v0.1.0-alpha.1]
- | └─ sudo-log [v0.1.0-alpha.1]
- | ├─ env_logger [v0.9.3]
- | | ├─ atty [v0.2.14]
- | | | └─ libc [v0.2.144]
- | | ├─ humantime [v2.1.0]
- | | ├─ log [v0.4.17]
- | | ├─ regex [v1.8.1]
- | | └─ termcolor [v1.2.0]
- | ├─ log [v0.4.17]
- | └─ syslog [v6.1.0]
- | ├─ error-chain [v0.12.4]
- | | └─ version_check [v0.9.4]
- | ├─ hostname [v0.3.1]
- | | ├─ libc [v0.2.144]
- | | └─ match_cfg [v0.1.0]
- | ├─ libc [v0.2.144]
- | ├─ log [v0.4.17]
- | └─ time [v0.3.21]
- | ├─ itoa [v1.0.6]
- | ├─ libc [v0.2.144]
- | ├─ num_threads [v0.1.6]
- | └─ time-core [v0.1.1]
-
+ | | └─ time [v0.3.20]
+ | | ├─ itoa [v1.0.6]
+ | | ├─ libc [v0.2.140]
+ | | ├─ num_threads [v0.1.6]
+ | | └─ time-core [v0.1.0]
+ | └─ thiserror [v1.0.40]
+
├─ sudo-env [v0.1.0-alpha.1]
| ├─ sudo-common [v0.1.0-alpha.1]
| ├─ sudo-system [v0.1.0-alpha.1]
| └─ sudoers [v0.1.0-alpha.1]
| ├─ digest [v0.10.6]
| | ├─ block-buffer [v0.10.4]
| | | └─ generic-array [v0.14.7]
| | | ├─ typenum [v1.16.0]
| | | └─ version_check [v0.9.4]
| | └─ crypto-common [v0.1.6]
| | ├─ generic-array [v0.14.7]
| | └─ typenum [v1.16.0]
| ├─ glob [v0.3.1]
| ├─ sha2 [v0.10.6]
| | ├─ cfg-if [v1.0.0]
- | | ├─ cpufeatures [v0.2.7]
-
+ | | ├─ cpufeatures [v0.2.6]
+
| | └─ digest [v0.10.6]
| ├─ sudo-defaults [v0.1.0-alpha.1]
| ├─ sudo-log [v0.1.0-alpha.1]
| └─ sudo-system [v0.1.0-alpha.1]
├─ sudo-exec [v0.1.0-alpha.1]
| ├─ signal-hook [v0.3.15]
- | | ├─ libc [v0.2.144]
-
+ | | ├─ libc [v0.2.140]
+
| | ├─ signal-hook-registry [v1.4.1]
- | | | └─ libc [v0.2.144]
-
+ | | | └─ libc [v0.2.140]
+
| | └─ cc [v1.0.79]
| ├─ sudo-common [v0.1.0-alpha.1]
| ├─ sudo-log [v0.1.0-alpha.1]
| └─ sudo-system [v0.1.0-alpha.1]
├─ sudo-log [v0.1.0-alpha.1]
├─ sudo-pam [v0.1.0-alpha.1]
├─ sudo-system [v0.1.0-alpha.1]
└─ sudoers [v0.1.0-alpha.1] |
marlonbaeten
approved these changes
May 9, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This replaces the old behavior based around
exec_nopty
and usesexec_pty
instead. The rough logic described inman sudo
is implemented but some details are missing: