[SCM] Samba Shared Repository - branch master updated
Christian Ambach
ambi at samba.org
Fri Feb 26 13:41:05 UTC 2016
The branch, master has been updated
via 39081af selftest: Add a blackbox test for smbget
via 6ceba4d selftest: add a helper for the smbget binary
via 2588cf3 selftest: Reduce code duplication
via fcb56e0 s3:utils/smbget fix option parsing
via dc0bd62 WHATSNEW: document removal of -P in smbget
via 301c698 s3:utils/smbget update manpage with -P option removal
via dfc3504 s3:utils/smbget remove -P option
via 113f8dd s3:utils/smbget improve check of write() result
via 01ba35dc s3:utils/smbget abort recursive download on error
via c91dde9 s3:utils/smbget another int -> bool conversion
from 0c74d62 s3:libads: setup the msDS-SupportedEncryptionTypes attribute on ldap_add
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 39081afbe5f79192f6b42aa5670ebb757c98e875
Author: Christian Ambach <ambi at samba.org>
Date: Sat Feb 6 10:30:29 2016 +0100
selftest: Add a blackbox test for smbget
Signed-off-by: Christian Ambach <ambi at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
Autobuild-User(master): Christian Ambach <ambi at samba.org>
Autobuild-Date(master): Fri Feb 26 14:40:55 CET 2016 on sn-devel-144
commit 6ceba4def6641c94c794bb62b4c470c0ac60b83a
Author: Christian Ambach <ambi at samba.org>
Date: Thu Feb 4 21:41:08 2016 +0100
selftest: add a helper for the smbget binary
Signed-off-by: Christian Ambach <ambi at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 2588cf37c05d0247bb7a9ac9572b0ccf11c63ec0
Author: Christian Ambach <ambi at samba.org>
Date: Thu Feb 18 00:48:04 2016 +0100
selftest: Reduce code duplication
Factor out a createuser sub.
Signed-off-by: Christian Ambach <ambi at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit fcb56e0e1150f995823aff7dbcb0c09b87a39f6d
Author: Christian Ambach <ambi at samba.org>
Date: Sat Feb 20 21:11:51 2016 +0100
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 at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit dc0bd62a236e9d58370fb6d2be668f6a75f2998a
Author: Christian Ambach <ambi at samba.org>
Date: Wed Feb 17 22:57:59 2016 +0100
WHATSNEW: document removal of -P in smbget
Signed-off-by: Christian Ambach <ambi at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 301c69816c87c92184155a59814fd2d6652ea76e
Author: Christian Ambach <ambi at samba.org>
Date: Wed Feb 17 19:25:59 2016 +0100
s3:utils/smbget update manpage with -P option removal
Signed-off-by: Christian Ambach <ambi at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit dfc35044d81d413b03d5bf2b33c07c82a244ff57
Author: Christian Ambach <ambi at samba.org>
Date: Mon Feb 15 22:25:11 2016 +0100
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 at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 113f8dd3d9e0d04b03b61f415b3c410ba75260f5
Author: Christian Ambach <ambi at samba.org>
Date: Mon Feb 8 23:27:09 2016 +0100
s3:utils/smbget improve check of write() result
check that all bytes in the buffer have been written
Signed-off-by: Christian Ambach <ambi at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit 01ba35dca2f721fa5b3c31da7fa991e7d1479cc7
Author: Christian Ambach <ambi at samba.org>
Date: Mon Feb 8 23:25:04 2016 +0100
s3:utils/smbget abort recursive download on error
Signed-off-by: Christian Ambach <ambi at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
commit c91dde9caec39ac76d50602f8b32b6917dfeefba
Author: Christian Ambach <ambi at samba.org>
Date: Mon Feb 8 23:24:36 2016 +0100
s3:utils/smbget another int -> bool conversion
Signed-off-by: Christian Ambach <ambi at samba.org>
Reviewed-by: Andreas Schneider <asn at samba.org>
-----------------------------------------------------------------------
Summary of changes:
WHATSNEW.txt | 1 +
docs-xml/manpages/smbget.1.xml | 6 -
selftest/selftesthelpers.py | 1 +
selftest/target/Samba3.pm | 55 +++++----
source3/script/tests/test_smbget.sh | 236 ++++++++++++++++++++++++++++++++++++
source3/selftest/tests.py | 1 +
source3/utils/smbget.c | 119 +++++++++---------
7 files changed, 332 insertions(+), 87 deletions(-)
create mode 100755 source3/script/tests/test_smbget.sh
Changeset truncated at 500 lines:
diff --git a/WHATSNEW.txt b/WHATSNEW.txt
index 7c748c2..d81e1ed6 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
-------------
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>
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')
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index cb9ee08..2dde4ca 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -606,6 +606,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
@@ -641,7 +644,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",
@@ -1061,6 +1069,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) = @_;
@@ -1283,6 +1307,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);
@@ -1301,6 +1326,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;
@@ -1681,6 +1707,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
@@ -1752,29 +1779,9 @@ 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");
+ 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
diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c
index 91809d1..4909fa2 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;
@@ -163,17 +162,14 @@ 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;
struct smbc_dirent *dirent;
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 +185,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 +202,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:
@@ -256,30 +252,18 @@ static int smb_download_dir(const char *base, const char *name, int resume)
newname, dirent->smbc_type);
break;
}
- free(newname);
- }
- 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 1;
- }
-
--
Samba Shared Repository
More information about the samba-cvs
mailing list