Normal view

There are new articles available, click to refresh the page.
Before yesterdayMain stream

Delving deep into user accounts in Directory Services

By: hoakley
31 July 2024 at 14:30

The kernel at the heart of macOS is XNU, standing for X is Not Unix, as, however much macOS might have in common with Unix, once you scratch its surface it’s all very different. Several of you commented recently that what I referred to as a user’s UniqueID should have been termed User ID as it would be in Unix. But dig deeper and you’ll see that macOS does indeed refer to that internally as the UniqueID, because that’s how it’s named for Directory Services in macOS.

Older versions of macOS used to provide advanced options for users in Users & Groups settings, where you could even change a user’s UUID. Then a bright spark thought it would be fun to tell users to change that in a misguided bid to improve their privacy. When someone who seems to know what they’re writing about tells you to do that, you go and try it, don’t you? Only changing a user’s UUID is catastrophic, and most who did so ended up having to rebuild the contents of their Mac from scratch to put the damage right. The lesson is that you should never try anything you don’t understand, for which there’s no simple undo, and which might have serious side-effects. Please don’t do that: it’s such a crazy idea that it’s malicious in intent. As a result, Apple has progressively removed those dangerous advanced user settings, to keep them out of harm’s way.

But there are times when you do need to make such changes, or at least check what current settings are. For those you’ll need Directory Services’ editor, Directory Utility, which is carefully hidden in /System/Library/CoreServices/Applications. Whatever you do, please don’t authenticate to Directory Utility, to ensure that you can’t inadvertently change anything that could give you grief.

Modern Directory Services have a long history that I’ll explain on Saturday morning, but they’re basically descended from NeXTSTEP’s NetInfo and the Lightweight Directory Access Protocol (LDAP) implemented in Apple’s successor Open Directory. These flourished in the days of Mac OS X Server, but since then have carried on quietly serving macOS with information about users, groups, and a whole lot more.

Directory Utility may be hidden away, but it’s still well documented, and its Help book is worth browsing. Unless your Mac is connected to a server delivering it LDAPv3, Active Directory or similar services, once you’ve selected the Directory Editor at the top, view Users in the node /Local/Default, as your Mac’s local directory. There you’ll find your personal details, including your UUID as GeneratedUID, your Home folder as NFSHomeDirectory, long user name as RealName, short name as RecordName, and user ID as UniqueID.

dirutil2024

Listed as users are many of the services your Mac connects to on your behalf, including the App Store, Apple Pay, Find My and more. Each of these has its own UniqueID, PrimaryGroupID, and more. There may also be hidden users that you thought had been removed, and shared folders from years ago. Don’t give way to any temptation to try ‘cleaning’ this up, as it’s all too easy to wreak havoc unintentionally.

In the past, Directory Utility was commonly used to enable the root user and change its password, features that may still available today in its Edit menu once you’ve authenticated. At one time this was useful, but shouldn’t be used any more unless you’re advised to by Apple.

Directory Utility is now mainly used when integrating a Mac with a network directory server, including Open Directory (formerly in Mac OS X Server), LDAP on a Linux or other server, and Microsoft’s Active Directory. For the advanced user it gathers important information in one place, and every once in a blue moon it can unscramble a Mac or user account that would otherwise require starting from scratch. But please don’t authenticate and start making changes, as you’ll most likely regret it.

Check UPS, batteries and input devices using Unhidden

By: hoakley
8 July 2024 at 14:30

Sometimes developing software is a journey of exploration without a clear destination. A couple of weeks ago, I wrote about how log entries from Battery Center revealed useful information about input devices like keyboards and mice, and Uninterruptible Power Supplies (UPS). Several of you remarked that it would be useful to have a utility to provide easy access to those. This is my first progress report, and comes complete with a first version of that utility, Unhidden.

Battery Center

It turns out that those log entries from the com.apple.BatteryCenter don’t come from macOS itself, but from one of three new Private Frameworks added to macOS Sonoma: BatteryCenter itself, and two supporting frameworks BatteryCenterUI and BatteryUIKit. In Ventura and earlier, similar log entries came from com.apple.iohid, although those weren’t as extensive.

Battery Center appears to support Battery widgets in /System/Library/CoreServices/Batteries.app named BatteriesAvocadoWidget, and offered in Sonoma’s new range of widgets.

unhidwidgets

Thus, com.apple.BatteryCenter periodically checks known connected input devices (‘HID’ for Human Interface Devices), UPS, and internal batteries in Mac notebooks, and publishes lists of information in the log. That data is used by the background service app Batteries.app to feed the data displayed in the Battery widgets available in Sonoma.

