initial commit of file from CVS for smeserver-print-monitor on Sat Sep 7 20:55:37 AEST 2024

This commit is contained in:
Trevor Batley
2024-09-07 20:55:37 +10:00
parent 204cbf06cf
commit 66b2b136f2
35 changed files with 3779 additions and 2 deletions

View File

@@ -0,0 +1,20 @@
<html>
<head>
<META NAME="CONTACT" CONTENT="Komarnitsky, Alek O">
<META NAME="SENSITIVITY" CONTENT="UNRESTRICTED">
</head>
<a href="http://www-sa.SOMEDOMAIN/Presentations/lprng/" target=new>LPRng presentation</a>
<br>
<a href="http://www.SOMEDOMAIN:8080/printflow" target=new>Printing Info/Standards</a>
<br>
<a href="/LPRng/HOWTO/LPRng.html" target = new>LPRng Technical Info</a>
<br>
<a href="http:/LPRng/pprdist" target=new>Pprdist documentation</a>
<br>
<a href="/LPRng/admin/cgi-bin/lpinfo?printer=bogus&checkprintservers=1" target=adminout>Check LPRng Print Servers</a>
<br>
<a href="/LPRng/admin/cgi-bin/lpinfo?printer=bogus&showactivebroke=1" target="adminout">Show Active/Broke Queues</a>
<br>
<a href="/LPRng/admin/cgi-bin/lpinfo?printer=bogus&misconfigured=1" target=adminout>Mis-configured NT Queues</a>
<br><br>
</html>

View File

@@ -0,0 +1,68 @@
#!/usr/bin/perl
#^^^^^^^^^^^^^^^^^^^^ Update pathname appropriately to where you have Perl installed
# And update the path below of the configuration file as appropriate.
$suid_ph = "/var/www/html/LPRng/admin/cgi-bin/suid.ph";
#-------------- Should be fairly boilerplate from here on out --------------
# lpc.suid - a setUID script to allow httpd to issue lpc commands ...
# This script would be setUID root and in a directory readable by httpd ONLY
# and protected via a .htaccess file
# Copyright 1997, 1998, 1999, 2000 by Alek Komarnitsky, alek@komar.org, http://www.komar.org/
# Use and distribution of this software is covered by the GNU GPL license.
# Please see the LICENSE file and http://www.gnu.org/
# Grab stuff from suid.ph ...
if ( -r "$suid_ph" ) {
require "$suid_ph";
} else {
print "could not open $suid_ph - serious error ... \n";
exit(2);
}
if ($#ARGV < 4) {
print ("Usage: lpc_suid adminmode browserhost queuename printserver lpc-options\n");
exit(1);
}
# LPRng requires setting UID to EUID ...
$< = $>;
$ARGV[0] =~ /^(\S+)$/;
$_ = $1; # Not tainted
$adminmode = sanitize($_);
$adminmode = nobody if ($adminmode eq 0 ) ;
$ARGV[1] =~ /^(\S+)$/;
$_ = $1; # Not tainted
$browserhost = sanitize($_);
$ARGV[2] =~ /^(\S+)$/;
$_ = $1; # Not tainted
$queuename = sanitize($_);
$ARGV[3] =~ /^(\S+)$/;
$_ = $1; # Not tainted
$printserver = sanitize($_);
$temp = "@ARGV[4 .. $#ARGV]";
$temp =~ /^(.+)$/;
$_ = $1; # Not tainted
$lpc_options = sanitize($_);
if ( $printserver =~ /unix/ ) {
$command = "$lpc -P$queuename $lpc_options";
$command = "$lpc release $queuename all" if ( $lpc_options eq "release");
} else {
$< = "$lprng_uid";
$command = "rsh $printserver \"$nt_lpc $queuename /$lpc_options\"" ;
}
print "<h2>Executing: &nbsp; $command <br><br>\n";
$_ = `$command`;
print "Results: &nbsp; &nbsp; &nbsp; $_";
&openlog("lpc_suid","cons,pid","local2");
&syslog('info',"lpc -P$queuename $lpc_options from browserhost $browserhost by $adminmode");
&closelog();
exit();

View File

