/usr/bin/snpp is in sendpage-client 1.0.3-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | #!/usr/bin/perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if 0; # not running under some shell
#
# quick script for sending SNPP messages
#
# $Id: snpp 316 2008-01-03 20:21:19Z keescook $
#
# Copyright (C) 2000-2004 Kees Cook
# kees@outflux.net, http://outflux.net/
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# http://www.gnu.org/copyleft/gpl.html
=head1 NAME
snpp - send pages via SNPP
=head1 SYNOPSIS
snpp [OPTIONS] recipient...
=head1 OPTIONS
=over 4
=item -s SERVER[:PORT]
Connect to the specified SERVER (and PORT, if given). Default is
"localhost:444".
=item -f USER
Show that the sent page is coming from USER. Default is the current user.
=item -m MESSAGE
Send the given MESSAGE instead of reading text from stdin.
=item -n
Do not notify the 'from' user about the status of the page.
=item -d
Display SNPP session debugging.
=item -C CONF
Read CONF instead of /etc/sendpage/snpp.conf for server default.
=item -h
Display a summary of all the available command line options.
=back
=head1 DESCRIPTION
This tool is used to send a page via the Simple Network Paging Protocol
(level 2). It is designed to be used with 'sendpage', but should work
with any other SNPP servers as well.
The /etc/sendpage/snpp.conf file can contain a single line in the form of
server:ADDRESS[:PORT]
where ADDRESS and PORT are the defaults for snpp.
=head1 AUTHOR
Kees Cook <kees@outflux.net>
=head1 BUGS
Not much happening in this tool, but I bet the use of "CALLer id" is
not standard, and other SNPP server may require this tool run with
the '-n' option all the time.
=head1 COPYRIGHT
snpp is free software; it can be used under the terms of the GNU General
Public License.
=head1 SEE ALSO
perl(1), sendpage(1), Net::SNPP(3)
=cut
use Getopt::Std;
use Net::SNPP;
use Sys::Hostname;
use IO::File;
my %opts;
our $VERSION="0.1";
sub Usage {
die "Usage: $0 [OPTIONS] pin1 [pin2 [...]]
version $VERSION
-s SERVER[:PORT] SNPP server to use (default is 'localhost')
-f USER force page to be from user USER (default is current user)
-m MESSAGE message to send (reads from stdin by default)
-n no email carboning to 'from'
-d turn debug on
-C CONF read CONF instead of /etc/sendpage/snpp.conf
-h you're reading it. :)
";
}
# get our options
if (!getopts('hdns:f:m:C:',\%opts) || $opts{h} || !@ARGV) {
Usage();
}
### DEFAULTS
# set config file
$opts{C}="/etc/sendpage/snpp.conf" unless ($opts{C});
# set server
my $server="localhost";
my $fh = new IO::File $opts{C}, "r";
if (!defined($fh)) {
warn "Cannot read '$opts{C}' file (using defaults): $!\n";
}
else {
my $num=0;
my $line;
foreach $line (<$fh>) {
chomp($line);
$num++;
# skip comments and blanks
next if ($line =~ /^\s*#/ || $line =~ /^\s*$/);
($cmd,$arg)=split(/:/,$line,2);
if ($cmd eq "server") {
$server=$arg;
}
else {
warn "unknown command '$cmd' in '$opts{C}', line ".
"$num\n";
}
}
undef $fh;
}
# override config file and defaults
$opts{s}=$server unless ($opts{s});
# verify that there is a "SNPP" service (weakness in Net::SNPP...)
$proto=getprotobyname("tcp");
if (!defined($proto))
{
die "Could not resolve 'tcp' protocol into a protocol number!\nPlease check /etc/protocols\n";
}
else
{
warn "'tcp' is proto $proto\n" if ($opts{d});
}
$port=getservbyname("snpp","tcp");
if (!defined($port))
{
die "Could not resolve 'snpp' service into a port number!\nPlease check /etc/services\n";
}
else
{
warn "'snpp' is service $port\n" if ($opts{d});
}
$snpp = Net::SNPP->new($opts{s}, Debug => $opts{d} );
if (!defined($snpp)) {
die "Could not connect to SNPP server '$opts{s}'\n";
}
# get the pins
my @pins = @ARGV;
# get the page text
undef $/;
my $text = $opts{m} ? $opts{m} : <STDIN>;
$/="\n";
# who is it from?
if (!defined($opts{f}) && !$opts{n}) {
$opts{f}=scalar(getpwuid($<))."\@";
$opts{f}.=hostname;
}
# send pins
foreach $pin (@pins) {
if (!$snpp->pager_id($pin)) {
warn $snpp->message();
if ($snpp->status()==4) {
exit($snpp->code()-400);
}
}
}
# send 'caller id', if we need to
if (!$opts{n}) {
if (!$snpp->caller_id($opts{f})) {
warn $snpp->message();
if ($snpp->status()==4) {
exit($snpp->code()-400);
}
}
}
# send text
if (!$snpp->data($text)) {
warn $snpp->message();
if ($snpp->status()==4) {
exit($snpp->code()-400);
}
}
# issue the send
if (!$snpp->send()) {
warn $snpp->message();
exit($snpp->code()%100);
}
$snpp->quit;
undef $snpp;
|