Handle hostnames with upper-case letters
[webmin.git] / useradmin / aix-lib.pl
1 # aix-lib.pl
2 # Functions for aix password file format
3
4 # passfiles_type()
5 # Returns 0 for old-style passwords (/etc/passwd only), 1 for FreeBSD-style
6 # (/etc/master.passwd), 2 for SysV (/etc/passwd & /etc/shadow), 3 for
7 # /etc/passwd with update via useradd and 4 for AIX (/etc/passwd &
8 # /etc/security/passwd)
9 sub passfiles_type
10 {
11 return 4;
12 }
13
14 # groupfiles_type()
15 # Returns 0 for normal group file (/etc/group only), 2 for shadowed
16 # (/etc/group and /etc/gshadow), and 4 for AIX (/etc/group &
17 # /etc/security/group)
18 sub groupfiles_type
19 {
20 return 4;
21 }
22
23 # open_last_command(handle, user)
24 sub open_last_command
25 {
26 local ($fh, $user) = @_;
27 open($fh, "last $user |");
28 }
29
30 # read_last_line(handle)
31 # Parses a line of output from last into an array of
32 #  user, tty, host, login, logout, period
33 sub read_last_line
34 {
35 local $fh = $_[0];
36 while(1) {
37         chop($line = <$fh>);
38         if (!$line) { return (); }
39         if ($line =~ /system boot/) { next; }
40         if ($line =~ /^(\S+)\s+(\S+)\s+(\S+)?\s+(\S+\s+\S+\s+\d+\s+\d+:\d+)\s+\-\s+(\d+:\d+)\s+\((\d+:\d+)\)/) {
41                 return ($1, $2, $3, $4, $5, $6);
42                 }
43         elsif ($line =~ /^(\S+)\s+(\S+)\s+(\S+)?\s+(\S+\s+\S+\s+\d+\s+\d+:\d+)\s+still/) {
44                 return ($1, $2, $3, $4);
45                 }
46         }
47 }
48
49 1;
50