Showing posts with label macOS. Show all posts
Showing posts with label macOS. Show all posts

18 June 2019

How to dump macOS security-rights database

macOS handles some security items in a custom database, which may or may not be SQLite. The official way to interact with such database, outside of Objective-C, is the /usr/bin/security utility, with the parameter authorizationdb and specifying the required operation on the class of rights, e.g. security authorizationdb read system.login.console

Unfortunately, there is no way (that I could find) to simply list all classes. I was trying to uninstall something that might have had references in that db, but I wasn't sure about the class it might be registered under, so I wanted to dump them all.

Luckily I found what looks looks like a comprehensive list of rights. After a quick scraping job with Python, I had a list that I could use like this:

cat osxrights.txt | xargs -I % sh -c 'sudo security authorizationdb read %' | grep -B 10 myAnnoyingItemToRemove

... and the bundle wasn't anywhere, so I could just chuck it.

(Note: had the item been found, I would have had to dump the whole security class to a .plist file with security authorizationdb read the.class > my.plist , edited the file to remove it, then write it back to the db with security authorizationdb write the.class < my.plist )

14 March 2019

How to remove all bars in fullscreen mode in Firefox on MacOS/OSX ("kiosk mode")

Procedure

If you want to remove all toolbars from Firefox in fullscreen mode on Mac, this is the procedure:

  1. Type about:config: in the location bar to open advanced settings. (If it is the first time you do it, you might have to click "confirm" or something like that in the scary screen that comes up first.)
  2. search for full-screen-api.allow-trusted-requests-only and double-click the line that is found, so the value changes to false
  3. Bring up the Bookmark Toolbar if you don't have it (menu View -> Toolbars -> Bookmark Toolbar)
  4. Right-click on empty space in the Bookmark Toolbar, and select New Bookmark...
  5. In the Name field, type something like "Enter Fullscreen" (it doesn't really matter, just don't leave it blank)
  6. In the Location field, enter the following line:
    javascript:document.getElementsByTagName('html')[0].mozRequestFullScreen();void(0)
  7. Click Add to save the bookmark.
Now, when you click on that bookmark, Firefox will go "real fullscreen", hiding all toolbars. To get them back, you will have to press ESC.

Now, there is a bit of a snag. That preference in about:config: is set to true by default for a reason: it is a bit unsafe to allow any website to use fullscreen-enabling javascript. For this reason I would suggest to only do this for limited periods, then switch it back once you're done.

Long-winded explanation

FF has a preference, browser.fullscreen.autohide, that in theory should govern the behaviour of toolbars when going fullscreen. It is set to true by default, meaning toolbars should disappear. However, for some reason this property has (almost) always failed to work on MacOS/OSX builds of Firefox.

There used to be a few extensions that corrected that behaviour, but they've all gone away when Firefox switched to WebExtension APIs, which basically sandboxed extensions more rigidly and blocked them from changing the browser interface as deeply as they could before. This was the price for the dramatic performance improvement seen in Firefox 57+.

This workaround hence relies on the new Fullscreen WebAPI, which is supposed to be a new, standard way to enable fullscreen via Javascript on any browser (well, any browser that implements it - just a few at the moment). However, because of security concerns, this API is locked down by default; so, in order to use it, we first have to relax checks as described above. Once that is done, we can launch a bit of JS from a bookmark that triggers "real" fullscreen.

Credit to this AskDifferent post where I first found the trick.

25 April 2017

how to force-refresh macOS text auto-expansions without turning off iCloud

One of the little niceties OSX has had for a while is the automatic synchronization of text-expansion shortcuts across all iCloud-enabled Apple devices (i.e. what you find in System Preferences -> Keyboard -> Text on Mac, and General -> Keyboard -> Text Replacement on iOS). Unfortunately Apple tries a bit too hard to make it look "magic", which means that there is nothing one can do when the magic somehow refuses to work.

In my case, I ended up in a situation where the mac had lost all shortcuts. Various people on the internet recommend turning iCloud Drive on and off to get them back, but that's a very disruptive step I didn't want to take.

Luckily, this worked for me:

  1. Open a command terminal
  2. rm -rf ~/Library/Mobile\ Documents/com~apple~TextInput
  3. Log off
  4. make a change to the list of expansions on some other device (e.g. iPhone)
  5. log back on
This seems to have forced a refresh, and got all my shortcuts back.

It would be nice if Apple provided some command-line tool to perform this sort of explicit management for iCloud elements. As the saying goes, cache invalidation is one of the hardest problems in Computer Science; in order to do the right thing, any system needs all the help it can get. I should be able to say "just blow all my settings for this feature and refresh from iCloud" or "these are the good settings, overwrite whatever is in iCloud for this feature". Magic is nice, but as the citizens of Troy found out so many years ago, it's better to have backup plans for when the gods are against you.

13 October 2015

OSX 10.11 El Capitan / Sierra and Kinesis Freestyle 2 Bluetooth little glitch

UPDATE 2017-04-25: this solution came in handy when I had another glitch with Sierra: keys would lag or repeat very erratically. Tried resetting pram etc to no avail, so then I performed these steps out of desperation and it all went back to normal.

After upgrading to El Capitan, my Kinesis Freestyle 2 Bluetooth keyboard had a small issue, which I'm documenting here in case other people hit it.

Basically, after installing the OS update, F*/special keys were dead. Solution:

  1.  Open System Preferences -> Bluetooth
  2. Click on the X icon to the right of the keyboard, in order to un-pair it.
  3. turn the Kinesis off, then on again, and press the CONNECT button at the back of the keyboard
  4. The keyboard should pop on the screen, select it and pair it again (you will have to type a few numbers shown on screen)
All done! You should now have your special keys back.

Anonymization by Anonymouse.org ~ Adverts
Anonymouse better ad-free, faster and with encryption?
X