The Samba-Bugzilla – Attachment 11887 Details for
Bug 11767
removal of smbget -P option
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch for 4.4 with cherry-pick information
smbget_v4_4.patch (text/plain), 35.13 KB, created by
Christian Ambach
on 2016-03-01 20:40:52 UTC
(
hide
)
Description:
patch for 4.4 with cherry-pick information
Filename:
MIME Type:
Creator:
Christian Ambach
Created:
2016-03-01 20:40:52 UTC
Size:
35.13 KB
patch
obsolete
>From a2ef30090082401745f22689647ce02b6cedbe87 Mon Sep 17 00:00:00 2001 >From: Robin Hack <rhack@redhat.com> >Date: Fri, 4 Dec 2015 14:50:56 +0100 >Subject: [PATCH 01/11] samba3.blackbox.smbclient.forceuser_validusers: Add new > test for force user option. > >Test covers commit >cf0934caf282f4ade8c8a701b0e40b68a2f17ace > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878 >RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651 > >How to test: >$ make -j test TESTS="samba3.blackbox.smbclient.forceuser_validusers" >RESULD: Should PASS >$ git revert cf0934caf282f4ade8c8a701b0e40b68a2f17ace >$ make -j test TESTS="samba3.blackbox.smbclient.forceuser_validusers" >RESULT: Should FAIL > >Signed-off-by: Robin Hack <rhack@redhat.com> >Reviewed-by: Uri Simchoni <uri@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> > >Autobuild-User(master): Uri Simchoni <uri@samba.org> >Autobuild-Date(master): Thu Feb 4 03:44:42 CET 2016 on sn-devel-144 > >(cherry picked from commit e2699685cad6fc341079ac4a677df8d6be26e9d9) >--- > selftest/target/Samba3.pm | 35 +++++++++++++- > source3/script/tests/test_forceuser_validusers.sh | 59 +++++++++++++++++++++++ > source3/selftest/tests.py | 1 + > 3 files changed, 93 insertions(+), 2 deletions(-) > create mode 100755 source3/script/tests/test_forceuser_validusers.sh > >diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm >index 5002a81..076bcb1 100755 >--- a/selftest/target/Samba3.pm >+++ b/selftest/target/Samba3.pm >@@ -599,6 +599,9 @@ sub setup_fileserver($$) > my $offline_sharedir="$share_dir/offline"; > push(@dirs,$offline_sharedir); > >+ my $force_user_valid_users_dir = "$share_dir/force_user_valid_users"; >+ push(@dirs, $force_user_valid_users_dir); >+ > my $fileserver_options = " > [lowercase] > path = $lower_case_share_dir >@@ -624,6 +627,16 @@ sub setup_fileserver($$) > [offline] > path = $offline_sharedir > vfs objects = offline >+ >+# BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878 >+# RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651 >+[force_user_valid_users] >+ path = $force_user_valid_users_dir >+ comment = force user with valid users combination test share >+ valid users = +force_user >+ force user = force_user >+ force group = everyone >+ write list = force_user > "; > > my $vars = $self->provision($path, >@@ -1266,10 +1279,12 @@ sub provision($$$$$$$$) > my ($max_uid, $max_gid); > my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup); > my ($uid_pdbtest_wkn); >+ my ($uid_force_user); > my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins); > my ($gid_userdup, $gid_everyone); >+ my ($gid_force_user); > >- if ($unix_uid < 0xffff - 5) { >+ if ($unix_uid < 0xffff - 7) { > $max_uid = 0xffff; > } else { > $max_uid = $unix_uid; >@@ -1281,8 +1296,9 @@ sub provision($$$$$$$$) > $uid_pdbtest2 = $max_uid - 4; > $uid_userdup = $max_uid - 5; > $uid_pdbtest_wkn = $max_uid - 6; >+ $uid_force_user = $max_uid - 7; > >- if ($unix_gids[0] < 0xffff - 7) { >+ if ($unix_gids[0] < 0xffff - 8) { > $max_gid = 0xffff; > } else { > $max_gid = $unix_gids[0]; >@@ -1295,6 +1311,7 @@ sub provision($$$$$$$$) > $gid_domadmins = $max_gid - 5; > $gid_userdup = $max_gid - 6; > $gid_everyone = $max_gid - 7; >+ $gid_force_user = $max_gid - 8; > > ## > ## create conffile >@@ -1659,6 +1676,7 @@ pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false > pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false > userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false > pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false >+force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false > "; > if ($unix_uid != 0) { > print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false >@@ -1677,6 +1695,7 @@ domusers:X:$gid_domusers: > domadmins:X:$gid_domadmins: > userdup:x:$gid_userdup:$unix_name > everyone:x:$gid_everyone: >+force_user:x:$gid_force_user: > "; > if ($unix_gids[0] != 0) { > print GROUP "root:x:$gid_root: >@@ -1739,6 +1758,18 @@ everyone:x:$gid_everyone: > warn("Unable to set password for test account\n$cmd"); > return undef; > } >+ >+ # Add another user named: force_user >+ my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a force_user > /dev/null"; >+ unless (open(PWD, "|$cmd")) { >+ warn("Unable to set password for test account force_user\n$cmd"); >+ return undef; >+ } >+ print PWD "$password\n$password\n"; >+ unless (close(PWD)) { >+ warn("Unable to set password for test account force_user\n$cmd"); >+ return undef; >+ } > print "DONE\n"; > > open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list"); >diff --git a/source3/script/tests/test_forceuser_validusers.sh b/source3/script/tests/test_forceuser_validusers.sh >new file mode 100755 >index 0000000..07aa1a5 >--- /dev/null >+++ b/source3/script/tests/test_forceuser_validusers.sh >@@ -0,0 +1,59 @@ >+#!/bin/sh >+# >+# Blackbox test for share with force user settings >+# >+ >+if [ $# -lt 6 ]; then >+cat <<EOF >+Usage: test_forceuser.sh SERVER DOMAIN USERNAME PASSWORD LOCAL_PATH SMBCLIENT <smbclient arguments> >+EOF >+exit 1; >+fi >+ >+SERVER="$1" >+DOMAIN="$2" >+USERNAME="force_user" >+PASSWORD="$4" >+LOCAL_PATH="$5" >+SMBCLIENT="$6" >+SMBCLIENT="$VALGRIND ${SMBCLIENT}" >+shift 6 >+ADDARGS="$*" >+failed=0 >+ >+ >+incdir=`dirname $0`/../../../testprogs/blackbox >+. $incdir/subunit.sh >+ >+ >+run_cmd_nooutput() { >+ CMD="$1" >+ >+ out=`eval ${CMD} &> TESTOUT` >+ if [ $? != 0 ] ; then >+ cat TESTOUT >+ rm -f TESTOUT >+ echo "command failed" >+ false >+ return >+ fi >+ >+ rm -f TESTOUT >+ true >+ return >+} >+ >+test_force_user_valid_users() >+{ >+ SMB_SHARE="force_user_valid_users" >+ run_cmd_nooutput "${SMBCLIENT} //${SERVER}/${SMB_SHARE} -U$USERNAME%$PASSWORD -c 'ls'" >+} >+ >+# Test >+testit "force user not works when combined with valid users" \ >+ test_force_user_valid_users || failed=`expr $failed + 1` >+ >+# Cleanup >+ >+# Results >+testok $0 $failed >diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py >index 42119cc..b2bae75 100755 >--- a/source3/selftest/tests.py >+++ b/source3/selftest/tests.py >@@ -181,6 +181,7 @@ for env in ["fileserver"]: > plantestsuite("samba3.blackbox.valid_users (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_valid_users.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$PREFIX', smbclient3]) > plantestsuite("samba3.blackbox.offline (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_offline.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/offline', smbclient3]) > plantestsuite("samba3.blackbox.shadow_copy2 (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_shadow_copy.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/shadow', smbclient3]) >+ plantestsuite("samba3.blackbox.smbclient.forceuser_validusers (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_forceuser_validusers.sh"), '$SERVER', '$DOMAIN', '$USERNAME', '$PASSWORD', '$LOCAL_PATH', smbclient3]) > > # > # tar command tests >-- >1.9.1 > > >From f297423f4a707a5b8f2abced285ea68469b3eb9d Mon Sep 17 00:00:00 2001 >From: Christian Ambach <ambi@samba.org> >Date: Mon, 8 Feb 2016 23:24:36 +0100 >Subject: [PATCH 02/11] s3:utils/smbget another int -> bool conversion > >Signed-off-by: Christian Ambach <ambi@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >(cherry picked from commit c91dde9caec39ac76d50602f8b32b6917dfeefba) >--- > source3/utils/smbget.c | 26 ++++++++++++-------------- > 1 file changed, 12 insertions(+), 14 deletions(-) > >diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c >index 91809d1..24f26b0 100644 >--- a/source3/utils/smbget.c >+++ b/source3/utils/smbget.c >@@ -163,9 +163,7 @@ static void get_auth_data(const char *srv, const char *shr, char *wg, int wglen, > } > } > >-/* Return 1 on error, 0 on success. */ >- >-static int smb_download_dir(const char *base, const char *name, int resume) >+static bool smb_download_dir(const char *base, const char *name, int resume) > { > char path[SMB_MAXPATHLEN]; > int dirhandle; >@@ -173,7 +171,7 @@ static int smb_download_dir(const char *base, const char *name, int resume) > const char *relname = name; > char *tmpname; > struct stat remotestat; >- int ret = 0; >+ bool ok = false; > > snprintf(path, SMB_MAXPATHLEN-1, "%s%s%s", base, > (base[0] && name[0] && name[0] != '/' && >@@ -189,7 +187,7 @@ static int smb_download_dir(const char *base, const char *name, int resume) > } > fprintf(stderr, "Can't open directory %s: %s\n", path, > strerror(errno)); >- return 1; >+ return false; > } > > while (*relname == '/') { >@@ -206,28 +204,28 @@ static int smb_download_dir(const char *base, const char *name, int resume) > } > if (asprintf(&newname, "%s/%s", tmpname, dirent->name) == -1) { > free(tmpname); >- return 1; >+ return false; > } > switch (dirent->smbc_type) { > case SMBC_DIR: >- ret = smb_download_dir(base, newname, resume); >+ ok = smb_download_dir(base, newname, resume); > break; > > case SMBC_WORKGROUP: >- ret = smb_download_dir("smb://", dirent->name, resume); >+ ok = smb_download_dir("smb://", dirent->name, resume); > break; > > case SMBC_SERVER: >- ret = smb_download_dir("smb://", dirent->name, resume); >+ ok = smb_download_dir("smb://", dirent->name, resume); > break; > > case SMBC_FILE: >- ret = smb_download_file(base, newname, true, resume, >+ ok = smb_download_file(base, newname, true, resume, > false, NULL); > break; > > case SMBC_FILE_SHARE: >- ret = smb_download_dir(base, newname, resume); >+ ok = smb_download_dir(base, newname, resume); > break; > > case SMBC_PRINTER_SHARE: >@@ -266,7 +264,7 @@ static int smb_download_dir(const char *base, const char *name, int resume) > "Unable to get stats on %s on remote server\n", > path); > smbc_closedir(dirhandle); >- return 1; >+ return false; > } > > if (chmod(relname, remotestat.st_mode) < 0) { >@@ -274,12 +272,12 @@ static int smb_download_dir(const char *base, const char *name, int resume) > "Unable to change mode of local dir %s to %o\n", > relname, (unsigned int)remotestat.st_mode); > smbc_closedir(dirhandle); >- return 1; >+ return false; > } > } > > smbc_closedir(dirhandle); >- return ret; >+ return ok; > } > > static char *print_time(long t) >-- >1.9.1 > > >From 5c483bee1bc5e6bec93eadfd931cd54a18b7ce75 Mon Sep 17 00:00:00 2001 >From: Christian Ambach <ambi@samba.org> >Date: Mon, 8 Feb 2016 23:25:04 +0100 >Subject: [PATCH 03/11] s3:utils/smbget abort recursive download on error > >Signed-off-by: Christian Ambach <ambi@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >(cherry picked from commit 01ba35dca2f721fa5b3c31da7fa991e7d1479cc7) >--- > source3/utils/smbget.c | 6 ++++++ > 1 file changed, 6 insertions(+) > >diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c >index 24f26b0..7957417 100644 >--- a/source3/utils/smbget.c >+++ b/source3/utils/smbget.c >@@ -254,6 +254,12 @@ static bool smb_download_dir(const char *base, const char *name, int resume) > newname, dirent->smbc_type); > break; > } >+ >+ if (!ok) { >+ fprintf(stderr, "Failed to download %s: %s\n", >+ newname, strerror(errno)); >+ return false; >+ } > free(newname); > } > free(tmpname); >-- >1.9.1 > > >From c88fc450b08e9120dfc13af02a775ff5c3e27dcc Mon Sep 17 00:00:00 2001 >From: Christian Ambach <ambi@samba.org> >Date: Mon, 8 Feb 2016 23:27:09 +0100 >Subject: [PATCH 04/11] s3:utils/smbget improve check of write() result > >check that all bytes in the buffer have been written > >Signed-off-by: Christian Ambach <ambi@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >(cherry picked from commit 113f8dd3d9e0d04b03b61f415b3c410ba75260f5) >--- > source3/utils/smbget.c | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) > >diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c >index 7957417..998761f 100644 >--- a/source3/utils/smbget.c >+++ b/source3/utils/smbget.c >@@ -600,9 +600,10 @@ static bool smb_download_file(const char *base, const char *name, > /* Now, download all bytes from offset_download to the end */ > for (curpos = offset_download; curpos < remotestat.st_size; > curpos += opt.blocksize) { >- ssize_t bytesread = smbc_read(remotehandle, >- readbuf, >- opt.blocksize); >+ ssize_t bytesread; >+ ssize_t byteswritten; >+ >+ bytesread = smbc_read(remotehandle, readbuf, opt.blocksize); > if(bytesread < 0) { > fprintf(stderr, > "Can't read %zu bytes at offset %jd, file %s\n", >@@ -617,7 +618,8 @@ static bool smb_download_file(const char *base, const char *name, > > total_bytes += bytesread; > >- if(write(localhandle, readbuf, bytesread) < 0) { >+ byteswritten = write(localhandle, readbuf, bytesread); >+ if (byteswritten != bytesread) { > fprintf(stderr, > "Can't write %zd bytes to local file %s at " > "offset %jd\n", bytesread, path, >-- >1.9.1 > > >From 8666aaca789a207333018771fbf17269e214b0ab Mon Sep 17 00:00:00 2001 >From: Christian Ambach <ambi@samba.org> >Date: Mon, 15 Feb 2016 22:25:11 +0100 >Subject: [PATCH 05/11] s3:utils/smbget remove -P option > >as agreed on samba-technical list. >It does not really provide a useful function but can cause confusion > >Signed-off-by: Christian Ambach <ambi@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >(cherry picked from commit dfc35044d81d413b03d5bf2b33c07c82a244ff57) >--- > source3/utils/smbget.c | 32 -------------------------------- > 1 file changed, 32 deletions(-) > >diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c >index 998761f..5ee73db 100644 >--- a/source3/utils/smbget.c >+++ b/source3/utils/smbget.c >@@ -51,7 +51,6 @@ struct opt { > bool nonprompt; > bool quiet; > bool dots; >- bool keep_permissions; > bool verbose; > bool send_stdout; > bool update; >@@ -170,7 +169,6 @@ static bool smb_download_dir(const char *base, const char *name, int resume) > struct smbc_dirent *dirent; > const char *relname = name; > char *tmpname; >- struct stat remotestat; > bool ok = false; > > snprintf(path, SMB_MAXPATHLEN-1, "%s%s%s", base, >@@ -264,24 +262,6 @@ static bool smb_download_dir(const char *base, const char *name, int resume) > } > free(tmpname); > >- if (opt.keep_permissions) { >- if (smbc_fstat(dirhandle, &remotestat) < 0) { >- fprintf(stderr, >- "Unable to get stats on %s on remote server\n", >- path); >- smbc_closedir(dirhandle); >- return false; >- } >- >- if (chmod(relname, remotestat.st_mode) < 0) { >- fprintf(stderr, >- "Unable to change mode of local dir %s to %o\n", >- relname, (unsigned int)remotestat.st_mode); >- smbc_closedir(dirhandle); >- return false; >- } >- } >- > smbc_closedir(dirhandle); > return ok; > } >@@ -657,17 +637,6 @@ static bool smb_download_file(const char *base, const char *name, > fputc('\n', stderr); > } > >- if (opt.keep_permissions && !opt.send_stdout) { >- if (fchmod(localhandle, remotestat.st_mode) < 0) { >- fprintf(stderr, "Unable to change mode of local " >- "file %s to %o\n", >- path, (unsigned int)remotestat.st_mode); >- smbc_close(remotehandle); >- close(localhandle); >- return false; >- } >- } >- > smbc_close(remotehandle); > if (localhandle != STDOUT_FILENO) { > close(localhandle); >@@ -802,7 +771,6 @@ int main(int argc, char **argv) > {"resume", 'r', POPT_ARG_NONE, &resume, 0, "Automatically resume aborted files" }, > {"update", 'u', POPT_ARG_NONE, &opt.update, 0, "Download only when remote file is newer than local file or local file is missing"}, > {"recursive", 'R', POPT_ARG_NONE, &recursive, 0, "Recursively download files" }, >- {"keep-permissions", 'P', POPT_ARG_NONE, &opt.keep_permissions, 'P', "Keep permissions" }, > {"blocksize", 'b', POPT_ARG_INT, &opt.blocksize, 'b', "Change number of bytes in a block"}, > > {"outputfile", 'o', POPT_ARG_STRING, &opt.outputfile, 'o', "Write downloaded data to specified file" }, >-- >1.9.1 > > >From 039a776339a07b398248273e1cc4f73b050f080d Mon Sep 17 00:00:00 2001 >From: Christian Ambach <ambi@samba.org> >Date: Wed, 17 Feb 2016 19:25:59 +0100 >Subject: [PATCH 06/11] s3:utils/smbget update manpage with -P option removal > >Signed-off-by: Christian Ambach <ambi@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >(cherry picked from commit 301c69816c87c92184155a59814fd2d6652ea76e) >--- > docs-xml/manpages/smbget.1.xml | 6 ------ > 1 file changed, 6 deletions(-) > >diff --git a/docs-xml/manpages/smbget.1.xml b/docs-xml/manpages/smbget.1.xml >index 59e2ffe..d77cb8e 100644 >--- a/docs-xml/manpages/smbget.1.xml >+++ b/docs-xml/manpages/smbget.1.xml >@@ -27,7 +27,6 @@ > <arg choice="opt">-n, --nonprompt</arg> > <arg choice="opt">-d, --debuglevel=INT</arg> > <arg choice="opt">-D, --dots</arg> >- <arg choice="opt">-P, --keep-permissions</arg> > <arg choice="opt">-o, --outputfile</arg> > <arg choice="opt">-f, --rcfile</arg> > <arg choice="opt">-q, --quiet</arg> >@@ -102,11 +101,6 @@ > </varlistentry> > > <varlistentry> >- <term>-P, --keep-permissions</term> >- <listitem><para>Set same permissions on local file as are set on remote file.</para></listitem> >- </varlistentry> >- >- <varlistentry> > <term>-o, --outputfile</term> > <listitem><para>Write the file that is being downloaded to the specified file. Can not be used together with -R.</para></listitem> > </varlistentry> >-- >1.9.1 > > >From 1740964323a07a372ee3f7b981750ed2f99114b6 Mon Sep 17 00:00:00 2001 >From: Christian Ambach <ambi@samba.org> >Date: Wed, 17 Feb 2016 22:57:59 +0100 >Subject: [PATCH 07/11] WHATSNEW: document removal of -P in smbget > >Signed-off-by: Christian Ambach <ambi@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >(cherry picked from commit dc0bd62a236e9d58370fb6d2be668f6a75f2998a) >--- > WHATSNEW.txt | 1 + > 1 file changed, 1 insertion(+) > >diff --git a/WHATSNEW.txt b/WHATSNEW.txt >index 721eb9c..f6d8d5e 100644 >--- a/WHATSNEW.txt >+++ b/WHATSNEW.txt >@@ -71,6 +71,7 @@ The -u and -p options for user and password were replaced by the -U option that > accepts username[%password] as in many other tools of the Samba suite. > Similary, smbgetrc files do not accept username and password options any more, > only a single "user" option which also accepts user%password combinations. >+The -P option was removed. > > s4-rpc_server > ------------- >-- >1.9.1 > > >From 6f8b3f9f7cbe4eaca947f281226144fbf1282724 Mon Sep 17 00:00:00 2001 >From: Christian Ambach <ambi@samba.org> >Date: Sat, 20 Feb 2016 21:11:51 +0100 >Subject: [PATCH 08/11] s3:utils/smbget fix option parsing > >* use proper values for val in poptOption >* popt does not support bool, so set them via the switch statement >* abort when option parsing reported errors > >Signed-off-by: Christian Ambach <ambi@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >(cherry picked from commit fcb56e0e1150f995823aff7dbcb0c09b87a39f6d) >--- > source3/utils/smbget.c | 49 ++++++++++++++++++++++++++++++++++++++++--------- > 1 file changed, 40 insertions(+), 9 deletions(-) > >diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c >index 5ee73db..4909fa2 100644 >--- a/source3/utils/smbget.c >+++ b/source3/utils/smbget.c >@@ -764,20 +764,20 @@ int main(int argc, char **argv) > {"user", 'U', POPT_ARG_STRING, &opt.username, 'U', "Username to use" }, > {"guest", 'a', POPT_ARG_NONE, NULL, 'a', "Work as user guest" }, > >- {"nonprompt", 'n', POPT_ARG_NONE, &opt.nonprompt, 'n', "Don't ask anything (non-interactive)" }, >+ {"nonprompt", 'n', POPT_ARG_NONE, NULL, 'n', "Don't ask anything (non-interactive)" }, > {"debuglevel", 'd', POPT_ARG_INT, &opt.debuglevel, 'd', "Debuglevel to use" }, > > {"encrypt", 'e', POPT_ARG_NONE, NULL, 'e', "Encrypt SMB transport" }, >- {"resume", 'r', POPT_ARG_NONE, &resume, 0, "Automatically resume aborted files" }, >- {"update", 'u', POPT_ARG_NONE, &opt.update, 0, "Download only when remote file is newer than local file or local file is missing"}, >- {"recursive", 'R', POPT_ARG_NONE, &recursive, 0, "Recursively download files" }, >+ {"resume", 'r', POPT_ARG_NONE, NULL, 'r', "Automatically resume aborted files" }, >+ {"update", 'u', POPT_ARG_NONE, NULL, 'u', "Download only when remote file is newer than local file or local file is missing"}, >+ {"recursive", 'R', POPT_ARG_NONE, NULL, 'R', "Recursively download files" }, > {"blocksize", 'b', POPT_ARG_INT, &opt.blocksize, 'b', "Change number of bytes in a block"}, > > {"outputfile", 'o', POPT_ARG_STRING, &opt.outputfile, 'o', "Write downloaded data to specified file" }, >- {"stdout", 'O', POPT_ARG_NONE, &opt.send_stdout, 'O', "Write data to stdout" }, >- {"dots", 'D', POPT_ARG_NONE, &opt.dots, 'D', "Show dots as progress indication" }, >- {"quiet", 'q', POPT_ARG_NONE, &opt.quiet, 'q', "Be quiet" }, >- {"verbose", 'v', POPT_ARG_NONE, &opt.verbose, 'v', "Be verbose" }, >+ {"stdout", 'O', POPT_ARG_NONE, NULL, 'O', "Write data to stdout" }, >+ {"dots", 'D', POPT_ARG_NONE, NULL, 'D', "Show dots as progress indication" }, >+ {"quiet", 'q', POPT_ARG_NONE, NULL, 'q', "Be quiet" }, >+ {"verbose", 'v', POPT_ARG_NONE, NULL, 'v', "Be verbose" }, > {"rcfile", 'f', POPT_ARG_STRING, NULL, 'f', "Use specified rc file"}, > > POPT_TABLEEND >@@ -803,7 +803,7 @@ int main(int argc, char **argv) > > pc = poptGetContext(argv[0], argc, argv_const, long_options, 0); > >- while ((c = poptGetNextOpt(pc)) >= 0) { >+ while ((c = poptGetNextOpt(pc)) > 0) { > switch (c) { > case 'f': > readrcfile(poptGetOptArg(pc), long_options); >@@ -827,9 +827,40 @@ int main(int argc, char **argv) > opt.password_specified = true; > } > break; >+ case 'n': >+ opt.nonprompt = true; >+ break; >+ case 'r': >+ resume = true; >+ break; >+ case 'u': >+ opt.update = true; >+ break; >+ case 'R': >+ recursive = true; >+ break; >+ case 'O': >+ opt.send_stdout = true; >+ break; >+ case 'D': >+ opt.dots = true; >+ break; >+ case 'q': >+ opt.quiet = true; >+ break; >+ case 'v': >+ opt.verbose = true; >+ break; > } > } > >+ if (c < -1) { >+ fprintf(stderr, "%s: %s\n", >+ poptBadOption(pc, POPT_BADOPTION_NOALIAS), >+ poptStrerror(c)); >+ return 1; >+ } >+ > if ((opt.send_stdout || resume || opt.outputfile) && opt.update) { > fprintf(stderr, "The -o, -R or -O and -U options can not be " > "used together.\n"); >-- >1.9.1 > > >From d0c9ce3ec821bf712dbe2924312028d860e7a178 Mon Sep 17 00:00:00 2001 >From: Christian Ambach <ambi@samba.org> >Date: Thu, 18 Feb 2016 00:48:04 +0100 >Subject: [PATCH 09/11] selftest: Reduce code duplication > >Factor out a createuser sub. > >Signed-off-by: Christian Ambach <ambi@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >(cherry picked from commit 2588cf37c05d0247bb7a9ac9572b0ccf11c63ec0) >--- > selftest/target/Samba3.pm | 41 ++++++++++++++++++----------------------- > 1 file changed, 18 insertions(+), 23 deletions(-) > >diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm >index 076bcb1..2013088 100755 >--- a/selftest/target/Samba3.pm >+++ b/selftest/target/Samba3.pm >@@ -1057,6 +1057,22 @@ sub check_or_start($$$$$) { > return $self->wait_for_start($env_vars, $nmbd, $winbindd, $smbd); > } > >+sub createuser($$$$) >+{ >+ my ($self, $username, $password, $conffile) = @_; >+ my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $username > /dev/null"; >+ unless (open(PWD, "|$cmd")) { >+ warn("Unable to set password for $username account\n$cmd"); >+ return undef; >+ } >+ print PWD "$password\n$password\n"; >+ unless (close(PWD)) { >+ warn("Unable to set password for $username account\n$cmd"); >+ return undef; >+ } >+ print "DONE\n"; >+} >+ > sub provision($$$$$$$$) > { > my ($self, $prefix, $server, $password, $extra_options, $dc_server_ip, $dc_server_ipv6, $no_delete_prefix) = @_; >@@ -1748,29 +1764,8 @@ force_user:x:$gid_force_user: > $ENV{RESOLV_WRAPPER_HOSTS} = $dns_host_file; > } > >- my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a $unix_name > /dev/null"; >- unless (open(PWD, "|$cmd")) { >- warn("Unable to set password for test account\n$cmd"); >- return undef; >- } >- print PWD "$password\n$password\n"; >- unless (close(PWD)) { >- warn("Unable to set password for test account\n$cmd"); >- return undef; >- } >- >- # Add another user named: force_user >- my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a force_user > /dev/null"; >- unless (open(PWD, "|$cmd")) { >- warn("Unable to set password for test account force_user\n$cmd"); >- return undef; >- } >- print PWD "$password\n$password\n"; >- unless (close(PWD)) { >- warn("Unable to set password for test account force_user\n$cmd"); >- return undef; >- } >- print "DONE\n"; >+ createuser($self, $unix_name, $password, $conffile) || die("Unable to create user"); >+ createuser($self, "force_user", $password, $conffile) || die("Unable to create force_user"); > > open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list"); > print DNS_UPDATE_LIST "A $server. $server_ip\n"; >-- >1.9.1 > > >From ead15edc1ab57f7af5e8a1206cb70f781ac0afde Mon Sep 17 00:00:00 2001 >From: Christian Ambach <ambi@samba.org> >Date: Thu, 4 Feb 2016 21:41:08 +0100 >Subject: [PATCH 10/11] selftest: add a helper for the smbget binary > >Signed-off-by: Christian Ambach <ambi@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> >(cherry picked from commit 6ceba4def6641c94c794bb62b4c470c0ac60b83a) >--- > selftest/selftesthelpers.py | 1 + > 1 file changed, 1 insertion(+) > >diff --git a/selftest/selftesthelpers.py b/selftest/selftesthelpers.py >index a5ab3f9..42499b0 100644 >--- a/selftest/selftesthelpers.py >+++ b/selftest/selftesthelpers.py >@@ -184,3 +184,4 @@ wbinfo = binpath('wbinfo') > dbwrap_tool = binpath('dbwrap_tool') > vfstest = binpath('vfstest') > smbcquotas = binpath('smbcquotas') >+smbget = binpath('smbget') >-- >1.9.1 > > >From 791712e5e08227c76536dd8bf946d0650080dc5d Mon Sep 17 00:00:00 2001 >From: Christian Ambach <ambi@samba.org> >Date: Sat, 6 Feb 2016 10:30:29 +0100 >Subject: [PATCH 11/11] selftest: Add a blackbox test for smbget > >Signed-off-by: Christian Ambach <ambi@samba.org> >Reviewed-by: Andreas Schneider <asn@samba.org> > >Autobuild-User(master): Christian Ambach <ambi@samba.org> >Autobuild-Date(master): Fri Feb 26 14:40:55 CET 2016 on sn-devel-144 > >(cherry picked from commit 39081afbe5f79192f6b42aa5670ebb757c98e875) >--- > selftest/target/Samba3.pm | 14 ++- > source3/script/tests/test_smbget.sh | 236 ++++++++++++++++++++++++++++++++++++ > source3/selftest/tests.py | 1 + > 3 files changed, 250 insertions(+), 1 deletion(-) > create mode 100755 source3/script/tests/test_smbget.sh > >diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm >index 2013088..6f7407a 100755 >--- a/selftest/target/Samba3.pm >+++ b/selftest/target/Samba3.pm >@@ -602,6 +602,9 @@ sub setup_fileserver($$) > my $force_user_valid_users_dir = "$share_dir/force_user_valid_users"; > push(@dirs, $force_user_valid_users_dir); > >+ my $smbget_sharedir="$share_dir/smbget"; >+ push(@dirs,$smbget_sharedir); >+ > my $fileserver_options = " > [lowercase] > path = $lower_case_share_dir >@@ -637,7 +640,12 @@ sub setup_fileserver($$) > force user = force_user > force group = everyone > write list = force_user >- "; >+ >+[smbget] >+ path = $smbget_sharedir >+ comment = smb username is [%U] >+ guest ok = yes >+"; > > my $vars = $self->provision($path, > "FILESERVER", >@@ -1295,6 +1303,7 @@ sub provision($$$$$$$$) > my ($max_uid, $max_gid); > my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup); > my ($uid_pdbtest_wkn); >+ my ($uid_smbget); > my ($uid_force_user); > my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins); > my ($gid_userdup, $gid_everyone); >@@ -1313,6 +1322,7 @@ sub provision($$$$$$$$) > $uid_userdup = $max_uid - 5; > $uid_pdbtest_wkn = $max_uid - 6; > $uid_force_user = $max_uid - 7; >+ $uid_smbget = $max_uid - 8; > > if ($unix_gids[0] < 0xffff - 8) { > $max_gid = 0xffff; >@@ -1693,6 +1703,7 @@ pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false > userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false > pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false > force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false >+smbget_user:x:$uid_smbget:$gid_domusers:smbget_user gecos:$prefix_abs:/bin/false > "; > if ($unix_uid != 0) { > print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false >@@ -1766,6 +1777,7 @@ force_user:x:$gid_force_user: > > createuser($self, $unix_name, $password, $conffile) || die("Unable to create user"); > createuser($self, "force_user", $password, $conffile) || die("Unable to create force_user"); >+ createuser($self, "smbget_user", $password, $conffile) || die("Unable to create smbget_user"); > > open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list"); > print DNS_UPDATE_LIST "A $server. $server_ip\n"; >diff --git a/source3/script/tests/test_smbget.sh b/source3/script/tests/test_smbget.sh >new file mode 100755 >index 0000000..f21a131 >--- /dev/null >+++ b/source3/script/tests/test_smbget.sh >@@ -0,0 +1,236 @@ >+#!/bin/bash >+# >+# Blackbox test for smbget. >+# >+ >+if [ $# -lt 7 ]; then >+cat <<EOF >+Usage: test_smbget SERVER SERVER_IP DOMAIN USERNAME PASSWORD WORKDIR SMBGET >+EOF >+exit 1; >+fi >+ >+SERVER=${1} >+SERVER_IP=${2} >+DOMAIN=${3} >+USERNAME=${4} >+PASSWORD=${5} >+WORKDIR=${6} >+SMBGET="$VALGRIND ${7}" >+ >+TMPDIR="$SRCDIR_ABS/st/tmp" >+ >+incdir=`dirname $0`/../../../testprogs/blackbox >+. $incdir/subunit.sh >+ >+create_test_data() >+{ >+ pushd $WORKDIR >+ dd if=/dev/urandom bs=1024 count=128 of=testfile >+ chmod 644 testfile >+ mkdir dir1 >+ dd if=/dev/urandom bs=1024 count=128 of=dir1/testfile1 >+ mkdir dir2 >+ dd if=/dev/urandom bs=1024 count=128 of=dir2/testfile2 >+ popd >+} >+ >+remove_test_data() >+{ >+ rm -rf dir1 dir2 testfile >+ pushd $WORKDIR >+ rm -rf dir1 dir2 testfile >+ popd >+} >+ >+test_singlefile_guest() >+{ >+ [ -e testfile ] && rm testfile >+ echo "$SMBGET -v -a smb://$SERVER_IP/smbget/testfile" >+ $SMBGET -v -a smb://$SERVER_IP/smbget/testfile >+ if [ $? -ne 0 ]; then >+ echo 'ERROR: RC does not match, expected: 0' >+ return 1 >+ fi >+ cmp --silent $WORKDIR/testfile ./testfile >+ if [ $? -ne 0 ]; then >+ echo 'ERROR: file content does not match' >+ return 1 >+ fi >+ return 0 >+} >+ >+test_singlefile_U() >+{ >+ [ -e testfile ] && rm testfile >+ $SMBGET -v -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/testfile >+ if [ $? -ne 0 ]; then >+ echo 'ERROR: RC does not match, expected: 0' >+ return 1 >+ fi >+ cmp --silent $WORKDIR/testfile ./testfile >+ if [ $? -ne 0 ]; then >+ echo 'ERROR: file content does not match' >+ return 1 >+ fi >+ return 0 >+} >+ >+test_singlefile_smburl() >+{ >+ [ -e testfile ] && rm testfile >+ $SMBGET -w $DOMAIN smb://$USERNAME:$PASSWORD@$SERVER_IP/smbget/testfile >+ if [ $? -ne 0 ]; then >+ echo 'ERROR: RC does not match, expected: 0' >+ return 1 >+ fi >+ cmp --silent $WORKDIR/testfile ./testfile >+ if [ $? -ne 0 ]; then >+ echo 'ERROR: file content does not match' >+ return 1 >+ fi >+ return 0 >+} >+ >+test_singlefile_rcfile() >+{ >+ [ -e testfile ] && rm testfile >+ echo "user $USERNAME%$PASSWORD" > $TMPDIR/rcfile >+ $SMBGET -vn -f $TMPDIR/rcfile smb://$SERVER_IP/smbget/testfile >+ rc=$? >+ rm -f $TMPDIR/rcfile >+ if [ $rc -ne 0 ]; then >+ echo 'ERROR: RC does not match, expected: 0' >+ return 1 >+ fi >+ cmp --silent $WORKDIR/testfile ./testfile >+ if [ $? -ne 0 ]; then >+ echo 'ERROR: file content does not match' >+ return 1 >+ fi >+ return 0 >+} >+ >+test_recursive_U() >+{ >+ [ -e testfile ] && rm testfile >+ [ -d dir1 ] && rm -rf dir1 >+ [ -d dir2 ] && rm -rf dir2 >+ $SMBGET -v -R -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/ >+ if [ $? -ne 0 ]; then >+ echo 'ERROR: RC does not match, expected: 0' >+ return 1 >+ fi >+ >+ cmp --silent $WORKDIR/testfile ./testfile && \ >+ cmp --silent $WORKDIR/dir1/testfile1 ./dir1/testfile1 && \ >+ cmp --silent $WORKDIR/dir2/testfile2 ./dir2/testfile2 >+ if [ $? -ne 0 ]; then >+ echo 'ERROR: file content does not match' >+ return 1 >+ fi >+ >+ return 0 >+} >+ >+test_resume() >+{ >+ [ -e testfile ] && rm testfile >+ cp $WORKDIR/testfile . >+ truncate -s 1024 testfile >+ $SMBGET -v -r -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/testfile >+ if [ $? -ne 0 ]; then >+ echo 'ERROR: RC does not match, expected: 0' >+ return 1 >+ fi >+ >+ cmp --silent $WORKDIR/testfile ./testfile >+ if [ $? -ne 0 ]; then >+ echo 'ERROR: file content does not match' >+ return 1 >+ fi >+ >+ return 0 >+} >+ >+test_resume_modified() >+{ >+ dd if=/dev/urandom bs=1024 count=2 of=testfile >+ $SMBGET -v -r -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/testfile >+ if [ $? -ne 1 ]; then >+ echo 'ERROR: RC does not match, expected: 1' >+ return 1 >+ fi >+ >+ return 0 >+} >+ >+test_update() >+{ >+ [ -e testfile ] && rm testfile >+ $SMBGET -v -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/testfile >+ if [ $? -ne 0 ]; then >+ echo 'ERROR: RC does not match, expected: 0' >+ return 1 >+ fi >+ >+ # secondary download should pass >+ $SMBGET -v -u -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/testfile >+ if [ $? -ne 0 ]; then >+ echo 'ERROR: RC does not match, expected: 0' >+ return 1 >+ fi >+ >+ echo "modified" >> testfile >+ # touch source to trigger new download >+ sleep 2 >+ touch -m $WORKDIR/testfile >+ $SMBGET -v -u -U$USERNAME%$PASSWORD smb://$SERVER_IP/smbget/testfile >+ if [ $? -ne 0 ]; then >+ echo 'ERROR: RC does not match, expected: 0' >+ return 1 >+ fi >+ >+ cmp --silent $WORKDIR/testfile ./testfile >+ if [ $? -ne 0 ]; then >+ echo 'ERROR: file content does not match' >+ return 1 >+ fi >+ >+ return 0 >+} >+ >+create_test_data >+ >+pushd $TMPDIR >+ >+failed=0 >+testit "download single file as guest" test_singlefile_guest \ >+ || failed=`expr $failed + 1` >+ >+testit "download single file with -U" test_singlefile_U \ >+ || failed=`expr $failed + 1` >+ >+testit "download single file with smb URL" test_singlefile_smburl \ >+ || failed=`expr $failed + 1` >+ >+testit "download single file with rcfile" test_singlefile_rcfile \ >+ || failed=`expr $failed + 1` >+ >+testit "recursive download" test_recursive_U \ >+ || failed=`expr $failed + 1` >+ >+testit "resume download" test_resume \ >+ || failed=`expr $failed + 1` >+ >+testit "resume download (modified file)" test_resume_modified \ >+ || failed=`expr $failed + 1` >+ >+testit "update" test_update \ >+ || failed=`expr $failed + 1` >+ >+popd >+ >+remove_test_data >+ >+exit $failed >diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py >index b2bae75..48e082f 100755 >--- a/source3/selftest/tests.py >+++ b/source3/selftest/tests.py >@@ -182,6 +182,7 @@ for env in ["fileserver"]: > plantestsuite("samba3.blackbox.offline (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_offline.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/offline', smbclient3]) > plantestsuite("samba3.blackbox.shadow_copy2 (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_shadow_copy.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/shadow', smbclient3]) > plantestsuite("samba3.blackbox.smbclient.forceuser_validusers (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_forceuser_validusers.sh"), '$SERVER', '$DOMAIN', '$USERNAME', '$PASSWORD', '$LOCAL_PATH', smbclient3]) >+ plantestsuite("samba3.blackbox.smbget (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_smbget.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', 'smbget_user', '$PASSWORD', '$LOCAL_PATH/smbget', smbget]) > > # > # tar command tests >-- >1.9.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
asn
:
review+
Actions:
View
Attachments on
bug 11767
: 11887