joshua-d-miller / macOSLAPS

Swift binary that will change a local administrator password to a random generated password. Similar behavior to LAPS for Windows
MIT License
385 stars 58 forks source link

fatal error: 'try!' #7

Closed ilikebigruts closed 7 years ago

ilikebigruts commented 7 years ago

Hi,

I'm having trouble with the swift version of macOSLAPS (python version works a treat). I Installed the latest version of macOSLAPS and added plist config file to /Library/Preferences/edu.psu.macoslaps.plist I keep getting this error in terminal as soon as I run "sudo /usr/local/laps/macOSLAPS"

fatal error: 'try!' expression unexpectedly raised an error: Foundation._GenericObjCError.nilError: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-802.0.53/src/swift/stdlib/public/core/ErrorType.swift, line 182 Current stack trace: 0 macOSLAPS 0x000000010ebe3990 swift_reportError + 129 1 macOSLAPS 0x000000010ec002a0 _swift_stdlib_reportFatalErrorInFile + 100 2 macOSLAPS 0x000000010e9603c0 (_assertionFailure(StaticString, String, file : StaticString, line : UInt, flags : UInt32) -> Never).(closure #1).(closure #1).(closure #1) + 124 3 macOSLAPS 0x000000010eba55d0 partial apply for (_assertionFailure(StaticString, String, file : StaticString, line : UInt, flags : UInt32) -> Never).(closure #1).(closure #1).(closure #1) + 93 4 macOSLAPS 0x000000010e95f0b0 specialized specialized StaticString.withUTF8Buffer<A> ((UnsafeBufferPointer<UInt8>) -> A) -> A + 342 5 macOSLAPS 0x000000010eba7710 partial apply for (_assertionFailure(StaticString, String, file : StaticString, line : UInt, flags : UInt32) -> Never).(closure #1).(closure #1) + 144 6 macOSLAPS 0x000000010e95fce0 specialized specialized String._withUnsafeBufferPointerToUTF8<A> ((UnsafeBufferPointer<UInt8>) throws -> A) throws -> A + 127 7 macOSLAPS 0x000000010eb69600 partial apply for (_assertionFailure(StaticString, String, file : StaticString, line : UInt, flags : UInt32) -> Never).(closure #1) + 185 8 macOSLAPS 0x000000010e95f0b0 specialized specialized StaticString.withUTF8Buffer<A> ((UnsafeBufferPointer<UInt8>) -> A) -> A + 342 9 macOSLAPS 0x000000010eb22b50 specialized _assertionFailure(StaticString, String, file : StaticString, line : UInt, flags : UInt32) -> Never + 144 10 macOSLAPS 0x000000010e9ade20 swift_unexpectedError_merged + 289 11 macOSLAPS 0x000000010e89d550 ad_tools(computer_record : [ODRecord], tool : String, password : String?, new_ad_exp_date : String?) -> String? + 3082 12 macOSLAPS 0x000000010e8999f0 macOSLAPS() -> () + 655 13 macOSLAPS 0x000000010e8999c0 main + 32 14 libdyld.dylib 0x00007fffbc9a6234 start + 1 Also there is no /Library/Logs/macOSLAPS.log file generated, I do find an error log in /Library/Logs/DiagnosticReports/ though, see attachment.

macOSLAPS_2017-08-22-115659_UW-C02FQ0NLDHJR.crash.zip

I've tried it on 10.11 and 10.12 and even did a fresh rebuild of 10.12 just to be sure I wasn't working on a damaged system. I've attached the config .plist as well incase that helps. Your assistance would be greatly appreciated. edu.psu.macoslaps.plist.zip

Kind Regards Craig

joshua-d-miller commented 7 years ago

So looking at your config I see you have | in the exclusion sets. Exclusion sets are an entire set of characters and are set like this: "symbols". To exclude the | character you want to add it to RemovePassChars. Give that a try and let me know! :)

ilikebigruts commented 7 years ago

Hi, thanks for the response,

I’ve removed the pipe from the “ExclusionSets” key and confirmed that the PasswordLength and DaysTillExpiration values are integers but I’m getting the same error.

The first line of the terminal output is: fatal error: 'try!' expression unexpectedly raised an error: Foundation._GenericObjCError.nilError: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-802.0.53/src/swift/stdlib/public/core/ErrorType.swift, line 182 Current stack trace: 0

I don’t know if it's relevant but If I look in /Library/Caches/ I don’t have the “com.apple.xbs” directory it mentions in the above error, or is that referring to a relative path to the “Foundation” module which is imported?

Kind Regards Craig

On 23 Aug 2017, at 1:18 am, Joshua D. Miller notifications@github.com wrote:

So looking at your config I see you have | in the exclusion sets. Exclusion sets are an entire set of characters and are set like this: "symbols". To exclude the | character you want to add it to RemovePassChars. Give that a try and let me know! :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

joshua-d-miller commented 7 years ago

Is your local admin account actually called admin?

ilikebigruts commented 7 years ago

No, I changed the admin username in the plist I sent you for the purpose of keeping my local admin account off the internet, but the right username is in my preference .plist and it works fine with the python version of macOSLAPS.

Kind Regards Craig

joshua-d-miller commented 7 years ago

Craig,

Are you using my previous compiled build? This was before @bartreardon made some changes to how if a password was never set. Please download the new build and let me know if you see the same issue.

Thanks!

ilikebigruts commented 7 years ago

Hi Joshua,

Thanks for getting back to me, I’ve downloaded the latest release and now get a slightly different output: "fatal error: Index out of range"

`Warning|Mon Sep 11, 2017 11:09:44 AM|macOSLAPS|There has never been a random password generated for this device. Setting a default expiration date of 01/01/2001 in Active Directory to force a password change... Info|Mon Sep 11, 2017 11:09:44 AM|macOSLAPS|Password Change is required as the LAPS password for **** has expired fatal error: Index out of range Current stack trace: 0 macOSLAPS 0x00000001008a7910 swift_reportError + 129 1 macOSLAPS 0x00000001008c4330 _swift_stdlib_reportFatalError + 60 2 macOSLAPS 0x0000000100623030 specialized specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) -> A) -> A + 342 3 macOSLAPS 0x000000010082d4d0 partial apply for (_fatalErrorMessage(StaticString, StaticString, file : StaticString, line : UInt, flags : UInt32) -> Never).(closure #2) + 109 4 macOSLAPS 0x0000000100623030 specialized specialized StaticString.withUTF8Buffer ((UnsafeBufferPointer) -> A) -> A + 342 5 macOSLAPS 0x00000001007e3b00 specialized _fatalErrorMessage(StaticString, StaticString, file : StaticString, line : UInt, flags : UInt32) -> Never + 96 6 macOSLAPS 0x000000010056e820 specialized Array.subscript.getter + 128 7 macOSLAPS 0x000000010055e160 generate_random_pw(length : Int) -> String + 2460 8 macOSLAPS 0x0000000100563110 perform_password_change(computer_record : [ODRecord], local_admin : String) -> () + 1394 9 macOSLAPS 0x000000010055d770 macOSLAPS() -> () + 1379 10 macOSLAPS 0x000000010055d740 main + 32 11 libdyld.dylib 0x00007fff8a7285ac start + 1

Illegal Instruction: 4 `

I've also attached the crash log. macOSLAPS_2017-09-11-113756_UW-C02FQ0NLDHJR.crash.zip

Kind Regards Craig

ilikebigruts commented 7 years ago

Sorry I didn't mean to close this out.

joshua-d-miller commented 7 years ago

@ilikebigruts would you be able to post your plist config file obviously removing your admin username?

ilikebigruts commented 7 years ago

Hi Joshua,

Thanks for getting back to me, I had another look at my plist config and noticed that I had an empty string in the "ExclusionSets" array, showing up as quotes which macosLAPS obviously doesn't like. { DaysTillExpiration = 30; ExclusionSets = ( "" ); LocalAdminAccount = admin; PasswordLength = 12; RemoveKeyChain = true; RemovePassChars = "'"; }

I removed the string from the "ExclusionSets" array and SUCCESS! It's working now.

Thanks for your assistance and my apologies for my dodgy plist creation skills.

Kind Regards Craig

joshua-d-miller commented 7 years ago

Craig,

I'm so glad it is working for you now 👍 . If you have any other issues please be sure to let me know!