Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] DDFileLogger causes crash when logging from background app #129

Closed
belenko opened this issue Aug 3, 2013 · 3 comments
Closed

[iOS] DDFileLogger causes crash when logging from background app #129

belenko opened this issue Aug 3, 2013 · 3 comments
Labels
Milestone

Comments

@belenko
Copy link

belenko commented Aug 3, 2013

DDFileLogger causes application to crash under following conditions:

  • Application is running in background
  • Device is passcode protected
  • Device has been locked for at least 10 seconds (data protection keys are purged from memory after 10 seconds)
  • com.apple.developer.default-data-protection entitlement is set to NSFileProtectionComplete (which is default for me -- I haven't specified this value explicitly)

Crash log will show exception being raised in [DDFileLogger logMessage:] as a result of [NSConcreteFileHandle writeData:]. The reason is DDFileLogger tries to write to a file that is encrypted by Data Protection and is not accessible because device is locked.

Workaround is to override default attributes when creating log file, i.e. set attributes to @{NSFileProtectionKey : NSFileProtectionNone} when calling [NSFileManager createFileAtPath:contents:attributes:] in [DDLogFileManagerDefault createNewLogFile].

This has security implications. If application is not supposed to be relaunched by iOS while device is locked (majority of apps are of this kind, I suppose) then NSFileProtectionCompleteUnlessOpen or NSFileProtectionCompleteUntilFirstUserAuthentication should be used instead of NSFileProtectionNone.

@bpoplauschi
Copy link
Member

@belenko
Copy link
Author

belenko commented Nov 1, 2013

That commit resolves the problem, yes, but it is more of a workaround than a proper fix. Setting log protection class to NSFileProtectionNone has security implications and thus I am not sure that commit should be merged.

dvor added a commit to dvor/CocoaLumberjack that referenced this issue Dec 2, 2013
…ow we are setting appropriate NSFileProtectionKey

(NSFileProtectionCompleteUntilFirstUserAuthentication if app is able launch from background and NSFileProtectionCompleteUnlessOpen in other cases).
dvor added a commit to dvor/CocoaLumberjack that referenced this issue Dec 2, 2013
…ow we are setting appropriate NSFileProtectionKey

(NSFileProtectionCompleteUntilFirstUserAuthentication if app is able launch from background and NSFileProtectionCompleteUnlessOpen in other cases).
@rivera-ernesto
Copy link
Member

Fixed by #183.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants