Skip to content

Preferences not being stored on macOS Sierra #737

Closed

Description

@MarqueIV

Details for the issue

When running SQLiteBrowser (now renamed to DB Browser for SQLite) on macOS Sierra beta, because the app is unsigned, it can not find its preferences file and as such, the colors in the data browser tab are all black, meaning black text on black background. Even if you change them, while they will work for that session, closing and reopening the app resets all of your settings.

My suspicion is this has to do with the new way macOS Sierra handles unsigned applications. It stores them in a 'random, secure' portion on disk, not simply the application folder even though it looks like that's where it is. This is part of their new security. My guess is this is the cause of the app not being able to find the preferences.

That said, even if the preference file isn't found, the defaults should not be black on black. At least set them to black on white, possibly making nulls gray on white.

All of the above is also pure speculation and I could be completely wrong, but I am not seeing this behavior on earlier versions of OS X, including El Capitan, only macOS Sierra.

Useful extra information

I'm opening this issue because:

  • DB4S is crashing
  • DB4S has a bug
  • DB4S needs a feature
  • DB4S has another problem

I'm using DB4S on:

  • Windows
  • Linux: ( distro: ___ )
  • Mac OS
  • Other: ___

I'm using DB4S version:

  • 3.9.0 beta1
  • 3.8.0
  • Other: ___

I have also:

