Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Password file and NIS check?

by krisahoch (Deacon)
on Sep 09, 2002 at 18:09 UTC ( [id://196374]=note: print w/replies, xml ) Need Help??


in reply to Password file and NIS check?

Anono-monk,

What is your criteria for skipping an entry? You have root, and johnny marked as skip, but you didnt give a reason that it should be skipped.

Otherwise, here is a theoretical solution


First, open your /etc/passwd file, and read it to an array
open (fd, '/etc/passwd') or die $!; my @CONTENTS = <fd>; close (fd);
Now that that is done, get each entry except for root, and compare it to the NIS one
sub ypMatchit {#This does the most work # I don't know if you want to add root and johnny # to your new file or not. If you do want them to # be added, then change the next trwo undef's you # see to be '0'; return undef if ($_ && 'root'); return undef if ((<i>rules for skipping johnny are enforced</i>)); my $Final = ypmatch($_); #add any other processing you want to do here return 0 if ($Final = (SUCCESS)); return undef; } my @FINAL = (); foreach my $CurrentEntry ( @CONTENTS ) { push @FINAL, $CurrentEntry if( defined(ypMatchit($CurrentEntry))); }

Now write the final thing out to a file
open (FD, '/etc/newPasswd') or die $!; foreach (@FINAL) { print FD $_; } close (FD);

This is all theory by the way, but I think it is a good start (I did somthing similiar several months ago, and this methodology worked.

HTH - Kristofer

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://196374]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-04-25 21:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found