selftest/Samba4: make use of get_cmd_env_vars() to setup all relevant env variables
[samba.git] / source3 / modules / vfs_tsmsm.c
index b943515a8fcb13210135daeaa093da6f9643a84b..89191f7e3ae55be0d38083365fc33754efcacc3e 100644 (file)
@@ -89,6 +89,8 @@ static void tsmsm_free_data(void **pptr) {
 static int tsmsm_connect(struct vfs_handle_struct *handle,
                         const char *service,
                         const char *user) {
+       const struct loadparm_substitution *lp_sub =
+               loadparm_s3_global_substitution();
        struct tsmsm_struct *tsmd;
        const char *fres;
        const char *tsmname;
@@ -115,18 +117,18 @@ static int tsmsm_connect(struct vfs_handle_struct *handle,
        tsmname = (handle->param ? handle->param : "tsmsm");
        
        /* Get 'hsm script' and 'dmapi attribute' parameters to tsmd context */
-       tsmd->hsmscript = lp_parm_talloc_string(
-               tsmd, SNUM(handle->conn), tsmname,
+       tsmd->hsmscript = lp_parm_substituted_string(
+               tsmd, lp_sub, SNUM(handle->conn), tsmname,
                "hsm script", NULL);
        talloc_steal(tsmd, tsmd->hsmscript);
        
-       tsmd->attrib_name = lp_parm_talloc_string(
-               tsmd, SNUM(handle->conn), tsmname,
+       tsmd->attrib_name = lp_parm_substituted_string(
+               tsmd, lp_sub, SNUM(handle->conn), tsmname,
                "dmapi attribute", DM_ATTRIB_OBJECT);
        talloc_steal(tsmd, tsmd->attrib_name);
        
-       tsmd->attrib_value = lp_parm_talloc_string(
-               tsmd, SNUM(handle->conn), tsmname,
+       tsmd->attrib_value = lp_parm_substituted_string(
+               tsmd, lp_sub, SNUM(handle->conn), tsmname,
                "dmapi value", NULL);
        talloc_steal(tsmd, tsmd->attrib_value);
        
@@ -195,7 +197,7 @@ static bool tsmsm_is_offline(struct vfs_handle_struct *handle,
         * become_root() is just as good anyway (tridge) 
         */
 
-       /* Also, AIX has DMAPI but no POSIX capablities support. In this case,
+       /* Also, AIX has DMAPI but no POSIX capabilities support. In this case,
         * we need to be root to do DMAPI manipulations.
         */
        become_root();
@@ -266,20 +268,6 @@ done:
        return offline;
 }
 
-static NTSTATUS tsmsm_get_dos_attributes(struct vfs_handle_struct *handle,
-                                        struct smb_filename *fname,
-                                        uint32_t *dosmode)
-{
-       bool offline;
-
-       offline = tsmsm_is_offline(handle, fname, &fname->st);
-       if (offline) {
-               *dosmode |= FILE_ATTRIBUTE_OFFLINE;
-       }
-
-       return SMB_VFS_NEXT_GET_DOS_ATTRIBUTES(handle, fname, dosmode);
-}
-
 static NTSTATUS tsmsm_fget_dos_attributes(struct vfs_handle_struct *handle,
                                          files_struct *fsp,
                                          uint32_t *dosmode)
@@ -517,11 +505,12 @@ static NTSTATUS tsmsm_set_offline(struct vfs_handle_struct *handle,
        /* Now, call the script */
        command = talloc_asprintf(tsmd, "%s offline \"%s\"", tsmd->hsmscript, path);
        if(!command) {
-               DEBUG(1, ("tsmsm_set_offline: can't allocate memory to run hsm script"));
+               DEBUG(1, ("tsmsm_set_offline: can't allocate memory to run hsm script\n"));
                return NT_STATUS_NO_MEMORY;
        }
        DEBUG(10, ("tsmsm_set_offline: Running [%s]\n", command));
-       if((result = smbrun(command, NULL)) != 0) {
+       result = smbrun(command, NULL, NULL);
+       if(result != 0) {
                DEBUG(1,("tsmsm_set_offline: Running [%s] returned %d\n", command, result));
                TALLOC_FREE(command);
                return NT_STATUS_INTERNAL_ERROR;
@@ -530,37 +519,6 @@ static NTSTATUS tsmsm_set_offline(struct vfs_handle_struct *handle,
        return NT_STATUS_OK;
 }
 
-static NTSTATUS tsmsm_set_dos_attributes(struct vfs_handle_struct *handle,
-                                        const struct smb_filename *smb_fname,
-                                        uint32_t dosmode)
-{
-       NTSTATUS status;
-       uint32_t old_dosmode;
-       struct smb_filename *fname = NULL;
-
-       /* dos_mode() doesn't like const smb_fname */
-       fname = cp_smb_filename(talloc_tos(), smb_fname);
-       if (fname == NULL) {
-               return NT_STATUS_NO_MEMORY;
-       }
-
-       old_dosmode = dos_mode(handle->conn, fname);
-       TALLOC_FREE(fname);
-
-       status = SMB_VFS_NEXT_SET_DOS_ATTRIBUTES(handle, smb_fname, dosmode);
-       if (!NT_STATUS_IS_OK(status)) {
-               return status;
-       }
-
-       if (!(old_dosmode & FILE_ATTRIBUTE_OFFLINE) &&
-           (dosmode & FILE_ATTRIBUTE_OFFLINE))
-       {
-               return NT_STATUS_OK;
-       }
-
-       return tsmsm_set_offline(handle, smb_fname);
-}
-
 static NTSTATUS tsmsm_fset_dos_attributes(struct vfs_handle_struct *handle,
                                          struct files_struct *fsp,
                                          uint32_t dosmode)
@@ -568,7 +526,7 @@ static NTSTATUS tsmsm_fset_dos_attributes(struct vfs_handle_struct *handle,
        NTSTATUS status;
        uint32_t old_dosmode;
 
-       old_dosmode = dos_mode(handle->conn, fsp->fsp_name);
+       old_dosmode = fdos_mode(fsp);
 
        status = SMB_VFS_NEXT_FSET_DOS_ATTRIBUTES(handle, fsp, dosmode);
        if (!NT_STATUS_IS_OK(status)) {
@@ -601,14 +559,14 @@ static struct vfs_fn_pointers tsmsm_fns = {
        .pwrite_send_fn = tsmsm_pwrite_send,
        .pwrite_recv_fn = tsmsm_pwrite_recv,
        .sendfile_fn = tsmsm_sendfile,
-       .set_dos_attributes_fn = tsmsm_set_dos_attributes,
        .fset_dos_attributes_fn = tsmsm_fset_dos_attributes,
-       .get_dos_attributes_fn = tsmsm_get_dos_attributes,
+       .get_dos_attributes_send_fn = vfs_not_implemented_get_dos_attributes_send,
+       .get_dos_attributes_recv_fn = vfs_not_implemented_get_dos_attributes_recv,
        .fget_dos_attributes_fn = tsmsm_fget_dos_attributes,
 };
 
-NTSTATUS vfs_tsmsm_init(void);
-NTSTATUS vfs_tsmsm_init(void)
+static_decl_vfs;
+NTSTATUS vfs_tsmsm_init(TALLOC_CTX *ctx)
 {
        return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
                                "tsmsm", &tsmsm_fns);