Commit 3067fd84 authored by Joel Rennich's avatar Joel Rennich

add RunScript

parent 05ea9b8b
Pipeline #35520798 failed with stage
in 28 seconds
......@@ -20,3 +20,4 @@ let enableFDELog = OSLog(subsystem: "menu.nomad.login.ad", category: "EnableFDEL
let sierraFixesLog = OSLog(subsystem: "menu.nomad.login.ad", category: "SierraFixesLog")
let keychainAddLog = OSLog(subsystem: "menu.nomad.login.ad", category: "KeychainAdd")
let eulaLog = OSLog(subsystem: "menu.nomad.login.ad", category: "EULA")
let runScriptLog = OSLog(subsystem: "menu.nomad.login.ad", category: "RunScript")
......@@ -46,6 +46,7 @@ struct MechanismRecord {
Boolean fEnableFDE;
Boolean fSierraFixes;
Boolean fEULA;
Boolean fRunScript;
};
typedef struct MechanismRecord MechanismRecord;
......
......@@ -100,6 +100,7 @@ extern OSStatus AuthorizationPluginCreate(const AuthorizationCallbacks *callback
mechanism->fEnableFDE = (strcmp(mechanismId, "EnableFDE") == 0);
mechanism->fSierraFixes = (strcmp(mechanismId, "SierraFixes") == 0);
mechanism->fEULA = (strcmp(mechanismId, "EULA") == 0);
mechanism->fRunScript = (strcmp(mechanismId, "RunScript") == 0);
*outMechanism = mechanism;
os_log_debug(pluginLog, "NoLoPlugin:MechanismCreate: inPlugin=%p, inEngine=%p, mechanismId='%{public}s'", inPlugin, inEngine, mechanismId);
return errSecSuccess;
......@@ -152,6 +153,11 @@ extern OSStatus AuthorizationPluginCreate(const AuthorizationCallbacks *callback
EULA * eula = [[EULA alloc] initWithMechanism:mechanism];
[eula run];
NSLog(@"EULA done");
} else if (mechanism->fRunScript) {
NSLog(@"Calling RunScript");
RunScript * runScript = [[RunScript alloc] initWithMechanism:mechanism];
[runScript run];
NSLog(@"RunScript done");
}
return noErr;
}
......
......@@ -51,6 +51,10 @@ enum Preferences: String {
case LoginLogoData
/// Should NoLo display a macOS-style login screen instead of a window? Set as a `Bool`,
case LoginScreen
/// Arguments for the script that will run
case ScriptArgs
/// Path to the script
case ScriptPath
/// A string to show as the placeholder in the Username textfield
case UsernameFieldPlaceholder
/// A filesystem path to an image to set the user profile image to as a `String`
......
//
// RunScript.swift
// NoMADLoginAD
//
// Created by Joel Rennich on 3/30/18.
// Copyright © 2018 Orchard & Grove. All rights reserved.
//
import Foundation
class RunScript : NoLoMechanism {
let kArgError = "ERROR"
@objc func run() {
os_log("RunScript mech starting", log: runScriptLog, type: .default)
if let scriptPath = getManagedPreference(key: .ScriptPath) as? String {
let task = Process.init()
// check to make sure the path is there
let fm = FileManager.default
if fm.isExecutableFile(atPath: scriptPath) {
task.launchPath = scriptPath
if let args = getManagedPreference(key: .ScriptArgs) as? [String] {
var cleanArgs = [String]()
for arg in args {
if arg == "<<username>>" {
cleanArgs.append(usernameContext ?? "")
} else {
cleanArgs.append(arg)
}
}
task.arguments = cleanArgs
}
do {
if #available(OSX 10.13, *) {
try task.run()
} else {
task.launch()
}
// snooze for a second before we hit the next mechanism to let things start
sleep(1)
} catch {
os_log("Unable to run script.", log: runScriptLog, type: .default)
}
} else {
// ScriptPath isn't executable
os_log("Script path is not executable.", log: runScriptLog, type: .default)
}
} else {
os_log("Unable to get path to script, allowing login.", log: runScriptLog, type: .default)
}
// always let login proceed
_ = allowLogin()
}
}
......@@ -17,7 +17,7 @@
<key>CFBundleShortVersionString</key>
<string>1.2.2-demobilze</string>
<key>CFBundleVersion</key>
<string>306</string>
<string>307</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2018 Orchard &amp; Grove. All rights reserved.</string>
<key>NSPrincipalClass</key>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment