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

Fresh From the Land Down Under – The Tou...
After a two week hiatus, we are back with another episode of The TouchArcade Show. Eli is fresh off his trip to Australia, which according to him is very similar to America but more upside down. Also kangaroos all over. Other topics this week... | Read more »
TouchArcade Game of the Week: ‘Dungeon T...
I’m a little conflicted on this week’s pick. Pretty much everyone knows the legend of Dungeon Raid, the match-3 RPG hybrid that took the world by storm way back in 2011. Everyone at the time was obsessed with it, but for whatever reason the... | Read more »
SwitchArcade Round-Up: Reviews Featuring...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for July 19th, 2024. In today’s article, we finish up the week with the unusual appearance of a review. I’ve spent my time with Hot Lap Racing, and I’m ready to give my verdict. After... | Read more »
Draknek Interview: Alan Hazelden on Thin...
Ever since I played my first release from Draknek & Friends years ago, I knew I wanted to sit down with Alan Hazelden and chat about the team, puzzle games, and much more. | Read more »
The Latest ‘Marvel Snap’ OTA Update Buff...
I don’t know about all of you, my fellow Marvel Snap (Free) players, but these days when I see a balance update I find myself clenching my… teeth and bracing for the impact to my decks. They’ve been pretty spicy of late, after all. How will the... | Read more »
‘Honkai Star Rail’ Version 2.4 “Finest D...
HoYoverse just announced the Honkai Star Rail (Free) version 2.4 “Finest Duel Under the Pristine Blue" update alongside a surprising collaboration. Honkai Star Rail 2.4 follows the 2.3 “Farewell, Penacony" update. Read about that here. | Read more »
‘Vampire Survivors+’ on Apple Arcade Wil...
Earlier this month, Apple revealed that poncle’s excellent Vampire Survivors+ () would be heading to Apple Arcade as a new App Store Great. I reached out to poncle to check in on the DLC for Vampire Survivors+ because only the first two DLCs were... | Read more »
Homerun Clash 2: Legends Derby opens for...
Since launching in 2018, Homerun Clash has performed admirably for HAEGIN, racking up 12 million players all eager to prove they could be the next baseball champions. Well, the title will soon be up for grabs again, as Homerun Clash 2: Legends... | Read more »
‘Neverness to Everness’ Is a Free To Pla...
Perfect World Games and Hotta Studio (Tower of Fantasy) announced a new free to play open world RPG in the form of Neverness to Everness a few days ago (via Gematsu). Neverness to Everness has an urban setting, and the two reveal trailers for it... | Read more »
Meditative Puzzler ‘Ouros’ Coming to iOS...
Ouros is a mediative puzzle game from developer Michael Kamm that launched on PC just a couple of months back, and today it has been revealed that the title is now heading to iOS and Android devices next month. Which is good news I say because this... | Read more »

Price Scanner via MacPrices.net

Amazon is still selling 16-inch MacBook Pros...
Prime Day in July is over, but Amazon is still selling 16-inch Apple MacBook Pros for $500-$600 off MSRP. Shipping is free. These are the lowest prices available this weekend for new 16″ Apple... Read more
Walmart continues to sell clearance 13-inch M...
Walmart continues to offer clearance, but new, Apple 13″ M1 MacBook Airs (8GB RAM, 256GB SSD) online for $699, $300 off original MSRP, in Space Gray, Silver, and Gold colors. These are new MacBooks... Read more
Apple is offering steep discounts, up to $600...
Apple has standard-configuration 16″ M3 Max MacBook Pros available, Certified Refurbished, starting at $2969 and ranging up to $600 off MSRP. Each model features a new outer case, shipping is free,... Read more
Save up to $480 with these 14-inch M3 Pro/M3...
Apple has 14″ M3 Pro and M3 Max MacBook Pros in stock today and available, Certified Refurbished, starting at $1699 and ranging up to $480 off MSRP. Each model features a new outer case, shipping is... Read more
Amazon has clearance 9th-generation WiFi iPad...
Amazon has Apple’s 9th generation 10.2″ WiFi iPads on sale for $80-$100 off MSRP, starting only $249. Their prices are the lowest available for new iPads anywhere: – 10″ 64GB WiFi iPad (Space Gray or... Read more
Apple is offering a $50 discount on 2nd-gener...
Apple has Certified Refurbished White and Midnight HomePods available for $249, Certified Refurbished. That’s $50 off MSRP and the lowest price currently available for a full-size Apple HomePod today... Read more
The latest MacBook Pro sale at Amazon: 16-inc...
Amazon is offering instant discounts on 16″ M3 Pro and 16″ M3 Max MacBook Pros ranging up to $400 off MSRP as part of their early July 4th sale. Shipping is free. These are the lowest prices... Read more
14-inch M3 Pro MacBook Pros with 36GB of RAM...
B&H Photo has 14″ M3 Pro MacBook Pros with 36GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 Pro MacBook Pro (... Read more
14-inch M3 MacBook Pros with 16GB of RAM on s...
B&H Photo has 14″ M3 MacBook Pros with 16GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $150-$200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 MacBook Pro (... Read more
Amazon is offering $170-$200 discounts on new...
Amazon is offering a $170-$200 discount on every configuration and color of Apple’s M3-powered 15″ MacBook Airs. Prices start at $1129 for models with 8GB of RAM and 256GB of storage: – 15″ M3... Read more

Jobs Board

*Apple* Systems Engineer - Chenega Corporati...
…LLC,** a **Chenega Professional Services** ' company, is looking for a ** Apple Systems Engineer** to support the Information Technology Operations and Maintenance 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
*Apple* / Mac Administrator - JAMF Pro - Ame...
Amentum is seeking an ** Apple / Mac Administrator - JAMF Pro** to provide support with the Apple Ecosystem to include hardware and software to join our team and Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.