[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Mon Sep 25 20:00:02 UTC 2023


The branch, master has been updated
       via  fab08854af3 libsmb: Pass neg contexts through sync smbXcli_negprot_recv()
       via  b693b6accc5 libsmb: Make libsmb/clispnego.c static to libads/
       via  a0181938c1a libcli: Correct guard #define
       via  cd2e6c45628 clifuse: Start implementing forget()
       via  27ae6bdbb15 clifuse: Use an empty array for holding the inode path
       via  94dcda1ee2c examples: Slightly modernize printfs in teststat
       via  aef98c6356b libsmb: Remove two #defines just used once
       via  446a3b3e8ae smbd: Modernize a few DBG statements
       via  94433d1d019 examples: Use explicit SMBCCTX
       via  3b8cfda1c96 lib: Avoid a tdb handle leak
       via  46f710c95f4 lib: Modernize tdb_fetch_lifetime()
       via  e6136139be9 libsmb: Remove unused cli_is_dos_error()
       via  b0b1fc1974b libsmb: Remove unused cli_dos_error()
       via  05828c3e382 libsmb: Eliminate a reader of cli->raw_status
       via  3cfe1683ddd libsmb: Remove SMBC_errno()
       via  15ff9c18198 libsmb: Remove a call to SMBC_errno()
       via  bb8ec333400 libsmb: Remove a call to SMBC_errno()
       via  9ec7245b1b4 libsmb: Remove a call to SMBC_errno()
       via  2399b105fe1 libsmb: Remove unused cli_is_nt_error()
       via  aaf5821dac4 smbclient: Save lines with talloc_asprintf_addbuf()
      from  9c316623e5f libsmb: Extend cli_mknod to create NFS reparse points

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit fab08854af3843a5de42fefe209090a7563e7f11
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Sep 19 11:10:12 2023 -0700

    libsmb: Pass neg contexts through sync smbXcli_negprot_recv()
    
    Looks much larger than it is, there's a lot of callers too feed NULL to.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Mon Sep 25 19:59:17 UTC 2023 on atb-devel-224

commit b693b6accc5c889dd2ccb137b510282aff6ef619
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Sep 14 19:00:06 2023 +0200

    libsmb: Make libsmb/clispnego.c static to libads/
    
    It's only called there. The "+" part of this patch might not conform
    to README.Coding because it's a literal cut&paste.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a0181938c1a6073b4afaf7d395d6225afcbe9b4b
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Sep 10 07:05:04 2023 +0200

    libcli: Correct guard #define
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit cd2e6c4562828b40edff3be49703cef5f09485f1
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 22 12:58:29 2023 +0200

    clifuse: Start implementing forget()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 27ae6bdbb157c81f0e8a16dc03788dc930fa8b0f
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Aug 22 09:22:13 2023 +0200

    clifuse: Use an empty array for holding the inode path
    
    Cleaner these days.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 94dcda1ee2c2d11bee0ad9cdfc0341d2a209c10a
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Aug 14 17:28:28 2023 +0200

    examples: Slightly modernize printfs in teststat
    
    long long works, but it's a bit too specific now that we have intmax_t
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit aef98c6356b351f0fa8b7f1612384df865b4547f
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Aug 23 13:25:37 2023 +0200

    libsmb: Remove two #defines just used once
    
    To me these two did not create clarity.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 446a3b3e8ae2c0603ac3c4d504b9d1b19e89f414
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Aug 23 16:36:06 2023 +0200

    smbd: Modernize a few DBG statements
    
    Changes on level from 4 to 3 in store_file_unix_basic().
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 94433d1d0194ae78bb48cd24d09953a08c444390
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Aug 23 16:46:56 2023 +0200

    examples: Use explicit SMBCCTX
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3b8cfda1c963d75ce95f6a7921691aa52a07df07
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Sep 23 00:50:41 2023 -0700

    lib: Avoid a tdb handle leak
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 46f710c95f4461c7ad2b6b757549ffb5e5c31d8c
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Sep 23 00:41:22 2023 -0700

    lib: Modernize tdb_fetch_lifetime()
    
    Just came across this, avoid mallocs.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit e6136139be95203782db095ef4163be853461320
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 22 19:05:38 2023 -0700

    libsmb: Remove unused cli_is_dos_error()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b0b1fc1974bd8d2d7ecf94e6ad09d068d3c0d29c
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 22 18:56:58 2023 -0700

    libsmb: Remove unused cli_dos_error()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 05828c3e38226385b8294c661c8ccd460aef97b1
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 22 18:47:21 2023 -0700

    libsmb: Eliminate a reader of cli->raw_status
    
    At some point we should get rid of cli->raw_status.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3cfe1683ddd0903aeefc791e4b77a8c925558dc5
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 22 18:44:14 2023 -0700

    libsmb: Remove SMBC_errno()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 15ff9c1819826cf4ed5535fa20741adffbbe7281
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 22 18:42:24 2023 -0700

    libsmb: Remove a call to SMBC_errno()
    
    This involves converting cli_printjob_del() to NTSTATUS and thus
    touches a few callers.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit bb8ec33340068dfeaa4cf588d9766dbf954be99e
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 22 17:55:55 2023 -0700

    libsmb: Remove a call to SMBC_errno()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 9ec7245b1b40da3fd1887c7131f92d267b08e254
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 22 17:50:58 2023 -0700

    libsmb: Remove a call to SMBC_errno()
    
    All returns from cacl_get() now explicitly set the errno.
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2399b105fe158552fea62db8b90af87ad199bf7c
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Sep 22 17:50:19 2023 -0700

    libsmb: Remove unused cli_is_nt_error()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit aaf5821dac4bd333ff78d0e2cbe75c72a53a1175
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Sep 19 10:29:15 2023 -0700

    smbclient: Save lines with talloc_asprintf_addbuf()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 examples/fuse/clifuse.c           |  22 +++-
 examples/libsmbclient/teststat.c  |  36 ++++--
 lib/param/util.c                  |  60 ++++++----
 libcli/smb/reparse.h              |   4 +-
 libcli/smb/smbXcli_base.c         |   9 +-
 libcli/smb/smbXcli_base.h         |   5 +-
 source3/client/client.c           |  59 +++-------
 source3/include/libsmb_internal.h |   7 --
 source3/include/proto.h           |  10 --
 source3/libads/authdata.c         |  43 +++++++
 source3/libads/sasl.c             | 139 ++++++++++++++++++++++
 source3/libsmb/cli_smb2_fnum.c    |  19 ++--
 source3/libsmb/clidfs.c           |   8 +-
 source3/libsmb/clierror.c         |  47 --------
 source3/libsmb/cliprint.c         |  61 +++++++---
 source3/libsmb/clispnego.c        | 205 ---------------------------------
 source3/libsmb/libsmb_dir.c       |   6 +-
 source3/libsmb/libsmb_misc.c      |  31 -----
 source3/libsmb/libsmb_printjob.c  |  12 +-
 source3/libsmb/libsmb_server.c    |   8 +-
 source3/libsmb/libsmb_stat.c      |   4 +-
 source3/libsmb/libsmb_xattr.c     |   7 +-
 source3/libsmb/passchange.c       |   8 +-
 source3/libsmb/proto.h            |   5 +-
 source3/nmbd/nmbd_synclists.c     |   9 +-
 source3/smbd/smb2_trans2.c        |  20 ++--
 source3/torture/test_posix.c      |   5 +-
 source3/torture/test_smb2.c       | 234 +++++++++++++++++++++++++++-----------
 source3/torture/torture.c         |  55 +++++++--
 source3/utils/net_rap.c           |   9 +-
 source3/utils/net_rpc.c           |   8 +-
 source3/utils/net_time.c          |   8 +-
 source3/winbindd/winbindd_cm.c    |   8 +-
 source3/wscript_build             |   1 -
 34 files changed, 642 insertions(+), 530 deletions(-)
 delete mode 100644 source3/libsmb/clispnego.c


Changeset truncated at 500 lines:

diff --git a/examples/fuse/clifuse.c b/examples/fuse/clifuse.c
index 890dae16307..533fe14c2d4 100644
--- a/examples/fuse/clifuse.c
+++ b/examples/fuse/clifuse.c
@@ -54,7 +54,7 @@ struct mount_state {
 struct inode_state {
 	struct idr_context *ino_ctx;
 	fuse_ino_t ino;
-	char path[1];
+	char path[];
 };
 
 static int inode_state_destructor(struct inode_state *s);
@@ -736,6 +736,25 @@ static void cli_ll_lookup_done(struct tevent_req *req)
 	TALLOC_FREE(state);
 }
 
+static void
+cli_ll_forget(fuse_req_t freq, fuse_ino_t ino, unsigned long nlookup)
+{
+	struct mount_state *mstate =
+		talloc_get_type_abort(fuse_req_userdata(freq),
+				      struct mount_state);
+	struct inode_state *istate = NULL;
+
+	DBG_DEBUG("ino=%ju, nlookup=%lu\n", (uintmax_t)ino, nlookup);
+
+	istate = idr_find(mstate->ino_ctx, ino);
+	if (istate == NULL) {
+		fuse_reply_err(freq, ENOENT);
+		return;
+	}
+	TALLOC_FREE(istate);
+	fuse_reply_none(freq);
+}
+
 struct ll_getattr_state {
 	struct mount_state *mstate;
 	fuse_req_t freq;
@@ -1399,6 +1418,7 @@ static void cli_ll_releasedir_done(struct tevent_req *req)
 
 static struct fuse_lowlevel_ops cli_ll_ops = {
 	.lookup = cli_ll_lookup,
+	.forget = cli_ll_forget,
 	.getattr = cli_ll_getattr,
 	.open = cli_ll_open,
 	.create = cli_ll_create,
diff --git a/examples/libsmbclient/teststat.c b/examples/libsmbclient/teststat.c
index 593609bd9cf..c8973e6ad0d 100644
--- a/examples/libsmbclient/teststat.c
+++ b/examples/libsmbclient/teststat.c
@@ -8,6 +8,7 @@
 
 int main(int argc, char * argv[])
 {
+	SMBCCTX *ctx = NULL;
 	int             debug = 0;
 	char            m_time[32];
 	char            c_time[32];
@@ -35,18 +36,30 @@ int main(int argc, char * argv[])
 		return 1;
 	}
 
-	smbc_init(get_auth_data_fn, debug);
+	ctx = smbc_new_context();
+	if (ctx == NULL) {
+		perror("smbc_new_context failed");
+		return 1;
+	}
+
+	smbc_setOptionDebugToStderr(ctx, 1);
+	smbc_setDebug(ctx, debug);
+	smbc_init_context(ctx);
+	smbc_setFunctionAuthData(ctx, get_auth_data_fn);
 
-	ret = smbc_stat(pSmbPath, &st);
+	ret = smbc_getFunctionStat(ctx)(ctx, pSmbPath, &st);
 	if (ret < 0) {
 		perror("smbc_stat");
 		return 1;
 	}
 
-	printf("\nSAMBA\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n",
-	       (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time),
-	       (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time),
-	       (long long)st.st_atime, ctime_r(&st.st_atime, a_time));
+	printf("\nSAMBA\n mtime:%jd/%s ctime:%jd/%s atime:%jd/%s\n",
+	       (intmax_t)st.st_mtime,
+	       ctime_r(&st.st_mtime, m_time),
+	       (intmax_t)st.st_ctime,
+	       ctime_r(&st.st_ctime, c_time),
+	       (intmax_t)st.st_atime,
+	       ctime_r(&st.st_atime, a_time));
 
 	if (pLocalPath != NULL) {
 		ret = stat(pLocalPath, &st);
@@ -55,10 +68,13 @@ int main(int argc, char * argv[])
 			return 1;
 		}
 
-		printf("LOCAL\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n",
-		       (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time),
-		       (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time),
-		       (long long)st.st_atime, ctime_r(&st.st_atime, a_time));
+		printf("LOCAL\n mtime:%jd/%s ctime:%jd/%s atime:%jd/%s\n",
+		       (intmax_t)st.st_mtime,
+		       ctime_r(&st.st_mtime, m_time),
+		       (intmax_t)st.st_ctime,
+		       ctime_r(&st.st_ctime, c_time),
+		       (intmax_t)st.st_atime,
+		       ctime_r(&st.st_atime, a_time));
 	}
 
 	return 0;
diff --git a/lib/param/util.c b/lib/param/util.c
index b9055e86e9d..8d862ad6768 100644
--- a/lib/param/util.c
+++ b/lib/param/util.c
@@ -273,30 +273,37 @@ const char *lpcfg_sam_dnsname(struct loadparm_context *lp_ctx)
 	}
 }
 
-static long tdb_fetch_lifetime(TALLOC_CTX *mem_ctx, struct tdb_context *tdb, const char *keystr)
+static int
+tdb_fetch_lifetime_fn(TDB_DATA key, TDB_DATA data, void *private_data)
 {
-	TDB_DATA key;
-	TDB_DATA ret;
-	char *tmp = NULL;
-	long result;
-
-	key.dptr = discard_const_p(unsigned char, keystr);
-	key.dsize = strlen(keystr);
-
-	if (!key.dptr)
-		return -1;
+	if (data.dsize < 256) {
+		long *result = private_data;
+		char tmp[data.dsize + 1];
+		memcpy(tmp, data.dptr, data.dsize);
+		tmp[data.dsize] = '\0';
+		*result = atol(tmp);
+		return 0;
+	}
+	return -1;
+}
 
-	ret = tdb_fetch(tdb, key);
-	if (ret.dsize == 0)
+static long tdb_fetch_lifetime(struct tdb_context *tdb,
+			       const char *keystr)
+{
+	long result = -1;
+	int ret;
+
+	ret = tdb_parse_record(
+		tdb,
+		(TDB_DATA){
+			.dptr = discard_const_p(uint8_t, keystr),
+			.dsize = strlen(keystr),
+		},
+		tdb_fetch_lifetime_fn,
+		&result);
+	if (ret == -1) {
 		return -1;
-
-	tmp = talloc_realloc(mem_ctx, tmp, char, ret.dsize+1);
-	memset(tmp, 0, ret.dsize+1);
-	memcpy(tmp, ret.dptr, ret.dsize);
-	free(ret.dptr);
-
-	result = atol(tmp);
-	talloc_free(tmp);
+	}
 	return result;
 }
 
@@ -314,15 +321,20 @@ void lpcfg_default_kdc_policy(TALLOC_CTX *mem_ctx,
 	if (kdc_tdb)
 		ctx = tdb_open(kdc_tdb, 0, TDB_DEFAULT, O_RDWR, 0600);
 
-	if (!ctx || ( val = tdb_fetch_lifetime(mem_ctx, ctx, "kdc:service_ticket_lifetime") ) == -1 )
+	if (!ctx || ( val = tdb_fetch_lifetime(ctx, "kdc:service_ticket_lifetime") ) == -1 )
 		val = lpcfg_parm_long(lp_ctx, NULL, "kdc", "service ticket lifetime", 10);
 	*svc_tkt_lifetime = val * 60 * 60;
 
-	if (!ctx || ( val = tdb_fetch_lifetime(mem_ctx, ctx, "kdc:user_ticket_lifetime") ) == -1 )
+	if (!ctx || ( val = tdb_fetch_lifetime(ctx, "kdc:user_ticket_lifetime") ) == -1 )
 		val = lpcfg_parm_long(lp_ctx, NULL, "kdc", "user ticket lifetime", 10);
 	*usr_tkt_lifetime = val * 60 * 60;
 
-	if (!ctx || ( val = tdb_fetch_lifetime(mem_ctx, ctx, "kdc:renewal_lifetime") ) == -1 )
+	if (!ctx || ( val = tdb_fetch_lifetime(ctx, "kdc:renewal_lifetime") ) == -1 )
 		val = lpcfg_parm_long(lp_ctx, NULL, "kdc", "renewal lifetime", 24 * 7);
 	*renewal_lifetime = val * 60 * 60;
+
+	if (ctx != NULL) {
+		tdb_close(ctx);
+		ctx = NULL;
+	}
 }
diff --git a/libcli/smb/reparse.h b/libcli/smb/reparse.h
index 1e593272a66..23274bf3852 100644
--- a/libcli/smb/reparse.h
+++ b/libcli/smb/reparse.h
@@ -15,8 +15,8 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef __UTIL_REPARSE_H__
-#define __UTIL_REPARSE_H__
+#ifndef __LIBCLI_SMB_REPARSE_H__
+#define __LIBCLI_SMB_REPARSE_H__
 
 #include <talloc.h>
 #include "replace.h"
diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c
index c3df2278618..d3a70cce85f 100644
--- a/libcli/smb/smbXcli_base.c
+++ b/libcli/smb/smbXcli_base.c
@@ -5595,7 +5595,10 @@ NTSTATUS smbXcli_negprot_recv(
 NTSTATUS smbXcli_negprot(struct smbXcli_conn *conn,
 			 uint32_t timeout_msec,
 			 enum protocol_types min_protocol,
-			 enum protocol_types max_protocol)
+			 enum protocol_types max_protocol,
+			 struct smb2_negotiate_contexts *in_ctx,
+			 TALLOC_CTX *mem_ctx,
+			 struct smb2_negotiate_contexts **out_ctx)
 {
 	TALLOC_CTX *frame = talloc_stackframe();
 	struct tevent_context *ev;
@@ -5622,7 +5625,7 @@ NTSTATUS smbXcli_negprot(struct smbXcli_conn *conn,
 		min_protocol,
 		max_protocol,
 		WINDOWS_CLIENT_PURE_SMB2_NEGPROT_INITIAL_CREDIT_ASK,
-		NULL);
+		in_ctx);
 	if (req == NULL) {
 		goto fail;
 	}
@@ -5630,7 +5633,7 @@ NTSTATUS smbXcli_negprot(struct smbXcli_conn *conn,
 	if (!ok) {
 		goto fail;
 	}
-	status = smbXcli_negprot_recv(req, NULL, NULL);
+	status = smbXcli_negprot_recv(req, mem_ctx, out_ctx);
  fail:
 	TALLOC_FREE(frame);
 	return status;
diff --git a/libcli/smb/smbXcli_base.h b/libcli/smb/smbXcli_base.h
index fef68b6b38d..f582cc9964c 100644
--- a/libcli/smb/smbXcli_base.h
+++ b/libcli/smb/smbXcli_base.h
@@ -481,7 +481,10 @@ NTSTATUS smbXcli_negprot_recv(
 NTSTATUS smbXcli_negprot(struct smbXcli_conn *conn,
 			 uint32_t timeout_msec,
 			 enum protocol_types min_protocol,
-			 enum protocol_types max_protocol);
+			 enum protocol_types max_protocol,
+			 struct smb2_negotiate_contexts *in_ctx,
+			 TALLOC_CTX *mem_ctx,
+			 struct smb2_negotiate_contexts **out_ctx);
 
 struct tevent_req *smb2cli_validate_negotiate_info_send(TALLOC_CTX *mem_ctx,
 						struct tevent_context *ev,
diff --git a/source3/client/client.c b/source3/client/client.c
index 7831e54f5cb..f14e3f4130e 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -2282,11 +2282,12 @@ static int cmd_mput(void)
 
 static int do_cancel(int job)
 {
-	if (cli_printjob_del(cli, job)) {
+	NTSTATUS status = cli_printjob_del(cli, job);
+
+	if (NT_STATUS_IS_OK(status)) {
 		d_printf("Job %d cancelled\n",job);
 		return 0;
 	} else {
-		NTSTATUS status = cli_nt_error(cli);
 		d_printf("Error cancelling job %d : %s\n",
 			 job, nt_errstr(status));
 		return 1;
@@ -3179,62 +3180,36 @@ static int cmd_posix(void)
 	d_printf("Server supports CIFS extensions %u.%u\n", (unsigned int)major, (unsigned int)minor);
 
 	caps = talloc_strdup(ctx, "");
-	if (!caps) {
-		return 1;
-	}
-        if (caplow & CIFS_UNIX_FCNTL_LOCKS_CAP) {
-		caps = talloc_asprintf_append(caps, "locks ");
-		if (!caps) {
-			return 1;
-		}
+	if (caplow & CIFS_UNIX_FCNTL_LOCKS_CAP) {
+		talloc_asprintf_addbuf(&caps, "locks ");
 	}
         if (caplow & CIFS_UNIX_POSIX_ACLS_CAP) {
-		caps = talloc_asprintf_append(caps, "acls ");
-		if (!caps) {
-			return 1;
-		}
+		talloc_asprintf_addbuf(&caps, "acls ");
 	}
         if (caplow & CIFS_UNIX_XATTTR_CAP) {
-		caps = talloc_asprintf_append(caps, "eas ");
-		if (!caps) {
-			return 1;
-		}
+		talloc_asprintf_addbuf(&caps, "eas ");
 	}
         if (caplow & CIFS_UNIX_POSIX_PATHNAMES_CAP) {
-		caps = talloc_asprintf_append(caps, "pathnames ");
-		if (!caps) {
-			return 1;
-		}
+		talloc_asprintf_addbuf(&caps, "pathnames ");
 	}
         if (caplow & CIFS_UNIX_POSIX_PATH_OPERATIONS_CAP) {
-		caps = talloc_asprintf_append(caps, "posix_path_operations ");
-		if (!caps) {
-			return 1;
-		}
+		talloc_asprintf_addbuf(&caps, "posix_path_operations ");
 	}
         if (caplow & CIFS_UNIX_LARGE_READ_CAP) {
-		caps = talloc_asprintf_append(caps, "large_read ");
-		if (!caps) {
-			return 1;
-		}
+		talloc_asprintf_addbuf(&caps, "large_read ");
 	}
         if (caplow & CIFS_UNIX_LARGE_WRITE_CAP) {
-		caps = talloc_asprintf_append(caps, "large_write ");
-		if (!caps) {
-			return 1;
-		}
+		talloc_asprintf_addbuf(&caps, "large_write ");
 	}
 	if (caplow & CIFS_UNIX_TRANSPORT_ENCRYPTION_CAP) {
-		caps = talloc_asprintf_append(caps, "posix_encrypt ");
-		if (!caps) {
-			return 1;
-		}
+		talloc_asprintf_addbuf(&caps, "posix_encrypt ");
 	}
 	if (caplow & CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP) {
-		caps = talloc_asprintf_append(caps, "mandatory_posix_encrypt ");
-		if (!caps) {
-			return 1;
-		}
+		talloc_asprintf_addbuf(&caps, "mandatory_posix_encrypt ");
+	}
+
+	if (caps == NULL) {
+		return 1;
 	}
 
 	if (*caps && caps[strlen(caps)-1] == ' ') {
diff --git a/source3/include/libsmb_internal.h b/source3/include/libsmb_internal.h
index 6ca265ad38a..e30bfeb6690 100644
--- a/source3/include/libsmb_internal.h
+++ b/source3/include/libsmb_internal.h
@@ -32,8 +32,6 @@
 #include "libsmb/clirap.h"
 
 #define SMBC_MAX_NAME  1023
-#define SMBC_FILE_MODE (S_IFREG | 0444)
-#define SMBC_DIR_MODE  (S_IFDIR | 0555)
 
 /*
  * DOS Attribute values (used internally)
@@ -431,11 +429,6 @@ SMBC_ftruncate_ctx(SMBCCTX *context,
 /* Functions in libsmb_misc.c */
 bool SMBC_dlist_contains(SMBCFILE * list, SMBCFILE *p);
 
-int
-SMBC_errno(SMBCCTX *context,
-           struct cli_state *c);
-
-
 /* Functions in libsmb_path.c */
 int
 SMBC_parse_path(TALLOC_CTX *ctx,
diff --git a/source3/include/proto.h b/source3/include/proto.h
index bf6797514e3..5dd35c3c0df 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -578,16 +578,6 @@ bool wins_server_tag_ips(const char *tag, TALLOC_CTX *mem_ctx,
 			 struct in_addr **pservers, size_t *pnum_servers);
 unsigned wins_srv_count_tag(const char *tag);
 
-#ifndef ASN1_MAX_OIDS
-#define ASN1_MAX_OIDS 20
-#endif
-bool spnego_parse_negTokenInit(TALLOC_CTX *ctx,
-			       DATA_BLOB blob,
-			       char *OIDs[ASN1_MAX_OIDS],
-			       char **principal,
-			       DATA_BLOB *secblob);
-DATA_BLOB spnego_gen_krb5_wrap(TALLOC_CTX *ctx, const DATA_BLOB ticket, const uint8_t tok_id[2]);
-
 /* The following definitions come from libsmb/conncache.c  */
 
 NTSTATUS check_negative_conn_cache( const char *domain, const char *server);
diff --git a/source3/libads/authdata.c b/source3/libads/authdata.c
index 4f58644f3ba..10adc3ee8a9 100644
--- a/source3/libads/authdata.c
+++ b/source3/libads/authdata.c
@@ -32,6 +32,7 @@
 #include "auth/gensec/gensec.h"
 #include "auth/gensec/gensec_internal.h" /* TODO: remove this */
 #include "../libcli/auth/spnego.h"
+#include "lib/util/asn1.h"
 
 #ifdef HAVE_KRB5
 
@@ -39,6 +40,48 @@
 
 struct smb_krb5_context;
 
+/*
+  generate a krb5 GSS-API wrapper packet given a ticket
+*/
+static DATA_BLOB spnego_gen_krb5_wrap(
+	TALLOC_CTX *ctx, const DATA_BLOB ticket, const uint8_t tok_id[2])
+{
+	ASN1_DATA *data;
+	DATA_BLOB ret = data_blob_null;
+
+	data = asn1_init(talloc_tos(), ASN1_MAX_TREE_DEPTH);
+	if (data == NULL) {
+		return data_blob_null;
+	}
+
+	if (!asn1_push_tag(data, ASN1_APPLICATION(0))) goto err;
+	if (!asn1_write_OID(data, OID_KERBEROS5)) goto err;
+
+	if (!asn1_write(data, tok_id, 2)) goto err;
+	if (!asn1_write(data, ticket.data, ticket.length)) goto err;
+	if (!asn1_pop_tag(data)) goto err;
+
+	if (!asn1_extract_blob(data, ctx, &ret)) {
+		goto err;
+	}
+
+	asn1_free(data);
+	data = NULL;
+
+  err:
+
+	if (data != NULL) {
+		if (asn1_has_error(data)) {
+			DEBUG(1, ("Failed to build krb5 wrapper at offset %d\n",
+				  (int)asn1_current_ofs(data)));
+		}
+
+		asn1_free(data);
+	}
+
+	return ret;
+}
+
 /*
  * Given the username/password, do a kinit, store the ticket in
  * cache_name if specified, and return the PAC_LOGON_INFO (the
diff --git a/source3/libads/sasl.c b/source3/libads/sasl.c
index 1bcfe0490a8..5ae8b999e66 100644
--- a/source3/libads/sasl.c
+++ b/source3/libads/sasl.c
@@ -27,6 +27,7 @@
 #include "system/gssapi.h"
 #include "lib/param/loadparm.h"
 #include "krb5_env.h"
+#include "lib/util/asn1.h"
 
 #ifdef HAVE_LDAP
 
@@ -496,6 +497,144 @@ static ADS_STATUS ads_generate_service_principal(ADS_STRUCT *ads,
 
 #endif /* HAVE_KRB5 */
 
+/*
+  parse a negTokenInit packet giving a GUID, a list of supported
+  OIDs (the mechanisms) and a principal name string
+*/
+static bool spnego_parse_negTokenInit(TALLOC_CTX *ctx,
+				      DATA_BLOB blob,
+				      char *OIDs[ASN1_MAX_OIDS],
+				      char **principal,
+				      DATA_BLOB *secblob)
+{
+	int i;
+	bool ret = false;
+	ASN1_DATA *data;
+
+	for (i = 0; i < ASN1_MAX_OIDS; i++) {


-- 
Samba Shared Repository



More information about the samba-cvs mailing list