@@ -0,0 +1,60 @@
#!/usr/bin/perl
#^^^^^^^^^^^^^^^^^^^^ Update pathname appropriately to where you have Perl installed
# And update the path below of the configuration file as appropriate.
$suid_ph = "/var/www/html/LPRng/admin/cgi-bin/suid.ph";
#-------------- Should be fairly boilerplate from here on out --------------
# lpq_nt - a setUID script to determine NT queue status via a direct rsh
# The ONLY reason this exists is because the NT LPD server truncates the
# IP address when queried via an lpq ... and it is setUID because we restrict
# rsh's to a certain named user
# This script would be setUID root and in a directory readable by httpd ONLY
# and protected via a .htaccess file
# Copyright 1997, 1998, 1999, 2000 by Alek Komarnitsky, alek@komar.org, http://www.komar.org/
# Use and distribution of this software is covered by the GNU GPL license.
# Please see the LICENSE file and http://www.gnu.org/
# Grab stuff from suid.ph ...
if ( -r "$suid_ph" ) {
require "$suid_ph";
} else {
print "could not open $suid_ph - serious error ... \n";
exit(2);
}
if ($#ARGV != 1) {
print ("Usage: lpq_nt queuename printserver\n");
exit(1);
}
$< = "$lprng_uid";
$ARGV[0] =~ /^(\S+)$/;
$_ = $1; # Not tainted
$queuename = sanitize($_);
$ARGV[1] =~ /^(\S+)$/;
$_ = $1; # Not tainted
$printserver = sanitize($_);
$command = "rsh $printserver \"$nt_lpc $queuename /JL\"" ;
$output = `$command`;
print " Windows NT LPD Server \n Rank Owner/NT-ID Class Job Files Size\n";
print "----------------------------------------------------------------------------------------\n";
if ( ! ($output =~ /There are no print jobs for printer/) ) {
@lpqout = split(/\n/,$output);
$count = 1;
foreach $line (@lpqout) {
if ( ($line =~ /JOB LOG FOR PRINTER/) || ($line =~ /^Job:/) || ($line =~ /--------------------/) || ($line =~ /^\s*$/)) {
next;
} else {
($jobid,$owner,$_,$jobname,$size) = split(/\s+/,$line);
s/\(// ; s/\)//;
$owner = "$owner" . "@" . "$_" . "+1";
printf "%-2s%5s%-31s%3s%5s%2s%-30s%9s%s",$count," ",$owner,"NT",$jobid," ",$jobname,$size,"\n";
$count++;
}
}
}
exit();

View File

@@ -0,0 +1,66 @@
#!/usr/bin/perl
#^^^^^^^^^^^^^^^^^^^^ Update pathname appropriately to where you have Perl installed
# And update the path below of the configuration file as appropriate.
$suid_ph = "/var/www/html/LPRng/admin/cgi-bin/suid.ph";
#-------------- Should be fairly boilerplate from here on out --------------
# lprm_suid - a setUID script to allow httpd to lprm selected jobs
# This script would be setUID root and in a directory readable by httpd ONLY
# and protected via a .htaccess file
# Copyright 1997, 1998, 1999, 2000 by Alek Komarnitsky, alek@komar.org, http://www.komar.org/
# Use and distribution of this software is covered by the GNU GPL license.
# Please see the LICENSE file and http://www.gnu.org/
# Grab stuff from suid.ph ...
if ( -r "$suid_ph" ) {
require "$suid_ph";
} else {
print "could not open $suid_ph - serious error ... \n";
exit(2);
}
if ($#ARGV != 4) {
print ("Usage: lprm_suid adminmode browserhost queuename printserver jobnumber\n");
exit(1);
}
# LPRng requires setting UID to EUID ...
$< = $>;
$ARGV[0] =~ /^(\S+)$/;
$_ = $1; # Not tainted
$adminmode = sanitize($_);
$adminmode = nobody if ($adminmode eq 0 ) ;
$ARGV[1] =~ /^(\S+)$/;
$_ = $1; # Not tainted
$browserhost = sanitize($_);
$ARGV[2] =~ /^(\S+)$/;
$_ = $1;
$queuename = sanitize($_);
$ARGV[3] =~ /^(\S+)$/;
$_ = $1;
$printserver = sanitize($_);
$ARGV[4] =~ /^(\S+)$/;
$_ = $1;
$jobnumber = sanitize($_);
if ( $printserver =~ /unix/ ) {
$command = "$lprm -P$queuename $jobnumber";
} else {
$< = "$lprng_uid";
if ($jobnumber eq "all") {
$command = "rsh $printserver \"$nt_lpc $queuename /PG\"";
} else {
$command = "rsh $printserver \"$nt_lpc $queuename /JK$jobnumber\"" ;
}
}
$_ = `$command`;
print "$_";
&openlog("lprm_suid","cons,pid","local2");
&syslog('info',"lprm -P$queuename $jobnumber from browserhost $browserhost by $adminmode");
&closelog();
exit();

View File

@@ -0,0 +1,27 @@
# suid.ph ... misc. stuff needed for setUID (be careful!) programs with LPRng lpinfo
# Copyright 1997, 1998, 1999, 2000 by Alek Komarnitsky, alek@komar.org, http://www.komar.org/
# Use and distribution of this software is covered by the GNU GPL license.
# Please see the LICENSE file and http://www.gnu.org/
$ENV{'PATH'} = "/bin:/usr/bin:/usr/ucb:/usr/etc";
require Sys::Syslog;
import Sys::Syslog;
$lpc = "/usr/sbin/lpc";
$lprm = "/usr/bin/lprm";
$nt_lpc = "c:\\ent\\util\\ntp\\release\\ntp.exe" ;
$lprng_uid = "6743";
$| = 1;
sub sanitize {
local ($OK_CHARS);
$OK_CHARS=' \-\.a-zA-Z0-9_';
s/[^$OK_CHARS]/_/go;
/^(.*)$/;
return $1;
}
1;