Skip to content

[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

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

justice-adams-apple
Copy link

Follow up from #350 and #352

  • Add a new command list-depenencies which lists toolchain dependencies for the given platorm
  • Ask to install the dependencies for the user with elevated privileges and give option to auto install with -I

ToDo: Add tests

// 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 {
Copy link
Member

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
Copy link
Member

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) }
Copy link
Member

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.

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.

2 participants