Mastering the NetInfo database

tachyon

Registered
Hi folks. It would appear to me that many of the problems that my clients get themselves into would not require reinstalling OS X so often if I had a better grip on repairing their Netinfo database; I am gathering information... so the 1st question is: What's the best way to use the command line to make sure that the only user that exists is an admin?
i.e. How to use nicl and niutil,while booted into single-user mode, to ensure that the one and only user is part of group "admin" and that the root user is part of groups 'wheel", "admin" and so forth?
 
The easiest way to maintain groups is to use (as previously mentioned) 'nidump group / > /etc/group'. Now you can use your favorite editor and it that file.

When you're ready to update NetInfo use 'niload group / < /etc/group'.

Brian G.
 
Cool, thanks.
Since I posted I figured out some more about nicl, so I can get to groups/wheel and groups/admin but the next stage is to figure out how to make modifications without destroying everything!
So will these ni* commands work when booted into Single-User mode?
 
tachyon said:
So will these ni* commands work when booted into Single-User mode?

Only nicl will work, with the -raw option, unless you do something to start up some other stuff. It might be easier to log on as >console, since everything required is then running.
 
oldfogey said:
Only nicl will work, with the -raw option, unless you do something to start up some other stuff. It might be easier to log on as >console, since everything required is then running.

Well, the thing is, you can't log in as anything on these machines, because the problem with them is they have one user that is not an administrator, no root user enabled, OR the user has changed some things around in NetInfo Manager and things like shortnames don't match.

The usual fix has been to remove .AppleSetupDone and reinstall OS X, then make a new user... one technician just makes another user with the same name if possible (I am a bit hesitant to do this)

But I wish to restore correct users with commandline work in single-user mode, without having to reinstall.
 
tachyon said:
Well, the thing is, you can't log in as anything on these machines, because the problem with them is they have one user that is not an administrator, no root user enabled, OR the user has changed some things around in NetInfo Manager and things like shortnames don't match.

The usual fix has been to remove .AppleSetupDone and reinstall OS X, then make a new user... one technician just makes another user with the same name if possible (I am a bit hesitant to do this)

But I wish to restore correct users with commandline work in single-user mode, without having to reinstall.

OK, then as I said, only 'nicl' will work, and you need to use the '-raw' option. This allows you to work directly with the NetInfo database. All the other ni* commands, and nicl without '-raw', require the NetInfo daemon to be running. You can start this other stuff up if you like, but there's probably not much point.

If the only user on the machine is not an admin user, you can usually correct this easily, but if other changes to the database have been made, this might not work.

To make 'user1' and admin user in Single User mode:
Code:
/sbin/mount -uw /
nicl -raw /var/db/netinfo/local.db -merge /groups/admin users user1
If you then reboot and log in as 'user1' you will have admin privileges.
 
Back
Top