Skip to content

Commit

Permalink
cleaned up logging a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
twocanoes committed May 10, 2023
1 parent 574a51b commit dfbf57f
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 50 deletions.
30 changes: 15 additions & 15 deletions XCreds/Logger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ import Foundation
func TCSLogWithMark(_ message: String = "",
file: String = #file, line: Int = #line, function: String = #function ) {

let date = Date()
// let date = Date()

let comp = file.components(separatedBy: "/")
if let lastPart = comp.last{
TCSLog("\(date) FILE:\(lastPart) LINE:\(line) FUNCTION:\(function) \(message)")

}

}

func Mark(
file: String = #file, line: Int = #line, function: String = #function ) {

let date = Date()

let comp = file.components(separatedBy: "/")
if let lastPart = comp.last{
TCSLog("\(date) FILE:\(lastPart) LINE:\(line) FUNCTION:\(function)")
TCSLog("\(lastPart):\(line) \(function) \(message)")

}

}
//
//func Mark(
// file: String = #file, line: Int = #line, function: String = #function ) {
//
// let date = Date()
//
// let comp = file.components(separatedBy: "/")
// if let lastPart = comp.last{
// TCSLog("\(date) FILE:\(lastPart) LINE:\(line) FUNCTION:\(function)")
//
// }
//
//}
4 changes: 2 additions & 2 deletions XCreds/MainController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MainController: NSObject {


// //now we set the password.
Mark()
// Mark()
DispatchQueue.main.async {
mainMenu.webView?.window?.close()

Expand All @@ -45,7 +45,7 @@ class MainController: NSObject {
return
}
if let refreshToken = tokens.refreshToken, refreshToken.count>0 {
Mark()
// Mark()
mainMenu.statusBarItem.button?.image=NSImage(named: "xcreds menu icon check")
}
let localPassword = self.localPassword()
Expand Down
12 changes: 2 additions & 10 deletions XCreds/WebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,9 @@ class WebViewController: NSWindowController {
case .invalid,.trialExpired, .expired:
let allBundles = Bundle.allBundles
for currentBundle in allBundles {
TCSLogWithMark(currentBundle.bundlePath)
if currentBundle.bundlePath.contains("XCreds") {
TCSLogWithMark()
let loadPageURL = currentBundle.url(forResource: "errorpage", withExtension: "html")
if let loadPageURL = loadPageURL {
TCSLogWithMark(loadPageURL.debugDescription ?? "none")
self.webView.load(URLRequest(url:loadPageURL))
}
break
Expand All @@ -63,10 +60,7 @@ class WebViewController: NSWindowController {
let allBundles = Bundle.allBundles
for currentBundle in allBundles {
if currentBundle.bundlePath.contains("XCreds") {
TCSLogWithMark(currentBundle.bundlePath)
TCSLogWithMark()
let loadPageURL = currentBundle.url(forResource: "loadpage", withExtension: "html")
TCSLogWithMark(loadPageURL.debugDescription ?? "none")
if let loadPageURL = loadPageURL {
self.webView.load(URLRequest(url:loadPageURL))
}
Expand Down Expand Up @@ -117,7 +111,7 @@ extension WebViewController: WKNavigationDelegate {
TCSLogWithMark("inserting javascript to get password")
webView.evaluateJavaScript("result", completionHandler: { response, error in
if error != nil {
TCSLogWithMark(error?.localizedDescription ?? "unknown error")
// TCSLogWithMark(error?.localizedDescription ?? "unknown error")
}
else {
if let responseDict = response as? NSDictionary, let ids = responseDict["ids"] as? Array<String>, let passwords = responseDict["passwords"] as? Array<String>, passwords.count>0 {
Expand Down Expand Up @@ -182,7 +176,6 @@ extension WebViewController: WKNavigationDelegate {
}

func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
TCSLogWithMark("did finish")
//this inserts javascript to copy passwords to a variable. Sometimes the
//div gets removed before we can evaluate it so this helps. It works by
// attaching to keydown. At each keydown, it attaches to password elements
Expand All @@ -193,7 +186,6 @@ extension WebViewController: WKNavigationDelegate {
var pathURL:URL?
let allBundles = Bundle.allBundles
for currentBundle in allBundles {
TCSLogWithMark(currentBundle.bundlePath)
if currentBundle.bundlePath.contains("XCreds") {
TCSLogWithMark()
pathURL = currentBundle.url(forResource: "get_pw", withExtension: "js")
Expand All @@ -214,7 +206,7 @@ extension WebViewController: WKNavigationDelegate {

webView.evaluateJavaScript(javascript, completionHandler: { response, error in
if (error != nil){
TCSLogWithMark(error?.localizedDescription ?? "empty error")
// TCSLogWithMark(error?.localizedDescription ?? "empty error")
}
else {
TCSLogWithMark("inserted javascript for password setup")
Expand Down
16 changes: 8 additions & 8 deletions XCredsLoginPlugIn/LoginWindow/AuthorizationDBManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ class AuthorizationDBManager: NSObject {
let positionOfRight = consoleRights.firstIndex(of: right)

if positionOfRight == nil {
TCSLogWithMark("did not find \(right)")
// TCSLogWithMark("did not find \(right)")
return false
}
TCSLogWithMark("found \(right)")
// TCSLogWithMark("found \(right)")

return true
}
Expand All @@ -148,9 +148,9 @@ class AuthorizationDBManager: NSObject {

consoleRights.insert(newRight, at: positionOfRight+1)
}
else {
print("right already exists")
}
// else {
// print("right already exists")
// }


return setConsoleRights(rights: consoleRights)
Expand All @@ -168,9 +168,9 @@ class AuthorizationDBManager: NSObject {
consoleRights.insert(newRight, at: positionOfRight)

}
else {
print("right already exists")
}
// else {
// print("right already exists")
// }
let success = setConsoleRights(rights: consoleRights)
return success
}
Expand Down
1 change: 0 additions & 1 deletion XCredsLoginPlugIn/WifiManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ class WifiManager: CWEventDelegate {

monitor?.pathUpdateHandler = { path in
TCSLogWithMark("network changed. Checking to see if it was WiFi...")
TCSLogWithMark()
if path.status != .satisfied {
TCSLogWithMark("not connected")
}
Expand Down
1 change: 0 additions & 1 deletion XCredsLoginPlugIn/WifiWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class WifiWindowController: NSWindowController, WifiManagerDelegate, NSMenuDeleg
@IBOutlet weak var networkUsernameLabel: NSTextField!
@IBOutlet weak var wifiPopupMenu: NSMenu!
@IBAction func help(_ sender: Any) {
TCSLogWithMark()
}

@IBOutlet weak var networkUsernameView: NSView?
Expand Down
7 changes: 1 addition & 6 deletions XCredsLoginPlugIn/XCredsLoginPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ - (OSStatus)MechanismCreate:(AuthorizationPluginRef)inPlugin

MechanismRecord *mechanism = (MechanismRecord *)malloc(sizeof(MechanismRecord));
if (mechanism == NULL) return errSecMemoryError;
TCSLog([NSString stringWithFormat:@"mech is %s\n",mechanismId]);
TCSLog([NSString stringWithFormat:@"Authorization Plugin ^%s Mechanism created.\n",mechanismId]);
mechanism->fMagic = kMechanismMagic;
mechanism->fEngine = inEngine;
mechanism->fPlugin = (PluginRecord *)inPlugin;
Expand Down Expand Up @@ -131,31 +131,26 @@ - (OSStatus)MechanismInvoke:(AuthorizationMechanismRef)inMechanism {

}
else if (mechanism->fPowerControl){
NSLog(@"Calling PowerControl");
XCredsPowerControlMechanism *powerControl = [[XCredsPowerControlMechanism alloc] initWithMechanism:mechanism];
[powerControl run];

}
else if (mechanism->fEnableFDE){
NSLog(@"Calling EnableFDE");
XCredsEnableFDE *fdeMech = [[XCredsEnableFDE alloc] initWithMechanism:mechanism];
[fdeMech run];

}
else if (mechanism->fKeychainAdd){
NSLog(@"Calling fKeychainAdd");
XCredsKeychainAdd *keychainAdd = [[XCredsKeychainAdd alloc] initWithMechanism:mechanism];
[keychainAdd run];

}
else if (mechanism->fCreateUser){
NSLog(@"Calling CreateUser");
XCredsCreateUser *createUser = [[XCredsCreateUser alloc] initWithMechanism:mechanism];
[createUser run];

}
else if (mechanism->fLoginDone){
NSLog(@"Calling LoginDone");
XCredsLoginDone *loginDone = [[XCredsLoginDone alloc] initWithMechanism:mechanism];
[loginDone run];

Expand Down
2 changes: 1 addition & 1 deletion app_to_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ popd

ssh root@"${REMOTE_MAC}" 'bash -c "if [ -e "/tmp/xcreds.zip" ] ; then echo removing; rm -rf "/tmp/xcreds.zip"; fi"'

scp -r /tmp/xcreds/xcreds.zip root@"${REMOTE_MAC}":/tmp/xcreds.zip
scp -Cr /tmp/xcreds/xcreds.zip root@"${REMOTE_MAC}":/tmp/xcreds.zip


ssh root@"${REMOTE_MAC}" unzip /tmp/xcreds.zip -d /Applications
Expand Down
3 changes: 3 additions & 0 deletions build_resources/Packages/XCreds/scripts/postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ fi

if [ -e "${plugin_path}" ]; then

if [ -e "${target_volume}"/Library/Security/SecurityAgentPlugins/XCredsLoginPlugin.bundle ]; then
rm -rf "${target_volume}"/Library/Security/SecurityAgentPlugins/XCredsLoginPlugin.bundle
fi
cp -R "${plugin_path}" "${target_volume}"/Library/Security/SecurityAgentPlugins/
chown -R root:wheel "${target_volume}"/Library/Security/SecurityAgentPlugins/XCredsLoginPlugin.bundle
fi
Expand Down
12 changes: 6 additions & 6 deletions xCreds.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3624;
CURRENT_PROJECT_VERSION = 3634;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1048,7 +1048,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3624;
CURRENT_PROJECT_VERSION = 3634;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UXP6YEHSPW;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1113,7 +1113,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3624;
CURRENT_PROJECT_VERSION = 3634;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1149,7 +1149,7 @@
CODE_SIGN_ENTITLEMENTS = "XCreds Login Overlay/XCreds_Login_Overlay.entitlements";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3624;
CURRENT_PROJECT_VERSION = 3634;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1298,7 +1298,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3624;
CURRENT_PROJECT_VERSION = 3634;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -1333,7 +1333,7 @@
CODE_SIGN_ENTITLEMENTS = XCreds/xCreds.entitlements;
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 3624;
CURRENT_PROJECT_VERSION = 3634;
DEVELOPMENT_TEAM = UXP6YEHSPW;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down
Binary file not shown.

0 comments on commit dfbf57f

Please sign in to comment.