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 @@
enabled

View File

@@ -0,0 +1 @@
service

View File

@@ -0,0 +1,65 @@
#!/usr/bin/perl
#----------------------------------------------------------------------
# copyright (C) 1999 Ip, Tak Hong
# copyright (C) 2000-2006 Mitel Networks Corporation
#
# 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
#
#----------------------------------------------------------------------
package esmith;
use strict;
use warnings;
use Errno;
use esmith::util;
use esmith::AccountsDB;
my $adb = esmith::AccountsDB->open_ro();
my $event = $ARGV [0];
my $printerName = $ARGV [1];
my @printers;
#------------------------------------------------------------
# Create the printer
#------------------------------------------------------------
if ($printerName)
{
my $p = $adb->get($printerName);
die "Invalid printer $printerName; create printer failed.\n"
unless ($p and $p->prop('type') eq 'printer');
@printers = ($p);
}
else
{
@printers = $adb->printers;
}
foreach (@printers)
{
$printerName = $_->key;
unless (-d "/var/spool/lpd/$printerName")
{
mkdir ("/var/spool/lpd/$printerName", 0700)
or die "Could not create spool directory " .
"'/var/spool/lpd/$printerName'; $! : create printer failed.\n";
esmith::util::chownFile ("lp", "lp", "/var/spool/lpd/$printerName");
}
}
exit (0);

View File

@@ -0,0 +1,48 @@
#!/usr/bin/perl -w
#----------------------------------------------------------------------
# copyright (C) 1999 Ip, Tak Hong
# copyright (C) 2000-2005 Mitel Networks Corporation
#
# 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
#
#----------------------------------------------------------------------
package esmith;
use strict;
use Errno;
use esmith::AccountsDB;
my $adb = esmith::AccountsDB->open_ro();
my $event = $ARGV [0];
my $printerName = $ARGV [1];
#------------------------------------------------------------
# delete the printer
#------------------------------------------------------------
die "printerName argument missing." unless defined ($printerName);
my $p = $adb->get($printerName);
die "Invalid printer $printerName; delete printer failed.\n" unless
(defined $p && $p->prop('type') eq 'printer-deleted');
system("/bin/rm", "-rf", "/var/spool/lpd/$printerName") == 0
or die "Could not delete spool directory '/var/spool/lpd/$printerName';" .
"delete printer failed.\n";
exit (0);

View File

@@ -0,0 +1,177 @@
<lexicon lang="en-us">
<entry>
<base>FORM_TITLE</base>
<trans>Add or remove printers</trans>
</entry>
<entry>
<base>INITIAL_DESC</base>
<trans>
<![CDATA[
<P><A class="button-like" HREF="printers?page=0&Next=Add">Add printer</A></P>
]]>
</trans>
</entry>
<entry>
<base>NO_PRINTERS</base>
<trans>There are no printers in the system.</trans>
</entry>
<entry>
<base>CURRENT_LIST</base>
<trans>Current List of printers</trans>
</entry>
<entry>
<base>REMOTE_ADDRESS</base>
<trans>Remote address</trans>
</entry>
<entry>
<base>REMOTE_NAME</base>
<trans>Remote name</trans>
</entry>
<entry>
<base>CREATE_NEW_PRINTER</base>
<trans>Create a new printer</trans>
</entry>
<entry>
<base>CREATE_NEW_DESC</base>
<trans>
Please choose a unique name for the printer and enter a brief
description. The printer name should contain only lower-case
letters and numbers, and should start with a lower-case
letter. For example "hplaser", "epsonlp", and
"canonbj" are valid choices, but "HP Laser Jet",
"Canon BubbleJet", and
"HP JetDirect Printer" are not.
Avoid names and descriptions that contain these terms,
"offline", "disabled", "down", "off", "waiting", "jam",
"paper", "error" and "responding".
</trans>
</entry>
<entry>
<base>PRINTER_NAME</base>
<trans>Printer name</trans>
</entry>
<entry>
<base>LOCAL_PRINTER_0</base>
<trans>Local printer port 0 (LPT1)</trans>
</entry>
<entry>
<base>LOCAL_PRINTER_1</base>
<trans>Local printer port 1 (LPT2)</trans>
</entry>
<entry>
<base>LOCAL_PRINTER_2</base>
<trans>Local printer port 2 (LPT3)</trans>
</entry>
<entry>
<base>NET_PRINTER</base>
<trans>Network printer ...</trans>
</entry>
<entry>
<base>FIRST_USB_PRINTER</base>
<trans>First USB attached printer</trans>
</entry>
<entry>
<base>SECOND_USB_PRINTER</base>
<trans>Second USB attached printer</trans>
</entry>
<entry>
<base>ERR_UNEXPECTED_NAME</base>
<trans>
<![CDATA[
<P>Error: unexpected characters in printer name.</P>
<P>The printer name should contain only lower-case
letters and numbers, and should start with a lower-case
letter. For example "hplaser", "epsonlp", and
"canonbj" are valid names.</P>
]]>
</trans>
</entry>
<entry>
<base>ERR_UNEXPECTED_DESC</base>
<trans>
Error: unexpected or missing characters in description.
Did not create new printer.
</trans>
</entry>
<entry>
<base>ERR_EXISTS</base>
<trans>Error: An account with the same name exists with type: </trans>
</entry>
<entry>
<base>ERR_INVALID_ADDRESS</base>
<trans>Error: invalid network address. Did not create new printer.</trans>
</entry>
<entry>
<base>ERR_INVALID_REMOTE_NAME</base>
<trans>Error: invalid network printer name. Did not create new printer.</trans>
</entry>
<entry>
<base>ERR_CREATING</base>
<trans>Error occurred while creating printer.</trans>
</entry>
<entry>
<base>CREATED_SUCCESSFULLY</base>
<trans>Successfully created printer: </trans>
</entry>
<entry>
<base>CREATE_NETWORK_PRINTER</base>
<trans>Create a new network printer</trans>
</entry>
<entry>
<base>ERR_OPENING_DB</base>
<trans>Error occurred while opening accounts database.</trans>
</entry>
<entry>
<base>CREATE_NETWORK_DESC</base>
<trans>Please enter the address and name of the network printer</trans>
</entry>
<entry>
<base>HOSTNAME_OR_IP</base>
<trans>Hostname or IP address of the network printer</trans>
</entry>
<entry>
<base>REMOTE_NAME_DESC</base>
<trans>
<![CDATA[
Network printer name (enter raw if not sure)
]]>
</trans>
</entry>
<entry>
<base>REMOVE_PRINTER</base>
<trans>Remove printer</trans>
</entry>
<entry>
<base>ABOUT_TO_REMOVE</base>
<trans>You are about to remove the printer: </trans>
</entry>
<entry>
<base>SPOOL_FILE_WARNING</base>
<trans>All the spool files for this printer will be deleted.</trans>
</entry>
<entry>
<base>ARE_YOU_SURE</base>
<trans>Are you sure you wish to remove this printer?</trans>
</entry>
<entry>
<base>ERR_INTERNAL_FAILURE</base>
<trans>Error: internal failure while removing printer: </trans>
</entry>
<entry>
<base>ERR_DELETING</base>
<trans>Error occurred while deleting printer.</trans>
</entry>
<entry>
<base>DELETED_SUCCESSFULLY</base>
<trans>Successfully deleted printer: </trans>
</entry>
<entry>
<base>MUST_BE_VALID_HOSTNAME_OR_IP</base>
<trans>Must be a valid hostname or IP number</trans>
</entry>
<entry>
<base>Printers</base>
<trans>Printers</trans>
</entry>
</lexicon>

