File: pwdInfo

package info (click to toggle)
libcdk-perl 4.9.10-3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 884 kB
  • ctags: 414
  • sloc: perl: 6,419; makefile: 45; sh: 27
file content (74 lines) | stat: -rwxr-xr-x 1,749 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/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' => '<C></U>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   : </R>$name",
		"UID/GID        : ($uid/$gid)",
		"Comment        : </R>$comment",
		"GCOS Value     : </R>$gcos",
		"Home Directory : </R>$dir",
		"Shell          : </R>$shell"];

   my $title = new Cdk::Label ('Message' => $info);
 
   # Draw the label.
   $title->draw ('Box' => "TRUE");
   $title->wait();
   undef $title;
}