Activity

  1. self-assigned this
    on Aug 20, 2016
  2. justinclift commented on Aug 20, 2016

    @justinclift
    Member

    Thanks @MarqueIV, that's a very timely report. 😄

    We have an open ToDo list item for signing our releases, but weren't thinking to get it done just yet.

    Sounds like it should be a higher priority. I'll spend some time looking into it today/tomorrow, and see if it's possible to get tomorrow's release signed in time.

    For macOS Sierra itself... might be time to get my Apple Dev Membership renewed, and start looking through the beta too. Not sure when though. 😉

  3. MarqueIV commented on Aug 21, 2016

    @MarqueIV
    Author

    The good news is macOS Beta is now open to everyone, even without the developer network. Even so, your product has greatly improved my development environment so I would be more than happy to help you with testing, signed or unsigned. Let me know. I don't mind installing out for test builds.

    Feel free to reach out to me directly too. 234-248-6275 or Mark@MarkDonohoe.com

    Hope I can help!

    Mark

  4. justinclift commented on Aug 21, 2016

    @justinclift
    Member

    Thanks Mark. 😄

    It looks like the Apple Developer staff work on weekends, and they just sorted out the paperwork for that side of things. Now.. reading time. 😄

  5. justinclift commented on Aug 21, 2016

    @justinclift
    Member

    It's taken some doing, but I think signing on OSX is working ok now.

    @MarqueIV If you have a few minutes to try it, please grab this latest build (3.9.x series) and test if OSX throws up a warning when trying to run it:

        http://nightlies.sqlitebrowser.org/osx-prerelease/DB%20Browser%20for%20SQLite-3.9.0-beta2.dmg

    In theory the signature is all good, OSX is happy, etc. But... would prefer some people (other than me) test it first, just to be on the safe side. 😄

  6. justinclift commented on Aug 22, 2016

    @justinclift
    Member

    @MarqueIV Tested the latest nightly build on macOS Sierra (newly installed "Version 10.12 Beta (16A239m)") just now:

    •   https://nightlies.sqlitebrowser.org/osx/Older%20Versions/Aug%202016/DB%20Browser%20for%20SQLite-sqlcipher_20160822.dmg

    Two fairly concerning problems show up immediately, though both seem more like bugs with Sierra.

    When trying to mount the .dmg on Sierra through Finder, it claims the .dmg is damaged and should be moved to the trash. The .dmg is actually fine, as mounting it from the command line poses no issue:

    $ hdiutil attach DB\ Browser\ for\ SQLite-sqlcipher_20160822.dmg 
    Checksumming Protective Master Boot Record (MBR : 0)…
    Protective Master Boot Record (MBR :: verified   CRC32 $252B40D3
    Checksumming GPT Header (Primary GPT Header : 1)…
     GPT Header (Primary GPT Header : 1): verified   CRC32 $61E08442
    Checksumming GPT Partition Data (Primary GPT Table : 2)…
    GPT Partition Data (Primary GPT Tabl: verified   CRC32 $303E3D74
    Checksumming  (Apple_Free : 3)…
                        (Apple_Free : 3): verified   CRC32 $00000000
    Checksumming disk image (Apple_HFS : 4)…
    ..................................................................................................................................
              disk image (Apple_HFS : 4): verified   CRC32 $22F28C10
    Checksumming  (Apple_Free : 5)…
                        (Apple_Free : 5): verified   CRC32 $00000000
    Checksumming GPT Partition Data (Backup GPT Table : 6)…
    GPT Partition Data (Backup GPT Table: verified   CRC32 $303E3D74
    Checksumming GPT Header (Backup GPT Header : 7)…
      GPT Header (Backup GPT Header : 7): verified   CRC32 $61F46220
    verified   CRC32 $96EB1D9F
    /dev/disk1              GUID_partition_scheme           
    /dev/disk1s1            Apple_HFS                       /Volumes/Install DB4S Nightly build
    

    After dragging and dropping the DB4S icon to Applications... DB4S refuses to start, claiming it's damaged. Again, this is just plain wrong, as launching it directly from the command line works fine:

    $ /Applications/DB\ Browser\ for\ SQLite.app/Contents/MacOS/DB\ Browser\ for\ SQLite
    [the application starts fine, seems to work ok, and preferences are stored between runs]
    

    It's signature seems ok too:

    $ codesign --verify --verbose /Applications/DB\ Browser\ for\ SQLite.app
    /Applications/DB Browser for SQLite.app: valid on disk
    /Applications/DB Browser for SQLite.app: satisfies its Designated Requirement
    

    Judging by Sierra's flat out inaccuracy above... it might be best to wait for a few more betas... 😉

    Note - I haven't tried with any of the older, unsigned builds. It's completely possible they'll have different behaviour.

  7. justinclift commented on Aug 22, 2016

    @justinclift
    Member

    Hmmm, Sierra is saying there is a new update available (Beta 7). Going to give that a try too, just in case it fixes the bugs seen above.

  8. MarqueIV commented on Aug 23, 2016

    @MarqueIV
    Author

    Yeah, just came out today I think. I'm installing it on my machine too if you want another tester.

  9. MarqueIV commented on Aug 23, 2016

    @MarqueIV
    Author

    The DMG worked fine for me. As for the app, it worked after I disabled the security prompt.

    Even so, there was another issue... if you say 'run it this time' from sys prefs security, it doesn't actually open but instead prompts you again. You have to completely disable the security, run the app, then reenable.

    My guess is you're using a boot strap mech which would cause that as the boot strapped part runs, but then the main app gets blocked. But that's purely a guess.

    Again, disabling it temporarily solves the issue.

    One thing though, signing, sierra and the rest aside, you should still change the defaults to black on white instead of black on black when prefs aren't found. At least it's a temporary work-around rather than making a user have to change it every start as I do now. Of course this goes away with signing, but still... it's a good practice regardless.

    [Sent from my iPad Pro]

    On Aug 22, 2016, at 7:36 PM, Justin Clift notifications@github.com wrote:

    @MarqueIV Tested the latest nightly build on macOS Sierra (newly installed "Version 10.12 Beta (16A239m)") just now:

    http://nightlies.sqlitebrowser.org/osx/DB%20Browser%20for%20SQLite-sqlcipher_20160822.dmg
    

    Two fairly concerning problems show up immediately, though both seem more like bugs with Sierra.

    When trying to mount the .dmg on Sierra through Finder, it claims the .dmg is damaged and should be moved to the trash. The .dmg is actually fine, as mounting it from the command line poses no issue:

    $ hdiutil attach DB\ Browser\ for\ SQLite-sqlcipher_20160822.dmg
    Checksumming Protective Master Boot Record (MBR : 0)…
    Protective Master Boot Record (MBR :: verified CRC32 $252B40D3
    Checksumming GPT Header (Primary GPT Header : 1)…
    GPT Header (Primary GPT Header : 1): verified CRC32 $61E08442
    Checksumming GPT Partition Data (Primary GPT Table : 2)…
    GPT Partition Data (Primary GPT Tabl: verified CRC32 $303E3D74
    Checksumming (Apple_Free : 3)…
    (Apple_Free : 3): verified CRC32 $00000000
    Checksumming disk image (Apple_HFS : 4)…
    ..................................................................................................................................
    disk image (Apple_HFS : 4): verified CRC32 $22F28C10
    Checksumming (Apple_Free : 5)…
    (Apple_Free : 5): verified CRC32 $00000000
    Checksumming GPT Partition Data (Backup GPT Table : 6)…
    GPT Partition Data (Backup GPT Table: verified CRC32 $303E3D74
    Checksumming GPT Header (Backup GPT Header : 7)…
    GPT Header (Backup GPT Header : 7): verified CRC32 $61F46220
    verified CRC32 $96EB1D9F
    /dev/disk1 GUID_partition_scheme
    /dev/disk1s1 Apple_HFS /Volumes/Install DB4S Nightly build
    After dragging and dropping the DB4S icon to Applications... DB4S refuses to start, claiming it's damaged. Again, this is just plain wrong, as launching it directly from the command line works fine:

    $ /Applications/DB\ Browser\ for\ SQLite.app/Contents/MacOS/DB\ Browser\ for\ SQLite
    [the application starts fine, seems to work ok, and preferences are stored between runs]
    It's signature seems ok too:

    $ codesign --verify --verbose /Applications/DB\ Browser\ for\ SQLite.app
    /Applications/DB Browser for SQLite.app: valid on disk
    /Applications/DB Browser for SQLite.app: satisfies its Designated Requirement
    Judging by Sierra's flat out inaccuracy above... it might be best to wait for a few more betas... 😉

    Note - I haven't tried with any of the older, unsigned builds. It's completely possible they'll have different behaviour.

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

  10. MarqueIV commented on Aug 23, 2016

    @MarqueIV
    Author

    Crap! Missed this. I'll test when I'm back on my machine in about an hour.

  11. MarqueIV commented on Aug 23, 2016

    @MarqueIV
    Author

    Just a quick update... both the beta 2 and nightly open fine here on my desktop running El Capitan. No security prompts anymore so it's recognized as being signed.

    I'm currently installing the latest beta (Sierra 7) on my notebook and will let you know what happens there.

  12. 53 remaining items

  13. revolter commented on Jan 12, 2017

    @revolter
    Member
  14. justinclift commented on Jan 12, 2017

    @justinclift
    Member

    Excellent, thanks @revolter. 😄

  15. rmariuzzo commented on Jun 2, 2017

    @rmariuzzo

    I was fighting against this issue, had to delete my config files:

    find ~/Library/Preferences -name '*sqlitebrowser*' -delete

    Now, everything back to normal.

  16. justinclift commented on Jun 2, 2017

    @justinclift
    Member

    @rmariuzzo Interesting. Any idea if using the 1st or 2nd version of our 3.9.1 release for OSX?

    The original version we released (October last year) had a Qt bug causing this. So we made a 2nd version a few weeks later (with "v2" on the end of the filename) which should have fixed it for everyone. In theory. 😉

    If you're using the 2nd version, that's definitely something we'll need to keep an eye on!

  17. rmariuzzo commented on Jun 2, 2017

    @rmariuzzo

    I had the issue from 2-3 months ago, and I deleted the version I had and I downloaded today the DB.Browser.for.SQLite-3.9.1v2.dmg file and the error was there. Probably, because I already had the issue. I will try to customize my preferences and see if it happens again.

    Thanks for the quick reply :)

  18. justinclift commented on Jun 2, 2017

    @justinclift
    Member

    No worries. 😄

  19. donmontalvo commented on Aug 22, 2017

    @donmontalvo

    3.10.0 is out, and we'd like to offer it to our developers using Jamf Pro (Casper or JSS).

    Where is DB Browser for SQLite 3.10.0 storing it's prefs...in a DB? #shudder :)

  20. justinclift commented on Aug 22, 2017

    @justinclift
    Member

    @donmontalvo From memory on OSX they're stored in a flat file in the ~/Library/Preferences directory.

    I'm not on my OSX desktop atm though, but guessing you'll have one handy so would be able to check pretty quickly. 😄

    Now you mention it though... it is kind of ironic we're not storing them in a SQLite database. 😀

  21. donmontalvo commented on Aug 22, 2017

    @donmontalvo

    @justinclift, yep, first place I checked. I didn't see a key written for disabling updates when I did so through the app's GUI. Checked in ~/Library/Container/ and ~/Library/Group\ Containers/ even though the app isn't signed/sandboxed, just to be sure.

  22. justinclift commented on Aug 22, 2017

    @justinclift
    Member

    When you say, disabling updates, are you meaning to stop the automatic version check?

    It should definitely be there. We had a bug in the first version of it, where it wasn't being read back correctly (ugh), but that was ages ago. I really hope we haven't busted that again with the recent refactoring for getting the remote stuff working.

    I'll jump on my OSX desktop shortly and take a look.

  23. justinclift commented on Aug 22, 2017

    @justinclift
    Member

    k, took a while to refresh my memory and hunt around, but found it.

    On my local OSX desktop, the setting for it is stored in:

    ~/Library/Preferences/com.sqlitebrowser.sqlitebrowser.plist
    

    Mine was in binary plist format, so needed converting to the ascii format before being able to grok it:

    cp ~/Library/Preferences/com.sqlitebrowser.sqlitebrowser.plist ~/foo.plist
    plutil -convert xml1 foo.plist
    

    The value itself is called checkversion so grepping the above converted foo.plist for that string should find it. It does on mine.

    Does that help? 😄

  24. justinclift commented on Aug 22, 2017

    @justinclift
    Member

    Looking into it even more, this is the code in 3.10.0 which kicks off the version check:

    #ifdef CHECKNEWVERSION
    // Check for a new version if automatic update check aren't disabled in the settings dialog
    if(Settings::getValue("checkversion", "enabled").toBool())
    {
    m_remoteDb->fetch("https://raw.githubusercontent.com/sqlitebrowser/sqlitebrowser/master/currentrelease",
    RemoteDatabase::RequestTypeNewVersionCheck);
    }
    #endif

    As well as first checking if the user has disabled the remote check, the code for doing the check itself can be left out when DB4S is compiled.

    That flag is included for Windows and OSX by default in the Qt project file. The OSX line is here:

    QMAKE_CXXFLAGS += -DCHECKNEWVERSION

    So, if you want to be 100% sure... it's pretty easy to compile DB4S (the instructions are in BUILDING.md). You'd want to remove the above option from the src.pro file, then do the compile.

    For super overkill 😉, this is a copy of the script that builds our OSX nightly releases:

        https://gist.github.com/justinclift/59e2c975100c5cd647d773bc797312f0

    Might be useful bits in there if you want to see how our packaging gets put together. 😄

  25. donmontalvo commented on Aug 22, 2017

    @donmontalvo

    Ok sorted it out...clif note for disabling version when deploying this awesome app:

    bash-3.2# defaults read /Users/username/Library/Preferences/com.sqlitebrowser.sqlitebrowser checkversion.enabled
    1
    bash-3.2# defaults write /Users/username/Library/Preferences/com.sqlitebrowser.sqlitebrowser checkversion.enabled -bool false
    bash-3.2# defaults read /Users/username/Library/Preferences/com.sqlitebrowser.sqlitebrowser checkversion.enabled
    0
    bash-3.2# 
    

    Our deployment method loops through existing users, so an easy *.plist key to set.

    https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/defaults.1.html

  26. donmontalvo commented on Aug 22, 2017

    @donmontalvo

    BTW, on macOS, using defaults commands there's no reason to convert the file.

    What we do is:

    1. Download the DMG
    2. Wrap it using any tool (Whitebox Packages, Apple pkgbuild, Jamf Composer, etc.).
    3. Add postinstall.sh script to the package to set the setting (since it is per user), using a loop.
    4. Push the package using Jamf Pro, Munki, Apple Remote Desktop, etc.
    #!/bin/sh
    
    over500=$( dscl . list /Users UniqueID | awk '$2 > 500 { print $1 }' )
    
    APPLICATION="/Applications/DB Browser for SQLite.app"
    
    #-------------------------------------------------------
    # Remove Quarantine flag if not owned by root:wheel
    #-------------------------------------------------------
    
    /usr/bin/xattr -r -d com.apple.quarantine /Applications/"$APPLICATION"
    
    #-------------------------------------------------------
    # Set pref User Template for future users
    #-------------------------------------------------------
    
    /usr/bin/defaults write /System/Library/Preferences/com.sqlitebrowser.sqlitebrowser "checkversion.enabled" -bool false
    /bin/chmod -R 700 /System/Library/User\ Template/English.lproj/Library/Preferences/com.sqlitebrowser.sqlitebrowser.plist
    /usr/sbin/chown root:wheel /System/Library/User\ Template/English.lproj/Library/Preferences/com.sqlitebrowser.sqlitebrowser.plist
    
    #-------------------------------------------------------
    # Set prefs for existing users
    #-------------------------------------------------------
    
    for u in $over500 ;
    do
    	/usr/bin/defaults write /Users/"$u"/Library/Preferences/com.sqlitebrowser.sqlitebrowser "checkversion.enabled" -bool false
    	/bin/chmod -R 700 /Users/"$u"/Library/Preferences/com.sqlitebrowser.sqlitebrowser.plist
    	/usr/sbin/chown "$u" /Users/"$u"/Library/Preferences/com.sqlitebrowser.sqlitebrowser.plist
    done
    
    exit 0
    
  27. justinclift commented on Aug 23, 2017

    @justinclift
    Member

    Cool. Thanks @donmontalvo. 😄

    That certainly looks like it'll be useful reference material for people. 😀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions