Commit 2a0b57b5 authored by Tom Nook's avatar Tom Nook

Converted all instances of logit(_: _:) to use the new LogLevel enum.

parent 02073ea8
......@@ -57,14 +57,14 @@
1A08F1EC1D36CDF700FA68C4 /* PasswordChangeWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PasswordChangeWindow.xib; sourceTree = "<group>"; };
1A08F1EE1D36CE0C00FA68C4 /* PreferencesWindow.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PreferencesWindow.xib; sourceTree = "<group>"; };
1A08F1F21D36DA0900FA68C4 /* NoMADApplication.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoMADApplication.swift; sourceTree = "<group>"; };
1A206B2C1D58312800539FA6 /* KeychainUtil.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeychainUtil.swift; sourceTree = "<group>"; };
1A206B2C1D58312800539FA6 /* KeychainUtil.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = KeychainUtil.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
1A24EF471D7F01B3006A1866 /* Logger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = "<group>"; };
1A26AFF41D3BE620000776A4 /* WindowsCATools.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WindowsCATools.swift; sourceTree = "<group>"; };
1A26AFF41D3BE620000776A4 /* WindowsCATools.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = WindowsCATools.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
1A26AFF61D46E4BF000776A4 /* GetHelp.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetHelp.swift; sourceTree = "<group>"; };
1ADCEC611D75476D005D33F5 /* ShareMounter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ShareMounter.swift; sourceTree = "<group>"; };
1AE1DFC21DA6B1E100456E3E /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Base; path = Base.lproj/Languages.plist; sourceTree = "<group>"; };
1AE1DFC51DA6B52300456E3E /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = en; path = en.lproj/Languages.plist; sourceTree = "<group>"; };
1AFEAC351D68FEAF00B7FA88 /* UserInformation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UserInformation.swift; sourceTree = "<group>"; };
1AFEAC351D68FEAF00B7FA88 /* UserInformation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = UserInformation.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
345226E31DAA052C0066C922 /* ADLDAPPing.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ADLDAPPing.swift; sourceTree = "<group>"; };
345226E81DAA266B0066C922 /* Network.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Network.swift; sourceTree = "<group>"; };
346CD2721DA205B500255F66 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
......@@ -77,10 +77,10 @@
34E186BE1D9C681000265138 /* DNSResolver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DNSResolver.m; sourceTree = "<group>"; };
34E186C11D9E405400265138 /* libresolv.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libresolv.tbd; path = usr/lib/libresolv.tbd; sourceTree = SDKROOT; };
8454EFDA1D34ADA600422D4E /* NSTaskWrapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSTaskWrapper.swift; sourceTree = "<group>"; };
8454EFDC1D34ADEE00422D4E /* PasswordChangeWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PasswordChangeWindow.swift; sourceTree = "<group>"; };
8454EFE41D35968100422D4E /* LoginWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginWindow.swift; sourceTree = "<group>"; };
8454EFDC1D34ADEE00422D4E /* PasswordChangeWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = PasswordChangeWindow.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
8454EFE41D35968100422D4E /* LoginWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = LoginWindow.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
84847A661D3DDF5600FAE468 /* KlistUtil.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KlistUtil.swift; sourceTree = "<group>"; };
84996CA71D503F8400793747 /* LDAPUtil.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LDAPUtil.swift; sourceTree = "<group>"; };
84996CA71D503F8400793747 /* LDAPUtil.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = LDAPUtil.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
84996CA91D503F9100793747 /* KerbUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KerbUtil.h; sourceTree = "<group>"; };
84996CAA1D503F9100793747 /* KerbUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KerbUtil.m; sourceTree = "<group>"; };
84996CAC1D503F9700793747 /* PreferencesWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PreferencesWindow.swift; sourceTree = "<group>"; };
......@@ -91,7 +91,7 @@
84CC67EB1D30A1A500115C76 /* GSS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GSS.framework; path = System/Library/Frameworks/GSS.framework; sourceTree = SDKROOT; };
84CC67ED1D30A1B100115C76 /* NoMAD.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = NoMAD.entitlements; sourceTree = "<group>"; };
84CC67EE1D30A24000115C76 /* NoMAD-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NoMAD-Bridging-Header.h"; sourceTree = "<group>"; };
84CC68041D30A25500115C76 /* NoMADMenuController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NoMADMenuController.swift; sourceTree = "<group>"; };
84CC68041D30A25500115C76 /* NoMADMenuController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = NoMADMenuController.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
84F93A2A1D3886FA00ED2070 /* AutoConfigure.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AutoConfigure.swift; sourceTree = "<group>"; };
BF34324A1D52844300CE8F89 /* NoMADTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NoMADTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
BF34324C1D52844300CE8F89 /* NoMADTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoMADTests.swift; sourceTree = "<group>"; };
......
......@@ -123,7 +123,7 @@ class ADLDAPPing {
init?( ldapPingBase64String: String ) {
//let cleanedNetlogonBase64String = netlogonBase64String.componentsSeparatedByString(": ")[1]
guard let netlogonData = Data(base64Encoded: ldapPingBase64String, options: []) else {
myLogger.logit(2, message: "Netlogon base64 encoded string is invalid.")
myLogger.logit(.notice, message: "Netlogon base64 encoded string is invalid.")
return nil
}
var cursor = UInt16(24)
......@@ -136,11 +136,11 @@ class ADLDAPPing {
flags = DS_FLAGS(rawValue: tempFlags)
//flags.contains(.DS_PDC_FLAG)
myLogger.logit(3, message: "Is PDC: " + flags.contains(.DS_PDC_FLAG).description)
myLogger.logit(3, message: "Is GC: " + flags.contains(.DS_GC_FLAG).description)
myLogger.logit(3, message: "Is LDAP: " + flags.contains(.DS_LDAP_FLAG).description)
myLogger.logit(3, message: "Is Writable: " + flags.contains(.DS_WRITABLE_FLAG).description)
myLogger.logit(3, message: "Is Closest: " + flags.contains(.DS_CLOSEST_FLAG).description)
myLogger.logit(.debug, message: "Is PDC: " + flags.contains(.DS_PDC_FLAG).description)
myLogger.logit(.debug, message: "Is GC: " + flags.contains(.DS_GC_FLAG).description)
myLogger.logit(.debug, message: "Is LDAP: " + flags.contains(.DS_LDAP_FLAG).description)
myLogger.logit(.debug, message: "Is Writable: " + flags.contains(.DS_WRITABLE_FLAG).description)
myLogger.logit(.debug, message: "Is Closest: " + flags.contains(.DS_CLOSEST_FLAG).description)
// END
......@@ -152,11 +152,11 @@ class ADLDAPPing {
} catch let error {
switch error {
case DecodeError.cyclicPointer:
myLogger.logit(2, message: "Decoding RFC1035 string created loop.")
myLogger.logit(.notice, message: "Decoding RFC1035 string created loop.")
case DecodeError.illegalTag:
myLogger.logit(2, message: "Decoding RFC1035 string found an illegal tag.")
myLogger.logit(.notice, message: "Decoding RFC1035 string found an illegal tag.")
default:
myLogger.logit(2, message: "Unable to decode RFC1035 string.")
myLogger.logit(.notice, message: "Unable to decode RFC1035 string.")
}
return nil
}
......@@ -166,11 +166,11 @@ class ADLDAPPing {
} catch let error {
switch error {
case DecodeError.cyclicPointer:
myLogger.logit(2, message: "Decoding RFC1035 string created loop.")
myLogger.logit(.notice, message: "Decoding RFC1035 string created loop.")
case DecodeError.illegalTag:
myLogger.logit(2, message: "Decoding RFC1035 string found an illegal tag.")
myLogger.logit(.notice, message: "Decoding RFC1035 string found an illegal tag.")
default:
myLogger.logit(2, message: "Unable to decode RFC1035 string.")
myLogger.logit(.notice, message: "Unable to decode RFC1035 string.")
}
return nil
}
......@@ -180,11 +180,11 @@ class ADLDAPPing {
} catch let error {
switch error {
case DecodeError.cyclicPointer:
myLogger.logit(2, message: "Decoding RFC1035 string created loop.")
myLogger.logit(.notice, message: "Decoding RFC1035 string created loop.")
case DecodeError.illegalTag:
myLogger.logit(2, message: "Decoding RFC1035 string found an illegal tag.")
myLogger.logit(.notice, message: "Decoding RFC1035 string found an illegal tag.")
default:
myLogger.logit(2, message: "Unable to decode RFC1035 string.")
myLogger.logit(.notice, message: "Unable to decode RFC1035 string.")
}
return nil
}
......@@ -194,11 +194,11 @@ class ADLDAPPing {
} catch let error {
switch error {
case DecodeError.cyclicPointer:
myLogger.logit(2, message: "Decoding RFC1035 string created loop.")
myLogger.logit(.notice, message: "Decoding RFC1035 string created loop.")
case DecodeError.illegalTag:
myLogger.logit(2, message: "Decoding RFC1035 string found an illegal tag.")
myLogger.logit(.notice, message: "Decoding RFC1035 string found an illegal tag.")
default:
myLogger.logit(2, message: "Unable to decode RFC1035 string.")
myLogger.logit(.notice, message: "Unable to decode RFC1035 string.")
}
return nil
}
......@@ -208,11 +208,11 @@ class ADLDAPPing {
} catch let error {
switch error {
case DecodeError.cyclicPointer:
myLogger.logit(2, message: "Decoding RFC1035 string created loop.")
myLogger.logit(.notice, message: "Decoding RFC1035 string created loop.")
case DecodeError.illegalTag:
myLogger.logit(2, message: "Decoding RFC1035 string found an illegal tag.")
myLogger.logit(.notice, message: "Decoding RFC1035 string found an illegal tag.")
default:
myLogger.logit(2, message: "Unable to decode RFC1035 string.")
myLogger.logit(.notice, message: "Unable to decode RFC1035 string.")
}
return nil
}
......@@ -222,11 +222,11 @@ class ADLDAPPing {
} catch let error {
switch error {
case DecodeError.cyclicPointer:
myLogger.logit(2, message: "Decoding RFC1035 string created loop.")
myLogger.logit(.notice, message: "Decoding RFC1035 string created loop.")
case DecodeError.illegalTag:
myLogger.logit(2, message: "Decoding RFC1035 string found an illegal tag.")
myLogger.logit(.notice, message: "Decoding RFC1035 string found an illegal tag.")
default:
myLogger.logit(2, message: "Unable to decode RFC1035 string.")
myLogger.logit(.notice, message: "Unable to decode RFC1035 string.")
}
return nil
}
......@@ -236,11 +236,11 @@ class ADLDAPPing {
} catch let error {
switch error {
case DecodeError.cyclicPointer:
myLogger.logit(2, message: "Decoding RFC1035 string created loop.")
myLogger.logit(.notice, message: "Decoding RFC1035 string created loop.")
case DecodeError.illegalTag:
myLogger.logit(2, message: "Decoding RFC1035 string found an illegal tag.")
myLogger.logit(.notice, message: "Decoding RFC1035 string found an illegal tag.")
default:
myLogger.logit(2, message: "Unable to decode RFC1035 string.")
myLogger.logit(.notice, message: "Unable to decode RFC1035 string.")
}
return nil
}
......@@ -250,11 +250,11 @@ class ADLDAPPing {
} catch let error {
switch error {
case DecodeError.cyclicPointer:
myLogger.logit(2, message: "Decoding RFC1035 string created loop.")
myLogger.logit(.notice, message: "Decoding RFC1035 string created loop.")
case DecodeError.illegalTag:
myLogger.logit(2, message: "Decoding RFC1035 string found an illegal tag.")
myLogger.logit(.notice, message: "Decoding RFC1035 string found an illegal tag.")
default:
myLogger.logit(2, message: "Unable to decode RFC1035 string.")
myLogger.logit(.notice, message: "Unable to decode RFC1035 string.")
}
return nil
}
......
......@@ -21,7 +21,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
func applicationDidFinishLaunching(_ aNotification: Notification) {
myLogger.logit(0, message:"---NoMAD Initialized---")
myLogger.logit(.base, message:"---NoMAD Initialized---")
//NSUserNotificationCenter.defaultUserNotificationCenter().delegate = self
......
......@@ -130,14 +130,14 @@ class KeychainUtil {
myErr = SecItemCopyMatching(identitySearchDict as CFDictionary, &searchReturn)
if myErr != 0 {
myLogger.logit(0, message: "Error getting Certificates.")
myLogger.logit(.base, message: "Error getting Certificates.")
return nil
}
let foundCerts = searchReturn as! CFArray as Array
if foundCerts.count == 0 {
myLogger.logit(1, message: "No certificates found.")
myLogger.logit(.info, message: "No certificates found.")
return nil
}
......@@ -146,7 +146,7 @@ class KeychainUtil {
myErr = SecIdentityCopyCertificate(cert as! SecIdentity, &myCert)
if myErr != 0 {
myLogger.logit(0, message: "Error getting Certificate references.")
myLogger.logit(.base, message: "Error getting Certificate references.")
return nil
}
......@@ -192,8 +192,8 @@ class KeychainUtil {
}
}
}
myLogger.logit(3, message: "Found " + String(matchingCerts.count) + " certificates.")
myLogger.logit(3, message: "Found certificates: " + String(describing: matchingCerts) )
myLogger.logit(.debug, message: "Found " + String(matchingCerts.count) + " certificates.")
myLogger.logit(.debug, message: "Found certificates: " + String(describing: matchingCerts) )
return lastExpire
}
}
......@@ -42,21 +42,21 @@ class KlistUtil {
func getTicketJSON() {
realm = defaults.string(forKey: "KerberosRealm") ?? ""
myLogger.logit(3, message:"Looking for tickets using realm: " + realm )
myLogger.logit(.debug, message:"Looking for tickets using realm: " + realm )
dateFormatter.dateFormat = "yyyyMMddHHmmss"
let rawJSON = cliTask("/usr/bin/klist --json")
myLogger.logit(3, message: "Raw ticket cache: " + String(rawJSON))
myLogger.logit(.debug, message: "Raw ticket cache: " + String(rawJSON))
rawTicket = rawJSON.data(using: String.Encoding.utf8)!
if returnAllTickets().contains("cache") {
if returnAllTickets().contains("@" + realm ) {
myLogger.logit(0, message:"Ticket found for domain: " + realm)
myLogger.logit(.base, message:"Ticket found for domain: " + realm)
state = true
} else {
myLogger.logit(0, message:"No ticket found for domain: " + realm)
myLogger.logit(.base, message:"No ticket found for domain: " + realm)
state = false
}
} else {
myLogger.logit(0, message:"No tickets found.")
myLogger.logit(.base, message:"No tickets found.")
state = false
}
}
......@@ -66,16 +66,16 @@ class KlistUtil {
let rawJSON = cliTask("/usr/bin/klist -l --json")
let rawCache = rawJSON.data(using: String.Encoding.utf8)!
if returnAllTickets().contains("cache") {
myLogger.logit(0, message:"Tickets found.")
myLogger.logit(.base, message:"Tickets found.")
if returnAllTickets().contains("@" + defaults.string(forKey: "KerberosRealm")!) {
myLogger.logit(0, message:"Ticket found for domain: " + defaults.string(forKey: "KerberosRealm")!)
myLogger.logit(.base, message:"Ticket found for domain: " + defaults.string(forKey: "KerberosRealm")!)
state = true
} else {
myLogger.logit(0, message:"No ticket found for domain: " + defaults.string(forKey: "KerberosRealm")!)
myLogger.logit(.base, message:"No ticket found for domain: " + defaults.string(forKey: "KerberosRealm")!)
state = false
}
} else {
myLogger.logit(0, message:"No tickets found.")
myLogger.logit(.base, message:"No tickets found.")
state = false
}
}
......@@ -103,20 +103,20 @@ class KlistUtil {
if let tickets = jsonDict?["tickets"] as? [[String: AnyObject]] {
for ticket in tickets {
myLogger.logit(3, message: "Looking at ticket: " + String(describing: ticket))
myLogger.logit(.debug, message: "Looking at ticket: " + String(describing: ticket))
if let tick = ticket["Principal"] as? String {
let issue = dateFormatter.date(from: (ticket["Issued"] as? String)!)
let expire = dateFormatter.date(from: (ticket["Expires"] as? String)!)
let myTicket = Ticket(Issued: issue!, Expires: expire!, Principal: tick )
myLogger.logit(3, message: "Appending ticket: " + String(describing: myTicket))
myLogger.logit(.debug, message: "Appending ticket: " + String(describing: myTicket))
allTickets.append(myTicket)
state = true
}
}
}
} catch {
myLogger.logit(3, message: "No tickets found")
myLogger.logit(.debug, message: "No tickets found")
state = false }
getExpiration()
}
......@@ -135,18 +135,18 @@ class KlistUtil {
for ticket in allTickets {
if ticket.Principal.contains("krbtgt") {
expire = ticket.Expires
myLogger.logit(3, message:"Checking for expired tickets.")
myLogger.logit(.debug, message:"Checking for expired tickets.")
// we need to check for an expired TGT and set state to false if we are
if expire.compare(Date()) == ComparisonResult.orderedAscending {
myLogger.logit(0, message:"Tickets are expired")
myLogger.logit(.base, message:"Tickets are expired")
state = false
}
break
}
}
} else {
myLogger.logit(3, message:"No tickets, so no need to look for expired tickets.")
myLogger.logit(.debug, message:"No tickets, so no need to look for expired tickets.")
}
}
......
......@@ -36,7 +36,7 @@ class LDAPServers : NSObject, DNSResolverDelegate {
var current: Int {
didSet(LDAPServer) {
myLogger.logit(0, message:"Setting the current LDAP server to: " + hosts[current].host)
myLogger.logit(.base, message:"Setting the current LDAP server to: " + hosts[current].host)
}
}
......@@ -51,7 +51,7 @@ class LDAPServers : NSObject, DNSResolverDelegate {
current = 0
self.resolver = DNSResolver.init()
//myLogger.logit(2, message:"Looking up tickets.")
//myLogger.logit(.notice, message:"Looking up tickets.")
//tickets.getDetails()
}
......@@ -59,7 +59,7 @@ class LDAPServers : NSObject, DNSResolverDelegate {
func setDomain(_ domain: String) {
myLogger.logit(0, message:"Finding LDAP Servers.")
myLogger.logit(.base, message:"Finding LDAP Servers.")
// set the domain to the current AD Domain
......@@ -165,7 +165,7 @@ class LDAPServers : NSObject, DNSResolverDelegate {
// TODO: just re-test the non-dead servers
func dead() {
myLogger.logit(1, message:"Marking server as dead: " + hosts[current].host)
myLogger.logit(.info, message:"Marking server as dead: " + hosts[current].host)
hosts[current].status = "dead"
hosts[current].timeStamp = Date()
if (hosts.count > current) { testHosts() }
......@@ -205,13 +205,13 @@ class LDAPServers : NSObject, DNSResolverDelegate {
if testSocket(self.currentServer) && testLDAP(self.currentServer) && tickets.state {
if defaultNamingContext != "" && site != "" {
myLogger.logit(0, message:"Using same LDAP server: " + self.currentServer)
myLogger.logit(.base, message:"Using same LDAP server: " + self.currentServer)
} else {
findSite()
}
} else {
if tickets.state {
myLogger.logit(0, message:"Can't connect to LDAP server, finding new one")
myLogger.logit(.base, message:"Can't connect to LDAP server, finding new one")
}
networkChange()
}
......@@ -529,7 +529,7 @@ class LDAPServers : NSObject, DNSResolverDelegate {
fileprivate func testLDAP ( _ host: String ) -> Bool {
if defaults.integer(forKey: "Verbose") >= 1 {
myLogger.logit(1, message:"Testing " + host + ".")
myLogger.logit(.info, message:"Testing " + host + ".")
}
let attribute = "defaultNamingContext"
let myLDAPResult = cliTask("/usr/bin/ldapsearch -N -LLL -Q -l 3 -s base -H ldap://" + host + " " + attribute)
......@@ -559,12 +559,12 @@ class LDAPServers : NSObject, DNSResolverDelegate {
RunLoop.current.run(mode: RunLoopMode.defaultRunLoopMode, before: Date.distantFuture)
}
if (self.resolver.error == nil) {
myLogger.logit(3, message: "Did Receive Query Result: " + self.resolver.queryResults.description)
myLogger.logit(.debug, message: "Did Receive Query Result: " + self.resolver.queryResults.description)
//let dnsResults = self.resolver.queryResults as! [[String:AnyObject]]
currentState = true
return true
} else {
myLogger.logit(2, message: "Can't find any SRV records for domain.")
myLogger.logit(.notice, message: "Can't find any SRV records for domain.")
currentState = false
return false
}
......@@ -586,7 +586,7 @@ class LDAPServers : NSObject, DNSResolverDelegate {
}
if (self.resolver.error == nil) {
myLogger.logit(3, message: "Did Receive Query Result: " + self.resolver.queryResults.description)
myLogger.logit(.debug, message: "Did Receive Query Result: " + self.resolver.queryResults.description)
let records = self.resolver.queryResults as! [[String:AnyObject]]
for record: Dictionary in records {
let host = record["target"] as! String
......@@ -594,7 +594,7 @@ class LDAPServers : NSObject, DNSResolverDelegate {
}
} else {
myLogger.logit(3, message: "Query Error: " + self.resolver.error.localizedDescription)
myLogger.logit(.debug, message: "Query Error: " + self.resolver.error.localizedDescription)
}
return results
}
......@@ -616,7 +616,7 @@ class LDAPServers : NSObject, DNSResolverDelegate {
}
if (self.resolver.error == nil) {
myLogger.logit(3, message: "Did Receive Query Result: " + self.resolver.queryResults.description)
myLogger.logit(.debug, message: "Did Receive Query Result: " + self.resolver.queryResults.description)
var newHosts = [LDAPServer]()
let records = self.resolver.queryResults as! [[String:AnyObject]]
......@@ -637,7 +637,7 @@ class LDAPServers : NSObject, DNSResolverDelegate {
self.currentState = true
} else {
myLogger.logit(3, message: "Query Error: " + self.resolver.error.localizedDescription)
myLogger.logit(.debug, message: "Query Error: " + self.resolver.error.localizedDescription)
self.currentState = false
hosts.removeAll()
}
......@@ -651,7 +651,7 @@ class LDAPServers : NSObject, DNSResolverDelegate {
if self.currentState == true {
for i in 0...( hosts.count - 1) {
if hosts[i].status != "dead" {
myLogger.logit(1, message:"Trying host: " + hosts[i].host)
myLogger.logit(.info, message:"Trying host: " + hosts[i].host)
// socket test first - this could be falsely negative
// also note that this needs to return stderr
......@@ -669,20 +669,20 @@ class LDAPServers : NSObject, DNSResolverDelegate {
defaultNamingContext = getAttributeForSingleRecordFromCleanedLDIF(attribute, ldif: ldifResult)
hosts[i].status = "live"
hosts[i].timeStamp = Date()
myLogger.logit(0, message:"Current LDAP Server is: " + hosts[i].host )
myLogger.logit(0, message:"Current default naming context: " + defaultNamingContext )
myLogger.logit(.base, message:"Current LDAP Server is: " + hosts[i].host )
myLogger.logit(.base, message:"Current default naming context: " + defaultNamingContext )
current = i
break
}
}
// We didn't get an actual LDIF Result... so LDAP isn't working.
myLogger.logit(1, message:"Server is dead by way of ldap test: " + hosts[i].host)
myLogger.logit(.info, message:"Server is dead by way of ldap test: " + hosts[i].host)
hosts[i].status = "dead"
hosts[i].timeStamp = Date()
break
} else {
myLogger.logit(1, message:"Server is dead by way of socket test: " + hosts[i].host)
myLogger.logit(.info, message:"Server is dead by way of socket test: " + hosts[i].host)
hosts[i].status = "dead"
hosts[i].timeStamp = Date()
}
......@@ -695,7 +695,7 @@ class LDAPServers : NSObject, DNSResolverDelegate {
}
if hosts.last!.status == "dead" {
myLogger.logit(0, message: "All DCs in are dead! You should really fix this.")
myLogger.logit(.base, message: "All DCs in are dead! You should really fix this.")
self.currentState = false
} else {
self.currentState = true
......@@ -706,11 +706,11 @@ class LDAPServers : NSObject, DNSResolverDelegate {
var resolver: DNSResolver;
func dnsResolver(_ resolver: DNSResolver!, didReceiveQueryResult queryResult: [AnyHashable: Any]!) {
myLogger.logit(3, message: "Did Recieve Query Result: " + queryResult.description);
myLogger.logit(.debug, message: "Did Recieve Query Result: " + queryResult.description);
}
func dnsResolver(_ resolver: DNSResolver!, didStopQueryWithError error: NSError!) {
myLogger.logit(3, message: "Did Recieve Query Result: " + error.description);
myLogger.logit(.debug, message: "Did Recieve Query Result: " + error.description);
}
}
......@@ -107,7 +107,7 @@ class LoginWindow: NSWindowController, NSWindowDelegate {
alertController.addButton(withTitle: "Change Password")
alertController.beginSheetModal(for: self.window!, completionHandler: { [unowned self] (returnCode) -> Void in
if returnCode == NSAlertFirstButtonReturn {
myLogger.logit(0, message:myError!)
myLogger.logit(.base, message:myError!)
self.setWindowToChange()
}
})
......@@ -115,14 +115,14 @@ class LoginWindow: NSWindowController, NSWindowDelegate {
let alertController = NSAlert()
alertController.messageText = "Invalid username. Please try again."
alertController.beginSheetModal(for: self.window!, completionHandler: nil)
myLogger.logit(0, message:myError!)
myLogger.logit(.base, message:myError!)
EXIT_FAILURE
//
default:
let alertController = NSAlert()
alertController.messageText = "Invalid password. Please try again."
alertController.beginSheetModal(for: self.window!, completionHandler: nil)
myLogger.logit(0, message:myError!)
myLogger.logit(.base, message:myError!)
EXIT_FAILURE
}
// TODO: figure out if this is the proper way to handle this.
......@@ -198,13 +198,13 @@ class LoginWindow: NSWindowController, NSWindowDelegate {
let alertController = NSAlert()
alertController.messageText = "Invalid password. Please try again."
alertController.beginSheetModal(for: self.window!, completionHandler: nil)
myLogger.logit(0, message:myError!)
myLogger.logit(0, message:"Local password wrong.")
myLogger.logit(.base, message:myError!)
myLogger.logit(.base, message:"Local password wrong.")
EXIT_FAILURE
// TODO: figure out if this is the proper way to handle this.
return
}
myLogger.logit(0, message:"Local password is right. Syncing.")
myLogger.logit(.base, message:"Local password is right. Syncing.")
do {
try noMADUser.changeCurrentConsoleUserPassword(currentLocalPassword, newPassword1: newPassword, newPassword2: newPassword, forceChange: true)
......@@ -229,7 +229,7 @@ class LoginWindow: NSWindowController, NSWindowDelegate {
myError = "Could not change your local keychain password."
}
} else {
myLogger.logit(0, message:"Local sync cancelled by user.")
myLogger.logit(.base, message:"Local sync cancelled by user.")
}
})
......@@ -251,7 +251,7 @@ class LoginWindow: NSWindowController, NSWindowDelegate {
let alertController = NSAlert()
alertController.messageText = nomadUserError.description
alertController.beginSheetModal(for: self.window!, completionHandler: nil)
myLogger.logit(0, message:myError!)
myLogger.logit(.base, message:myError!)
EXIT_FAILURE
self.Password.stringValue = ""
self.close()
......@@ -259,7 +259,7 @@ class LoginWindow: NSWindowController, NSWindowDelegate {
let alertController = NSAlert()
alertController.messageText = "Unknown error."
alertController.beginSheetModal(for: self.window!, completionHandler: nil)
myLogger.logit(0, message:myError!)
myLogger.logit(.base, message:myError!)
EXIT_FAILURE
self.Password.stringValue = ""
self.close()
......@@ -325,7 +325,7 @@ class LoginWindow: NSWindowController, NSWindowDelegate {
}
})
}
myLogger.logit(0, message:myError)
myLogger.logit(.base, message:myError)
} else {
let alertController = NSAlert()
......@@ -409,11 +409,11 @@ class LoginWindow: NSWindowController, NSWindowDelegate {
var myError: String = ""
if (currentPassword.isEmpty || newPassword1.isEmpty || newPassword2.isEmpty) {
myLogger.logit(0, message:"Some of the fields are empty")
myLogger.logit(.base, message:"Some of the fields are empty")
myError = "All fields must be filled in"
return myError
} else {
myLogger.logit(2, message:"All fields are filled in, continuing")
myLogger.logit(.notice, message:"All fields are filled in, continuing")
}
// If the user entered the same value for both password fields.
if ( newPassword1 == newPassword2) {
......@@ -424,7 +424,7 @@ class LoginWindow: NSWindowController, NSWindowDelegate {
if (localPasswordSync == 1 ) && myError == "" {
do { try testLocalPassword(currentPassword) }
catch {
myLogger.logit(1, message:"Local password check Swift = no")
myLogger.logit(.info, message:"Local password check Swift = no")
myError = "Your current local password does not match your AD password."
}
}
......@@ -447,7 +447,7 @@ class LoginWindow: NSWindowController, NSWindowDelegate {
// Update the keychain password
if (localPasswordSync == 1 ) && myError == "" {
if (ChangePassword.changeKeychainPassword(currentPassword, newPassword1) == 0) {
myLogger.logit(1, message:"Error changing local keychain")
myLogger.logit(.info, message:"Error changing local keychain")
myError = "Could not change your local keychain password."
}
}
......@@ -457,7 +457,7 @@ class LoginWindow: NSWindowController, NSWindowDelegate {
if (localPasswordSync == 1 ) && myError == "" {
do { try changeLocalPassword( currentPassword, newPassword: newPassword1) }
catch {
myLogger.logit(0, message:"Local password change failed")
myLogger.logit(.base, message:"Local password change failed")
myError = "Local password change failed"
}
}
......@@ -493,7 +493,7 @@ class LoginWindow: NSWindowController, NSWindowDelegate {
}
fileprivate func sendResetMessage() -> Void {
myLogger.logit(0, message:"Need to reset user's password.")
myLogger.logit(.base, message:"Need to reset user's password.")
notificationQueue.enqueue(resetNotificationKey, postingStyle: .now, coalesceMask: .onName, forModes: nil)
}
}
......@@ -39,7 +39,7 @@ public func cliTask( _ command: String, arguments: [String]? = nil) -> String {
} else {
commandLaunchPath = command
commandPieces = arguments!
//myLogger.logit(3, message: commandLaunchPath + " " + arguments!.joinWithSeparator(" "))
//myLogger.logit(.debug, message: commandLaunchPath + " " + arguments!.joinWithSeparator(" "))
}
// make sure the launch path is the full path -- think we're going down a rabbit hole here
......
......@@ -113,7 +113,7 @@ if searchDomain != nil {
let searchDomain2 = myValues!["SupplementalMatchDomains"] as! [String]
if searchDomain2.contains(currentDomain) {
myLogger.logit(2, message: "Using domain-specific interface.")
myLogger.logit(.notice, message: "Using domain-specific interface.")
// get the interface GUID
let interfaceGUID = myValues!["ConfirmedServiceID"]
......@@ -133,12 +133,12 @@ return network
}
}
myLogger.logit(3, message: "Looking for primary interface.")
myLogger.logit(.debug, message: "Looking for primary interface.")
let globalInterface = SCDynamicStoreCopyValue(store, "State:/Network/Global/IPv4")
let interface = globalInterface!["PrimaryInterface"] as! String
myLogger.logit(3, message: "Primary interface is " + interface)
myLogger.logit(.debug, message: "Primary interface is " + interface)
let val = SCDynamicStoreCopyValue(store, "State:/Network/Interface/" + interface + "/IPv4") as! NSDictionary
......@@ -219,14 +219,14 @@ return dec
private func getInterfaceMatchingDomain() -> String? {
// TODO: Replace cliTask
// not the best looking code, but it works
myLogger.logit(2, message: "Trying to get interface with search domain of \(currentServer)")
myLogger.logit(.notice, message: "Trying to get interface with search domain of \(currentServer)")
let interfaceRaw = cliTask("/sbin/route get " + currentServer )
if interfaceRaw.containsString("interface") {
for line in interfaceRaw.componentsSeparatedByString("\n") {
if line.containsString("interface") {
myLogger.logit(3, message: line)
myLogger.logit(.debug, message: line)
return line.stringByReplacingOccurrencesOfString(" interface: ", withString: "").stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
}
}
......@@ -237,7 +237,7 @@ private func getInterfaceMatchingDomain() -> String? {
// MARK: IP/Subnet Stuff
private func getPrimaryInterface() -> String {
myLogger.logit(2, message: "Getting the primary interface.")
myLogger.logit(.notice, message: "Getting the primary interface.")
let globalInterface = SCDynamicStoreCopyValue(store, "State:/Network/Global/IPv4")
let interface = globalInterface!["PrimaryInterface"] as! String
return interface
......@@ -246,7 +246,7 @@ private func getPrimaryInterface() -> String {
// private function to get IP and mask
private func getNetworkInfoForInterface( interface:String ) -> Network {
myLogger.logit(3, message: "Getting network info for interface " + interface)
myLogger.logit(.debug, message: "Getting network info for interface " + interface)
let val = SCDynamicStoreCopyValue(store, "State:/Network/Interface/" + interface + "/IPv4") as! [String: [String]]
......
This diff is collapsed.
......@@ -96,7 +96,7 @@ class PasswordChangeWindow: NSWindowController, NSWindowDelegate {
}