/[smeserver]/rpms/samba/sme10/samba-v4-6-fix_smbclient_username_parsing.patch
ViewVC logotype

Contents of /rpms/samba/sme10/samba-v4-6-fix_smbclient_username_parsing.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download)
Wed Aug 9 04:48:51 2023 UTC (9 months, 2 weeks ago) by jpp
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
FILE REMOVED
Initial import

1 From 7417ea49cc998d07e0208736269b40f8ac3f2c48 Mon Sep 17 00:00:00 2001
2 From: Andreas Schneider <asn@samba.org>
3 Date: Mon, 19 Jun 2017 14:50:33 +0200
4 Subject: [PATCH 1/2] s3:popt_common: Reparse the username in
5 popt_common_credentials_post()
6
7 When we parse the username in the options handling, the smb.conf file
8 has not been loaded yet. So we are not aware of a 'winbind separator'
9 set in the config file.
10
11 We need to read and set the username again in the post-processing of the
12 credentials.
13
14 https://bugzilla.samba.org/show_bug.cgi?id=12849
15
16 Signed-off-by: Andreas Schneider <asn@samba.org>
17 Reviewed-by: Stefan Metzmacher <metze@samba.org>
18 (cherry picked from commit 0caf40ec0196de0de016fda0d4aff0734d498d2b)
19 ---
20 source3/lib/popt_common.c | 15 +++++++++++++++
21 1 file changed, 15 insertions(+)
22
23 diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c
24 index 3589a4fbd2b..9928c708e89 100644
25 --- a/source3/lib/popt_common.c
26 +++ b/source3/lib/popt_common.c
27 @@ -238,6 +238,7 @@ void popt_common_credentials_set_delay_post(void)
28 void popt_common_credentials_post(void)
29 {
30 struct user_auth_info *auth_info = cmdline_auth_info;
31 + const char *username = NULL;
32
33 if (get_cmdline_auth_info_use_machine_account(auth_info) &&
34 !set_cmdline_auth_info_machine_account_creds(auth_info))
35 @@ -248,6 +249,20 @@ void popt_common_credentials_post(void)
36 }
37
38 set_cmdline_auth_info_getpass(auth_info);
39 +
40 + /*
41 + * When we set the username during the handling of the options passed to
42 + * the binary we haven't loaded the config yet. This means that we
43 + * didnn't take the 'winbind separator' into account.
44 + *
45 + * The username might contain the domain name and thus it hasn't been
46 + * correctly parsed yet. If we have a username we need to set it again
47 + * to run the string parser for the username correctly.
48 + */
49 + username = get_cmdline_auth_info_username(auth_info);
50 + if (username != NULL && username[0] != '\0') {
51 + set_cmdline_auth_info_username(auth_info, username);
52 + }
53 }
54
55 static void popt_common_credentials_callback(poptContext con,
56 --
57 2.13.1
58
59
60 From 5143e70481e5b47f37a2eb16a8b74bf74d8ec639 Mon Sep 17 00:00:00 2001
61 From: Andreas Schneider <asn@samba.org>
62 Date: Mon, 19 Jun 2017 15:52:23 +0200
63 Subject: [PATCH 2/2] s3:tests: Add test for smbclient -UDOMAIN+username
64
65 BUG: https://bugzilla.samba.org/show_bug.cgi?id=12849
66
67 Signed-off-by: Andreas Schneider <asn@samba.org>
68 Reviewed-by: Stefan Metzmacher <metze@samba.org>
69
70 Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
71 Autobuild-Date(master): Tue Jun 20 14:48:33 CEST 2017 on sn-devel-144
72
73 (cherry picked from commit e60aeb6f56a26019788442247361ed516bf965af)
74 ---
75 source3/script/tests/test_smbclient_basic.sh | 62 ++++++++++++++++++++++++++++
76 source3/selftest/tests.py | 1 +
77 2 files changed, 63 insertions(+)
78 create mode 100755 source3/script/tests/test_smbclient_basic.sh
79
80 diff --git a/source3/script/tests/test_smbclient_basic.sh b/source3/script/tests/test_smbclient_basic.sh
81 new file mode 100755
82 index 00000000000..90e579b68e9
83 --- /dev/null
84 +++ b/source3/script/tests/test_smbclient_basic.sh
85 @@ -0,0 +1,62 @@
86 +#!/bin/sh
87 +
88 +# this runs the file serving tests that are expected to pass with samba3 against shares with various options
89 +
90 +if [ $# -lt 5 ]; then
91 +cat <<EOF
92 +Usage: test_smbclient_basic.sh SERVER SERVER_IP DOMAIN USERNAME PASSWORD SMBCLIENT <smbclient arguments>
93 +EOF
94 +exit 1;
95 +fi
96 +
97 +SERVER="$1"
98 +SERVER_IP="$2"
99 +USERNAME="$3"
100 +PASSWORD="$4"
101 +smbclient="$5"
102 +CONFIGURATION="$6"
103 +shift 6
104 +ADDARGS="$@"
105 +
106 +incdir=`dirname $0`/../../../testprogs/blackbox
107 +. $incdir/subunit.sh
108 +
109 +test_smbclient() {
110 + name="$1"
111 + cmd="$2"
112 + shift
113 + shift
114 + echo "test: $name"
115 + $VALGRIND $smbclient $CONFIGURATION //$SERVER/tmp -c "$cmd" $@
116 + status=$?
117 + if [ x$status = x0 ]; then
118 + echo "success: $name"
119 + else
120 + echo "failure: $name"
121 + fi
122 + return $status
123 +}
124 +
125 +# TEST using \ as the separator (default)
126 +test_smbclient "smbclient as $DOMAIN\\$USERNAME" 'ls' -U$DOMAIN\\$USERNAME%$PASSWORD $CONFIGURATION || failed=`expr $failed + 1`
127 +# TEST using / as the separator (default)
128 +test_smbclient "smbclient as $DOMAIN/$USERNAME" 'ls' -U$DOMAIN/$USERNAME%$PASSWORD $CONFIGURATION || failed=`expr $failed + 1`
129 +
130 +# TEST using 'winbind separator = +'
131 +test_smbclient "smbclient as $DOMAIN+$USERNAME" 'ls' -U$DOMAIN+$USERNAME%$PASSWORD $CONFIGURATION --option=winbindseparator=+ || failed=`expr $failed + 1`
132 +
133 +# TEST using 'winbind separator = +' set in a config file
134 +smbclient_config="$PREFIX/tmpsmbconf"
135 +cat > $smbclient_config <<EOF
136 +[global]
137 + include = $(echo $CONFIGURATION | cut -d= -f2)
138 + winbind separator = +
139 +EOF
140 +
141 +SAVE_CONFIGURATION="$CONFIGURATION"
142 +CONFIGURATION="--configfile=$smbclient_config"
143 +test_smbclient "smbclient as $DOMAIN+$USERNAME" 'ls' -U$DOMAIN+$USERNAME%$PASSWORD || failed=`expr $failed + 1`
144 +CONFIGURATION="$SAVE_CONFIGURATION"
145 +rm -rf $smbclient_config
146 +
147 +exit $failed
148 diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
149 index dfe7866b283..d3cb071b903 100755
150 --- a/source3/selftest/tests.py
151 +++ b/source3/selftest/tests.py
152 @@ -152,6 +152,7 @@ plantestsuite("samba.vfstest.xattr-tdb-1", "nt4_dc:local", [os.path.join(samba3s
153 plantestsuite("samba.vfstest.acl", "nt4_dc:local", [os.path.join(samba3srcdir, "script/tests/vfstest-acl/run.sh"), binpath("vfstest"), "$PREFIX", configuration])
154 plantestsuite("samba.vfstest.catia", "nt4_dc:local", [os.path.join(samba3srcdir, "script/tests/vfstest-catia/run.sh"), binpath("vfstest"), "$PREFIX", configuration])
155
156 +plantestsuite("samba3.blackbox.smbclient_basic", "ad_member", [os.path.join(samba3srcdir, "script/tests/test_smbclient_basic.sh"), '$SERVER', '$SERVER_IP', '$DC_USERNAME', '$DC_PASSWORD', smbclient3, configuration])
157 for options in ["", "--option=clientntlmv2auth=no", "--option=clientusespnego=no", "--option=clientusespnego=no --option=clientntlmv2auth=no", "--option=clientntlmv2auth=no --option=clientlanmanauth=yes --max-protocol=LANMAN2", "--option=clientntlmv2auth=no --option=clientlanmanauth=yes --option=clientmaxprotocol=NT1"]:
158 env = "nt4_dc"
159 plantestsuite("samba3.blackbox.smbclient_auth.plain (%s) %s" % (env, options), env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_auth.sh"), '$SERVER', '$SERVER_IP', '$DC_USERNAME', '$DC_PASSWORD', smbclient3, configuration, options])
160 --
161 2.13.1
162

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed