The branch, v4-10-test has been updated
       via  f441f026b66 lib:util: Fix smbclient -l basename dir
       via  3566d8826f1 Add a test for smbclient -l basename
       via  198e810bc28 testprogs: Add 'net ads join createupn' test also 
verifying the keytab
       via  f798edaea3c s3:libads: Fix ads_get_upn()
       via  3bff6f6ad28 libsmb: Protect cli_oem_change_password() from rprcnt<2
       via  c25c2fc665f libsmb: Protect cli_RNetServerEnum against rprcnt<6
       via  bfe436e4c80 libsmb: Protect cli_RNetShareEnum() against rprcnt<6
       via  70d390656b6 libsmb: Fix indentation in cli_RNetShareEnum()
      from  ad2c619133d libsmb: Don't try to find posix stat info in 
SMBC_getatr()

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-10-test


- Log -----------------------------------------------------------------
commit f441f026b66f8a742976f476843e35b37ebff632
Author: Amit Kumar <[email protected]>
Date:   Wed Apr 22 06:53:42 2020 -0500

    lib:util: Fix smbclient -l basename dir
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14345
    
    Pair-Programmed-With: Andreas Schneider <[email protected]>
    Signed-off-by: Andreas Schneider <[email protected]>
    Signed-off-by: Amit Kumar <[email protected]>
    Reviewed-by: Alexander Bokovoy <[email protected]>
    (cherry picked from commit c83ce5f4f99aef94530411ec82cc03e9935b352d)
    
    Autobuild-User(v4-10-test): Karolin Seeger <[email protected]>
    Autobuild-Date(v4-10-test): Thu May 14 12:11:49 UTC 2020 on sn-devel-144

commit 3566d8826f1e3297f8ebc21046eb4a4beff3232d
Author: Amit Kumar <[email protected]>
Date:   Wed Apr 22 06:53:33 2020 -0500

    Add a test for smbclient -l basename
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14345
    
    Signed-off-by: Amit Kumar <[email protected]>
    Reviewed-by: Andreas Schneider <[email protected]>
    Reviewed-by: Alexander Bokovoy <[email protected]>
    (cherry picked from commit 2a7fc40fb3f3ca994cecad3e2957433d7a411208)

commit 198e810bc28f0a4a41e228e9aeb13e5b9e70d508
Author: Andreas Schneider <[email protected]>
Date:   Fri Apr 3 15:40:48 2020 +0200

    testprogs: Add 'net ads join createupn' test also verifying the keytab
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14336
    
    Signed-off-by: Andreas Schneider <[email protected]>
    Reviewed-by: Alexander Bokovoy <[email protected]>
    
    Autobuild-User(master): Andreas Schneider <[email protected]>
    Autobuild-Date(master): Mon Apr  6 19:09:53 UTC 2020 on sn-devel-184
    
    (cherry picked from commit c4be195da2845be4f64e47883e3c911dedd90e48)

commit f798edaea3c9f1c97b1818d88532e7b33aabcf36
Author: Andreas Schneider <[email protected]>
Date:   Fri Apr 3 15:58:28 2020 +0200

    s3:libads: Fix ads_get_upn()
    
    This adds the userPrincipalName to ads_find_machine_acct() which
    fetches the data for us.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14336
    
    Signed-off-by: Andreas Schneider <[email protected]>
    Reviewed-by: Alexander Bokovoy <[email protected]>
    (cherry picked from commit ec69752cb963ae850568d3f4905d2941e485627e)

commit 3bff6f6ad28753235f2915edffcc7dd367bec594
Author: Volker Lendecke <[email protected]>
Date:   Sat May 2 15:18:07 2020 +0200

    libsmb: Protect cli_oem_change_password() from rprcnt<2
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=14366
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Andreas Schneider <[email protected]>
    
    Autobuild-User(master): Andreas Schneider <[email protected]>
    Autobuild-Date(master): Tue May  5 17:12:04 UTC 2020 on sn-devel-184
    
    (cherry picked from commit f80c97cb8da64f3cd9904e2e1fd43c29b691166d)

commit c25c2fc665ff9db4c1879f67a0c0d0deec6a40f6
Author: Volker Lendecke <[email protected]>
Date:   Sat May 2 15:10:14 2020 +0200

    libsmb: Protect cli_RNetServerEnum against rprcnt<6
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=14366
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Andreas Schneider <[email protected]>
    (cherry picked from commit ce8b70df7bd63e96723b8e8dc864f1690f5fad7b)

commit bfe436e4c8027959e64650369accf3a2f1170723
Author: Volker Lendecke <[email protected]>
Date:   Sat May 2 14:59:07 2020 +0200

    libsmb: Protect cli_RNetShareEnum() against rprcnt<6
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=14366
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Andreas Schneider <[email protected]>
    (cherry picked from commit 4a9fe4efefa67d6f24efcbe29722a43fc4859fdc)

commit 70d390656b6abe4d70979d0dd13e6b025a5261f0
Author: Volker Lendecke <[email protected]>
Date:   Sat May 2 14:54:01 2020 +0200

    libsmb: Fix indentation in cli_RNetShareEnum()
    
    Also remove a level of indentation with a "goto done;"
    
    Best review with "git show -b", almost no code change
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=14366
    Signed-off-by: Volker Lendecke <[email protected]>
    Reviewed-by: Andreas Schneider <[email protected]>
    (cherry picked from commit ae91d67a247424d4ddc89230f52365558d6ff402)

-----------------------------------------------------------------------

Summary of changes:
 lib/util/debug.c                                   |   8 +-
 source3/libads/ldap.c                              |   1 +
 source3/libsmb/clirap.c                            | 151 ++++++++++++---------
 .../script/tests/test_smbclient_log_basename.sh    |  36 +++++
 source3/selftest/tests.py                          |   3 +
 testprogs/blackbox/test_net_ads.sh                 |  17 +++
 6 files changed, 151 insertions(+), 65 deletions(-)
 create mode 100755 source3/script/tests/test_smbclient_log_basename.sh


Changeset truncated at 500 lines:

diff --git a/lib/util/debug.c b/lib/util/debug.c
index 38df787c658..bddea59ad77 100644
--- a/lib/util/debug.c
+++ b/lib/util/debug.c
@@ -1132,9 +1132,15 @@ bool reopen_logs_internal(void)
                dbgc_config[DBGC_ALL].fd = 2;
                return true;
 
-       case DEBUG_FILE:
+       case DEBUG_FILE: {
+               struct debug_backend *b = debug_find_backend("file");
+
+               if (b != NULL) {
+                       b->log_level = dbgc_config[DBGC_ALL].loglevel;
+               }
                break;
        }
+       }
 
        oldumask = umask( 022 );
 
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index afae46d2e79..db2b72ab1b5 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -1373,6 +1373,7 @@ char *ads_parent_dn(const char *dn)
                "userAccountControl",
                "DnsHostName",
                "ServicePrincipalName",
+               "userPrincipalName",
                "unicodePwd",
 
                /* Additional attributes Samba checks */
diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c
index b4b40ebdab4..8a844050461 100644
--- a/source3/libsmb/clirap.c
+++ b/source3/libsmb/clirap.c
@@ -174,6 +174,8 @@ int cli_RNetShareEnum(struct cli_state *cli, void 
(*fn)(const char *, uint32_t,
        unsigned int rdrcnt,rprcnt;
        char param[1024];
        int count = -1;
+       bool ok;
+       int res;
 
        /* now send a SMBtrans command with api RNetShareEnum */
        p = param;
@@ -191,74 +193,82 @@ int cli_RNetShareEnum(struct cli_state *cli, void 
(*fn)(const char *, uint32_t,
        SSVAL(p,2,0xFFE0);
        p += 4;
 
-       if (cli_api(cli,
-                   param, PTR_DIFF(p,param), 1024,  /* Param, length, maxlen */
-                   NULL, 0, 0xFFE0,            /* data, length, maxlen - Win2k 
needs a small buffer here too ! */
-                   &rparam, &rprcnt,                /* return params, length */
-                   &rdata, &rdrcnt))                /* return data, length */
-               {
-                       int res = rparam? SVAL(rparam,0) : -1;
-
-                       if (res == 0 || res == ERRmoredata) {
-                               int converter=SVAL(rparam,2);
-                               int i;
-                               char *rdata_end = rdata + rdrcnt;
-
-                               count=SVAL(rparam,4);
-                               p = rdata;
-
-                               for (i=0;i<count;i++,p+=20) {
-                                       char *sname;
-                                       int type;
-                                       int comment_offset;
-                                       const char *cmnt;
-                                       const char *p1;
-                                       char *s1, *s2;
-                                       size_t len;
-                                       TALLOC_CTX *frame = talloc_stackframe();
-
-                                       if (p + 20 > rdata_end) {
-                                               TALLOC_FREE(frame);
-                                               break;
-                                       }
-
-                                       sname = p;
-                                       type = SVAL(p,14);
-                                       comment_offset = (IVAL(p,16) & 0xFFFF) 
- converter;
-                                       if (comment_offset < 0 ||
-                                                       comment_offset > 
(int)rdrcnt) {
-                                               TALLOC_FREE(frame);
-                                               break;
-                                       }
-                                       cmnt = 
comment_offset?(rdata+comment_offset):"";
-
-                                       /* Work out the comment length. */
-                                       for (p1 = cmnt, len = 0; *p1 &&
-                                                       p1 < rdata_end; len++)
-                                               p1++;
-                                       if (!*p1) {
-                                               len++;
-                                       }
-                                       pull_string_talloc(frame,rdata,0,
-                                               &s1,sname,14,STR_ASCII);
-                                       pull_string_talloc(frame,rdata,0,
-                                               &s2,cmnt,len,STR_ASCII);
-                                       if (!s1 || !s2) {
-                                               TALLOC_FREE(frame);
-                                               continue;
-                                       }
-
-                                       fn(s1, type, s2, state);
+       ok = cli_api(
+               cli,
+               param, PTR_DIFF(p,param), 1024,  /* Param, length, maxlen */
+               NULL, 0, 0xFFE0,            /* data, length, maxlen - Win2k 
needs a small buffer here too ! */
+               &rparam, &rprcnt,                /* return params, length */
+               &rdata, &rdrcnt);                /* return data, length */
+       if (!ok) {
+               DEBUG(4,("NetShareEnum failed\n"));
+               goto done;
+       }
 
-                                       TALLOC_FREE(frame);
-                               }
-                       } else {
-                               DEBUG(4,("NetShareEnum res=%d\n", res));
+       if (rprcnt < 6) {
+               DBG_ERR("Got invalid result: rprcnt=%u\n", rprcnt);
+               goto done;
+       }
+
+       res = rparam? SVAL(rparam,0) : -1;
+
+       if (res == 0 || res == ERRmoredata) {
+               int converter=SVAL(rparam,2);
+               int i;
+               char *rdata_end = rdata + rdrcnt;
+
+               count=SVAL(rparam,4);
+               p = rdata;
+
+               for (i=0;i<count;i++,p+=20) {
+                       char *sname;
+                       int type;
+                       int comment_offset;
+                       const char *cmnt;
+                       const char *p1;
+                       char *s1, *s2;
+                       size_t len;
+                       TALLOC_CTX *frame = talloc_stackframe();
+
+                       if (p + 20 > rdata_end) {
+                               TALLOC_FREE(frame);
+                               break;
                        }
-               } else {
-                       DEBUG(4,("NetShareEnum failed\n"));
+
+                       sname = p;
+                       type = SVAL(p,14);
+                       comment_offset = (IVAL(p,16) & 0xFFFF) - converter;
+                       if (comment_offset < 0 ||
+                           comment_offset > (int)rdrcnt) {
+                               TALLOC_FREE(frame);
+                               break;
+                       }
+                       cmnt = comment_offset?(rdata+comment_offset):"";
+
+                       /* Work out the comment length. */
+                       for (p1 = cmnt, len = 0; *p1 &&
+                                    p1 < rdata_end; len++)
+                               p1++;
+                       if (!*p1) {
+                               len++;
+                       }
+                       pull_string_talloc(frame,rdata,0,
+                                          &s1,sname,14,STR_ASCII);
+                       pull_string_talloc(frame,rdata,0,
+                                          &s2,cmnt,len,STR_ASCII);
+                       if (!s1 || !s2) {
+                               TALLOC_FREE(frame);
+                               continue;
+                       }
+
+                       fn(s1, type, s2, state);
+
+                       TALLOC_FREE(frame);
                }
+       } else {
+                       DEBUG(4,("NetShareEnum res=%d\n", res));
+       }
 
+done:
        SAFE_FREE(rparam);
        SAFE_FREE(rdata);
 
@@ -362,6 +372,13 @@ bool cli_NetServerEnum(struct cli_state *cli, char 
*workgroup, uint32_t stype,
                }
 
                rdata_end = rdata + rdrcnt;
+
+               if (rprcnt < 6) {
+                       DBG_ERR("Got invalid result: rprcnt=%u\n", rprcnt);
+                       res = -1;
+                       break;
+               }
+
                res = rparam ? SVAL(rparam,0) : -1;
 
                if (res == 0 || res == ERRmoredata ||
@@ -560,10 +577,16 @@ bool cli_oem_change_password(struct cli_state *cli, const 
char *user, const char
                return False;
        }
 
+       if (rdrcnt < 2) {
+               cli->rap_error = ERRbadformat;
+               goto done;
+       }
+
        if (rparam) {
                cli->rap_error = SVAL(rparam,0);
        }
 
+done:
        SAFE_FREE(rparam);
        SAFE_FREE(rdata);
 
diff --git a/source3/script/tests/test_smbclient_log_basename.sh 
b/source3/script/tests/test_smbclient_log_basename.sh
new file mode 100755
index 00000000000..c721b3f5ca1
--- /dev/null
+++ b/source3/script/tests/test_smbclient_log_basename.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+# this test checks whether smbclient can log into -l log-basename
+
+if [ $# -lt 2 ]; then
+cat <<EOF
+Usage: test_smbclient_log_basename.sh SERVER SMBCLIENT PREFIX <smbclient 
arguments>
+EOF
+exit 1;
+fi
+
+SERVER="$1"
+SMBCLIENT="$2"
+PREFIX="$3"
+shift 3
+ADDARGS="$*"
+
+incdir=`dirname $0`/../../../testprogs/blackbox
+. $incdir/subunit.sh
+
+failed=0
+
+LOG_DIR=$PREFIX/st_log_basename_dir
+
+test_smbclient_log_basename()
+{
+       rm -rf $LOG_DIR
+       mkdir $LOG_DIR
+       cmd='$VALGRIND $SMBCLIENT -l $LOG_DIR -d3 //$SERVER/IPC\$ 
$CONFIGURATION -U%badpassword -c quit $ADDARGS'
+       out=`eval $cmd 2>&1`
+       grep 'lp_load_ex: refreshing parameters' $LOG_DIR/log.smbclient
+}
+
+testit "smbclient log-basename" test_smbclient_log_basename || failed=`expr 
$failed + 1`
+
+testok $0 $failed
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 8db24d6ca25..5a80457afc2 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -228,6 +228,9 @@ for env in ["nt4_dc", "nt4_member", "ad_member", "ad_dc", 
"ad_dc_ntvfs", "s4memb
     plantestsuite("samba3.blackbox.smbclient_machine_auth.plain (%s:local)" % 
env, "%s:local" % env, [os.path.join(samba3srcdir, 
"script/tests/test_smbclient_machine_auth.sh"), '$SERVER', smbclient3, 
configuration])
     plantestsuite("samba3.blackbox.smbclient_ntlm.plain (%s)" % env, env, 
[os.path.join(samba3srcdir, "script/tests/test_smbclient_ntlm.sh"), '$SERVER', 
'$DC_USERNAME', '$DC_PASSWORD', "never", smbclient3, configuration])
 
+
+plantestsuite("samba3.blackbox.smbclient_log_basename", "ad_dc", 
[os.path.join(samba3srcdir, "script/tests/test_smbclient_log_basename.sh"), 
'$SERVER', smbclient3, '$PREFIX', configuration])
+
 for options in ["--option=clientntlmv2auth=no", "--option=clientusespnego=no 
--option=clientntlmv2auth=no", "--option=clientusespnego=no 
--option=clientntlmv2auth=no -mNT1", ""]:
     for env in ["nt4_member", "ad_member"]:
         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])
diff --git a/testprogs/blackbox/test_net_ads.sh 
b/testprogs/blackbox/test_net_ads.sh
index 8bcff006b8e..95c0cf76f90 100755
--- a/testprogs/blackbox/test_net_ads.sh
+++ b/testprogs/blackbox/test_net_ads.sh
@@ -237,6 +237,23 @@ testit "leave+createcomputer" $VALGRIND $net_tool ads 
leave -U$DC_USERNAME%$DC_P
 
 testit "Remove OU=Servers" $VALGRIND $ldbdel -U$DC_USERNAME%$DC_PASSWORD -H 
ldap://$SERVER "OU=Servers,$base_dn"
 
+#
+# Test createupn option of 'net ads join'
+#
+testit "join+createupn" $VALGRIND $net_tool ads join 
-U$DC_USERNAME%$DC_PASSWORD createupn="host/test-$HOSTNAME@$REALM" || 
failed=`expr $failed + 1`
+
+testit_grep "checkupn" "userPrincipalName: host/test-$HOSTNAME@$REALM" 
$ldbsearch -U$DC_USERNAME%$DC_PASSWORD -H ldap://$SERVER.$REALM -s base -b 
"CN=$HOSTNAME,CN=Computers,$base_dn" || failed=`expr $failed + 1`
+
+dedicated_keytab_file="$PREFIX_ABS/test_net_create_dedicated_krb5.keytab"
+
+testit "create_keytab" $VALGRIND $net_tool ads keytab create 
--option="kerberosmethod=dedicatedkeytab" 
--option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=`expr $failed + 
1`
+
+testit_grep "checkupn+keytab" "host/test-$HOSTNAME@$REALM" $net_tool ads 
keytab list --option="kerberosmethod=dedicatedkeytab" 
--option="dedicatedkeytabfile=$dedicated_keytab_file" || failed=`expr $failed + 
1`
+
+rm -f $dedicated_keytab_file
+
+testit "leave+createupn" $VALGRIND $net_tool ads leave 
-U$DC_USERNAME%$DC_PASSWORD || failed=`expr $failed + 1`
+
 rm -rf $BASEDIR/$WORKDIR
 
 exit $failed


-- 
Samba Shared Repository

Reply via email to