-
Notifications
You must be signed in to change notification settings - Fork 53
[WIP] Add list-dependencies command #403
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
base: main
Are you sure you want to change the base?
Conversation
// This is very security sensitive code here and that's why there's special process handling | ||
// and an allow-list of what we will attempt to run as root. Also, the sudo binary is run directly | ||
// with a fully-qualified path without any checking in order to avoid TOCTOU. | ||
guard try Self.allowedInstallCommands.wholeMatch(in: installCmd) != nil else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: We could do this check before presenting the command to the user. They might try running it themselves without checking.
var format: SwiftlyCore.OutputFormat = .text | ||
|
||
@Flag(name: .shortAndLong, help: "Automatically install missing system dependencies with elevated permissions") | ||
var installSystemDeps: Bool = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: Let's call out sudo as the mechanism that will be used to install the system deps here to make that part clear. Sudo may or may not work for some users and machines.
|
||
let p = Process() | ||
p.executableURL = URL(fileURLWithPath: "/usr/bin/sudo") | ||
p.arguments = ["-k"] + ["-p", "Enter your sudo password to run the dependency install command right away (Ctrl-C aborts): "] + installCmd.split(separator: " ").map { String($0) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought: This pattern of invoking sudo came from my previous attempt to eliminate prompts where they weren't needed. It might be better to remove the "-k" and "-p" flags here, and just include the details in the above prompts.
Follow up from #350 and #352
list-depenencies
which lists toolchain dependencies for the given platorm-I
ToDo: Add tests