Unless your Mac has a Battery widget installed, perhaps on its Desktop, Battery Center entries don’t appear in its log. When you do add a Battery widget to the Desktop, though, checks are made every few seconds, and their results written to the log, and those continue even after removing the widget, at least until the next time that Mac is shut down or restarted.

Third-party software isn’t supposed to access private services like Battery Center, so creating an independent utility to perform similar functions would have to capture its own data. However, given access to the log, it’s possible to read Battery Center’s entries there instead.

Unhidden

This initial version does one job: each time you open a new window in the app, it displays the most recent results obtained by Battery Center, across all the devices that it checks. There are three essential requirements:

  • The Mac must be running macOS Sonoma or later (including Sequoia betas); this works on both Intel and Apple silicon Macs.
  • The user must have admin privileges, as those are required to access the log.
  • Battery Center must be running. This normally requires that a Battery widget has been installed since the last time that Mac started up, unless it’s already running.

Each time Unhidden opens a fresh window, it inspects the log for Battery Center entries. It initially checks the last 5 seconds, then increases the time period up to a maximum of half an hour. It then either reports that it can’t find any entries from Battery Center, or it displays them in the window.

unhidden1

Standard display gives all key results obtained in compact lines. If those aren’t clear or large enough, there’s optional Large Text.

unhidden2

Supported devices

Unhidden has been tested with the following:

  • Apple wireless Magic Keyboards, both operating on battery and when connected by their charging cable
  • Apple wireless Magic Mice, both operating on battery and when connected by their charging cable
  • Apple wireless Magic Trackpad 2, both operating on battery and when connected by their charging cable
  • Supported UPS connected by a USB cable
  • Standard Mac notebook internal batteries, both charging and not.

The range of peripherals is wide, and to make it easy to report problems with other devices, and errors, Unhidden has a Debug Mode. To enter that, it must be selected in Settings, the app quit, and opened again. Instead of seeing normal results in its window, Debug Mode displays the original raw log entries, together with a button to save those in a text file. Please add problem entries to this article as comments, or send them to me by email (address in the About page), so that Unhidden can accommodate more devices correctly.

Download

Unhidden version 1.0 is now available only from here for the time being: unhidden01

Future

I’d really like to discover a way of activating Battery Center without having to fiddle with widgets, something I’ll be looking at next. There are several alternative ways to present these results, and to check them at regular intervals, perhaps presenting changes graphically. Please let me know where you’d like Unhidden to go, if you’re interested in my developing it any further.

给群晖加一个UPS

18 December 2019 at 21:39

UPS——不间断电源,就是一个大型的充电宝,能在停电后给你的机器提供几分钟的供电时间,让你有时间思考一下是不是得换个小区住了。
——五花肉肉。

在一个月时间内家里连续停电两次,都是发生在夜间,停电后又恢复。第一次由于没有给群晖NAS设置停电后来电重启,导致我到了公司却连不上家里的NAS,耽误了些事。那次就决定买一个UPS不间断电源了,结果双十二忘记了,第二次发生在前天,起床后蹲马桶上就下了一单。

我知道现在的UPS都无法在停电后提供很长时间的供电,我想要的是停电后能自动关机,确保数据不会因为自动断电而损坏就行了,在这个基础上UPS的体积越小越好。

首先在群晖官网的兼容性列表里查我的918+兼容的UPS型号,大概考虑购买渠道、价钱、体积、外观几个因素后选定了Santak的TG-BOX 600,到底是不是最适合我的那些条件的,我也不知道,毕竟马桶不能蹲太久。

别废话,先看东西。

包装很简单,附送一条USB数据线和一张说明书就完了。说实话虽然选的最小号的UPS,但实物之大还是超乎我的想象,比我的脚大多了。需要注意的是左侧这一排是不间断电源,而右侧这一排则是普通防雷电源。

电源的顶部开关,保险,两个USB充电口(都说是个充电宝了嘛),还有一个USB通讯口,可以和NAS连接。背部还可以拆卸电池,如果内置电池寿命到了可以自行更换。

连接NAS

电源接入家里的电源插座,NAS电源插入UPS”不间断电源“这一排插座,附赠的USB数据线连接UPS的通讯口和NAS的USB接口就行了。

NAS设置

在群晖系统设置-电源-不断电系统里勾选“启用UPS支持”,应用即可。因为我购买的是群晖兼容性列表里提供的UPS型号,所以没什么其它设置了,如果不是的话可能还要选择UPS的型号。

”Diskstation进入安全模式之前的等待时间”选项是说当停电时不会马上关机,而是达到你设置的时间或者电池用完后才关机。

“设备信息”则可以查看UPS的状况。如下图

另外还要在电源-常规里勾选“电力故障排除后自动重启启动”,这样来电后就会自动开机了。

祝大家玩得开心。

❌
❌