#!/usr/bin/perl -w # $Id: pwdInfo,v 1.2 2002/07/27 20:07:47 tom Exp $ # # This reads the passwd file and creates an interface to browse the # information. # use Cdk; Cdk::init(); # # This function loads up the passwd file and returns a reference to the # data structure. # sub loadPasswd { my %passwd = (); my @logins = (); my ($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$dir,$shell); # Start reading through the passwd file. while (($name,$passwd,$uid,$gid,$quota,$comment,$gcos,$dir,$shell) = getpwent) { # Store the information. $passwd{$name} = "$uid$gid$comment$gcos$dir$shell"; push (@logins, $name); } return (\@logins, \%passwd); } # Load up the passwd file. my ($logins, $passwdObject) = loadPasswd(); # Create a scrolling list of all the names. my $mainScroll = new Cdk::Scroll ('Title' => 'Pick An Account', 'Numbers' => "TRUE", 'List' => $logins, 'Height' => 13, 'Width' => 45); # Do this forever. for (;;) { # Let the user select the login to view. my $selected = $mainScroll->activate(); # Did the user just hit escape? if (!defined $selected) { Cdk::end(); exit 0; } # Get the name and display the info. my $name = $logins->[$selected]; # Display the info. my ($uid, $gid, $comment, $gcos, $dir, $shell) = split (//, $passwdObject->{$name}); my $info = ["Account Name : $name", "UID/GID : ($uid/$gid)", "Comment : $comment", "GCOS Value : $gcos", "Home Directory : $dir", "Shell : $shell"]; my $title = new Cdk::Label ('Message' => $info); # Draw the label. $title->draw ('Box' => "TRUE"); $title->wait(); undef $title; }