Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

HPUX password merger

by Limbic~Region (Chancellor)
on Dec 05, 2002 at 20:18 UTC ( #217883=sourcecode: print w/replies, xml ) Need Help??
Category: Cryptography
Author/Contact Info Limbic~Region
Description: http://www.users.dircon.co.uk/~crypto/ requires to work against a file in the format of /etc/passwd. Unfortunately on HPUX in trusted mode, the encrypted passwords for each user is stored in /tcb/files/auth/<first character of user name>/<user name> This little program goes through and creates a /tmp/passwords file with the encrypted password back in the second field.
#!/usr/bin/perl

open (MERGED , "> /tmp/passwords");
open (PASSWD , "/etc/passwd");
while ( my $line = <PASSWD> ) {
 my @fields = split(":", $line);
 my $fletter = substr($fields[0],0,1); 
 my $trusted_file = "/tcb/files/auth/$fletter/$fields[0]"; 
 if ( -r $trusted_file ) {
  open (TRUSTED , $trusted_file);
  while ( my $entry = <TRUSTED> ) {
   next unless ( $entry =~ /u_pwd/ );
   if ( $entry =~ /u_pwd=(.*):.*$/ ) {
    $fields[1] = $1;
   } 
  }
 }
 close (TRUSTED);
 print MERGED join ':' , @fields;
}
close (PASSWD);
close (MERGED);
Replies are listed 'Best First'.
Re: HPUX password merger
by davis (Vicar) on Dec 06, 2002 at 09:27 UTC
    If that's all you want to do, how about:
    sh# cat /tcb/files/auth/*/* > /tmp/passwd
    Yes, This is shell.
    *duck*

    Update: Ok, you're doing some munging on the actual contents of the files. I see that now.
    davis
    Is this going out live?
    No, Homer, very few cartoons are broadcast live - it's a terrible strain on the animator's wrist

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2020-05-31 04:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (173 votes). Check out past polls.

    Notices?