s3/smbd: update some more DEBUG macros in smbd_smb2_create_send
[nivanova/samba-autobuild/.git] / source3 / smbd / pysmbd.c
index df8d0799929178d118af0272eb659c65b32b3dd0..63fc5d68c33ff525e27d425cda983cdc4be0fb6a 100644 (file)
@@ -81,6 +81,7 @@ static int set_sys_acl_conn(const char *fname,
                                 SMB_ACL_T theacl, connection_struct *conn)
 {
        int ret;
+       struct smb_filename *smb_fname = NULL;
        mode_t saved_umask;
 
        TALLOC_CTX *frame = talloc_stackframe();
@@ -89,7 +90,16 @@ static int set_sys_acl_conn(const char *fname,
           so set our umask to 0 */
        saved_umask = umask(0);
 
-       ret = SMB_VFS_SYS_ACL_SET_FILE( conn, fname, acltype, theacl);
+       smb_fname = synthetic_smb_fname_split(frame,
+                                       fname,
+                                       lp_posix_pathnames());
+       if (smb_fname == NULL) {
+               TALLOC_FREE(frame);
+               umask(saved_umask);
+               return -1;
+       }
+
+       ret = SMB_VFS_SYS_ACL_SET_FILE( conn, smb_fname, acltype, theacl);
 
        umask(saved_umask);
 
@@ -124,7 +134,9 @@ static NTSTATUS set_nt_acl_conn(const char *fname,
           so set our umask to 0 */
        saved_umask = umask(0);
 
-       smb_fname = synthetic_smb_fname_split(fsp, fname, NULL);
+       smb_fname = synthetic_smb_fname_split(fsp,
+                                       fname,
+                                       lp_posix_pathnames());
        if (smb_fname == NULL) {
                TALLOC_FREE(frame);
                umask(saved_umask);
@@ -195,8 +207,24 @@ static NTSTATUS get_nt_acl_conn(TALLOC_CTX *mem_ctx,
                                struct security_descriptor **sd)
 {
        TALLOC_CTX *frame = talloc_stackframe();
-       NTSTATUS status = SMB_VFS_GET_NT_ACL( conn, fname, security_info_wanted,
-                                    mem_ctx, sd);
+       NTSTATUS status;
+       struct smb_filename *smb_fname = synthetic_smb_fname(talloc_tos(),
+                                       fname,
+                                       NULL,
+                                       NULL,
+                                       lp_posix_pathnames() ?
+                                               SMB_FILENAME_POSIX_PATH : 0);
+
+       if (smb_fname == NULL) {
+               TALLOC_FREE(frame);
+               return NT_STATUS_NO_MEMORY;
+       }
+
+       status = SMB_VFS_GET_NT_ACL(conn,
+                               smb_fname,
+                               security_info_wanted,
+                               mem_ctx,
+                               sd);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(0,("get_nt_acl_conn: get_nt_acl returned %s.\n", nt_errstr(status)));
        }
@@ -361,6 +389,7 @@ static PyObject *py_smbd_chown(PyObject *self, PyObject *args, PyObject *kwargs)
        int uid, gid;
        TALLOC_CTX *frame;
        mode_t saved_umask;
+       struct smb_filename *smb_fname = NULL;
 
        if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sii|z",
                                         discard_const_p(char *, kwnames),
@@ -378,7 +407,20 @@ static PyObject *py_smbd_chown(PyObject *self, PyObject *args, PyObject *kwargs)
           so set our umask to 0 */
        saved_umask = umask(0);
 
-       ret = SMB_VFS_CHOWN( conn, fname, uid, gid);
+       smb_fname = synthetic_smb_fname(talloc_tos(),
+                                       fname,
+                                       NULL,
+                                       NULL,
+                                       lp_posix_pathnames() ?
+                                               SMB_FILENAME_POSIX_PATH : 0);
+       if (smb_fname == NULL) {
+               umask(saved_umask);
+               TALLOC_FREE(frame);
+               errno = ENOMEM;
+               return PyErr_SetFromErrno(PyExc_OSError);
+       }
+
+       ret = SMB_VFS_CHOWN(conn, smb_fname, uid, gid);
        if (ret != 0) {
                umask(saved_umask);
                TALLOC_FREE(frame);
@@ -420,7 +462,9 @@ static PyObject *py_smbd_unlink(PyObject *self, PyObject *args, PyObject *kwargs
                return NULL;
        }
 
-       smb_fname = synthetic_smb_fname_split(frame, fname, NULL);
+       smb_fname = synthetic_smb_fname_split(frame,
+                                       fname,
+                                       lp_posix_pathnames());
        if (smb_fname == NULL) {
                TALLOC_FREE(frame);
                return PyErr_NoMemory();
@@ -588,6 +632,8 @@ static PyObject *py_smbd_get_sys_acl(PyObject *self, PyObject *args, PyObject *k
        TALLOC_CTX *tmp_ctx = talloc_new(NULL);
        connection_struct *conn;
        char *service = NULL;
+       struct smb_filename *smb_fname = NULL;
+
        if (!tmp_ctx) {
                PyErr_NoMemory();
                return NULL;
@@ -608,7 +654,15 @@ static PyObject *py_smbd_get_sys_acl(PyObject *self, PyObject *args, PyObject *k
                return NULL;
        }
 
-       acl = SMB_VFS_SYS_ACL_GET_FILE( conn, fname, acl_type, tmp_ctx);
+       smb_fname = synthetic_smb_fname_split(frame,
+                                       fname,
+                                       lp_posix_pathnames());
+       if (smb_fname == NULL) {
+               TALLOC_FREE(frame);
+               TALLOC_FREE(tmp_ctx);
+               return NULL;
+       }
+       acl = SMB_VFS_SYS_ACL_GET_FILE( conn, smb_fname, acl_type, tmp_ctx);
        if (!acl) {
                TALLOC_FREE(frame);
                TALLOC_FREE(tmp_ctx);