s3-vfs: Add pread_send/recv to vfs modules
[kai/samba.git] / source3 / modules / vfs_cap.c
index e26d29d6673c6a42d813755370c3b521dc89077f..2454e12b6fa662fc970b1071ea507b5631545b7e 100644 (file)
@@ -23,6 +23,7 @@
 
 
 #include "includes.h"
+#include "smbd/smbd.h"
 
 /* cap functions */
 static char *capencode(TALLOC_CTX *ctx, const char *from);
@@ -42,7 +43,7 @@ static uint64_t cap_disk_free(vfs_handle_struct *handle, const char *path,
                                        dfree, dsize);
 }
 
-static SMB_STRUCT_DIR *cap_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32 attr)
+static DIR *cap_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32 attr)
 {
        char *capname = capencode(talloc_tos(), fname);
 
@@ -53,10 +54,12 @@ static SMB_STRUCT_DIR *cap_opendir(vfs_handle_struct *handle, const char *fname,
        return SMB_VFS_NEXT_OPENDIR(handle, capname, mask, attr);
 }
 
-static SMB_STRUCT_DIRENT *cap_readdir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp)
+static struct dirent *cap_readdir(vfs_handle_struct *handle,
+                                     DIR *dirp,
+                                     SMB_STRUCT_STAT *sbuf)
 {
-       SMB_STRUCT_DIRENT *result;
-       SMB_STRUCT_DIRENT *newdirent;
+       struct dirent *result;
+       struct dirent *newdirent;
        char *newname;
        size_t newnamelen;
        DEBUG(3,("cap: cap_readdir\n"));
@@ -72,14 +75,14 @@ static SMB_STRUCT_DIRENT *cap_readdir(vfs_handle_struct *handle, SMB_STRUCT_DIR
        }
        DEBUG(3,("cap: cap_readdir: %s\n", newname));
        newnamelen = strlen(newname)+1;
-       newdirent = (SMB_STRUCT_DIRENT *)TALLOC_ARRAY(talloc_tos(),
+       newdirent = (struct dirent *)talloc_array(talloc_tos(),
                        char,
-                       sizeof(SMB_STRUCT_DIRENT)+
+                       sizeof(struct dirent)+
                                newnamelen);
        if (!newdirent) {
                return NULL;
        }
-       memcpy(newdirent, result, sizeof(SMB_STRUCT_DIRENT));
+       memcpy(newdirent, result, sizeof(struct dirent));
        memcpy(&newdirent->d_name, newname, newnamelen);
        return newdirent;
 }
@@ -106,61 +109,154 @@ static int cap_rmdir(vfs_handle_struct *handle, const char *path)
        return SMB_VFS_NEXT_RMDIR(handle, cappath);
 }
 
-static int cap_open(vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode)
+static int cap_open(vfs_handle_struct *handle, struct smb_filename *smb_fname,
+                   files_struct *fsp, int flags, mode_t mode)
 {
-       char *cappath = capencode(talloc_tos(), fname);
+       char *cappath;
+       char *tmp_base_name = NULL;
+       int ret;
+
+       cappath = capencode(talloc_tos(), smb_fname->base_name);
 
        if (!cappath) {
                errno = ENOMEM;
                return -1;
        }
-       DEBUG(3,("cap: cap_open for %s\n", fname));
-       return SMB_VFS_NEXT_OPEN(handle, cappath, fsp, flags, mode);
+
+       tmp_base_name = smb_fname->base_name;
+       smb_fname->base_name = cappath;
+
+       DEBUG(3,("cap: cap_open for %s\n", smb_fname_str_dbg(smb_fname)));
+       ret = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
+
+       smb_fname->base_name = tmp_base_name;
+       TALLOC_FREE(cappath);
+
+       return ret;
 }
 
-static int cap_rename(vfs_handle_struct *handle, const char *oldname, const char *newname)
+static int cap_rename(vfs_handle_struct *handle,
+                     const struct smb_filename *smb_fname_src,
+                     const struct smb_filename *smb_fname_dst)
 {
-       char *capold = capencode(talloc_tos(), oldname);
-       char *capnew = capencode(talloc_tos(), newname);
+       char *capold = NULL;
+       char *capnew = NULL;
+       struct smb_filename *smb_fname_src_tmp = NULL;
+       struct smb_filename *smb_fname_dst_tmp = NULL;
+       NTSTATUS status;
+       int ret = -1;
 
+       capold = capencode(talloc_tos(), smb_fname_src->base_name);
+       capnew = capencode(talloc_tos(), smb_fname_dst->base_name);
        if (!capold || !capnew) {
                errno = ENOMEM;
-               return -1;
+               goto out;
        }
-       return SMB_VFS_NEXT_RENAME(handle, capold, capnew);
+
+       /* Setup temporary smb_filename structs. */
+       status = copy_smb_filename(talloc_tos(), smb_fname_src,
+                                  &smb_fname_src_tmp);
+       if (!NT_STATUS_IS_OK(status)) {
+               errno = map_errno_from_nt_status(status);
+               goto out;
+       }
+       status = copy_smb_filename(talloc_tos(), smb_fname_dst,
+                                  &smb_fname_dst_tmp);
+       if (!NT_STATUS_IS_OK(status)) {
+               errno = map_errno_from_nt_status(status);
+               goto out;
+       }
+
+       smb_fname_src_tmp->base_name = capold;
+       smb_fname_dst_tmp->base_name = capnew;
+
+       ret = SMB_VFS_NEXT_RENAME(handle, smb_fname_src_tmp,
+                                 smb_fname_dst_tmp);
+ out:
+       TALLOC_FREE(capold);
+       TALLOC_FREE(capnew);
+       TALLOC_FREE(smb_fname_src_tmp);
+       TALLOC_FREE(smb_fname_dst_tmp);
+
+       return ret;
 }
 
-static int cap_stat(vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf)
+static int cap_stat(vfs_handle_struct *handle, struct smb_filename *smb_fname)
 {
-       char *cappath = capencode(talloc_tos(), path);
+       char *cappath;
+       char *tmp_base_name = NULL;
+       int ret;
+
+       cappath = capencode(talloc_tos(), smb_fname->base_name);
 
        if (!cappath) {
                errno = ENOMEM;
                return -1;
        }
-       return SMB_VFS_NEXT_STAT(handle, cappath, sbuf);
+
+       tmp_base_name = smb_fname->base_name;
+       smb_fname->base_name = cappath;
+
+       ret = SMB_VFS_NEXT_STAT(handle, smb_fname);
+
+       smb_fname->base_name = tmp_base_name;
+       TALLOC_FREE(cappath);
+
+       return ret;
 }
 
-static int cap_lstat(vfs_handle_struct *handle, const char *path, SMB_STRUCT_STAT *sbuf)
+static int cap_lstat(vfs_handle_struct *handle, struct smb_filename *smb_fname)
 {
-       char *cappath = capencode(talloc_tos(), path);
+       char *cappath;
+       char *tmp_base_name = NULL;
+       int ret;
+
+       cappath = capencode(talloc_tos(), smb_fname->base_name);
 
        if (!cappath) {
                errno = ENOMEM;
                return -1;
        }
-       return SMB_VFS_NEXT_LSTAT(handle, cappath, sbuf);
+
+       tmp_base_name = smb_fname->base_name;
+       smb_fname->base_name = cappath;
+
+       ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
+
+       smb_fname->base_name = tmp_base_name;
+       TALLOC_FREE(cappath);
+
+       return ret;
 }
 
-static int cap_unlink(vfs_handle_struct *handle, const char *path)
+static int cap_unlink(vfs_handle_struct *handle,
+                     const struct smb_filename *smb_fname)
 {
-       char *cappath = capencode(talloc_tos(), path);
+       struct smb_filename *smb_fname_tmp = NULL;
+       char *cappath = NULL;
+       NTSTATUS status;
+       int ret;
 
+       cappath = capencode(talloc_tos(), smb_fname->base_name);
        if (!cappath) {
                errno = ENOMEM;
                return -1;
        }
-       return SMB_VFS_NEXT_UNLINK(handle, cappath);
+
+       /* Setup temporary smb_filename structs. */
+       status = copy_smb_filename(talloc_tos(), smb_fname,
+                                  &smb_fname_tmp);
+       if (!NT_STATUS_IS_OK(status)) {
+               errno = map_errno_from_nt_status(status);
+               return -1;
+       }
+
+       smb_fname_tmp->base_name = cappath;
+
+       ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname_tmp);
+
+       TALLOC_FREE(smb_fname_tmp);
+       return ret;
 }
 
 static int cap_chmod(vfs_handle_struct *handle, const char *path, mode_t mode)
@@ -208,20 +304,41 @@ static int cap_chdir(vfs_handle_struct *handle, const char *path)
        return SMB_VFS_NEXT_CHDIR(handle, cappath);
 }
 
-static int cap_ntimes(vfs_handle_struct *handle, const char *path,
+static int cap_ntimes(vfs_handle_struct *handle,
+                     const struct smb_filename *smb_fname,
                      struct smb_file_time *ft)
 {
-       char *cappath = capencode(talloc_tos(), path);
+       struct smb_filename *smb_fname_tmp = NULL;
+       char *cappath = NULL;
+       NTSTATUS status;
+       int ret;
+
+       cappath = capencode(talloc_tos(), smb_fname->base_name);
 
        if (!cappath) {
                errno = ENOMEM;
                return -1;
        }
-       return SMB_VFS_NEXT_NTIMES(handle, cappath, ft);
+
+       /* Setup temporary smb_filename structs. */
+       status = copy_smb_filename(talloc_tos(), smb_fname,
+                                  &smb_fname_tmp);
+       if (!NT_STATUS_IS_OK(status)) {
+               errno = map_errno_from_nt_status(status);
+               return -1;
+       }
+
+       smb_fname_tmp->base_name = cappath;
+
+       ret = SMB_VFS_NEXT_NTIMES(handle, smb_fname_tmp, ft);
+
+       TALLOC_FREE(smb_fname_tmp);
+       return ret;
 }
 
 
-static bool cap_symlink(vfs_handle_struct *handle, const char *oldpath, const char *newpath)
+static int cap_symlink(vfs_handle_struct *handle, const char *oldpath,
+                      const char *newpath)
 {
        char *capold = capencode(talloc_tos(), oldpath);
        char *capnew = capencode(talloc_tos(), newpath);
@@ -233,7 +350,8 @@ static bool cap_symlink(vfs_handle_struct *handle, const char *oldpath, const ch
        return SMB_VFS_NEXT_SYMLINK(handle, capold, capnew);
 }
 
-static bool cap_readlink(vfs_handle_struct *handle, const char *path, char *buf, size_t bufsiz)
+static int cap_readlink(vfs_handle_struct *handle, const char *path,
+                       char *buf, size_t bufsiz)
 {
        char *cappath = capencode(talloc_tos(), path);
 
@@ -267,7 +385,7 @@ static int cap_mknod(vfs_handle_struct *handle, const char *path, mode_t mode, S
        return SMB_VFS_NEXT_MKNOD(handle, cappath, mode, dev);
 }
 
-static char *cap_realpath(vfs_handle_struct *handle, const char *path, char *resolved_path)
+static char *cap_realpath(vfs_handle_struct *handle, const char *path)
 {
         /* monyo need capencode'ed and capdecode'ed? */
        char *cappath = capencode(talloc_tos(), path);
@@ -276,7 +394,7 @@ static char *cap_realpath(vfs_handle_struct *handle, const char *path, char *res
                errno = ENOMEM;
                return NULL;
        }
-       return SMB_VFS_NEXT_REALPATH(handle, path, resolved_path);
+       return SMB_VFS_NEXT_REALPATH(handle, cappath);
 }
 
 static int cap_chmod_acl(vfs_handle_struct *handle, const char *path, mode_t mode)
@@ -284,10 +402,6 @@ static int cap_chmod_acl(vfs_handle_struct *handle, const char *path, mode_t mod
        char *cappath = capencode(talloc_tos(), path);
 
        /* If the underlying VFS doesn't have ACL support... */
-       if (!handle->vfs_next.ops.chmod_acl) {
-               errno = ENOSYS;
-               return -1;
-       }
        if (!cappath) {
                errno = ENOMEM;
                return -1;
@@ -340,19 +454,6 @@ static ssize_t cap_getxattr(vfs_handle_struct *handle, const char *path, const c
         return SMB_VFS_NEXT_GETXATTR(handle, cappath, capname, value, size);
 }
 
-static ssize_t cap_lgetxattr(vfs_handle_struct *handle, const char *path, const char *name, void *value, size_t
-size)
-{
-       char *cappath = capencode(talloc_tos(), path);
-       char *capname = capencode(talloc_tos(), name);
-
-       if (!cappath || !capname) {
-               errno = ENOMEM;
-               return -1;
-       }
-        return SMB_VFS_NEXT_LGETXATTR(handle, cappath, capname, value, size);
-}
-
 static ssize_t cap_fgetxattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *path, void *value, size_t size)
 {
        char *cappath = capencode(talloc_tos(), path);
@@ -375,17 +476,6 @@ static ssize_t cap_listxattr(vfs_handle_struct *handle, const char *path, char *
         return SMB_VFS_NEXT_LISTXATTR(handle, cappath, list, size);
 }
 
-static ssize_t cap_llistxattr(vfs_handle_struct *handle, const char *path, char *list, size_t size)
-{
-       char *cappath = capencode(talloc_tos(), path);
-
-       if (!cappath) {
-               errno = ENOMEM;
-               return -1;
-       }
-        return SMB_VFS_NEXT_LLISTXATTR(handle, cappath, list, size);
-}
-
 static int cap_removexattr(vfs_handle_struct *handle, const char *path, const char *name)
 {
        char *cappath = capencode(talloc_tos(), path);
@@ -398,18 +488,6 @@ static int cap_removexattr(vfs_handle_struct *handle, const char *path, const ch
         return SMB_VFS_NEXT_REMOVEXATTR(handle, cappath, capname);
 }
 
-static int cap_lremovexattr(vfs_handle_struct *handle, const char *path, const char *name)
-{
-       char *cappath = capencode(talloc_tos(), path);
-       char *capname = capencode(talloc_tos(), name);
-
-       if (!cappath || !capname) {
-               errno = ENOMEM;
-               return -1;
-       }
-        return SMB_VFS_NEXT_LREMOVEXATTR(handle, cappath, capname);
-}
-
 static int cap_fremovexattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *path)
 {
        char *cappath = capencode(talloc_tos(), path);
@@ -433,18 +511,6 @@ static int cap_setxattr(vfs_handle_struct *handle, const char *path, const char
         return SMB_VFS_NEXT_SETXATTR(handle, cappath, capname, value, size, flags);
 }
 
-static int cap_lsetxattr(vfs_handle_struct *handle, const char *path, const char *name, const void *value, size_t size, int flags)
-{
-       char *cappath = capencode(talloc_tos(), path);
-       char *capname = capencode(talloc_tos(), name);
-
-       if (!cappath || !capname) {
-               errno = ENOMEM;
-               return -1;
-       }
-        return SMB_VFS_NEXT_LSETXATTR(handle, cappath, capname, value, size, flags);
-}
-
 static int cap_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp, const char *path, const void *value, size_t size, int flags)
 {
        char *cappath = capencode(talloc_tos(), path);
@@ -456,67 +522,45 @@ static int cap_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp, co
         return SMB_VFS_NEXT_FSETXATTR(handle, fsp, cappath, value, size, flags);
 }
 
-/* VFS operations structure */
-
-static vfs_op_tuple cap_op_tuples[] = {
-
-       /* Disk operations */
-
-       {SMB_VFS_OP(cap_disk_free),                     SMB_VFS_OP_DISK_FREE,           SMB_VFS_LAYER_TRANSPARENT},
-
-       /* Directory operations */
-
-       {SMB_VFS_OP(cap_opendir),                       SMB_VFS_OP_OPENDIR,             SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_readdir),                       SMB_VFS_OP_READDIR,             SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_mkdir),                 SMB_VFS_OP_MKDIR,               SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_rmdir),                 SMB_VFS_OP_RMDIR,               SMB_VFS_LAYER_TRANSPARENT},
-
-       /* File operations */
-
-       {SMB_VFS_OP(cap_open),                          SMB_VFS_OP_OPEN,                SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_rename),                        SMB_VFS_OP_RENAME,              SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_stat),                          SMB_VFS_OP_STAT,                SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_lstat),                 SMB_VFS_OP_LSTAT,               SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_unlink),                        SMB_VFS_OP_UNLINK,              SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_chmod),                 SMB_VFS_OP_CHMOD,               SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_chown),                 SMB_VFS_OP_CHOWN,               SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_lchown),                SMB_VFS_OP_LCHOWN,              SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_chdir),                 SMB_VFS_OP_CHDIR,               SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_ntimes),                        SMB_VFS_OP_NTIMES,              SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_symlink),                       SMB_VFS_OP_SYMLINK,             SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_readlink),                      SMB_VFS_OP_READLINK,            SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_link),                          SMB_VFS_OP_LINK,                SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_mknod),                 SMB_VFS_OP_MKNOD,               SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_realpath),                      SMB_VFS_OP_REALPATH,            SMB_VFS_LAYER_TRANSPARENT},
-
-       /* POSIX ACL operations */
-
-       {SMB_VFS_OP(cap_chmod_acl),                     SMB_VFS_OP_CHMOD_ACL,           SMB_VFS_LAYER_TRANSPARENT},
-
-       {SMB_VFS_OP(cap_sys_acl_get_file),              SMB_VFS_OP_SYS_ACL_GET_FILE,            SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_sys_acl_set_file),              SMB_VFS_OP_SYS_ACL_SET_FILE,            SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_sys_acl_delete_def_file),       SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,     SMB_VFS_LAYER_TRANSPARENT},
-
-       /* EA operations. */
-       {SMB_VFS_OP(cap_getxattr),                      SMB_VFS_OP_GETXATTR,                    SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_lgetxattr),                     SMB_VFS_OP_LGETXATTR,                   SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_fgetxattr),                     SMB_VFS_OP_FGETXATTR,                   SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_listxattr),                     SMB_VFS_OP_LISTXATTR,                   SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_llistxattr),                    SMB_VFS_OP_LLISTXATTR,                  SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_removexattr),                   SMB_VFS_OP_REMOVEXATTR,                 SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_lremovexattr),                  SMB_VFS_OP_LREMOVEXATTR,                SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_fremovexattr),                  SMB_VFS_OP_FREMOVEXATTR,                SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_setxattr),                      SMB_VFS_OP_SETXATTR,                    SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_lsetxattr),                     SMB_VFS_OP_LSETXATTR,                   SMB_VFS_LAYER_TRANSPARENT},
-       {SMB_VFS_OP(cap_fsetxattr),                     SMB_VFS_OP_FSETXATTR,                   SMB_VFS_LAYER_TRANSPARENT},
-
-       {NULL,                                          SMB_VFS_OP_NOOP,                        SMB_VFS_LAYER_NOOP}
+static struct vfs_fn_pointers vfs_cap_fns = {
+       .disk_free_fn = cap_disk_free,
+       .opendir_fn = cap_opendir,
+       .readdir_fn = cap_readdir,
+       .mkdir_fn = cap_mkdir,
+       .rmdir_fn = cap_rmdir,
+       .open_fn = cap_open,
+       .rename_fn = cap_rename,
+       .stat_fn = cap_stat,
+       .lstat_fn = cap_lstat,
+       .unlink_fn = cap_unlink,
+       .chmod_fn = cap_chmod,
+       .chown_fn = cap_chown,
+       .lchown_fn = cap_lchown,
+       .chdir_fn = cap_chdir,
+       .ntimes_fn = cap_ntimes,
+       .symlink_fn = cap_symlink,
+       .readlink_fn = cap_readlink,
+       .link_fn = cap_link,
+       .mknod_fn = cap_mknod,
+       .realpath_fn = cap_realpath,
+       .chmod_acl_fn = cap_chmod_acl,
+       .sys_acl_get_file_fn = cap_sys_acl_get_file,
+       .sys_acl_set_file_fn = cap_sys_acl_set_file,
+       .sys_acl_delete_def_file_fn = cap_sys_acl_delete_def_file,
+       .getxattr_fn = cap_getxattr,
+       .fgetxattr_fn = cap_fgetxattr,
+       .listxattr_fn = cap_listxattr,
+       .removexattr_fn = cap_removexattr,
+       .fremovexattr_fn = cap_fremovexattr,
+       .setxattr_fn = cap_setxattr,
+       .fsetxattr_fn = cap_fsetxattr
 };
 
 NTSTATUS vfs_cap_init(void);
 NTSTATUS vfs_cap_init(void)
 {
-       return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "cap", cap_op_tuples);
+       return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "cap",
+                               &vfs_cap_fns);
 }
 
 /* For CAP functions */
@@ -567,7 +611,7 @@ static char *capencode(TALLOC_CTX *ctx, const char *from)
        }
        len++;
 
-       to = TALLOC_ARRAY(ctx, char, len);
+       to = talloc_array(ctx, char, len);
        if (!to) {
                return NULL;
        }
@@ -600,14 +644,15 @@ static char *capdecode(TALLOC_CTX *ctx, const char *from)
        size_t len = 0;
 
        for (p1 = from; *p1; len++) {
-               if (is_hex(from)) {
+               if (is_hex(p1)) {
                        p1 += 3;
                } else {
                        p1++;
                }
        }
+       len++;
 
-       to = TALLOC_ARRAY(ctx, char, len);
+       to = talloc_array(ctx, char, len);
        if (!to) {
                return NULL;
        }