Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

HPUX password merger

by Limbic~Region (Chancellor)
on Dec 05, 2002 at 20:18 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: sourcecode [id://217883]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-16 13:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found