smbclient, SMBwrite vs SMBwriteX
Chris Dunlop
chris at onthe.net.au
Tue Oct 28 09:32:27 GMT 2003
G'day,
I've been having trouble with a Konica copier/printer returning
an error when trying to print, e.g.:
$ smbclient //konica/print ' ' -c 'print -' < /tmp/tmp.ps
Error writing file: ERRSRV - 22
Examining the network traffic revealed that the printer returns
the error when smbclient issues an SMBwriteX, and that the
MS-Windows printer driver (which works of course) was using
SMBwrite rather than SMBwriteX.
The patch below implements a '-w' flag for smbclient which makes
it use SMBwrite rather than SMBwriteX. (The line numbering may
be a bit off as I'm using the source from debian's
samba-3.0.0final-1.)
With this patch I'm able to print to the Konica.
There looks there may be a smattering of these types of problems
with other printers as well:
http://www.google.com/search?q=smbclient+%22ERRSRV+22%22
Possibly these are all using the same buggy (or simply old?)
underlying SMB implementation in their firmware.
Cheers,
Chris,
OnTheNet
diff -ru samba-3.0.0final-orig/docs/docbook/manpages/smbclient.1.xml samba-3.0.0final/docs/docbook/manpages/smbclient.1.xml
--- samba-3.0.0final-orig/docs/docbook/manpages/smbclient.1.xml Sat Aug 16 06:39:28 2003
+++ samba-3.0.0final/docs/docbook/manpages/smbclient.1.xml Tue Oct 28 20:17:18 2003
@@ -23,6 +23,7 @@
<arg choice="req">servicename</arg>
<arg choice="opt">password</arg>
<arg choice="opt">-b <buffer size></arg>
+ <arg choice="opt">-w</arg>
<arg choice="opt">-d debuglevel</arg>
<arg choice="opt">-D Directory</arg>
<arg choice="opt">-U username</arg>
@@ -288,6 +289,19 @@
is 65520 bytes. Setting this value smaller (to 1200 bytes) has been
observed to speed up file transfers to and from a Win9x server.
</para></listitem>
+ </varlistentry>
+
+
+ <varlistentry>
+ <term>-w</term>
+ <listitem><para>This option makes <command>smbclient</command> use
+ the low-level "SMBwrite" command rather than the "SMBwriteX"
+ command. This is useful for talking to broken servers that don't
+ understand the "SMBwriteX" command. In particular this
+ may be useful with some printers that return an error
+ like: </para>
+
+ <para>Error writing file: ERRSRV - 22 </para>
</varlistentry>
&popt.common.samba;
diff -ru samba-3.0.0final-orig/source/client/client.c samba-3.0.0final/source/client/client.c
--- samba-3.0.0final-orig/source/client/client.c Tue Sep 9 02:04:35 2003
+++ samba-3.0.0final/source/client/client.c Tue Oct 28 19:52:45 2003
@@ -39,6 +39,7 @@
static pstring password;
static BOOL use_kerberos;
static BOOL got_pass;
+static BOOL use_SMBwrite;
static char *cmdstr = NULL;
static int io_bufsize = 64512;
@@ -1125,7 +1126,12 @@
break;
}
- ret = cli_write(cli, fnum, 0, buf, nread + start, n);
+ if (use_SMBwrite) {
+ ret = cli_smbwrite(cli, fnum, buf, nread + start, n);
+ }
+ else {
+ ret = cli_write(cli, fnum, 0, buf, nread + start, n);
+ }
if (n != ret) {
d_printf("Error writing file: %s\n", cli_errstr(cli));
@@ -2795,6 +2801,7 @@
{ "command", 'c', POPT_ARG_STRING, &cmdstr, 'c', "Execute semicolon separated commands" },
{ "send-buffer", 'b', POPT_ARG_INT, &io_bufsize, 'b', "Changes the transmit/send buffer", "BYTES" },
{ "port", 'p', POPT_ARG_INT, &port, 'p', "Port to connect to", "PORT" },
+ { "SMBwrite", 'w', POPT_ARG_NONE, NULL, 'w', "Use SMBwrite" },
POPT_COMMON_SAMBA
POPT_COMMON_CONNECTION
POPT_COMMON_CREDENTIALS
@@ -2886,6 +2893,9 @@
break;
case 'D':
fstrcpy(base_directory,poptGetOptArg(pc));
+ break;
+ case 'w':
+ use_SMBwrite = 1;
break;
}
}
More information about the samba-technical
mailing list