File Coverage

blib/lib/Proc/ProcessTable/Match/Idle.pm
Criterion Covered Total %
statement 8 35 22.8
branch 0 12 0.0
condition 0 6 0.0
subroutine 3 5 60.0
pod 2 2 100.0
total 13 60 21.6


line stmt bran cond sub pod time code
1             package Proc::ProcessTable::Match::Idle;
2              
3 1     1   55601 use 5.006;
  1         9  
4 1     1   4 use strict;
  1         2  
  1         18  
5 1     1   3 use warnings;
  1         2  
  1         250  
6              
7             =head1 NAME
8              
9             Proc::ProcessTable::Match::Idle - Attempts to match the kernel idle process.
10              
11             =head1 VERSION
12              
13             Version 0.0.0
14              
15             =cut
16              
17             our $VERSION = '0.0.0';
18              
19             =head1 SYNOPSIS
20              
21             use Proc::ProcessTable::Match::Idle;
22            
23             my $checker=Proc::ProcessTable::Match::Idle->new;
24            
25             if ( $checker->match( $proc ) ){
26             print "It matches.\n";
27             }
28              
29             This modules functions via checking that the process matches the following.
30              
31             UID == 0
32             fname =~ /^idle$/
33             cmndline =~ /^$/
34              
35             =head1 METHODS
36              
37             =head2 new
38              
39             This intiates the object.
40              
41             my $checker=Proc::ProcessTable::Match::Idle->new;
42              
43             =cut
44              
45             sub new{
46 0     0 1   my $self = {
47             };
48 0           bless $self;
49              
50 0           return $self;
51             }
52              
53             =head2 match
54              
55             Checks if a single Proc::ProcessTable::Process object matches the stack.
56              
57             One argument is taken and that is a Proc::ProcessTable::Process object.
58              
59             The returned value is a boolean.
60              
61             if ( $checker->match( $proc ) ){
62             print "The connection matches.\n";
63             }
64              
65             =cut
66              
67             sub match{
68 0     0 1   my $self=$_[0];
69 0           my $object=$_[1];
70              
71 0 0         if ( !defined( $object ) ){
72 0           return 0;
73             }
74              
75 0 0         if ( ref( $object ) ne 'Proc::ProcessTable::Process' ){
76 0           return 0;
77             }
78              
79 0           my $proc_fname;
80 0           eval{
81 0           $proc_fname=$object->fname;
82             };
83              
84             # don't bother proceeding, the object won't match ever
85             # as it does not have a fname
86 0 0         if ( ! defined( $proc_fname ) ){
87 0           return 0;
88             }
89              
90 0           my $proc_uid;
91 0           eval{
92 0           $proc_uid=$object->uid;
93             };
94              
95             # don't bother proceeding, the object won't match ever
96             # as it does not have a uid
97 0 0         if ( ! defined( $proc_uid ) ){
98 0           return 0;
99             }
100              
101 0           my $proc_cmd;
102 0           eval{
103 0           $proc_cmd=$object->cmndline;
104             };
105              
106             # don't bother proceeding, the object won't match ever
107             # as it does not have a cmndline
108 0 0         if ( ! defined( $proc_cmd ) ){
109 0           return 0;
110             }
111              
112 0 0 0       if (
      0        
113             ( $proc_uid eq 0 ) &&
114             ( $proc_fname =~ /^idle$/ ) &&
115             ( $proc_cmd =~ /^$/ )
116             ){
117 0           return 1;
118             }
119              
120 0           return 0;
121             }
122              
123             =head1 AUTHOR
124              
125             Zane C. Bowers-Hadley, C<< >>
126              
127             =head1 BUGS
128              
129             Please report any bugs or feature requests to C, or through
130             the web interface at L. I will be notified, and then you'll
131             automatically be notified of progress on your bug as I make changes.
132              
133              
134              
135              
136             =head1 SUPPORT
137              
138             You can find documentation for this module with the perldoc command.
139              
140             perldoc Proc::ProcessTable::Match
141              
142              
143             You can also look for information at:
144              
145             =over 4
146              
147             =item * RT: CPAN's request tracker (report bugs here)
148              
149             L
150              
151             =item * AnnoCPAN: Annotated CPAN documentation
152              
153             L
154              
155             =item * CPAN Ratings
156              
157             L
158              
159             =item * Search CPAN
160              
161             L
162              
163             =back
164              
165              
166             =head1 ACKNOWLEDGEMENTS
167              
168              
169             =head1 LICENSE AND COPYRIGHT
170              
171             Copyright 2019 Zane C. Bowers-Hadley.
172              
173             This program is free software; you can redistribute it and/or modify it
174             under the terms of the the Artistic License (2.0). You may obtain a
175             copy of the full license at:
176              
177             L
178              
179             Any use, modification, and distribution of the Standard or Modified
180             Versions is governed by this Artistic License. By using, modifying or
181             distributing the Package, you accept this license. Do not use, modify,
182             or distribute the Package, if you do not accept this license.
183              
184             If your Modified Version has been derived from a Modified Version made
185             by someone other than you, you are nevertheless required to ensure that
186             your Modified Version complies with the requirements of this license.
187              
188             This license does not grant you the right to use any trademark, service
189             mark, tradename, or logo of the Copyright Holder.
190              
191             This license includes the non-exclusive, worldwide, free-of-charge
192             patent license to make, have made, use, offer to sell, sell, import and
193             otherwise transfer the Package with respect to any patent claims
194             licensable by the Copyright Holder that are necessarily infringed by the
195             Package. If you institute patent litigation (including a cross-claim or
196             counterclaim) against any party alleging that the Package constitutes
197             direct or contributory patent infringement, then this Artistic License
198             to you shall terminate on the date that such litigation is filed.
199              
200             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
201             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
202             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
203             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
204             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
205             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
206             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
207             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
208              
209              
210             =cut
211              
212             1; # End of Proc::ProcessTable::Match