initial commit of file from CVS for e-smith-LPRng on Wed 12 Jul 08:48:21 BST 2023

This commit is contained in:
Brian Read
2023-07-12 08:48:21 +01:00
parent 6a1964d326
commit 56bb66d687
31 changed files with 2135 additions and 2 deletions

View File

@@ -0,0 +1,9 @@
#--------------------------------------------------------------------------
#
# Printing (ie unspooling) requests
#
#--------------------------------------------------------------------------
# Accept all requests
ACCEPT SERVICE=P

View File

@@ -0,0 +1,9 @@
#--------------------------------------------------------------------------
#
# Spooling (ie lpr) requests
#
#--------------------------------------------------------------------------
# Accept all requests
ACCEPT SERVICE=R

View File

@@ -0,0 +1,15 @@
#--------------------------------------------------------------------------
#
# Control (ie lpc) requests
#
#--------------------------------------------------------------------------
# Allow root on the server to control jobs
ACCEPT SERVICE=C SERVER REMOTEUSER=root
# Allow all others access only to server, status and printcap
ACCEPT SERVICE=C LPC=lpd,status,printcap
# Reject all other requests
REJECT SERVICE=C

View File

@@ -0,0 +1,15 @@
#--------------------------------------------------------------------------
#
# Removal (ie lprm) requests
#
#--------------------------------------------------------------------------
# Allow same user on originating host to remove a job
ACCEPT SERVICE=M SAMEHOST SAMEUSER
# Allow root on the server to remove a job
ACCEPT SERVICE=M SERVER REMOTEUSER=root
# Reject all other requests
REJECT SERVICE=M

View File

@@ -0,0 +1,9 @@
#--------------------------------------------------------------------------
#
# Information (ie lpq) requests
#
#--------------------------------------------------------------------------
# Allow all requests
ACCEPT SERVICE=Q

View File

@@ -0,0 +1,37 @@
#--------------------------------------------------------------------------
#
# Connection access. This controls access to ALL the request types. If
# a host does not match one of these rules it will be denied access,
# regardless of ANY of the other rules above.
#
#--------------------------------------------------------------------------
# Allow connections from the localhost
ACCEPT SERVICE=X REMOTEIP=127.0.0.1
# Allow connections from subnets in our control
{
use esmith::NetworksDB;
my $ndb = esmith::NetworksDB->open_ro();
my $prefix = "ACCEPT SERVICE=X REMOTEIP=";
my ($network, undef) =
esmith::util::computeNetworkAndBroadcast($LocalIP, $LocalNetmask);
my $result = $prefix . "${network}/${LocalNetmask}";
foreach my $net ($ndb->get_all_by_prop(type=>'network'))
{
my $key = $net->key;
my %properties = $net->props;
$result .= "\n" . $prefix . "${key}/$properties{'Mask'}";
}
return $result;
}
# Reject all other connections
REJECT SERVICE=X

View File

@@ -0,0 +1,9 @@
#--------------------------------------------------------------------------
#
# Default action
#
#--------------------------------------------------------------------------
# Reject anything which has not been explicitly allowed
DEFAULT=REJECT

View File

@@ -0,0 +1,13 @@
#--------------------------------------------------
# Example printcap entry:
#
# hplaser|HP Laser 5:\
# :server:\
# :mx#0:\
# :sh:\
# :ff_separator=false:\
# :sd=/var/spool/lpd/hplaser:\
# :lp=/dev/lp0:
#--------------------------------------------------

View File

@@ -0,0 +1,42 @@
{
# process all accounts
use esmith::AccountsDB;
my $adb = esmith::AccountsDB->open_ro();
$OUT = "";
foreach my $printer ( $adb->printers )
{
$OUT .= "\n";
$OUT .= $printer->key;
$OUT .= "|" . $printer->prop('Description') . ":\\\n";
$OUT .= "\t:server:\\\n";
$OUT .= "\t:mx#0:\\\n";
$OUT .= "\t:sh:\\\n";
$OUT .= "\t:ff_separator=false:\\\n";
$OUT .= "\t:sd=/var/spool/lpd/" . $printer->key . ":\\\n";
if ($printer->prop('Location') eq 'remote')
{
$OUT .= "\t:rm=" . $printer->prop('Address') . ":\\\n";
# no trailing backslash for last entry
if (defined $printer->prop('RemoteName'))
{
$OUT .= "\t:rp=" . $printer->prop('RemoteName') . ":\n";
}
else
{
$OUT .= "\t:rp=raw:\n";
}
}
else
{
# no trailing backslash for last entry
$OUT .= "\t:lp=/dev/" . $printer->prop('Location') . ":\n";
}
}
}

View File

@@ -0,0 +1,14 @@
{
# if you want to automatically load your printer list rather
# than setting them up individually then you'll need this
# It should not be necessary to spell out the print system type unless
# yours is non-standard. Currently supported print systems include:
# bsd, sysv, plp, lprng, aix, hpux, qnx
$OUT .= <<HERE;
printcap name = /etc/printcap
load printers = yes
printing = lprng
print command = /usr/bin/lpr -b -h -r -P%p %s
HERE
}

View File

@@ -0,0 +1,16 @@
{
# NOTE: If you have a BSD-style print system there is no need to
# specifically define each individual printer
# Set public = yes to allow user 'guest account' to print
$OUT = <<HERE;
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
guest ok = no
writable = no
printable = yes
HERE
$OUT .= "use client driver = ";
$OUT .= $smb{UseClientDriver} || "yes";
}

View File

@@ -0,0 +1,7 @@
# lpd specific service (lpd in init.d)
{
$status = $lpd{status} || 'disabled';
$status = ($status eq "enabled") ? "enable" : "disable";
$OUT .= "$status lpd.service\n";
}