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

Recruit two powerful-sounding students t...
I am a fan of anime, and I hear about a lot that comes through, but one that escaped my attention until now is A Certain Scientific Railgun T, and that name is very enticing. If it's new to you too, then players of Blue Archive can get a hands-on... | Read more »
Top Hat Studios unveils a new gameplay t...
There are a lot of big games coming that you might be excited about, but one of those I am most interested in is Athenian Rhapsody because it looks delightfully silly. The developers behind this project, the rather fancy-sounding Top Hat Studios,... | Read more »
Bound through time on the hunt for sneak...
Have you ever sat down and wondered what would happen if Dr Who and Sherlock Holmes went on an adventure? Well, besides probably being the best mash-up of English fiction, you'd get the Hidden Through Time series, and now Rogueside has announced... | Read more »
The secrets of Penacony might soon come...
Version 2.2 of Honkai: Star Rail is on the horizon and brings the culmination of the Penacony adventure after quite the escalation in the latest story quests. To help you through this new expansion is the introduction of two powerful new... | Read more »
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 »

Price Scanner via MacPrices.net

May 2024 Apple Education discounts on MacBook...
If you’re a student, teacher, or staff member at any educational institution, you can use your .edu email address when ordering at Apple Education to take up to $300 off the purchase of a new MacBook... Read more
Clearance 16-inch M2 Pro MacBook Pros in stoc...
Apple has clearance 16″ M2 Pro MacBook Pros available in their Certified Refurbished store starting at $2049 and ranging up to $450 off original MSRP. Each model features a new outer case, shipping... Read more
Save $300 at Apple on 14-inch M3 MacBook Pros...
Apple has 14″ M3 MacBook Pros with 16GB of RAM, Certified Refurbished, available for $270-$300 off MSRP. Each model features a new outer case, shipping is free, and an Apple 1-year warranty is... Read more
Apple continues to offer 14-inch M3 MacBook P...
Apple has 14″ M3 MacBook Pros, Certified Refurbished, available starting at only $1359 and ranging up to $270 off MSRP. Each model features a new outer case, shipping is free, and an Apple 1-year... Read more
Apple AirPods Pro with USB-C return to all-ti...
Amazon has Apple’s AirPods Pro with USB-C in stock and on sale for $179.99 including free shipping. Their price is $70 (28%) off MSRP, and it’s currently the lowest price available for new AirPods... Read more
Apple Magic Keyboards for iPads are on sale f...
Amazon has Apple Magic Keyboards for iPads on sale today for up to $70 off MSRP, shipping included: – Magic Keyboard for 10th-generation Apple iPad: $199, save $50 – Magic Keyboard for 11″ iPad Pro/... Read more
Apple’s 13-inch M2 MacBook Airs return to rec...
Apple retailers have 13″ MacBook Airs with M2 CPUs in stock and on sale this weekend starting at only $849 in Space Gray, Silver, Starlight, and Midnight colors. These are the lowest prices currently... Read more
Best Buy is clearing out iPad Airs for up to...
In advance of next week’s probably release of new and updated iPad Airs, Best Buy has 10.9″ M1 WiFi iPad Airs on record-low sale prices for up to $200 off Apple’s MSRP, starting at $399. Sale prices... Read more
Every version of Apple Pencil is on sale toda...
Best Buy has all Apple Pencils on sale today for $79, ranging up to 39% off MSRP for some models. Sale prices for online orders only, in-store prices may vary. Order online and choose free shipping... Read more
Sunday Sale: Apple Studio Display with Standa...
Amazon has the standard-glass Apple Studio Display on sale for $300 off MSRP for a limited time. Shipping is free: – Studio Display (Standard glass): $1299.97 $300 off MSRP For the latest prices and... Read more

Jobs Board

Liquor Stock Clerk - S. *Apple* St. - Idaho...
Liquor Stock Clerk - S. Apple St. Boise Posting Begin Date: 2023/10/10 Posting End Date: 2024/10/14 Category: Retail Sub Category: Customer Service Work Type: Part Read more
*Apple* App Developer - Datrose (United Stat...
…year experiencein programming and have computer knowledge with SWIFT. Job Responsibilites: Apple App Developer is expected to support essential tasks for the RxASL 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
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.