View File

@@ -0,0 +1 @@
TEMPLATE_PATH="/etc/lpd.perms"

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";
}

View File

@@ -0,0 +1,6 @@
# DO NOT MODIFY THIS FILE.
# This file is automatically maintained by the Mitel Networks SME Server
# configuration software. Manually editing this file may put your
# system in an unknown state.
#
# updated: Tue May 28 15:10:57 2002

View File

@@ -0,0 +1,83 @@
#!/usr/bin/perl -wT
#----------------------------------------------------------------------
# heading : Configuration
# description : Printers
# navigation : 6000 6400
#
# copyright (C) 2002 Mitel Networks Corp.
#
# 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
#
#----------------------------------------------------------------------
use strict;
use esmith::FormMagick::Panel::printers;
my $fm = esmith::FormMagick::Panel::printers->new();
$fm->display();
__DATA__
<form title="FORM_TITLE" header="/etc/e-smith/web/common/head.tmpl"
footer="/etc/e-smith/web/common/foot.tmpl">
<page name="First" pre-event="print_status_message">
<description>INITIAL_DESC</description>
<subroutine src="show_printers()"/>
</page>
<page name="Add" pre-event="print_status_message"
post-event="create_printer">
<title>CREATE_NEW_PRINTER</title>
<description>CREATE_NEW_DESC</description>
<field id="name" type="text" validation="nonblank, maxlength(32)">
<label>PRINTER_NAME</label>
</field>
<field id="description" type="text" validation="nonblank, maxlength(32)">
<label>DESCRIPTION_BRIEF</label>
</field>
<field id="location" type="select" options="'lp0'=>'LOCAL_PRINTER_0',
'lp1'=>'LOCAL_PRINTER_1','lp2'=>'LOCAL_PRINTER_2','remote'=>'NET_PRINTER',
'usb/lp0'=>'FIRST_USB_PRINTER','usb/lp1'=>'SECOND_USB_PRINTER'"
value="remote" validation="nonblank">
<label>LOCATION</label>
</field>
<subroutine src="print_button('ADD')"/>
</page>
<page name="AddNetwork" pre-event="turn_off_buttons"
post-event="create_printer">
<title>CREATE_NETWORK_PRINTER</title>
<description>CREATE_NETWORK_DESC</description>
<field id="address" type="text" validation="hostname_or_ip">
<label>HOSTNAME_OR_IP</label>
</field>
<field id="remoteName" type="text" value="raw" validation="nonblank">
<label>REMOTE_NAME_DESC</label>
</field>
<subroutine src="print_hidden_fields()"/>
<subroutine src="print_button('ADD')"/>
</page>
<page name="Delete" pre-event="turn_off_buttons">
</page>
<page name="ConfirmDelete" pre-event="turn_off_buttons"
post-event="delete_printer">
<title>REMOVE_PRINTER</title>
<subroutine src="show_delete_confirmation()"/>
<subroutine src="print_button('REMOVE')"/>
</page>
</form>