output overwrite problem with smbclient when i copy a large ( 4 GB ) file

2002-11-29 Thread gerzson
Hi,

I tried to copy more than 4 GB from an AIX host to a W2K NTFS share with
smbclient of Samba 2.2.4.

I tested it something like that:



$ dd if=/dev/zero bs=1024000 count=4200 | cat - f1 PIPE  

$ /smbclient //w2k_pc/t -U test%test -c put PIPE d.zer



Smbclient said everything ok on the client side, but the output file size
wasn't greater than 4GB on W2K side.

When I looked at the output file closer I noticed that smbclient overwrote
the beginning of the output file with the ending of the input file!

I think that is because of the nread variable overflowed in the do_put
function in the client.c.



I tried to modified type of the nread from int to off_t, but it also didn't
work. So I modified the do_put function to check overflowing of the nread:



static void do_put(char *rname,char *lname)

{

int fnum;

FILE *f;

unsigned int nread=0;/* int nread=0;
gerzson-20021128 */

char *buf=NULL;

int maxwrite=io_bufsize;



unsigned int MAX_FILE_SIZE=~0;   /* gerzson-20021128 */

BOOL toolarge = False; /* gerzson-20021128 */



int prev_nread=0;



struct timeval tp_start;

GetTimeOfDay(tp_start);





fnum = cli_open(cli, rname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE);



if (fnum == -1) {

DEBUG(0,(%s opening remote file
%s\n,cli_errstr(cli),rname));

return;

}



/* allow files to be piped into smbclient

   jdblair 24.jun.98 */

if (!strcmp(lname, -)) {

f = stdin;

/* size of file is not known */

} else {

f = sys_fopen(lname,r);

}



if (!f) {

DEBUG(0,(Error opening local file %s\n,lname));

return;

}





DEBUG(1,(putting file %s as %s ,lname,

 rname));



buf = (char *)malloc(maxwrite);

if (!buf) {

DEBUG(0, (ERROR: Not enough memory!\n));

return;

}

while (!feof(f)) {

int n = maxwrite;

int ret;



if ((n = readfile(buf,1,n,f))  1) {

if((n == 0)  feof(f))

break; /* Empty local file.
*/



DEBUG(0,(Error reading local file:
%s\n, strerror(errno) ));

break;

}



if ((toolarge = (nread  (MAX_FILE_SIZE-n+1
{/* gerzson-20021128 */

break;

}



ret = cli_write(cli, fnum, 0, buf, nread, n);



if (n != ret) {

DEBUG(0,(Error writing file: %s\n,
cli_errstr(cli)));

break;

}



nread += n;

}



if (!cli_close(cli, fnum)) {

DEBUG(0,(%s closing remote file
%s\n,cli_errstr(cli),rname));

fclose(f);

SAFE_FREE(buf);

return;

}





fclose(f);

SAFE_FREE(buf);



if (toolarge) {/* gerzson-20021128 */

if (f == stdin) {

cli_shutdown(cli);

}

DEBUG(0, (ERROR: Input file is too large (more than
%10u bytes)!\n,MAX_FILE_SIZE));

if (cmdstr) {

exit(1);

} else {

return;

}

}





{

struct timeval tp_end;

int this_time;



GetTimeOfDay(tp_end);

this_time =

(tp_end.tv_sec - tp_start.tv_sec)*1000 +

(tp_end.tv_usec -
tp_start.tv_usec)/1000;

put_total_time_ms += this_time;

put_total_size += nread;



DEBUG(1,((%3.1f kb/s) (average %3.1f kb/s)\n,

 nread / (1.024*this_time + 1.0e-4),

 put_total_size /
(1.024*put_total_time_ms)));

}



if (f == stdin) {

cli_shutdown(cli);

exit(0);

}

}



Gyrgyfalvay Mikls (gerzson)
[EMAIL PROTECTED]






DOMAIN GROUP CREATION description parameter, available to samba????

2002-11-29 Thread Ray Raszka
When a user running USER MANAGER on an NT workstation performs the add new
global group function, the dialog box presented includes a description
control. Is it possible to pick up this parameter on a Samba 3.0 PDC and
pass it to  the add group script function of the SMB.CONF file? If so what
would the substitution variable be?

Ray Raszka
Partners Healthcare
70 Jackson Drive
Cranford, New Jersey
(908) 931-9111 Ext. 2716




[PATCH] Fix Samba HEAD to observe executable extensions

2002-11-29 Thread Paul_GreenVOS
The following patch changes the HEAD version of Samba to
discover and use a required executable extension, if required by
the host OS.  It also changes torture/torture.c to use
shm_open() if shmget() is unavailable.  And it changes the only
reference to bcmp in Samba to a nice standard memcmp.

(I also have a patch for Samba 3.0; see separate letter).

I created it because Stratus VOS has a required executable
extension, and because we have POSIX not System V shared memory.

I have tested this patch here on VOS.  I used the version of
head that existed this morning (changing and testing these files
is a little like jumping on and off a moving train; they change
frequently...).  I tested the 3.0 version of the patch on SunOS
5.8, and these are basically the same changes, so I'm hoping I
won't break head too badly...  ;-).

I've tested it using autoconf 2.13.  The generated configure
script should work properly on Unix-type systems regardless of
which version of autoconf is used.

I still have a problem in that the Makefile tries to build
libsmbclient.so even on systems that don't support shared
objects, but I'll send that change in separately, when I have it
ready.

### START OF PATCH ###

diff -urp old/samba/source/Makefile.in new/samba/source/Makefile.in
--- old/samba/source/Makefile.inFri Nov 29 21:35:28 2002
+++ new/samba/source/Makefile.inFri Nov 29 21:35:55 2002
@@ -14,6 +14,7 @@ CC=@CC@
 SHLD=@SHLD@
 CFLAGS=@CFLAGS@
 CPPFLAGS=@CPPFLAGS@
+EXEEXT=@EXEEXT@
 LDFLAGS=@LDFLAGS@
 LDSHFLAGS=@LDSHFLAGS@ @LDFLAGS@ @CFLAGS@
 AWK=@AWK@
@@ -100,14 +101,21 @@ PATH_FLAGS5 = $(PATH_FLAGS4) -DLIBDIR=\
 PATH_FLAGS6 = $(PATH_FLAGS5) -DCONFIGDIR=\$(CONFIGFIR)\
 PATH_FLAGS = $(PATH_FLAGS6) $(PASSWD_FLAGS)
 
-SBIN_PROGS = bin/smbd bin/nmbd bin/swat bin/wrepld @EXTRA_SBIN_PROGS@
+# Note that all executable programs now provide for an optional executable suffix.
 
-BIN_PROGS1 = bin/smbclient bin/net bin/smbspool bin/testparm bin/testprns 
bin/smbstatus 
-BIN_PROGS2 = bin/smbcontrol bin/smbtree bin/tdbbackup bin/nmblookup bin/pdbedit
-BIN_PROGS3 = bin/smbpasswd bin/rpcclient bin/smbcacls bin/profiles bin/smbgroupedit 
bin/ntlm_auth
+SBIN_PROGS = bin/smbd@EXEEXT@ bin/nmbd@EXEEXT@ bin/swat@EXEEXT@ \
+   bin/wrepld@EXEEXT@ @EXTRA_SBIN_PROGS@
 
-TORTURE_PROGS = bin/smbtorture bin/msgtest bin/masktest bin/locktest \
-   bin/locktest2 bin/nsstest bin/vfstest
+BIN_PROGS1 = bin/smbclient@EXEEXT@ bin/net@EXEEXT@ bin/smbspool@EXEEXT@ \
+   bin/testparm@EXEEXT@ bin/testprns@EXEEXT@ bin/smbstatus@EXEEXT@ 
+BIN_PROGS2 = bin/smbcontrol@EXEEXT@ bin/smbtree@EXEEXT@ bin/tdbbackup@EXEEXT@ \
+   bin/nmblookup@EXEEXT@ bin/pdbedit@EXEEXT@
+BIN_PROGS3 = bin/smbpasswd@EXEEXT@ bin/rpcclient@EXEEXT@ bin/smbcacls@EXEEXT@ \
+   bin/profiles@EXEEXT@ bin/smbgroupedit@EXEEXT@ bin/ntlm_auth@EXEEXT@
+
+TORTURE_PROGS = bin/smbtorture@EXEEXT@ bin/msgtest@EXEEXT@ \
+   bin/masktest@EXEEXT@ bin/locktest@EXEEXT@ \
+   bin/locktest2@EXEEXT@ bin/nsstest@EXEEXT@ bin/vfstest@EXEEXT@
 
 BIN_PROGS = $(BIN_PROGS1) $(BIN_PROGS2) $(BIN_PROGS3) @EXTRA_BIN_PROGS@
 
@@ -556,27 +564,27 @@ smbwrapper : SHOWFLAGS @SMBWRAPPER@
 
 torture : SHOWFLAGS $(TORTURE_PROGS)
 
-smbtorture : SHOWFLAGS bin/smbtorture
+smbtorture : SHOWFLAGS bin/smbtorture@EXEEXT@
 
-masktest : SHOWFLAGS bin/masktest
+masktest : SHOWFLAGS bin/masktest@EXEEXT@
 
-msgtest : SHOWFLAGS bin/msgtest
+msgtest : SHOWFLAGS bin/msgtest@EXEEXT@
 
-locktest : SHOWFLAGS bin/locktest
+locktest : SHOWFLAGS bin/locktest@EXEEXT@
 
-smbcacls : SHOWFLAGS bin/smbcacls
+smbcacls : SHOWFLAGS bin/smbcacls@EXEEXT@
 
-locktest2 : SHOWFLAGS bin/locktest2
+locktest2 : SHOWFLAGS bin/locktest2@EXEEXT@
 
-rpctorture : SHOWFLAGS bin/rpctorture
+rpctorture : SHOWFLAGS bin/rpctorture@EXEEXT@
 
-debug2html : SHOWFLAGS bin/debug2html
+debug2html : SHOWFLAGS bin/debug2html@EXEEXT@
 
-smbfilter : SHOWFLAGS bin/smbfilter
+smbfilter : SHOWFLAGS bin/smbfilter@EXEEXT@
 
-talloctort : SHOWFLAGS bin/talloctort
+talloctort : SHOWFLAGS bin/talloctort@EXEEXT@
 
-nsswitch : SHOWFLAGS bin/winbindd bin/wbinfo nsswitch/libnss_winbind.so 
nsswitch/pam_winbind.so
+nsswitch : SHOWFLAGS bin/winbindd@EXEEXT@ bin/wbinfo@EXEEXT@ 
+nsswitch/libnss_winbind.so nsswitch/pam_winbind.so
 
 wins : SHOWFLAGS nsswitch/libnss_wins.@SHLIBEXT@
 
@@ -651,149 +659,149 @@ bin/.dummy:
  dir=bin $(MAKEDIR); fi
@:  $@ || :  $@ # what a fancy emoticon!
 
-bin/smbd: $(SMBD_OBJ) @BUILD_POPT@ bin/.dummy
+bin/smbd@EXEEXT@: $(SMBD_OBJ) @BUILD_POPT@ bin/.dummy
@echo Linking $@
@$(CC) $(FLAGS) -o $@ $(SMBD_OBJ) $(LDFLAGS) $(DYNEXP) $(PRINTLIBS) \
  $(AUTHLIBS) $(LIBS) @BUILD_POPT@
 
-bin/nmbd: $(NMBD_OBJ) @BUILD_POPT@ bin/.dummy
+bin/nmbd@EXEEXT@: $(NMBD_OBJ) @BUILD_POPT@ bin/.dummy
@echo Linking $@
@$(CC) $(FLAGS) -o $@ $(NMBD_OBJ) $(LDFLAGS) $(LIBS) @BUILD_POPT@
 
-bin/wrepld: $(WREPL_OBJ) bin/.dummy
+bin/wrepld@EXEEXT@: $(WREPL_OBJ) bin/.dummy
@echo Linking $@
@$(CC) 

[PATCH] Fix 3.0 to observe executable extensions

2002-11-29 Thread Paul_GreenVOS
The following patch changes the 3.0 version of Samba to discover
and use a required executable extension, if required by the host
OS.  It also changes torture/torture.c to use shm_open() if
shmget() is unavailable.

This is basically the same change that I just submitted to head.

I tested it on Stratus VOS and SunOS 5.8 using autoconf 2.13,
and samba-3.0alpha21.  It picked up the VOS suffix and did not
pick any suffix for Solaris.

The patch is up-to-date with the 3.0 branch as of today.

### START OF PATCH ###

diff -urp old/samba_3_0/source/Makefile.in new/samba_3_0/source/Makefile.in
--- old/samba_3_0/source/Makefile.inFri Nov 29 22:11:17 2002
+++ new/samba_3_0/source/Makefile.inFri Nov 29 22:11:52 2002
@@ -14,6 +14,7 @@ CC=@CC@
 SHLD=@SHLD@
 CFLAGS=@CFLAGS@
 CPPFLAGS=@CPPFLAGS@
+EXEEXT=@EXEEXT@
 LDFLAGS=@LDFLAGS@
 LDSHFLAGS=@LDSHFLAGS@ @LDFLAGS@ @CFLAGS@
 AWK=@AWK@
@@ -100,14 +101,21 @@ PATH_FLAGS5 = $(PATH_FLAGS4) -DLIBDIR=\
 PATH_FLAGS6 = $(PATH_FLAGS5) -DCONFIGDIR=\$(CONFIGFIR)\
 PATH_FLAGS = $(PATH_FLAGS6) $(PASSWD_FLAGS)
 
-SBIN_PROGS = bin/smbd bin/nmbd bin/swat bin/wrepld @EXTRA_SBIN_PROGS@
+# Note that all executable programs now provide for an optional executable suffix.
 
-BIN_PROGS1 = bin/smbclient bin/net bin/smbspool bin/testparm bin/testprns 
bin/smbstatus 
-BIN_PROGS2 = bin/smbcontrol bin/smbtree bin/tdbbackup bin/nmblookup bin/pdbedit
-BIN_PROGS3 = bin/smbpasswd bin/rpcclient bin/smbcacls bin/smbgroupedit
+SBIN_PROGS = bin/smbd@EXEEXT@ bin/nmbd@EXEEXT@ bin/swat@EXEEXT@ \
+   bin/wrepld@EXEEXT@ @EXTRA_SBIN_PROGS@
 
-TORTURE_PROGS = bin/smbtorture bin/msgtest bin/masktest bin/locktest \
-   bin/locktest2 bin/nsstest bin/vfstest
+BIN_PROGS1 = bin/smbclient@EXEEXT@ bin/net@EXEEXT@ bin/smbspool@EXEEXT@ \
+   bin/testparm@EXEEXT@ bin/testprns@EXEEXT@ bin/smbstatus@EXEEXT@
+BIN_PROGS2 = bin/smbcontrol@EXEEXT@ bin/smbtree@EXEEXT@ bin/tdbbackup@EXEEXT@ \
+   bin/nmblookup@EXEEXT@ bin/pdbedit@EXEEXT@
+BIN_PROGS3 = bin/smbpasswd@EXEEXT@ bin/rpcclient@EXEEXT@ bin/smbcacls@EXEEXT@ \
+   bin/smbgroupedit@EXEEXT@
+
+TORTURE_PROGS = bin/smbtorture@EXEEXT@ bin/msgtest@EXEEXT@ \
+   bin/masktest@EXEEXT@ bin/locktest@EXEEXT@ \
+   bin/locktest2@EXEEXT@ bin/nsstest@EXEEXT@ bin/vfstest@EXEEXT@
 
 BIN_PROGS = $(BIN_PROGS1) $(BIN_PROGS2) $(BIN_PROGS3) @EXTRA_BIN_PROGS@
 
@@ -544,27 +552,27 @@ smbwrapper : SHOWFLAGS @SMBWRAPPER@
 
 torture : SHOWFLAGS $(TORTURE_PROGS)
 
-smbtorture : SHOWFLAGS bin/smbtorture
+smbtorture : SHOWFLAGS bin/smbtorture@EXEEXT@
 
-masktest : SHOWFLAGS bin/masktest
+masktest : SHOWFLAGS bin/masktest@EXEEXT@
 
-msgtest : SHOWFLAGS bin/msgtest
+msgtest : SHOWFLAGS bin/msgtest@EXEEXT@
 
-locktest : SHOWFLAGS bin/locktest
+locktest : SHOWFLAGS bin/locktest@EXEEXT@
 
-smbcacls : SHOWFLAGS bin/smbcacls
+smbcacls : SHOWFLAGS bin/smbcacls@EXEEXT@
 
-locktest2 : SHOWFLAGS bin/locktest2
+locktest2 : SHOWFLAGS bin/locktest2@EXEEXT@
 
-rpctorture : SHOWFLAGS bin/rpctorture
+rpctorture : SHOWFLAGS bin/rpctorture@EXEEXT@
 
-debug2html : SHOWFLAGS bin/debug2html
+debug2html : SHOWFLAGS bin/debug2html@EXEEXT@
 
-smbfilter : SHOWFLAGS bin/smbfilter
+smbfilter : SHOWFLAGS bin/smbfilter@EXEEXT@
 
-talloctort : SHOWFLAGS bin/talloctort
+talloctort : SHOWFLAGS bin/talloctort@EXEEXT@
 
-nsswitch : SHOWFLAGS bin/winbindd bin/wbinfo nsswitch/libnss_winbind.so 
nsswitch/pam_winbind.so
+nsswitch : SHOWFLAGS bin/winbindd@EXEEXT@ bin/wbinfo@EXEEXT@ 
+nsswitch/libnss_winbind.so nsswitch/pam_winbind.so
 
 wins : SHOWFLAGS nsswitch/libnss_wins.@SHLIBEXT@
 
@@ -639,141 +647,141 @@ bin/.dummy:
  dir=bin $(MAKEDIR); fi
@:  $@ || :  $@ # what a fancy emoticon!
 
-bin/smbd: $(SMBD_OBJ) @BUILD_POPT@ bin/.dummy
+bin/smbd@EXEEXT@: $(SMBD_OBJ) @BUILD_POPT@ bin/.dummy
@echo Linking $@
@$(CC) $(FLAGS) -o $@ $(SMBD_OBJ) $(LDFLAGS) $(DYNEXP) $(PRINTLIBS) \
  $(AUTHLIBS) $(LIBS) @BUILD_POPT@
 
-bin/nmbd: $(NMBD_OBJ) @BUILD_POPT@ bin/.dummy
+bin/nmbd@EXEEXT@: $(NMBD_OBJ) @BUILD_POPT@ bin/.dummy
@echo Linking $@
@$(CC) $(FLAGS) -o $@ $(NMBD_OBJ) $(LDFLAGS) $(LIBS) @BUILD_POPT@
 
-bin/wrepld: $(WREPL_OBJ) bin/.dummy
+bin/wrepld@EXEEXT@: $(WREPL_OBJ) bin/.dummy
@echo Linking $@
@$(CC) $(FLAGS) -o $@ $(WREPL_OBJ) $(LDFLAGS) $(LIBS) 
 
-bin/swat: $(SWAT_OBJ) bin/.dummy
+bin/swat@EXEEXT@: $(SWAT_OBJ) bin/.dummy
@echo Linking $@
@$(CC) $(FLAGS) -o $@ $(SWAT_OBJ) $(LDFLAGS) $(DYNEXP) $(PRINTLIBS) \
  $(AUTHLIBS) $(LIBS) 
 
-bin/rpcclient: $(RPCCLIENT_OBJ) @BUILD_POPT@ bin/.dummy
+bin/rpcclient@EXEEXT@: $(RPCCLIENT_OBJ) @BUILD_POPT@ bin/.dummy
@echo Linking $@
@$(CC) $(FLAGS) -o $@ $(RPCCLIENT_OBJ) $(LDFLAGS) $(DYNEXP) $(TERMLDFLAGS) 
$(TERMLIBS) $(LIBS) @BUILD_POPT@
 
-bin/smbclient: $(CLIENT_OBJ) @BUILD_POPT@ bin/.dummy
+bin/smbclient@EXEEXT@: $(CLIENT_OBJ) @BUILD_POPT@ bin/.dummy
@echo Linking $@
@$(CC) $(FLAGS) -o $@ $(CLIENT_OBJ) $(LDFLAGS) $(TERMLDFLAGS) $(TERMLIBS)