| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::Spoor; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
164836
|
use v5.10; |
|
|
1
|
|
|
|
|
5
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
22
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
74
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
App::Spoor - A CPanel client for the Spoor service |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 VERSION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Version 0.08 |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=cut |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our $VERSION = '0.08'; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
This module (for now) only contains code to provide a naive implementation of a client for the |
|
22
|
|
|
|
|
|
|
Spoor API that plays nicely with CPanel. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
It is built with the following principles in mind: |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=over |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=item * Minimise the impact of the code on the existing CPanel instance |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=item * Minimise the footprint on the host, by keeping the dependencies to a bare minimum |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=item * Be as transparent as possible about the data that is being submitted |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=back |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Within the above context, App::Spoor consists of 3 main parts: |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=over |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item * Scripts running under systemd that tail the CPanel access, error and login logs |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=item * A transmitter script (also running under systemd) that communicates with the Spoor API |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=item * A module that registers functionality for tracking changes to mail forwarding within the CPanel standardised hook framework |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=back |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 Installing |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Before installing the module, you will need to enable the logging of successful logins via WHM. At the time of writing, |
|
51
|
|
|
|
|
|
|
this can be found by navigating to Server Configuration -> Tweak Settings -> Logging. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Once you have installed the module run the following from the commandline: |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
spoor_installer |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
It will setup a config file, some persistence directories, a number of systemd unit files and it will also create the |
|
58
|
|
|
|
|
|
|
file that will register functionality against CPanel's standardised hooks. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Once it has completed, it will list a number of actions that must be performed (as root)before the installation is complete: |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
systemctl enable spoor-access-follower.service |
|
63
|
|
|
|
|
|
|
systemctl enable spoor-error-follower.service |
|
64
|
|
|
|
|
|
|
systemctl enable spoor-login-follower.service |
|
65
|
|
|
|
|
|
|
systemctl enable spoor-transmitter.service |
|
66
|
|
|
|
|
|
|
systemctl start spoor-access-follower.service |
|
67
|
|
|
|
|
|
|
systemctl start spoor-error-follower.service |
|
68
|
|
|
|
|
|
|
systemctl start spoor-login-follower.service |
|
69
|
|
|
|
|
|
|
systemctl start spoor-transmitter.service |
|
70
|
|
|
|
|
|
|
cd /usr/local/cpanel/bin/ |
|
71
|
|
|
|
|
|
|
./manage_hooks add module SpoorForwardHook |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
The install script will create a number of directories, a config file for Spoor as well as several systemd unit files. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 Operation |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
App::Spoor operates on a simple principe of tailing CPanel's access, error and login log files. The follower services |
|
78
|
|
|
|
|
|
|
monitor the log files and if they come across an item of interest, they create a JSON-representation of the event and |
|
79
|
|
|
|
|
|
|
write it to /var/lib/spoor/parsed. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
The transmitter service monitors /var/lib/spoor/parsed for any changes and sends these to the Spoor API. If a transmission |
|
82
|
|
|
|
|
|
|
recives a response of HTTP 202, the JSON file is moved to /var/lib/spoor/transmitted, otherwise it remains in /var/lib/spoor/parsed and |
|
83
|
|
|
|
|
|
|
the transmitter will keep on retrying, pretty much until the end of time. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 Reporting |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Spoor provides rudimentary reporting functionality that can be accessed from the commandline. This functionality |
|
88
|
|
|
|
|
|
|
distinguished between reports (a report is created by the Spoor API when data is received) and mailbox events ( a |
|
89
|
|
|
|
|
|
|
mailbox event is created once the report has been parsed). |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
spoor_report_list #List the most recent reports for the current host |
|
92
|
|
|
|
|
|
|
spoor_mailbox_event_list #List the most recent mailbox events for the current host |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 Uninstalling |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
To uninstall,do the following (the below assumes that you are using cpanminus): |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
cd /usr/local/cpanel/bin/ |
|
99
|
|
|
|
|
|
|
./manage_hooks delete module SpoorForwardHook |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
systemctl stop spoor-access-follower.service |
|
102
|
|
|
|
|
|
|
systemctl stop spoor-error-follower.service |
|
103
|
|
|
|
|
|
|
systemctl stop spoor-login-follower.service |
|
104
|
|
|
|
|
|
|
systemctl stop spoor-transmitter.service |
|
105
|
|
|
|
|
|
|
systemctl disable spoor-access-follower.service |
|
106
|
|
|
|
|
|
|
systemctl disable spoor-error-follower.service |
|
107
|
|
|
|
|
|
|
systemctl disable spoor-login-follower.service |
|
108
|
|
|
|
|
|
|
systemctl disable spoor-transmitter.service |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
rm -rf /etc/spoor |
|
111
|
|
|
|
|
|
|
rm -rf /var/lib/spoor |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
cpanm --uninstall App::Spoor |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head2 Windows |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
For now, App::Spoor does not support Windows installations. |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 AUTHOR |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Rory McKinley, C<< <rorymckinley at capefox.co> >> |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 BUGS |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Please report any bugs or feature requests to C<bug-app-spoor at rt.cpan.org>, or through |
|
128
|
|
|
|
|
|
|
the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=App-Spoor>. I will be notified, and then you'll |
|
129
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 SUPPORT |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
perldoc App::Spoor |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
You can also look for information at: |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=over 4 |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=App-Spoor> |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
L<http://annocpan.org/dist/App-Spoor> |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
L<https://cpanratings.perl.org/d/App-Spoor> |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=item * Search CPAN |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
L<https://metacpan.org/release/App-Spoor> |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=back |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Copyright 2019 Rory McKinley. |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
165
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
|
166
|
|
|
|
|
|
|
copy of the full license at: |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
L<http://www.perlfoundation.org/artistic_license_2_0> |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
|
171
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
|
172
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
|
173
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
|
176
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
|
177
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
|
180
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
|
183
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
|
184
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
|
185
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
|
186
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
|
187
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
|
188
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
|
189
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
|
192
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
|
193
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
|
194
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
|
195
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
|
196
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
|
197
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
|
198
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=cut |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
1; # End of App::Spoor |