[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Tue Aug 21 01:04:03 MDT 2012


The branch, master has been updated
       via  a817959 build: Create bin/ when doing 'waf dist' from a fresh checkout
       via  dc063bf s3-pysmbd: Add get/set functions for the posix ACL layer
       via  4df2c65 s3-pysmbd: Correct comments in python VFS bindings
       via  02e25b2 s3-passdb: Allow pdb_sid_to_id to work on any SID
       via  d963aaf s3-pysmbd: Add hook for a VFS chown()
      from  4d5471f build: Remove special case for the build farm

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


- Log -----------------------------------------------------------------
commit a81795974ca838f48f8c323bc7563c56795e6bdd
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Aug 21 15:22:25 2012 +1000

    build: Create bin/ when doing 'waf dist' from a fresh checkout
    
    As suggested by Amitay.
    
    Andrew Bartlett
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Tue Aug 21 09:03:02 CEST 2012 on sn-devel-104

commit dc063bf3bdf06aff1582c5c8784a8e0d5b06d378
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Aug 21 15:11:30 2012 +1000

    s3-pysmbd: Add get/set functions for the posix ACL layer
    
    These will be used to verify that an ACL set as an NT ACL creates
    the correct posix ACL.
    
    Andrew Bartlett

commit 4df2c65ea637618971c406f05e68a93feb44c70c
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Aug 21 15:10:43 2012 +1000

    s3-pysmbd: Correct comments in python VFS bindings

commit 02e25b2a43ae02205a3412f862a1482d24b70aa4
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Aug 21 14:56:45 2012 +1000

    s3-passdb: Allow pdb_sid_to_id to work on any SID
    
    This is needed so that pdb_samba4 can map any SID during a provision.
    
    At runtime, winbindd will be asked first, but this shortcut direct to the
    ldb file makes it possible to set the permissions on the sysvol share at
    provision time.
    
    Andrew Bartlett

commit d963aaf73be22b0a027b3636c6c51292412b5931
Author: Andrew Bartlett <abartlet at samba.org>
Date:   Tue Aug 21 14:23:35 2012 +1000

    s3-pysmbd: Add hook for a VFS chown()

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

Summary of changes:
 source3/passdb/lookup_sid.c    |   22 +++----
 source3/passdb/pdb_interface.c |    5 ++
 source3/passdb/pdb_ldap.c      |    5 ++
 source3/smbd/pysmbd.c          |  146 +++++++++++++++++++++++++++++++++++++++-
 wscript                        |    1 +
 5 files changed, 164 insertions(+), 15 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/passdb/lookup_sid.c b/source3/passdb/lookup_sid.c
index a2d793f..26ce41c 100644
--- a/source3/passdb/lookup_sid.c
+++ b/source3/passdb/lookup_sid.c
@@ -1084,20 +1084,16 @@ static void legacy_gid_to_sid(struct dom_sid *psid, gid_t gid)
 static bool legacy_sid_to_unixid(const struct dom_sid *psid, struct unixid *id)
 {
 	GROUP_MAP *map;
-	if (sid_check_is_in_our_sam(psid)) {
-		bool ret;
-
-		become_root();
-		ret = pdb_sid_to_id(psid, id);
-		unbecome_root();
-
-		if (ret) {
-			goto done;
-		}
-
-		/* This was ours, but it was not mapped.  Fail */
+	bool ret;
+	
+	become_root();
+	ret = pdb_sid_to_id(psid, id);
+	unbecome_root();
+	
+	if (ret) {
+		goto done;
 	}
-
+	
 	if ((sid_check_is_in_builtin(psid) ||
 	     sid_check_is_in_wellknown_domain(psid))) {
 		bool ret;
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c
index cdbb378..d24301a 100644
--- a/source3/passdb/pdb_interface.c
+++ b/source3/passdb/pdb_interface.c
@@ -1429,6 +1429,11 @@ static bool pdb_default_sid_to_id(struct pdb_methods *methods,
 	uint32_t rid;
 	id->id = -1;
 
+	if (!sid_check_is_in_our_sam(sid)) {
+		/* Not our SID */
+		return False;
+	}
+
 	mem_ctx = talloc_new(NULL);
 
 	if (mem_ctx == NULL) {
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c
index 9b4d8a6..ffd5743 100644
--- a/source3/passdb/pdb_ldap.c
+++ b/source3/passdb/pdb_ldap.c
@@ -4938,6 +4938,11 @@ static bool ldapsam_sid_to_id(struct pdb_methods *methods,
 
 	TALLOC_CTX *mem_ctx;
 
+	if (!sid_check_is_in_our_sam(sid)) {
+		/* Not our SID */
+		return False;
+	}
+
 	mem_ctx = talloc_new(NULL);
 	if (mem_ctx == NULL) {
 		DEBUG(0, ("talloc_new failed\n"));
diff --git a/source3/smbd/pysmbd.c b/source3/smbd/pysmbd.c
index 0004887..8fca4e7 100644
--- a/source3/smbd/pysmbd.c
+++ b/source3/smbd/pysmbd.c
@@ -274,6 +274,56 @@ static PyObject *py_smbd_set_simple_acl(PyObject *self, PyObject *args)
 }
 
 /*
+  chown a file
+ */
+static PyObject *py_smbd_chown(PyObject *self, PyObject *args)
+{
+	connection_struct *conn;
+	NTSTATUS status = NT_STATUS_OK;
+	int ret;
+
+	char *fname;
+	int uid, gid;
+	TALLOC_CTX *frame;
+
+	if (!PyArg_ParseTuple(args, "sii", &fname, &uid, &gid))
+		return NULL;
+
+	frame = talloc_stackframe();
+
+	conn = talloc_zero(frame, connection_struct);
+	if (conn == NULL) {
+		PyErr_NoMemory();
+		return NULL;
+	}
+
+	if (!(conn->params = talloc(conn, struct share_params))) {
+		PyErr_NoMemory();
+		return NULL;
+	}
+
+	conn->params->service = -1;
+
+	set_conn_connectpath(conn, "/");
+
+	smbd_vfs_init(conn);
+
+	ret = SMB_VFS_CHOWN( conn, fname, uid, gid);
+	if (ret != 0) {
+		status = map_nt_error_from_unix_common(ret);
+		DEBUG(0,("chwon returned failure: %s\n", strerror(ret)));
+	}
+
+	conn_free(conn);
+
+	TALLOC_FREE(frame);
+
+	PyErr_NTSTATUS_IS_ERR_RAISE(status);
+
+	Py_RETURN_NONE;
+}
+
+/*
   check if we have ACL support
  */
 static PyObject *py_smbd_have_posix_acls(PyObject *self, PyObject *args)
@@ -286,7 +336,7 @@ static PyObject *py_smbd_have_posix_acls(PyObject *self, PyObject *args)
 }
 
 /*
-  set a simple ACL on a file, as a test
+  set the NT ACL on a file
  */
 static PyObject *py_smbd_set_nt_acl(PyObject *self, PyObject *args)
 {
@@ -312,7 +362,7 @@ static PyObject *py_smbd_set_nt_acl(PyObject *self, PyObject *args)
 }
 
 /*
-  set a simple ACL on a file, as a test
+  Return the NT ACL on a file
  */
 static PyObject *py_smbd_get_nt_acl(PyObject *self, PyObject *args)
 {
@@ -334,6 +384,89 @@ static PyObject *py_smbd_get_nt_acl(PyObject *self, PyObject *args)
 	return py_sd;
 }
 
+/*
+  set the posix (or similar) ACL on a file
+ */
+static PyObject *py_smbd_set_sys_acl(PyObject *self, PyObject *args)
+{
+	NTSTATUS status;
+	char *fname;
+	PyObject *py_acl;
+	struct smb_acl_t *acl;
+	int acl_type;
+
+	if (!PyArg_ParseTuple(args, "siO", &fname, &acl_type, &py_acl))
+		return NULL;
+
+	if (!py_check_dcerpc_type(py_acl, "samba.dcerpc.smb_acl", "sys_acl_t")) {
+		return NULL;
+	}
+
+	acl = pytalloc_get_type(py_acl, struct smb_acl_t);
+
+	status = set_sys_acl_no_snum(fname, acl_type, acl);
+	PyErr_NTSTATUS_IS_ERR_RAISE(status);
+
+	Py_RETURN_NONE;
+}
+
+/*
+  Return the posix (or similar) ACL on a file
+ */
+static PyObject *py_smbd_get_sys_acl(PyObject *self, PyObject *args)
+{
+	char *fname;
+	PyObject *py_acl;
+	struct smb_acl_t *acl;
+	int acl_type;
+	TALLOC_CTX *frame = talloc_stackframe();
+	connection_struct *conn;
+	NTSTATUS status = NT_STATUS_OK;
+
+	if (!PyArg_ParseTuple(args, "si", &fname, &acl_type)) {
+		TALLOC_FREE(frame);
+		return NULL;
+	}
+
+	conn = talloc_zero(frame, connection_struct);
+	if (conn == NULL) {
+		DEBUG(0, ("talloc failed\n"));
+		PyErr_NoMemory();
+		TALLOC_FREE(frame);
+		return NULL;
+	}
+
+	if (!(conn->params = talloc(conn, struct share_params))) {
+		DEBUG(0,("get_nt_acl_no_snum: talloc() failed!\n"));
+		PyErr_NoMemory();
+		TALLOC_FREE(frame);
+		return NULL;
+	}
+
+	conn->params->service = -1;
+
+	set_conn_connectpath(conn, "/");
+
+	smbd_vfs_init(conn);
+
+	acl = SMB_VFS_SYS_ACL_GET_FILE( conn, fname, acl_type);
+	if (!acl) {
+		TALLOC_FREE(frame);
+		status = map_nt_error_from_unix_common(errno);
+		DEBUG(0,("sys_acl_get_file returned NULL: %s\n", strerror(errno)));
+		PyErr_NTSTATUS_IS_ERR_RAISE(status);
+	}
+
+	talloc_steal(frame, acl);
+	conn_free(conn);
+
+	py_acl = py_return_ndr_struct("samba.dcerpc.smb_acl", "sys_acl_t", acl, acl);
+
+	TALLOC_FREE(frame);
+
+	return py_acl;
+}
+
 static PyMethodDef py_smbd_methods[] = {
 	{ "have_posix_acls",
 		(PyCFunction)py_smbd_have_posix_acls, METH_VARARGS,
@@ -347,6 +480,15 @@ static PyMethodDef py_smbd_methods[] = {
 	{ "get_nt_acl",
 		(PyCFunction)py_smbd_get_nt_acl, METH_VARARGS,
 		NULL },
+	{ "get_sys_acl",
+		(PyCFunction)py_smbd_get_sys_acl, METH_VARARGS,
+		NULL },
+	{ "set_sys_acl",
+		(PyCFunction)py_smbd_set_sys_acl, METH_VARARGS,
+		NULL },
+	{ "chown",
+		(PyCFunction)py_smbd_chown, METH_VARARGS,
+		NULL },
 	{ NULL }
 };
 
diff --git a/wscript b/wscript
index 3667a8d..fcf4a0f 100755
--- a/wscript
+++ b/wscript
@@ -239,6 +239,7 @@ def dist():
 
     if sambaversion.IS_SNAPSHOT:
         # write .distversion file and add to tar
+        os.makedirs(blddir)
         distversionf = tempfile.NamedTemporaryFile(mode='w', prefix='.distversion',dir=blddir)
         for field in sambaversion.vcs_fields:
             distveroption = field + '=' + str(sambaversion.vcs_fields[field])


-- 
Samba Shared Repository


More information about the samba-cvs mailing list