File Coverage

lib/Rex/User.pm
Criterion Covered Total %
statement 23 30 76.6
branch 6 12 50.0
condition n/a
subroutine 7 7 100.0
pod 0 1 0.0
total 36 50 72.0


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::User;
6              
7 33     33   458 use v5.12.5;
  33         128  
8 33     33   169 use warnings;
  33         69  
  33         1597  
9              
10             our $VERSION = '1.14.2.2'; # TRIAL VERSION
11              
12 33     33   249 use Rex::Commands::Gather;
  33         88  
  33         486  
13 33     33   261 use Rex::Logger;
  33         106  
  33         928  
14              
15             sub get {
16              
17 2     2 0 6 my $user_o = "Linux";
18 2 50       12 if (is_freebsd) {
    50          
    50          
    50          
    50          
19 0         0 $user_o = "FreeBSD";
20             }
21             elsif (is_netbsd) {
22 0         0 $user_o = "NetBSD";
23             }
24             elsif (is_openbsd) {
25 0         0 $user_o = "OpenBSD";
26             }
27             elsif ( operating_system_is("SunOS") ) {
28 0         0 $user_o = "SunOS";
29             }
30             elsif (is_openwrt) {
31 0         0 $user_o = "OpenWrt";
32             }
33              
34 2         75 my $class = "Rex::User::" . $user_o;
35 2     1   406 eval "use $class";
  1     1   36  
  1         4  
  1         19  
  1         8  
  1         12  
  1         19  
36              
37 2 50       47 if ($@) {
38              
39 0         0 Rex::Logger::info("OS not supported");
40 0         0 die("OS not supported");
41              
42             }
43              
44 2         31 return $class->new;
45              
46             }
47              
48             1;