TweetFollow Us on Twitter

MacEnterprise: Local MCX Revisited

Volume Number: 26
Issue Number: 03
Column Tag: MacEnterprise

MacEnterprise: Local MCX Revisited

Using an alternate local directory node for MCX data

by Greg Neagle, MacEnterprise.org

Introduction

About a year ago, I wrote a couple of columns on the subject of Local MCX - using the local directory to store Managed Preferences records. Those articles are in the MacTech archives for November 2008 and February 2009:

http://www.mactech.com/articles/mactech/Vol.24/24.11/2411MacEnterprise-MCX-NoExcuses/index.html

http://www.mactech.com/articles/mactech/Vol.25/25.02/2502MacEnterprise-LocoforLocalMCX/index.html

You can also read about local MCX in an even earlier article of mine:

http://managingosx.wordpress.com/2008/02/07/mcx-dslocal-and-leopard/

Local MCX seems to be one of the most popular topics I've written on, based on comments and mail I've received, and page views of the Local MCX articles. This month, we will look at Local MCX once again, and make some improvements in our implementation.

Back to Basics

The basic concept of Local MCX is simple: if you do not have or cannot use a central directory to store MCX data, you can still use Apple's Managed Preferences system to manage your machines by using the local directory service. You can use Workgroup Manager to create computer and computer group records in the local directory service store on a single machine. Since as of OS X 10.5, these are simply plist files in a special directory path, it's then possible to use any handy software distribution system you might have to deliver and install these files on all the machines you manage. If you already manage software installs on your machines, you can use the same methods to install these plist files.

In my earlier articles, I outlined a very specific strategy that I think gives you a lot of power and flexibility. The strategy is this: for each logical set of Managed Preferences, you create a computer group and manage a set of preferences for that group. For example, if you want to manage the screen saver, you create a computer group named "ScreenSaver" and use Workgroup Manager's preferences management editor to configure the managed preferences for that group. You then add a "local_computer" computer record to the computer group. This local_computer record (eventually) points to the local machine. You can create any number of computer groups, each with a logical grouping of preferences to be managed.

Since the "local_computer" computer record must contain the primary Ethernet MAC layer address of the machine as an identifier, you do have to implement a script that creates or modifies the "local_computer" computer record to contain the correct data for the current computer.

You now have the flexibility of deploying different sets of managed preferences to different machines by controlling which computer groups you copy to each machine's local directory service. If you have a group of machines for which you do not want to manage the screen saver, you just don't copy the screensaver.plist to that group of machine's /var/db/dslocal/nodes/Default/computergroups/ directory. In this way, you can mix-and-match different sets of managed preferences among your machines quite easily.

Minor Issues

I've been using this strategy for a little over two years now, and it's been working quite well. I had to make almost no changes when transitioning to Snow Leopard; most of my Local MCX computer groups worked unchanged. But there were a few rough edges.

The first may be merely cosmetic. When using Local MCX with computer records in the default local store (like the "local_computer" record described above), you would see entries like the following in the system log:

Mar 6 17:43:56 allure com.apple.loginwindow[39]: MCXCCacheGraph(local_computer, dsRecTypeStandard:Computers): Cannot cache because an existing record named "local_computer" has conflicting attributes and must be deleted before caching.

Mar 6 17:43:56 allure com.apple.loginwindow[39]: MCXD.getComputerInfoFromStartup: MCXCCacheGraph() == -2 (MCXCCacheGraph(local_computer, dsRecTypeStandard:Computers): Cannot cache because an existing record named "local_computer" has conflicting attributes and must be deleted before caching.)

Mar 6 19:48:52 allure /System/Library/CoreServices/ManagedClient.app/Contents/MacOS/ManagedClient[92889]: MCXCCacheGraph(local_computer, dsRecTypeStandard:Computers): Cannot cache because an existing record named "local_computer" has conflicting attributes and must be deleted before caching.

