Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

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: 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.

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.

    Update: Ok, you're doing some munging on the actual contents of the files. I see that now.
    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?

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2021-01-24 01:04 GMT
Find Nodes?
    Voting Booth?