Better ways to deal with yppasswd? 
Author Message
 Better ways to deal with yppasswd?

I want to obtain the name of the person using a script I'm writing.  
Unfortunately, our passwd file is only on 1 of our machines (the
ypmaster) and therefore not directly accessable if a person is not
actually logged into that machine.  This eliminates the use of such
wonderful functions as getpwnam(), getpwuid(), and getpwent().

To overcome this situation, I loaded the passwd file into an assoc. array
by assigning the array to a system call to ypcat the passwd file:

        %passwd_entry = `ypcat passwd`;

Then, in order to sort on uid i created the following loop:

        foreach (%passwd_entry) {

         ($login,$passwd,$uid,$gid,$gcos,$home,$shell) = split(/:/);
         ($name,$office,$phone,$junk) = split (/,/,$gcos);
         $uid_list{$uid} .= $name;

        }

I can then access the users name via $uid_list{$<}.

Is there an easier way to do this?  I can't find anything anywhere
relating to ypservers or ypserved files.  Did I miss something somewhere
in the Camel, ref pages, man pages, etc?

Thanks in advance,
Paul



Wed, 30 Jul 1997 06:14:04 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Seeking advice on semantics (pros / cons and best ways of) using constants across modules

2. Better ways to do this?

3. Better ways to...

4. Any better ways of doing this ?

5. EDITING DATAFILES - What is best of 3 ways?

6. yppasswd in perl?

7. yppasswd in perl?

8. Perl interface with yppasswd

9. crypt & solaris yppasswd

10. fast ways to count substrings

11. Ways to test for membership?

12. Two ways to undef?

 

 
Powered by phpBB® Forum Software