User admin modules

bda on 2004-04-28T04:39:32

Recently I've started getting more and more into automating tasks I do at work. Part of this is relates around some ideas I've had about shell use and ssh key generation, distribution, and keyhost networks.

I also recently started doing administration work for a free shell box service (metawire.org) and we need a nice way to distribute user accounts across some new machines we're getting in the next week or so.

So to implement the above, I need some way to easily manipulate user and group accounts on various flavors of UNIX. "Well," says I, I says, "I'll just check out CPAN. Surely, it being CPAN, which is for Perl, there will be many modules already written to deal with this stuff, since it much be such a common requirement."

My searching skills are either woefully pathetic, or there just isn't a nice generic module for dealing with user administration.

So I think, "Well, that's ok, I'll just start a nice generic module, write the OS-specific stuff I need, and other people can add stuff. Shouldn't be too hard."

So I look around some more, and discover and mdxi refers to as "one of the most spectacular abuses of CPAN and it's top-level namespace ever."

What the shizzy, yo: http://search.cpan.org/user/tbone/User-1.6/User.pm

That is 16 lines of code. I'm still pretty pissed about this.

So I suppose I'll just use "User::Accounts" or something along those lines. But really. What the hell?

rjbs pointed this out to me: http://search.cpan.org/user/vidul/Linux-usermod-0.3/usermod.pm

Seems okay for what it does, but not what I need, really.

So, whinging aside: Am I totally missing something incredibly obvious? It astounds me that there isn't a generic user admin package written, so I'm pretty sure I must just be being completely blind here.


I *am* an idiot.

bda on 2004-04-28T04:56:31

Good to know.

http://search.cpan.org/user/ssnodgra/Unix-ConfigFile-0.06/PasswdFile.pm
http://se arch.cpan.org/user/eestabroo/Passwd-Linux-0.70/Linux.pm

Other neat things:
http://search.cpan.org/user/nwiger/File-Remote-1.16/Remote.pm
http://searc h.cpan.org/user/razinf/Data-Password-1.03/Password.pm
http://search.cpan.org/user/nikip /Authen-PAM-0.14/d/PAM.pm
http://search.cpan.org/user/nwiger/Unix-Login-1.08/Login. pm

I would hold off on whining until looking for other obvious things, but then I'd never be motivated to do anything, to make up for looking like a fool.

3

Not sure what else...

phillup on 2004-04-28T04:59:38

I'm not sure what else you have in mind... but, I'd probably start with this:

http://search.cpan.org/user/drolsky/Net-SSH-Perl-1.25/lib/Net/SSH/Perl.pm

And try real hard to simply use the commands already available on each platform to do the rest.

poor top level name

jmm on 2004-04-28T13:31:45

I'd say that "user" would not be a good top level name here, actually. I'd suggest instead Admin::User, which would easily expand into supporting all sorts of other admin tasks under the same top level hierarchy. (However, it looks like you're not going to have to create a new name after all, so this point is moot.)

Solaris

djberg96 on 2004-04-28T13:58:09

Don't forget about NIS/NIS+. ;)

Re:Solaris

djberg96 on 2004-04-28T14:44:44

My searching skills are either woefully pathetic, or there just isn't a nice generic module for dealing with user administration.

As a related followup to my own message....

That's because there isn't a nice, generic API for *nix systems when it comes to adding, configuring and deleting users and groups. It's a PITA.

Doable, though.

Re:Solaris

bda on 2004-04-29T02:24:38

I'm not a big fan of NIS[+] so I probably won't ever write that. :)

But I've gotten so far as to hack Unix::PasswdFile into Unix::ShadowFile. Unix::MasterPasswdFile (BSD) should be finished by tomorrow, and I can start working on the User::Account or Admin::User modules. Namespace issues need to be resolved, definitely. :)

Pretty simple stuff, but neat.

Eventually the goal is to use something like Stem for inter-system messaging to pass out the files, etc.

Re:Solaris

djberg96 on 2004-04-29T03:17:49

That's cool - I noticed the lack of shadow file handling in Unix::PasswdFile, so I was a little scared off and tempted to just use the Solaris specific one.