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