Author: jsmeix
Date: Fri Nov 28 12:58:52 2008
New Revision: 53700
URL: http://svn.opensuse.org/viewcvs/yast?rev=53700&view=rev
Log:
- Removed the nasty inline bash scripts in connectionwizard.ycp
and replaced them by our well known external tools from
the old yast2-printer module test_device, test_remote_socket,
test_remote_lpd, test_remote_ipp, test_remote_smb, and
test_remote_novell and called them in a safe environment
via Printerlib::ExecuteBashCommand (in particular using a safe
locale which is required for the scripts to work correctly)
so that now the connection tests in the Connection Wizard should
again work as good as before in the old yast2-printer module
and provided an error popup with details when a test fails.
- 2.17.48
Added:
trunk/printer/tools/test_device (with props)
trunk/printer/tools/test_remote_ipp (with props)
trunk/printer/tools/test_remote_lpd (with props)
trunk/printer/tools/test_remote_novell (with props)
trunk/printer/tools/test_remote_smb (with props)
trunk/printer/tools/test_remote_socket (with props)
Modified:
trunk/printer/VERSION
trunk/printer/package/yast2-printer.changes
trunk/printer/src/connectionwizard.ycp
trunk/printer/tools/Makefile.am
trunk/printer/yast2-printer.spec.in
Modified: trunk/printer/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/VERSION?rev=53700&r1=53699&r2=53700&view=diff
==============================================================================
--- trunk/printer/VERSION (original)
+++ trunk/printer/VERSION Fri Nov 28 12:58:52 2008
@@ -1 +1 @@
-2.17.47
+2.17.48
Modified: trunk/printer/package/yast2-printer.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/package/yast2-printer.changes?rev=53700&r1=53699&r2=53700&view=diff
==============================================================================
--- trunk/printer/package/yast2-printer.changes (original)
+++ trunk/printer/package/yast2-printer.changes Fri Nov 28 12:58:52 2008
@@ -1,4 +1,19 @@
-------------------------------------------------------------------
+Fri Nov 28 12:37:23 CET 2008 - jsmeix@suse.de
+
+- Removed the nasty inline bash scripts in connectionwizard.ycp
+ and replaced them by our well known external tools from
+ the old yast2-printer module test_device, test_remote_socket,
+ test_remote_lpd, test_remote_ipp, test_remote_smb, and
+ test_remote_novell and called them in a safe environment
+ via Printerlib::ExecuteBashCommand (in particular using a safe
+ locale which is required for the scripts to work correctly)
+ so that now the connection tests in the Connection Wizard should
+ again work as good as before in the old yast2-printer module
+ and provided an error popup with details when a test fails.
+- 2.17.48
+
+-------------------------------------------------------------------
Thu Nov 27 14:05:38 CET 2008 - jsmeix@suse.de
- Several fixes regarding the Connection Wizard like
Modified: trunk/printer/src/connectionwizard.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/src/connectionwizard.ycp?rev=53700&r1=53699&r2=53700&view=diff
==============================================================================
--- trunk/printer/src/connectionwizard.ycp (original)
+++ trunk/printer/src/connectionwizard.ycp Fri Nov 28 12:58:52 2008
@@ -34,6 +34,7 @@
import "Label";
import "Printer";
+import "Printerlib";
import "Popup";
import "Wizard";
@@ -216,7 +217,7 @@
)
),
`Left
- ( `InputField( `id(`port), text[1]:"", text[2]:"" )
+ ( `InputField( `id(`port_or_queue), text[1]:"", text[2]:"" )
),
`Left
( // TRANSLATORS: Button to test remote printer machine
@@ -738,28 +739,35 @@
{ Popup::Error( _("Servername and printer couldn't be empty!") );
}
else
- { connection_uri = "smb://";
- if( size( smb["user"]:"" ) > 0
- && size( smb["pass"]:"" ) > 0
+ { if( ( size( smb["user"]:"" ) > 0 && size( smb["pass"]:"" ) == 0 )
+ || ( size( smb["user"]:"" ) == 0 && size( smb["pass"]:"" ) > 0 )
)
- { connection_uri = sformat( "%1%2:%3@",
- connection_uri,
- smb["user"]:"",
- smb["pass"]:""
- );
+ { Popup::Error( _("Both user and password must be specified!") );
}
- if( size( smb["domain"]:"" ) > 0 )
- { connection_uri = sformat( "%1%2/",
+ else
+ { connection_uri = "smb://";
+ if( size( smb["user"]:"" ) > 0
+ && size( smb["pass"]:"" ) > 0
+ )
+ { connection_uri = sformat( "%1%2:%3@",
+ connection_uri,
+ smb["user"]:"",
+ smb["pass"]:""
+ );
+ }
+ if( size( smb["domain"]:"" ) > 0 )
+ { connection_uri = sformat( "%1%2/",
+ connection_uri,
+ smb["domain"]:""
+ );
+ }
+ connection_uri = sformat( "%1%2/%3",
connection_uri,
- smb["domain"]:""
+ smb["hostname"]:"",
+ smb["printer"]:""
);
+ valid = true;
}
- connection_uri = sformat( "%1%2/%3",
- connection_uri,
- smb["hostname"]:"",
- smb["printer"]:""
- );
- valid = true;
}
if( valid )
{ connection_model = (string)UI::QueryWidget( `id("manufacturers_combo_box"), `Value );
@@ -771,7 +779,7 @@
break;
case(`tcp):
map tcp = $[ "hostname" : UI::QueryWidget( `hostname, `Value ),
- "port" : UI::QueryWidget( `port, `Value )
+ "port" : UI::QueryWidget( `port_or_queue, `Value )
];
if( size( tcp["hostname"]:"" ) > 0
&& size( tcp["port"]:"" ) > 0
@@ -792,7 +800,7 @@
break;
case(`lpd):
map lpd = $[ "hostname" : UI::QueryWidget( `hostname, `Value ),
- "queue" : UI::QueryWidget( `port, `Value )
+ "queue" : UI::QueryWidget( `port_or_queue, `Value )
];
if( size( lpd["hostname"]:"" ) > 0
&& size( lpd["queue"]:"" ) > 0
@@ -813,7 +821,7 @@
break;
case(`lpr):
map lpr = $[ "hostname" : UI::QueryWidget( `hostname, `Value ),
- "queue" : UI::QueryWidget( `port, `Value )
+ "queue" : UI::QueryWidget( `port_or_queue, `Value )
];
if( size( lpr["hostname"]:"" ) > 0
&& size( lpr["queue"]:"" ) > 0
@@ -978,80 +986,140 @@
}
boolean testQueue( symbol selected )
-{ boolean test = true;
- string host = (string)UI::QueryWidget( `hostname, `Value );
- integer ping_res = (integer)SCR::Execute( .target.bash, sformat( "ping -c 1 -w 5 %1", host ) );
- y2milestone( "ping %1 : %2", host, ping_res );
- if( ping_res != 0 )
- { Popup::Error(sformat(_("Host %1 unreachable!"), host));
- test = false;
- return false;
- }
- string port = (string)UI::QueryWidget( `port, `Value );
- integer port_test = -1;
- integer port_test_res = -1;
+{ string test_command = "";
+ string timeout = "5";
+ string host = "";
+ string port = "";
+ string queue = "";
+ string workgroup = "";
+ string user = "";
+ string password = "";
switch(selected)
{ case(`tcp):
- port_test = (integer)SCR::Execute( .target.bash, sformat( "netcat -w 5 -z %1 %2 2>&1", host, port ) );
- y2internal( "Test port result : %1", port_test );
- if( port_test != 0 )
- { Popup::Error( sformat( "%1 %2", _("No connection possible to port"), port ) );
- test = false;
+ host = (string)UI::QueryWidget( `hostname, `Value );
+ port = (string)UI::QueryWidget( `port_or_queue, `Value );
+ test_command = sformat( "%1test_remote_socket \"%2\" \"%3\" %4",
+ Printerlib::yast_bin_dir,
+ host,
+ port,
+ timeout
+ );
+ if( ! Printerlib::ExecuteBashCommand( test_command) )
+ { Popup::ErrorDetails( sformat( // Message of a Popup::ErrorDetails
+ // where %1 will be replaced by the port number
+ // and %2 will be replaced by the host name:
+ _("Access test failed for port '%1' on host '%2'."),
+ port,
+ host
+ ),
+ Printerlib::result["stderr"]:"" + "\n" + Printerlib::result["stdout"]:""
+ );
return false;
}
- port_test_res = (integer)SCR::Execute( .target.bash, sformat( "echo -en \"\\r\" | netcat -w 5 %1 %2 2>&1",
- host,
- port
- )
- );
- y2internal( "Test connection accept result : %1", port_test_res );
- if( port_test_res != 0 )
- { Popup::Error( sformat( "%1 %2 %3 %4 %5", _("Port"), port, _("on host"), host, _("doesn't accepts data") ) );
- test = false;
- }
- else
- { Popup::Message( _("Test OK") );
- }
break;
case(`lpd):
case(`lpr):
- string queue = port;
+ host = (string)UI::QueryWidget( `hostname, `Value );
+ queue = (string)UI::QueryWidget( `port_or_queue, `Value );
port = "515";
- port_test = (integer)SCR::Execute( .target.bash, sformat( "netcat -w 5 -z %1 %2 2>&1", host, port ) );
- y2internal( "Test port result : %1", port_test );
- if( port_test != 0 )
- { Popup::Error( sformat( "%1 %2", _("No connection possible to port"), port ) );
- test = false;
+ test_command = sformat( "%1test_remote_lpd \"%2\" \"%3\" %4",
+ Printerlib::yast_bin_dir,
+ host,
+ queue,
+ timeout
+ );
+ if( ! Printerlib::ExecuteBashCommand( test_command) )
+ { Popup::ErrorDetails( sformat( // Message of a Popup::ErrorDetails
+ // where %1 will be replaced by the queue name
+ // and %2 will be replaced by the host name:
+ _("Access test failed for queue '%1' on host '%2'."),
+ queue,
+ host
+ ),
+ Printerlib::result["stderr"]:"" + "\n" + Printerlib::result["stdout"]:""
+ );
+ return false;
+ }
+ break;
+ case(`cups):
+ host = (string)UI::QueryWidget( `hostname, `Value );
+ queue = (string)UI::QueryWidget( `queue, `Value );
+ test_command = sformat( "%1test_remote_ipp \"%2\" \"%3\" %4",
+ Printerlib::yast_bin_dir,
+ host,
+ queue,
+ timeout
+ );
+ if( ! Printerlib::ExecuteBashCommand( test_command) )
+ { Popup::ErrorDetails( sformat( // Message of a Popup::ErrorDetails
+ // where %1 will be replaced by the queue name
+ // and %2 will be replaced by the host name:
+ _("Access test failed for queue '%1' on host '%2'."),
+ queue,
+ host
+ ),
+ Printerlib::result["stderr"]:"" + "\n" + Printerlib::result["stdout"]:""
+ );
return false;
}
- map available_port = (map)SCR::Execute( .target.bash_output, "for I in 721 722 723 724 725 726 727 728 729 730 731; do fuser -n tcp $I &>/dev/null || { echo -n $I ; break ; } done" );
- y2milestone( "available port %1", available_port );
- map test_lpd = (map)SCR::Execute( .target.bash_output, sformat( "
-TMP_IN=$(mktemp -u /tmp/lpd_test.in.XXXXXX)
-TMP_OUT=$(mktemp -u /tmp/lpd_test.out.XXXXXX)
-mkfifo $TMP_IN
-mkfifo $TMP_OUT
-netcat -w 1 -p %1 %2 %3 <$TMP_IN >$TMP_OUT 2>/dev/null &
-NETCAT_PID=$!
-{ sleep 5s ; kill $NETCAT_PID &>/dev/null ; } &
-RESULT=''
-{ echo -en \"\\002%4\\n\" ; \
- RESULT=$(head --bytes=1 <$TMP_OUT | tr '\\000' '0') ; \
- [ \"$RESULT\" = \"0\" ] && echo -en \"\\001\\n\" ; } >$TMP_IN
-rm $TMP_IN
-rm $TMP_OUT
-exit $RESULT
-", available_port["stdout"]:"", host, port, queue ) );
- if( test_lpd["exit"]:-1 == 0 )
- { Popup::Message( _("Test OK") );
+ break;
+ case(`smb):
+ host = (string)UI::QueryWidget( `hostname, `Value );
+ queue = (string)UI::QueryWidget( `printer, `Value );
+ workgroup = (string)UI::QueryWidget( `domain, `Value );
+ user = (string)UI::QueryWidget( `user, `Value );
+ password = (string)UI::QueryWidget( `pass, `Value );
+ test_command = sformat( "%1test_remote_smb \"%2\" \"%3\" \"%4\" \"%5\" \"%6\" %7",
+ Printerlib::yast_bin_dir,
+ workgroup,
+ host,
+ queue,
+ user,
+ password,
+ timeout
+ );
+ if( ! Printerlib::ExecuteBashCommand( test_command) )
+ { Popup::ErrorDetails( sformat( // Message of a Popup::ErrorDetails
+ // where %1 will be replaced by the SMB share name
+ // and %2 will be replaced by the host name:
+ _("Access test failed for share '%1' on host '%2'."),
+ queue,
+ host
+ ),
+ Printerlib::result["stderr"]:"" + "\n" + Printerlib::result["stdout"]:""
+ );
+ return false;
}
- else
- { Popup::Error( test_lpd["stderr"]:"" );
- test = false;
+ break;
+ case(`ipx):
+ host = (string)UI::QueryWidget( `hostname, `Value );
+ queue = (string)UI::QueryWidget( `queue, `Value );
+ user = (string)UI::QueryWidget( `user, `Value );
+ password = (string)UI::QueryWidget( `pass, `Value );
+ test_command = sformat( "%1test_remote_novell \"%2\" \"%3\" \"%4\" \"%5\" %6",
+ Printerlib::yast_bin_dir,
+ host,
+ queue,
+ user,
+ password,
+ timeout
+ );
+ if( ! Printerlib::ExecuteBashCommand( test_command) )
+ { Popup::ErrorDetails( sformat( // Message of a Popup::ErrorDetails
+ // where %1 will be replaced by the queue name
+ // and %2 will be replaced by the host name:
+ _("Access test failed for queue '%1' on host '%2'."),
+ queue,
+ host
+ ),
+ Printerlib::result["stderr"]:"" + "\n" + Printerlib::result["stdout"]:""
+ );
+ return false;
}
- break;
+ break;
}
- return test;
+ Popup::Message( _("Test OK") );
+ return true;
}
boolean storeQueue( symbol selected )
Modified: trunk/printer/tools/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/tools/Makefile.am?rev=53700&r1=53699&r2=53700&view=diff
==============================================================================
--- trunk/printer/tools/Makefile.am (original)
+++ trunk/printer/tools/Makefile.am Fri Nov 28 12:58:52 2008
@@ -6,6 +6,12 @@
autodetect_print_queues \
determine_printer_driver_options \
modify_cupsd_conf \
- cups_client_only
+ cups_client_only \
+ test_device \
+ test_remote_ipp \
+ test_remote_lpd \
+ test_remote_novell \
+ test_remote_smb \
+ test_remote_socket
EXTRA_DIST = $(ybin_SCRIPTS)
Added: trunk/printer/tools/test_device
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/tools/test_device?rev=53700&view=auto
==============================================================================
--- trunk/printer/tools/test_device (added)
+++ trunk/printer/tools/test_device Fri Nov 28 12:58:52 2008
@@ -0,0 +1,29 @@
+#! /bin/bash
+# test_device sends a short message ($1) to device ($2).
+# Timeout is set to $3 sec.
+# Exits: 0 doesn't seem to have a problem
+# 1 operation has timed out
+# 2 problems while writing to $2
+#
+# Jan Holesovsky , 2000
+# Johannes Meixner , 2008
+# $Id: test_device 2928 2002-06-27 08:53:17Z jsrain $
+
+#set -x
+
+export PATH="/sbin:/usr/sbin:/usr/bin:/bin"
+export LC_ALL="POSIX"
+export LANG="POSIX"
+umask 022
+
+EXITCODE=2
+trap "EXITCODE=0" 10
+
+[ "$2" != "/dev/null" ] && fuser -k $2 # kill all processes using the device
+
+( sleep $3 ) &
+SL=$!
+( echo -en "$1" > $2 && kill -10 $$ ; kill $SL ) &
+PR=$!
+wait $SL && kill $PR && exit 1 # It cannot finish, it has timed out
+exit $EXITCODE # How the prining finished?
Added: trunk/printer/tools/test_remote_ipp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/tools/test_remote_ipp?rev=53700&view=auto
==============================================================================
--- trunk/printer/tools/test_remote_ipp (added)
+++ trunk/printer/tools/test_remote_ipp Fri Nov 28 12:58:52 2008
@@ -0,0 +1,55 @@
+#! /bin/bash
+#
+# Test ability to connect to remote IPP server.
+#
+# Exits: 0 doesn't seem to have a problem
+# 1 remote host $1 or queue $2 not set
+# 2 the remote host $1 is unreachable
+# 3 no connection possible to port 631 on host $1 (no cups server running ?)
+# 4 queue does not accept a print job (queue does not exist or queueing disabled ?)
+# 10 ping not executable (no iputils RPM installed?)
+# 11 netcat not executable (no netcat RPM installed?)
+# (12=fuser,13=mktemp,14=sed: see listen_remote_ipp)
+# 15 lp not executable (no cups-client RPM installed?)
+# The program head is in the coreutils RPM and therefore assumed to exist.
+#
+# Johannes Meixner , 2000, 2002, 2007, 2008
+# Jan Holesovsky , 2000
+# Jiri Srain , 2002
+# $Id: test_remote_ipp 43943 2008-01-28 13:38:58Z mzugec $
+
+#set -x
+
+# Make sure to have a clean environment:
+export PATH="/sbin:/usr/sbin:/usr/bin:/bin"
+export LC_ALL="POSIX"
+export LANG="POSIX"
+umask 022
+
+# Use the binaries of the operating system (no aliases, functions, /usr/local/):
+export PING=$( type -ap ping | head -n 1 )
+[ -z "$PING" ] && { echo -en "\nping not executable\n" 1>&2 ; exit 10 ; }
+export NETCAT=$( type -ap netcat | head -n 1 )
+[ -z "$NETCAT" ] && { echo -en "\nnetcat not executable\n" 1>&2 ; exit 11 ; }
+export LP=$( type -ap lp | head -n 1 )
+[ -z "$LP" ] && { echo -en "\nlp not executable\n" 1>&2 ; exit 15 ; }
+
+MY_NAME=${0##*/}
+HOST="$1"
+QUEUE="$2"
+[ -z "$HOST" -o -z "$QUEUE" ] && { echo -en "\nUsage:\n$MY_NAME HOST QUEUE [TIMEOUT]\n" 1>&2 ; exit 1 ; }
+TIMEOUT="$3"
+[ -z "$TIMEOUT" ] && TIMEOUT=10
+
+# test whether the remote host is accessible
+$PING -c 1 -w $TIMEOUT $HOST || { echo -en "\nHost $HOST unreachable\n" ; exit 2 ; }
+
+# test whether connection is possible to port 631 (ipp) on the remote host
+$NETCAT -w $TIMEOUT -z $HOST 631 || { echo -en "\nNo connection possible to port 631 (IPP) on host $HOST\n" ; exit 3 ; }
+
+# test whether the queue on the server accepts print jobs
+echo -en "\r" | $LP -d $QUEUE -h $HOST 2>&1
+[ "$?" = "0" ] && { echo -en "\nQueue $QUEUE on host $HOST accepts print jobs\n" ; exit 0 ; }
+echo -en "\nQueue $QUEUE on host $HOST does not accept print jobs\n"
+exit 4
+
Added: trunk/printer/tools/test_remote_lpd
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/tools/test_remote_lpd?rev=53700&view=auto
==============================================================================
--- trunk/printer/tools/test_remote_lpd (added)
+++ trunk/printer/tools/test_remote_lpd Fri Nov 28 12:58:52 2008
@@ -0,0 +1,98 @@
+#! /bin/bash
+#
+# Send RFC1179 commands to the port 515 (lpd) on remote host $1 regarding queue $2
+# and test whether queue $2 on remote host $1 would accept print jobs.
+# Remote host $1 and queue $2 are required parameters.
+# If no timeout $3 is given it is set to 10 seconds.
+#
+# Exits: 0 doesn't seem to have a problem
+# 1 remote host $1 or queue $2 not set
+# 2 the remote host $1 is unreachable
+# 3 no connection possible to port 515 on host $1 (no lpd running ?)
+# 4 queue does not accept a print job (queue does not exist or queueing disabled ?)
+# 10 ping not executable (no iputils RPM installed?)
+# 11 netcat not executable (no netcat RPM installed?)
+# 12 fuser not executable (no psmisc RPM installed?)
+# 13 mktemp not executable (no mktemp RPM installed?)
+# The programs head, mkfifo, sleep, tr, rm are in the coreutils RPM and therefore assumed to exist.
+#
+# Johannes Meixner , 2000, 2002, 2007, 2008
+# Jan Holesovsky , 2000
+# Jiri Srain , 2002
+# $Id: test_remote_lpd 43943 2008-01-28 13:38:58Z mzugec $
+
+#set -x
+
+# Make sure to have a clean environment:
+export PATH="/sbin:/usr/sbin:/usr/bin:/bin"
+export LC_ALL="POSIX"
+export LANG="POSIX"
+umask 022
+
+# Use the binaries of the operating system (no aliases, functions, /usr/local/):
+export PING=$( type -ap ping | head -n 1 )
+[ -z "$PING" ] && { echo -en "\nping not executable\n" 1>&2 ; exit 10 ; }
+export NETCAT=$( type -ap netcat | head -n 1 )
+[ -z "$NETCAT" ] && { echo -en "\nnetcat not executable\n" 1>&2 ; exit 11 ; }
+export FUSER=$( type -ap fuser | head -n 1 )
+[ -z "$FUSER" ] && { echo -en "\nfuser not executable\n" 1>&2 ; exit 12 ; }
+export MKTEMP=$( type -ap mktemp | head -n 1 )
+[ -z "$MKTEMP" ] && { echo -en "\nmktemp not executable\n" 1>&2 ; exit 13 ; }
+
+MY_NAME=${0##*/}
+HOST="$1"
+QUEUE="$2"
+[ -z "$HOST" -o -z "$QUEUE" ] && { echo -en "\nUsage:\n$MY_NAME HOST QUEUE [TIMEOUT]\n" 1>&2 ; exit 1 ; }
+TIMEOUT="$3"
+[ -z "$TIMEOUT" ] && TIMEOUT=10
+
+# test whether the remote host is accessible
+$PING -c 1 -w $TIMEOUT $HOST || { echo -en "\nHost $HOST unreachable\n" ; exit 2 ; }
+
+# test whether connection is possible to port 515 (lpd) on the remote host
+$NETCAT -w $TIMEOUT -z $HOST 515 || { echo -en "\nNo connection possible to port 515 (lpd)\n" ; exit 3 ; }
+
+# Find an available local port for connecting
+PORT=$(for I in 721 722 723 724 725 726 727 728 729 730 731
+ do
+ $FUSER -n tcp $I &>/dev/null || { echo $I ; break ; }
+ done)
+
+# Create temporary fifos
+TMP_IN=$( $MKTEMP -u /tmp/$MY_NAME.in.XXXXXX )
+TMP_OUT=$( $MKTEMP -u /tmp/$MY_NAME.out.XXXXXX)
+mkfifo $TMP_IN
+mkfifo $TMP_OUT
+
+# Test the queue:
+# Use source port $PORT and destination port 515 (LPD)
+# "\002$QUEUE\n" is a request to receive a new job for $QUEUE
+# The remote lpd sends '\000' if it accepts the request. Then we must
+# send "\001\n" back which is a request to cancel the new job.
+# After $TIMEOUT netcat would close the connection provided stdin of netcat
+# was closed too which would happen if there is any response from the remote port.
+# But as there may be no response from the remote port we have additionally
+# a time bomb which would kill the netcat process after $TIMEOUT.
+
+$NETCAT -w $TIMEOUT -p $PORT $HOST 515 <$TMP_IN >$TMP_OUT 2>/dev/null &
+NETCAT_PID=$!
+{ sleep ${TIMEOUT}s ; kill $NETCAT_PID &>/dev/null ; } &
+
+RESULT=""
+{ echo -en "\002$QUEUE\n" ; \
+ RESULT=$( head --bytes=1 <$TMP_OUT | tr '\000' '0' ) ; \
+ [ "$RESULT" = "0" ] && echo -en "\001\n" ; } >$TMP_IN
+
+rm $TMP_IN
+rm $TMP_OUT
+
+[ "$RESULT" = "0" ] && { echo -en "\nQueue $QUEUE on host $HOST accepts print jobs\n" ; exit 0 ; }
+
+echo -en "\nQueue $QUEUE on host $HOST does not accept print jobs\n"
+
+# If $QUEUE does not accept jobs, print $QUEUE status in long format.
+# "\004$QUEUE\n" is a request to receive $QUEUE status (very long output in case of LPRng).
+echo -en "\nStatus of the queue $QUEUE\n"
+echo -en "\004$QUEUE\n" | $NETCAT -w $TIMEOUT -p $PORT $HOST 515
+exit 4
+
Added: trunk/printer/tools/test_remote_novell
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/tools/test_remote_novell?rev=53700&view=auto
==============================================================================
--- trunk/printer/tools/test_remote_novell (added)
+++ trunk/printer/tools/test_remote_novell Fri Nov 28 12:58:52 2008
@@ -0,0 +1,43 @@
+#! /bin/bash
+#
+# Test ability to connect to remote IPX Novell server.
+#
+# Exits: 0 doesn't seem to have a problem
+# 1 remote host $1 or queue $2 not set
+# 4 queue does not accept a print job (queue does not exist or queueing disabled ?)
+# (10=ping,11=netcat,12=fuser,13=mktemp,14=sed,15=lp,16=smbclient: see test_remote_smb)
+# 17 nprint not executable (no ncpfs RPM installed?)
+#
+# Johannes Meixner , 2000, 2002, 2007, 2008
+# Jan Holesovsky , 2000
+# Jiri Srain , 2002
+# $Id: test_remote_novell 43943 2008-01-28 13:38:58Z mzugec $
+
+#set -x
+
+# Make sure to have a clean environment:
+export PATH="/sbin:/usr/sbin:/usr/bin:/bin"
+export LC_ALL="POSIX"
+export LANG="POSIX"
+umask 022
+
+# Use the binaries of the operating system (no aliases, functions, /usr/local/):
+export NPRINT=$( type -ap nprint | head -n 1 )
+[ -z "$NPRINT" ] && { echo -en "\nnprint not executable\n" 1>&2 ; exit 17 ; }
+
+MY_NAME=${0##*/}
+HOST=$1
+QUEUE=$2
+[ -z "$HOST" -o -z "$QUEUE" ] && { echo -en "\nUsage:\n$MY_NAME HOST QUEUE [TIMEOUT]\n" 1>&2 ; exit 1 ; }
+USER=$3
+PASSWORD=$4
+TIMEOUT="$5"
+
+[ -z "$TIMEOUT" ] && TIMEOUT=10
+
+# test whether the queue on the server accepts print jobs
+echo -en "\r" | $NPRINT -S "$HOST" -U "$USER" -P "$PASSWORD" -q "$QUEUE" - 2>&1
+[ "$?" = "0" ] && { echo -en "\nQueue $QUEUE on host $HOST accepts print jobs\n" ; exit 0 ; }
+echo -en "\nQueue $QUEUE on host $HOST does not accept print jobs\n"
+exit 4
+
Added: trunk/printer/tools/test_remote_smb
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/tools/test_remote_smb?rev=53700&view=auto
==============================================================================
--- trunk/printer/tools/test_remote_smb (added)
+++ trunk/printer/tools/test_remote_smb Fri Nov 28 12:58:52 2008
@@ -0,0 +1,54 @@
+#! /bin/bash
+#
+# Test ability to connect to remote SMB server.
+#
+# Exits: 0 doesn't seem to have a problem
+# 1 remote host $1 or queue $2 not set
+# 2 the remote host $1 is unreachable
+# 4 queue does not accept a print job (queue does not exist or queueing disabled ?)
+# 10 ping not executable (no iputils RPM installed?)
+# (11=netcat,12=fuser,13=mktemp,14=sed,15=lp: see test_remote_ipp)
+# 16 smbclient not executable (no samba-client RPM installed?)
+# The programs head, mkfifo, sleep, tr, rm are in the coreutils RPM and therefore assumed to exist.
+#
+# Johannes Meixner , 2000, 2002, 2007, 2008
+# Jan Holesovsky , 2000
+# Jiri Srain , 2002
+# $Id: test_remote_smb 43943 2008-01-28 13:38:58Z mzugec $
+
+#set -x
+
+# Make sure to have a clean environment:
+export PATH="/sbin:/usr/sbin:/usr/bin:/bin"
+export LC_ALL="POSIX"
+export LANG="POSIX"
+umask 022
+
+# Use the binaries of the operating system (no aliases, functions, /usr/local/):
+export PING=$( type -ap ping | head -n 1 )
+[ -z "$PING" ] && { echo -en "\nping not executable\n" 1>&2 ; exit 10 ; }
+export SMBCLIENT=$( type -ap smbclient | head -n 1 )
+[ -z "$SMBCLIENT" ] && { echo -en "\nsmbclient not executable\n" 1>&2 ; exit 16 ; }
+
+MY_NAME=${0##*/}
+WORKGROUP=$1
+HOST=$2
+QUEUE=$3
+[ -z "$HOST" -o -z "$QUEUE" ] && { echo -en "\nUsage:\n$MY_NAME WORKGROUP HOST QUEUE [USER] [PASS] [TIMEOUT]\n" 1>&2 ; exit 1 ; }
+USER=$4
+PASSWORD=$5
+TIMEOUT="$6"
+
+[ -z "$TIMEOUT" ] && TIMEOUT=10
+
+# test whether the remote host is accessible
+$PING -c 1 -w $TIMEOUT $HOST || { echo -en "\nHost $HOST unreachable\n" ; exit 2 ; }
+
+# test whether the queue on the server accepts print jobs
+echo -e "\nTesting $QUEUE on $WORKGROUP/$HOST:"
+test -z $PASSWORD && PASSWORD="-N"
+echo -en "\r" | $SMBCLIENT "//$HOST/$QUEUE" "$PASSWORD" -c "print -" -U "$USER" -W "$WORKGROUP"
+[ "$?" = "0" ] && { echo -en "\nShare $QUEUE on $WORKGROUP/$HOST accepts print jobs\n" ; exit 0 ; }
+echo -en "\nShare $QUEUE on $WORKGROUP/$HOST does not accept print jobs\n"
+exit 4
+
Added: trunk/printer/tools/test_remote_socket
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/tools/test_remote_socket?rev=53700&view=auto
==============================================================================
--- trunk/printer/tools/test_remote_socket (added)
+++ trunk/printer/tools/test_remote_socket Fri Nov 28 12:58:52 2008
@@ -0,0 +1,51 @@
+#! /bin/bash
+#
+# Test ability to connect to remote direct socket (JetDirect) server.
+#
+# Exits: 0 doesn't seem to have a problem
+# 1 remote host $1 not set
+# 2 the remote host $1 is unreachable
+# 3 no connection possible to port 9100 or port $2 on host $1
+# 4 port 9100 or port $2 on host $1 does not accept data
+# 10 ping not executable (no iputils RPM installed?)
+# 11 netcat not executable (no netcat RPM installed?)
+# The program head is in the coreutils RPM and therefore assumed to exist.
+#
+# Johannes Meixner 2002, 2007, 2008
+# Jiri Srain , 2002
+# $Id: test_remote_socket 43943 2008-01-28 13:38:58Z mzugec $
+
+#set -x
+
+# Make sure to have a clean environment:
+export PATH="/sbin:/usr/sbin:/usr/bin:/bin"
+export LC_ALL="POSIX"
+export LANG="POSIX"
+umask 022
+
+# Use the binaries of the operating system (no aliases, functions, /usr/local/):
+export PING=$( type -ap ping | head -n 1 )
+[ -z "$PING" ] && { echo -en "\nping not executable\n" 1>&2 ; exit 10 ; }
+export NETCAT=$( type -ap netcat | head -n 1 )
+[ -z "$NETCAT" ] && { echo -en "\nnetcat not executable\n" 1>&2 ; exit 11 ; }
+
+MY_NAME=${0##*/}
+HOST="$1"
+[ -z "$HOST" ] && { echo -en "\nUsage:\n$MY_NAME HOST [PORT [TIMEOUT]]\n" 1>&2 ; exit 1 ; }
+PORT="$2"
+[ -z "$PORT" ] && PORT=9100
+TIMEOUT="$3"
+[ -z "$TIMEOUT" ] && TIMEOUT=10
+
+# test whether the remote host is accessible
+$PING -c 1 -w $TIMEOUT $HOST || { echo -en "\nHost $HOST unreachable\n" ; exit 2 ; }
+
+# test whether connection is possible to $PORT on the remote host
+$NETCAT -w $TIMEOUT -z $HOST $PORT || { echo -en "\nNo connection possible to port $PORT\n" ; exit 3 ; }
+
+# test whether $PORT on the remote host accepts data
+echo -en "\r" | $NETCAT -w $TIMEOUT $HOST $PORT 2>&1
+[ "$?" = "0" ] && { echo -en "\nPort $PORT on host $HOST accepts data\n" ; exit 0 ; }
+echo -en "\nPort $PORT on host $HOST does not accept data\n"
+exit 4
+
Modified: trunk/printer/yast2-printer.spec.in
URL: http://svn.opensuse.org/viewcvs/yast/trunk/printer/yast2-printer.spec.in?rev=53700&r1=53699&r2=53700&view=diff
==============================================================================
--- trunk/printer/yast2-printer.spec.in (original)
+++ trunk/printer/yast2-printer.spec.in Fri Nov 28 12:58:52 2008
@@ -57,6 +57,12 @@
@ybindir@/determine_printer_driver_options
@ybindir@/cups_client_only
@ybindir@/modify_cupsd_conf
+@ybindir@/test_device
+@ybindir@/test_remote_ipp
+@ybindir@/test_remote_lpd
+@ybindir@/test_remote_novell
+@ybindir@/test_remote_smb
+@ybindir@/test_remote_socket
#Documentation
%dir @docdir@
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org