Mar 6 19:48:52 allure /System/Library/CoreServices/ManagedClient.app/Contents/MacOS/ManagedClient[92889]: MCXD.getComputerInfoFromStartup: MCXCCacheGraph() == -2 (MCXCCacheGraph(local_computer, dsRecTypeStandard:Computers): Cannot cache because an existing record named "local_computer" has conflicting attributes and must be deleted before caching.)

Even though these messages appear in the system log, the managed preferences seemed to work anyway, so it seems these warnings aren't fatal. Still, it seemed like we were doing something "wrong", and we should try to fix it.

A little more serious issue with our Local MCX strategy was this: occasionally, at startup, the "local_computer" record would mysteriously disappear or lose its ENetAddress attribute. The effect was that managed preferences stopped working. Another reboot generally cleared things up again, as a script that ran at startup recreated the local_computer data.

These two issues are probably related. It turns out that in a more traditional, Apple-supported configuration, where MCX data is coming from a network directory service, that MCX copies the active local computer record from the network directory service and creates a cached copy in the default local directory service node. By storing the MCX data in the default local directory service node, we get in the way of the caching process. It can't create its cached copy because we've already put something there. And on startup, under some conditions, it may delete our computer data, thinking it's just a cache file to be cleaned up.

I just lived with these issues, since the first wasn't serious, and the second I never saw on an actual user's machine - it just seemed to happen every once in a while on one of my test machines while I was testing something else. But every once in while, I'd poke at things, trying to make these issues go away. Until lately, I had no success.

Local directory nodes

Recently, on the MacEnterprise list, there was a discussion on using Local MCX on a NetBoot image. (You can read it here: http://groups.google.com/group/macenterprise/browse_thread/thread/f3c39db134738e66)

One of the participants suggested putting MCX data in a node other than /Local/Default. Immediately I saw the possibilities...

Let's step back a bit. If you've worked with Directory Services in OS X Leopard or Snow Leopard, you probably know that the local directory data is stored at /var/db/dslocal/nodes/Default. Inside that directory are subdirectories for users, groups, computers, computergroups, and more. Our original Local MCX implementation made use of plist files in the computers and computergroups directories.

You are probably also aware that OS X supports connecting to multiple network directory services concurrently. This is how the "Magic Triangle" works - a Mac is connected to both an Active Directory server and an Open Directory server, and gets directory information from both directories.

Even if you are connected to a single network directory, Mac OS X is making use of multiple directory sources. At the very least, it's consulting the local directory store as well as the network directory.

What many do not realize, though, is that OS X supports multiple local directory nodes. You might have gotten a clue from the directory names - the "nodes" in /var/db/dslocal/nodes/Default implies more than one node. It turns out that you can create additional local directory nodes.

I saw that we might be able to avoid the issues with the MCX caches by moving our MCX data out of the default local store and into an alternate local store. This would allow the MCX caching mechanism to copy data to the default local node, since we aren't using it anymore.

Let's get started. We'll assume you already have a Local MCX implementation with records in the default local node. If you don't, either follow along in your head, or find a copy of one of the older articles and set up a Local MCX implementation. Open a Terminal window:

cd /var/db/dslocal/nodes
sudo mkdir MCX
sudo chmod 700 MCX
sudo mkdir MCX/computers
sudo mkdir MCX/computergroups
sudo mv Default/computers/* MCX/computers/
sudo mv Default/computergroups/* MCX/computergroups/

What did we just do? We navigated to the dslocal/nodes directory. We created a new "MCX" node and set its permissions to match the Default node. We created computer and computergroup directories in the MCX node, and moved all the computer and computergroup objects from the Default node to the MCX node.

Now we need to let DirectoryService in on our changes - we just changed a bunch of stuff behind its back:

sudo killall DirectoryService

DirectoryService will restart by itself and notice our new local node.

Next, we need to tell DirectoryService to actually use the new node. Open Directory Utility. You can find it in /Applications/Utilities on Leopard, and in /System/Library/CoreServices on Snow Leopard. If you can't see the toolbar at the top of the Directory Utility window, click Show Advanced Settings. Click the Search Policy icon in the toolbar. Click the padlock icon and authenticate. Make sure the Search popup is set to Custom path. You should see something similar to Figure 1.


Figure 1 - Directory Utility Authentication search path

Let's add our new local node to our search path. Click the plus button under the list of Directory Domains. A sheet should appear like the one in Figure 2.


Figure 2 - adding the /Local/MCX directory node

Click Add. It will appear at the bottom of the search list. If you have a network directory in your list, move /Local/MCX above it, so it looks like Figure 3. Click Apply.


Figure 3 - /Local/MCX now in the search path

Now you can logout and back in, or restart, and take a look at your MCX settings using mcxquery or by looking in System Profiler. If all went well, you should see absolutely no change at all - everything should work exactly as it did before. If you look in the system log, you'll see the MCXCCacheGraph() warnings are gone!

So we've made some progress. We've moved the Local MCX data to an alternate local node, and MCX is still working. In order for this to be a usable solution, though, we need to make sure we can still work with the MCX data using Workgroup Manager. This was one of the appealing features of the original solution - we could use Workgroup Manager to set managed preferences almost as if we were using MCX with a network directory. We wouldn't want to lose that feature.

Launch Workgroup Manager. In the original Local MCX implementation, to access the local directory service, we connected to localhost with a local admin username and password, as in Figure 4.


Figure 4 - Workgroup Manager Connect

Once you do this, you should find yourself authenticated to local directory "/Local/Default". But since we've added a new node, we want to access that. Click the tiny globe next to the text that tells you which directory you are browsing and select Other... from the popup menu. From the sheet that appears, select Local, then MCX, as in Figure 5. Click OK.


Figure 5 - Selecting an alternate local node

You should now be viewing directory /Local/MCX. You can look at the computer and computergroup objects, but you can't edit them because you aren't authenticated. So click the padlock icon on the right side of the window. You'll get a dialog prompting you to authenticate to directory /Local/MCX. If you're like me, you'll enter the same admin username and password that you did to authenticate to /Local/Default. And you will be denied. Workgroup Manager will tell you "The login information is not valid for this server."

This puzzled me for a bit. I tried a few things, and then asked for help on the MacEnterprise list and on the Managing OS X site. A short time later, I had several suggestions to try adding an admin account to the /Local/MCX node. That seemed promising.

sudo dscl /Local/MCX create /Users/mcxadmin
sudo dscl /Local/MCX create /Users/mcxadmin uid 8080
sudo dscl /Local/MCX create /Users/mcxadmin gid 80
sudo dscl /Local/MCX create /Users/mcxadmin shell /dev/null
sudo dscl /Local/MCX passwd /Users/mcxadmin
New Password: <enter a password for the account>

Now what did we do? We used dscl to create a new user in the /Local/MCX node called "mcxadmin". (It's important that this name is different than any user in /Local/Default.) We set the uid to an arbitrary value (but one I thought was unique on this machine). We set the Group ID to 80, which is the Group ID of the admin group in /Local/Default. This gives the account admin rights. We set the shell to /dev/null because we don't want or need this account to be used to log in. We don't set a home directory for the same reason. Finally, we create a password for this new account.

Now go back to Workgroup Manager and try again to authenticate to the /Local/MCX directory, this time using the new mcxadmin account and password. Success! Figure 6 proves it. We can now create and edit managed preference records in our new local directory node.


Figure 6 - Authenticated to /Local/MCX

Finishing up

That was a lot of work to get back to where we started, and we've added another level of complexity to our Local MCX implementation. Is it worth it? That remains to be seen. It eliminates the MCXCCacheGraph() warnings from the log, so we're doing things in a way more compatible with how MCX was designed. It should eliminate the issue where local computer records are deleted at startup, though the jury is still out on that one. But we have added a new capability, which might be useful. It's now easy and straightforward to temporarily turn off all MCX management for a given computer - just launch Directory Utility and remove the /Local/MCX node from the search path. When you want to re-enable MCX, just add the /Local/MCX node back in.

If you decide to go forward with this change, you'll probably need to modify any scripts you have that create/modify the MAC layer address data in the local_computer record, since it now is in a different directory node. You'll need to modify your delivery mechanisms to deliver the computergroup plists to their new location as well. You'll need to find a way to add the new /Local/MCX node to the DirectoryService search path on all your managed machines. This can be done with dscl by manipulating the CSPSearchPath in the /Search node:

dscl /Search create / CSPSearchPath /Local/Default /BSD/local /Local/MCX /LDAPv3/ldap.pretendco.com

The above would be all on a single line. It might be easier to just package up the contents of /Library/Preferences/DirectoryService on a correctly configured machine and push that out to all your managed machines.

Conclusion

I've tested this on both Leopard and Snow Leopard, and it seems to work well. If you have a functioning Local MCX implementation that you are happy with, I don't blame you if you don't want to go through all the work needed to change to using an alternate local node. After all, the benefits of the change are minor. But if you are doing a new implementation, or overhauling your current implementation for a Snow Leopard rollout, consider using a /Local/MCX node. Good luck!


Greg Neagle is a member of the steering committee of the Mac OS X Enterprise Project (macenterprise.org) and is a senior systems engineer at a large animation studio. Greg has been working with the Mac since 1984, and with OS X since its release. He can be reached at gregneagle@mac.com.

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

The Legend of Heroes: Trails of Cold Ste...
I adore game series that have connecting lore and stories, which of course means the Legend of Heroes is very dear to me, Trails lore has been building for two decades. Excitedly, the next stage is upon us as Userjoy has announced the upcoming... | Read more »
Go from lowly lizard to wicked Wyvern in...
Do you like questing, and do you like dragons? If not then boy is this not the announcement for you, as Loongcheer Game has unveiled Quest Dragon: Idle Mobile Game. Yes, it is amazing Square Enix hasn’t sued them for copyright infringement, but... | Read more »
Aether Gazer unveils Chapter 16 of its m...
After a bit of maintenance, Aether Gazer has released Chapter 16 of its main storyline, titled Night Parade of the Beasts. This big update brings a new character, a special outfit, some special limited-time events, and, of course, an engaging... | Read more »
Challenge those pesky wyverns to a dance...
After recently having you do battle against your foes by wildly flailing Hello Kitty and friends at them, GungHo Online has whipped out another surprising collaboration for Puzzle & Dragons. It is now time to beat your opponents by cha-cha... | Read more »
Pack a magnifying glass and practice you...
Somehow it has already been a year since Torchlight: Infinite launched, and XD Games is celebrating by blending in what sounds like a truly fantastic new update. Fans of Cthulhu rejoice, as Whispering Mist brings some horror elements, and tests... | Read more »
Summon your guild and prepare for war in...
Netmarble is making some pretty big moves with their latest update for Seven Knights Idle Adventure, with a bunch of interesting additions. Two new heroes enter the battle, there are events and bosses abound, and perhaps most interesting, a huge... | Read more »
Make the passage of time your plaything...
While some of us are still waiting for a chance to get our hands on Ash Prime - yes, don’t remind me I could currently buy him this month I’m barely hanging on - Digital Extremes has announced its next anticipated Prime Form for Warframe. Starting... | Read more »
If you can find it and fit through the d...
The holy trinity of amazing company names have come together, to release their equally amazing and adorable mobile game, Hamster Inn. Published by HyperBeard Games, and co-developed by Mum Not Proud and Little Sasquatch Studios, it's time to... | Read more »
Amikin Survival opens for pre-orders on...
Join me on the wonderful trip down the inspiration rabbit hole; much as Palworld seemingly “borrowed” many aspects from the hit Pokemon franchise, it is time for the heavily armed animal survival to also spawn some illegitimate children as Helio... | Read more »
PUBG Mobile teams up with global phenome...
Since launching in 2019, SpyxFamily has exploded to damn near catastrophic popularity, so it was only a matter of time before a mobile game snapped up a collaboration. Enter PUBG Mobile. Until May 12th, players will be able to collect a host of... | Read more »

Price Scanner via MacPrices.net

Apple is offering significant discounts on 16...
Apple has a full line of 16″ M3 Pro and M3 Max MacBook Pros available, Certified Refurbished, starting at $2119 and ranging up to $600 off MSRP. Each model features a new outer case, shipping is free... Read more
Apple HomePods on sale for $30-$50 off MSRP t...
Best Buy is offering a $30-$50 discount on Apple HomePods this weekend on their online store. The HomePod mini is on sale for $69.99, $30 off MSRP, while Best Buy has the full-size HomePod on sale... Read more
Limited-time sale: 13-inch M3 MacBook Airs fo...
Amazon has the base 13″ M3 MacBook Air (8GB/256GB) in stock and on sale for a limited time for $989 shipped. That’s $110 off MSRP, and it’s the lowest price we’ve seen so far for an M3-powered... Read more
13-inch M2 MacBook Airs in stock today at App...
Apple has 13″ M2 MacBook Airs available for only $849 today in their Certified Refurbished store. These are the cheapest M2-powered MacBooks for sale at Apple. Apple’s one-year warranty is included,... Read more
New today at Apple: Series 9 Watches availabl...
Apple is now offering Certified Refurbished Apple Watch Series 9 models on their online store for up to $80 off MSRP, starting at $339. Each Watch includes Apple’s standard one-year warranty, a new... Read more
The latest Apple iPhone deals from wireless c...
We’ve updated our iPhone Price Tracker with the latest carrier deals on Apple’s iPhone 15 family of smartphones as well as previous models including the iPhone 14, 13, 12, 11, and SE. Use our price... Read more
Boost Mobile will sell you an iPhone 11 for $...
Boost Mobile, an MVNO using AT&T and T-Mobile’s networks, is offering an iPhone 11 for $149.99 when purchased with their $40 Unlimited service plan (12GB of premium data). No trade-in is required... Read more
Free iPhone 15 plus Unlimited service for $60...
Boost Infinite, part of MVNO Boost Mobile using AT&T and T-Mobile’s networks, is offering a free 128GB iPhone 15 for $60 per month including their Unlimited service plan (30GB of premium data).... Read more
$300 off any new iPhone with service at Red P...
Red Pocket Mobile has new Apple iPhones on sale for $300 off MSRP when you switch and open up a new line of service. Red Pocket Mobile is a nationwide MVNO using all the major wireless carrier... Read more
Clearance 13-inch M1 MacBook Airs available a...
Apple has clearance 13″ M1 MacBook Airs, Certified Refurbished, available for $759 for 8-Core CPU/7-Core GPU/256GB models and $929 for 8-Core CPU/8-Core GPU/512GB models. Apple’s one-year warranty is... Read more

Jobs Board

DMR Technician - *Apple* /iOS Systems - Haml...
…relevant point-of-need technology self-help aids are available as appropriate. ** Apple Systems Administration** **:** Develops solutions for supporting, deploying, Read more
Operating Room Assistant - *Apple* Hill Sur...
Operating Room Assistant - Apple Hill Surgical Center - Day Location: WellSpan Health, York, PA Schedule: Full Time Sign-On Bonus Eligible Remote/Hybrid Regular Read more
Solutions Engineer - *Apple* - SHI (United...
**Job Summary** An Apple Solution Engineer's primary role is tosupport SHI customers in their efforts to select, deploy, and manage Apple operating systems and Read more
DMR Technician - *Apple* /iOS Systems - Haml...
…relevant point-of-need technology self-help aids are available as appropriate. ** Apple Systems Administration** **:** Develops solutions for supporting, deploying, Read more
Omnichannel Associate - *Apple* Blossom Mal...
Omnichannel Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.