From f00ae396a612ba142ab7f6e3f36a03b2deee553d Mon Sep 17 00:00:00 2001 From: Brandon Evans Date: Fri, 1 Jan 2021 10:40:41 -0700 Subject: [PATCH] Remove Current.shell sudo functionality This'll be done in the helper --- Xcodes/Backend/Environment.swift | 17 ----------------- Xcodes/Backend/Process.swift | 9 --------- 2 files changed, 26 deletions(-) diff --git a/Xcodes/Backend/Environment.swift b/Xcodes/Backend/Environment.swift index 48b4f96..19644a1 100644 --- a/Xcodes/Backend/Environment.swift +++ b/Xcodes/Backend/Environment.swift @@ -27,28 +27,11 @@ public struct Shell { public var unxip: (URL) -> Promise = { Process.run(Path.root.usr.bin.xip, workingDirectory: $0.deletingLastPathComponent(), "--expand", "\($0.path)") } public var spctlAssess: (URL) -> Promise = { Process.run(Path.root.usr.sbin.spctl, "--assess", "--verbose", "--type", "execute", "\($0.path)") } public var codesignVerify: (URL) -> Promise = { Process.run(Path.root.usr.bin.codesign, "-vv", "-d", "\($0.path)") } - public var devToolsSecurityEnable: (String?) -> Promise = { Process.sudo(password: $0, Path.root.usr.sbin.DevToolsSecurity, "-enable") } - public var addStaffToDevelopersGroup: (String?) -> Promise = { Process.sudo(password: $0, Path.root.usr.sbin.dseditgroup, "-o", "edit", "-t", "group", "-a", "staff", "_developer") } - public var acceptXcodeLicense: (InstalledXcode, String?) -> Promise = { Process.sudo(password: $1, $0.path.join("/Contents/Developer/usr/bin/xcodebuild"), "-license", "accept") } - public var runFirstLaunch: (InstalledXcode, String?) -> Promise = { Process.sudo(password: $1, $0.path.join("/Contents/Developer/usr/bin/xcodebuild"),"-runFirstLaunch") } public var buildVersion: () -> Promise = { Process.run(Path.root.usr.bin.sw_vers, "-buildVersion") } public var xcodeBuildVersion: (InstalledXcode) -> Promise = { Process.run(Path.root.usr.libexec.PlistBuddy, "-c", "Print :ProductBuildVersion", "\($0.path.string)/Contents/version.plist") } public var getUserCacheDir: () -> Promise = { Process.run(Path.root.usr.bin.getconf, "DARWIN_USER_CACHE_DIR") } public var touchInstallCheck: (String, String, String) -> Promise = { Process.run(Path.root.usr.bin/"touch", "\($0)com.apple.dt.Xcode.InstallCheckCache_\($1)_\($2)") } - public var validateSudoAuthentication: () -> Promise = { Process.run(Path.root.usr.bin.sudo, "-nv") } - public var authenticateSudoerIfNecessary: (@escaping () -> Promise) -> Promise = { passwordInput in - firstly { () -> Promise in - Current.shell.validateSudoAuthentication().map { _ in return nil } - } - .recover { _ -> Promise in - return passwordInput().map(Optional.init) - } - } - public func authenticateSudoerIfNecessary(passwordInput: @escaping () -> Promise) -> Promise { - authenticateSudoerIfNecessary(passwordInput) - } - public var xcodeSelectPrintPath: () -> AnyPublisher = { Process.run(Path.root.usr.bin.join("xcode-select"), "-p") } } diff --git a/Xcodes/Backend/Process.swift b/Xcodes/Backend/Process.swift index b800d53..d5559b9 100644 --- a/Xcodes/Backend/Process.swift +++ b/Xcodes/Backend/Process.swift @@ -5,15 +5,6 @@ import Path public typealias ProcessOutput = (status: Int32, out: String, err: String) extension Process { - @discardableResult - static func sudo(password: String? = nil, _ executable: Path, workingDirectory: URL? = nil, _ arguments: String...) -> Promise { - var arguments = [executable.string] + arguments - if password != nil { - arguments.insert("-S", at: 0) - } - return run(Path.root.usr.bin.sudo.url, workingDirectory: workingDirectory, input: password, arguments) - } - @discardableResult static func run(_ executable: Path, workingDirectory: URL? = nil, input: String? = nil, _ arguments: String...) -> Promise { return run(executable.url, workingDirectory: workingDirectory, input: input, arguments)