Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37878426
en ru br
Репозитории ALT
S:2.4.7-alt1
5.1: 1.4.2-alt1.M51.2
4.1: 1.3.10-alt0.M41.4
+updates:1.3.9-alt1.M41.1
4.0: 1.2.12-alt6.M40.9
+updates:1.2.12-alt6.M40.8
3.0: 1.1.20-alt14.1
www.altlinux.org/Changes

Группа :: Система/Серверы
Пакет: cups

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

cups-ncp-0.2/000075500000000000000000000000001121171070200130715ustar00rootroot00000000000000cups-ncp-0.2/README000064400000000000000000000103271121171070200137540ustar00rootroot00000000000000NCP backend for CUPS
====================

This backend allows CUPS to send print jobs to Novell NetWare printers.



REQUIREMENTS

- Obviously, CUPS itself.
- Perl (tested on version 5.6.1, but probably any 5.x version
will be OK).
- nprint (from the ncpfs utilities package).



INSTALLATION

1. If you have Perl not in /usr/bin/perl, but in some other place, you
need to edit the "ncp" script and edit the first line to set the correct
perl path.

2. Check the configuration variables at the top of the script, change
the values if needed:

- Set NPRINT to the full path of the nprint program. The
default configuration assumes that nprint may be found
somewhere in the default PATH; if nprint is installed in some
other directory, put the full name into the script.

- Set NCP_HOME to the name of the directory which contains the
.nwclient file for use with this script. The default
configuration uses the /root directory. When choosing the
directory, remember that the .nwclient file contains cleartext
passwords for NetWare servers, so it should not be accessible
to anyone except root.

3. Copy the edited "ncp" script to the CUPS backends directory
(/usr/lib/cups/backend or similar, depending on where CUPS is
installed).

After adding the backend, you need to restart CUPS to let it notice the
new backend.

4. Decide how you will supply the NetWare user name and password to the
backend. There are three possible configurations:

1) You can specify the user name and password as part of the
printer URI in CUPS printer setup, like with SMB printers:

ncp://USERNAME:PASSWORD@SERVER/QUEUE

2) You can specify only the user name in the printer URI, and
place the password in $NCP_HOME/.nwclient:

ncp://USERNAME@SERVER/QUEUE

3) Finally, you can completely remove the NetWare user
information from the printer URI and place it only in
$NCP_HOME/.nwclient:

ncp://SERVER/QUEUE

If the user name and password are specified as part of the URI, they can
appear in the command line parameters and environment variables, where
they are accessible to local users. Storing user information in
$NCP_HOME/.nwclient avoids this. In any case, it is strongly
recommended to add a separate user on the NetWare server and limit its
privileges only to printing, to minimize the damage in case the password
is compromised.

Entries in $NCP_HOME/.nwclient have the following format:

SERVER/USER PASSWORD

If you want to use $NCP_HOME/.nwclient, you should create the file with
mode 0600 and owner and group root:root. You may want to test it with
nprint before trying to use it with CUPS. If you are using something
other than the root home directory for NCP_HOME, you will need to set
$HOME temporarily for testing (nprint uses this environment variable to
find .nwclient).

5. Add your NetWare printer(s) to the CUPS configuration. Note that you
cannot use most GUI configuration tools for this - they do not know
about the NCP backend, and some of them do not provide any way to enter
a custom printer URI. You can use the CUPS web interface for
configuration, or the lpadmin command-line utility.

If using the web interface, at the device selection step you should see
"NetWare printer via NCP" in the device list. If you do not see such
entry in the list, probably you did not restart CUPS after placing the
backend script into /usr/lib/cups/backend, or for some reason the script
is not executable.

Then you should enter the printer URI on one of these formats:

ncp://USERNAME:PASSWORD@SERVER/QUEUE
ncp://USERNAME@SERVER/QUEUE
ncp://SERVER/QUEUE

Choose the appropriate format depending on where you wish to put the
NetWare user name and password (this was discussed in step 4).

After that continue CUPS configuration as usual. Note that the URI is
not checked: if you make a mistake in it, it will show up only when you
try to print something.

6. Now you are ready to test the configuration. Try to print a test
page. If something is wrong with the NCP configuration, the printer
status will change to "stopped", and you see a message like "nprint
exited with status 256". In this case try to print something with
nprint directly to determine the cause of the problem.



AUTHOR

Sergey Vlasov <vsu@altlinux.ru>


vim: set tw=72:
cups-ncp-0.2/ncp000075500000000000000000000072061121171070200136040ustar00rootroot00000000000000#! /usr/bin/perl -w
#
# NCP backend for CUPS
#
# Copyright (C) 2001 Sergey Vlasov <vsu@altlinux.ru>
#
# 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;

########################################################################
# Configurable parameters
########################################################################

# nprint program name (you may want to put the full pathname here)
my $NPRINT = "nprint";

# Home directory (the .nwclient file will be searched there)
my $NCP_HOME = "/root";

########################################################################
# End of configurable parameters
########################################################################



# No arguments means show available devices
if (scalar(@ARGV) == 0) {
print "network ncp \"Unknown\" \"NetWare Printer via NCP\"\n";
exit 0;
}

# Check number of arguments
if (scalar(@ARGV) < 5 || scalar(@ARGV) > 6) {
print STDERR "ERROR: ncp job user title copies options [filename]\n";
exit 1;
}

my ($job, $user, $title, $copies, $options, $file) = @ARGV;
my $printer = $ENV{"DEVICE_URI"};

# These variables will hold the URI parts
my ($server, $queue, $nwuser, $nwpass);

# Parse the printer URI into parts
for ($printer) {

# ncp://USERNAME:PASSWORD@SERVER/QUEUE
m|^ncp://(.+):(.*)@(.+)/(.+)| && do {
$nwuser = $1;
$nwpass = $2;
$server = $3;
$queue = $4;
last;
};

# ncp://USERNAME@SERVER/QUEUE
m|^ncp://(.+)@(.+)/(.+)| && do {
$nwuser = $1;
$server = $2;
$queue = $3;
last;
};

# ncp://SERVER/QUEUE
m|^ncp://(.+)/(.+)| && do {
$server = $1;
$queue = $2;
last;
};
}

# Check if the URI was parsed correctly
if (not defined $server or not defined $queue) {
print STDERR "ERROR: malformed printer URI\n";
exit 1;
}

# Unquote the URI parts (must be done after splitting)
$nwuser =~ s/%([a-fA-F0-9]{2})/chr(hex($1))/ge if defined $nwuser;
$nwpass =~ s/%([a-fA-F0-9]{2})/chr(hex($1))/ge if defined $nwpass;
$server =~ s/%([a-fA-F0-9]{2})/chr(hex($1))/ge if defined $server;
$queue =~ s/%([a-fA-F0-9]{2})/chr(hex($1))/ge if defined $queue;

# Fixed part of the nprint command
my @command = ($NPRINT, "-S", $server, "-q", $queue, "-N");

# Add "-U USERNAME" if specified
if (defined $nwuser) {
push @command, "-U";
push @command, $nwuser;
}

# Add "-P PASSWORD" if specified
if (defined $nwpass) {
push @command, "-P";
push @command, $nwpass;
}

# Append the print file name or "-" to read from stdin
if (defined $file) {
if ($file =~ /^-/) {
# Avoid file names which look like switches
$file = "./$file";
}
push @command, $file;
} else {
push @command, "-";
}

# nprint will read $HOME/.nwclient, so need to set it
$ENV{"HOME"} = $NCP_HOME;

# all is ready, run nprint (directly, without using shell)
my $result = system { $command[0] } @command;

# if not ok, print the error message in the format required by CUPS
if ($result != 0) {
print STDERR "ERROR: nprint exited with status $result\n";
exit 1;
}

# normal exit
exit 0;
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin