コード例 #1
0
ファイル: vfs_netatalk.c プロジェクト: DanilKorotenko/samba
static int atalk_rmdir(struct vfs_handle_struct *handle,
			const struct smb_filename *smb_fname)
{
	bool add = False;
	TALLOC_CTX *ctx = 0;
	const char *path = smb_fname->base_name;
	char *dpath;

	if (!handle->conn->cwd || !path) goto exit_rmdir;

	/* due to there is no way to change bDeleteVetoFiles variable
	 * from this module, gotta use talloc stuff..
	 */

	strstr_m(path, APPLEDOUBLE) ? (add = False) : (add = True);

	if (!(ctx = talloc_init("remove_directory")))
		goto exit_rmdir;

	if (!(dpath = talloc_asprintf(ctx, "%s/%s%s", 
	  handle->conn->cwd, path, add ? "/"APPLEDOUBLE : "")))
		goto exit_rmdir;

	atalk_rrmdir(ctx, dpath);

exit_rmdir:
	talloc_destroy(ctx);
	return SMB_VFS_NEXT_RMDIR(handle, smb_fname);
}
コード例 #2
0
ファイル: vfs_posix_eadb.c プロジェクト: AIdrifter/samba
/*
 * On rmdir we need to delete the tdb record
 */
static int posix_eadb_rmdir(vfs_handle_struct *handle, const char *path)
{
	NTSTATUS status;
	struct tdb_wrap *ea_tdb;
	int ret;

	SMB_VFS_HANDLE_GET_DATA(handle, ea_tdb, struct tdb_wrap, return -1);

	if (tdb_transaction_start(ea_tdb->tdb) != 0) {
		return -1;
	}

	status = unlink_posix_eadb_raw(ea_tdb, path, -1);
	if (!NT_STATUS_IS_OK(status)) {
		tdb_transaction_cancel(ea_tdb->tdb);
	}

	ret = SMB_VFS_NEXT_RMDIR(handle, path);

	if (ret == -1) {
		tdb_transaction_cancel(ea_tdb->tdb);
	} else {
		if (tdb_transaction_commit(ea_tdb->tdb) != 0) {
			return -1;
		}
	}

	return ret;
}
コード例 #3
0
static int atalk_rmdir(struct vfs_handle_struct *handle, struct connection_struct *conn, const char *path)
{
	BOOL add = False;
	TALLOC_CTX *ctx = 0;
	char *dpath;

	if (!conn || !conn->origpath || !path) goto exit_rmdir;

	/* due to there is no way to change bDeleteVetoFiles variable
	 * from this module, gotta use talloc stuff..
	 */

	strstr(path, APPLEDOUBLE) ? (add = False) : (add = True);

	if (!(ctx = talloc_init("remove_directory")))
		goto exit_rmdir;

	if (!(dpath = talloc_asprintf(ctx, "%s/%s%s", 
	  conn->origpath, path, add ? "/"APPLEDOUBLE : "")))
		goto exit_rmdir;

	atalk_rrmdir(ctx, dpath);

exit_rmdir:
	talloc_destroy(ctx);
	return SMB_VFS_NEXT_RMDIR(handle, conn, path);
}
コード例 #4
0
static int rmdir_acl_tdb(vfs_handle_struct *handle, const char *path)
{

    SMB_STRUCT_STAT sbuf;
    struct db_context *db;
    int ret = -1;

    SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context, return -1);

    if (lp_posix_pathnames()) {
        ret = vfs_lstat_smb_fname(handle->conn, path, &sbuf);
    } else {
        ret = vfs_stat_smb_fname(handle->conn, path, &sbuf);
    }

    if (ret == -1) {
        return -1;
    }

    ret = SMB_VFS_NEXT_RMDIR(handle, path);
    if (ret == -1) {
        return -1;
    }

    acl_tdb_delete(handle, db, &sbuf);
    return 0;
}
コード例 #5
0
ファイル: vfsx.c プロジェクト: fudanchii/vfsx
static int vfsx_rmdir(vfs_handle_struct *handle, const char *path)
{
	int result = -1;
	int count;
	char buf[VFSX_MSG_OUT_SIZE];

	count = snprintf(buf, VFSX_MSG_OUT_SIZE, "rmdir:%s:%s:%s", handle->conn->user, handle->conn->origpath, path);
	if (vfsx_execute(buf, count) == VFSX_SUCCESS_TRANSPARENT) {
		result = SMB_VFS_NEXT_RMDIR(handle, path);
	}
	return result;
}
コード例 #6
0
ファイル: vfs_audit.c プロジェクト: gojdic/samba
static int audit_rmdir(vfs_handle_struct *handle, const char *path)
{
	int result;

	result = SMB_VFS_NEXT_RMDIR(handle, path);

	syslog(audit_syslog_priority(handle), "rmdir %s %s%s\n", 
	       path, 
	       (result < 0) ? "failed: " : "",
	       (result < 0) ? strerror(errno) : "");

	return result;
}
コード例 #7
0
static int greyhole_rmdir(vfs_handle_struct *handle, const char *path)
{
	int result;

	result = SMB_VFS_NEXT_RMDIR(handle, path);

	if (result >= 0) {
		gh_spoolf("rmdir\n%s\n%s\n\n",
			lp_servicename(talloc_tos(), handle->conn->params->service),
			path);
	}

	return result;
}
コード例 #8
0
ファイル: vfs_audit.c プロジェクト: DanilKorotenko/samba
static int audit_rmdir(vfs_handle_struct *handle,
		const struct smb_filename *smb_fname)
{
	int result;

	result = SMB_VFS_NEXT_RMDIR(handle, smb_fname);

	syslog(audit_syslog_priority(handle), "rmdir %s %s%s\n", 
	       smb_fname->base_name,
	       (result < 0) ? "failed: " : "",
	       (result < 0) ? strerror(errno) : "");

	return result;
}
コード例 #9
0
static int rmdir_acl_common(struct vfs_handle_struct *handle,
				const char *path)
{
	int ret;

	ret = SMB_VFS_NEXT_RMDIR(handle, path);
	if (!(ret == -1 && (errno == EACCES || errno == EPERM))) {
		DEBUG(10,("rmdir_acl_common: unlink of %s failed %s\n",
			path,
			strerror(errno) ));
		return ret;
	}

	return acl_common_remove_object(handle,
					path,
					true);
}
コード例 #10
0
ファイル: vfs_my_module.c プロジェクト: int-argc/CVFS2.0
static bool vfs_my_module_delete_dir(vfs_handle_struct *handle, const char *dname, const struct smb_filename *smb_fname){
    size_t len;
	mode_t mode;
	char *new_dir = NULL;
	char *tmp_str = NULL;
	char *token;
	char *tok_str;
	bool ret = False;
	char *saveptr;
    int j = 0;
	mode = vfs_my_module_directory_mode(handle);

	tmp_str = SMB_STRDUP(dname);
	ALLOC_CHECK(tmp_str, done);
	tok_str = tmp_str;

	len =strlen(dname)+1;
	new_dir = (char *)SMB_MALLOC(len + 1);
	ALLOC_CHECK(new_dir, done);
	*new_dir = '\0';
	if (dname[0] == '/') {
		/* Absolute path. */
		safe_strcat(new_dir,"/",len);
	}
	/* Create directory tree if neccessary */
	for(token = strtok_r(tok_str, "/", &saveptr); token;
	    token = strtok_r(NULL, "/", &saveptr)) {
		safe_strcat(new_dir, token, len);
			DEBUG(1, ("DELETE DIR: deleting dir %s\n", new_dir));
			if (SMB_VFS_NEXT_RMDIR(handle, new_dir) != 0) {
				DEBUG(1,("DELETE DIR: delete failed for %s with error: %s\n", new_dir, strerror(errno)));
				ret = False;
			}
		safe_strcat(new_dir, "/", len);
		mode = vfs_my_module_subdir_mode(handle);
		j++;
		DEBUG(1,("DELETE DIR COUNTER: %d\n", j));
		ret = True;
	}


done:
	SAFE_FREE(tmp_str);
	SAFE_FREE(new_dir);
	return ret;
}
コード例 #11
0
static int greyhole_rmdir(vfs_handle_struct *handle, const char *path)
{
	int result;
	FILE *spoolf;
	char filename[38];
	struct timeval tp;

	result = SMB_VFS_NEXT_RMDIR(handle, path);

	if (result >= 0) {
		gettimeofday(&tp, (struct timezone *) NULL);
		snprintf(filename, 37, "/var/spool/greyhole/%.0f", ((double) (tp.tv_sec)*1000000.0) + (((double) tp.tv_usec)));
		spoolf = fopen(filename, "wt");
		fprintf(spoolf, "rmdir\n%s\n%s\n\n",
			lp_servicename(handle->conn->params->service),
			path);
		fclose(spoolf);
	}

	return result;
}
コード例 #12
0
ファイル: vfs_acl_common.c プロジェクト: ekohl/samba
static int rmdir_acl_common(struct vfs_handle_struct *handle,
				const char *path)
{
	int ret;

	/* Try the normal rmdir first. */
	ret = SMB_VFS_NEXT_RMDIR(handle, path);
	if (ret == 0) {
		return 0;
	}
	if (errno == EACCES || errno == EPERM) {
		/* Failed due to access denied,
		   see if we need to root override. */
		return acl_common_remove_object(handle,
						path,
						true);
	}

	DEBUG(10,("rmdir_acl_common: unlink of %s failed %s\n",
		path,
		strerror(errno) ));
	return -1;
}
コード例 #13
0
ファイル: skel_transparent.c プロジェクト: dragotin/samba
static int skel_rmdir(vfs_handle_struct *handle,
		const struct smb_filename *smb_fname)
{
	return SMB_VFS_NEXT_RMDIR(handle, smb_fname);
}
コード例 #14
0
ファイル: skel_transparent.c プロジェクト: 0x24bin/winexe-1
static int skel_rmdir(vfs_handle_struct *handle,  const char *path)
{
	return SMB_VFS_NEXT_RMDIR(handle, path);
}
コード例 #15
0
static int acl_common_remove_object(vfs_handle_struct *handle,
					const char *path,
					bool is_directory)
{
	connection_struct *conn = handle->conn;
	struct file_id id;
	files_struct *fsp = NULL;
	int ret = 0;
	char *parent_dir = NULL;
	const char *final_component = NULL;
	struct smb_filename local_fname;
	int saved_errno = 0;

	if (!parent_dirname(talloc_tos(), path,
			&parent_dir, &final_component)) {
		saved_errno = ENOMEM;
		goto out;
	}

	DEBUG(10,("acl_common_remove_object: removing %s %s/%s\n",
		is_directory ? "directory" : "file",
		parent_dir, final_component ));

	/* cd into the parent dir to pin it. */
	ret = SMB_VFS_CHDIR(conn, parent_dir);
	if (ret == -1) {
		saved_errno = errno;
		goto out;
	}

	ZERO_STRUCT(local_fname);
	local_fname.base_name = CONST_DISCARD(char *,final_component);

	/* Must use lstat here. */
	ret = SMB_VFS_LSTAT(conn, &local_fname);
	if (ret == -1) {
		saved_errno = errno;
		goto out;
	}

	/* Ensure we have this file open with DELETE access. */
	id = vfs_file_id_from_sbuf(conn, &local_fname.st);
	for (fsp = file_find_di_first(id); fsp; file_find_di_next(fsp)) {
		if (fsp->access_mask & DELETE_ACCESS &&
				fsp->delete_on_close) {
			/* We did open this for delete,
			 * allow the delete as root.
			 */
			break;
		}
	}

	if (!fsp) {
		DEBUG(10,("acl_common_remove_object: %s %s/%s "
			"not an open file\n",
			is_directory ? "directory" : "file",
			parent_dir, final_component ));
		saved_errno = EACCES;
		goto out;
	}

	become_root();
	if (is_directory) {
		ret = SMB_VFS_NEXT_RMDIR(handle, final_component);
	} else {
		ret = SMB_VFS_NEXT_UNLINK(handle, &local_fname);
	}
	unbecome_root();

	if (ret == -1) {
		saved_errno = errno;
	}

  out:

	TALLOC_FREE(parent_dir);

	vfs_ChDir(conn, conn->connectpath);
	if (saved_errno) {
		errno = saved_errno;
	}
	return ret;
}
コード例 #16
0
ファイル: vfs_my_module.c プロジェクト: int-argc/CVFS2.0
static ssize_t vfs_my_module_pwrite(vfs_handle_struct *handle, files_struct *fsp,
			    const void *data, size_t n,
			    off_t offset)
{		connection_struct *conn = handle->conn;
	char *path_name = NULL;
       	char *temp_name = NULL;
	char *final_name = NULL;
	const struct smb_filename *smb_fname = fsp->fsp_name;
	struct smb_filename *smb_fname_final = NULL;
	const char *base;
	char *repository,*repositoryTemp = NULL;
	int i = 1;
	SMB_OFF_T maxsize, minsize;
	SMB_OFF_T file_size; /* space_avail;	*/
	bool exist;
	NTSTATUS status;
	ssize_t rc = -1;
    int count = 0;
    const char *share = "/mnt/share";
	repository = talloc_sub_advanced(NULL, lp_servicename(SNUM(conn)),
					conn->session_info->unix_name,
					conn->connectpath,
					conn->session_info->utok.gid,
					conn->session_info->sanitized_username,
					conn->session_info->info3->base.domain.string,
					sharevolume(handle));
	ALLOC_CHECK(repository, done);

	trim_char(repository, '\0', '/');

	if(!repository || *(repository) == '\0') {
		rc = SMB_VFS_NEXT_PWRITE(handle, fsp,data,n,offset);
		goto done;
	}

    file_size = vfs_my_module_get_file_size(handle, smb_fname);
    maxsize = vfs_my_module_maxsize(handle);

    if(maxsize > 0 && file_size > maxsize){
    repository = talloc_sub_advanced(NULL, lp_servicename(SNUM(conn)),
					conn->session_info->unix_name,
					conn->connectpath,
					conn->session_info->utok.gid,
					conn->session_info->sanitized_username,
					conn->session_info->info3->base.domain.string,
					stripevolume(handle));
	ALLOC_CHECK(repository, done);

	trim_char(repository, '\0', '/');

	if(!repository || *(repository) == '\0') {
		rc = SMB_VFS_NEXT_PWRITE(handle, fsp,data,n,offset);
		goto done;
	}
    }

	if (strncmp(smb_fname->base_name, repository,
		    strlen(repository)) == 0) {
		rc = SMB_VFS_NEXT_PWRITE(handle, fsp,data,n,offset);
		goto done;
	}

	base = strrchr(smb_fname->base_name, '/');
	if (base == NULL) {
		base = smb_fname->base_name;
		path_name = SMB_STRDUP("/");
		ALLOC_CHECK(path_name, done);
	}
	else {
		path_name = SMB_STRDUP(smb_fname->base_name);
		ALLOC_CHECK(path_name, done);
		path_name[base - smb_fname->base_name] = '\0';
		base++;
	}

	/* original filename with path */
	DEBUG(10, ("file transaction: fname = %s\n", smb_fname_str_dbg(smb_fname)));
	/* original path */
	DEBUG(10, ("file transaction: fpath = %s\n", path_name));
	/* filename without path */
	DEBUG(10, ("file transaction: base = %s\n", base));

    if (vfs_my_module_keep_dir_tree(handle) == True) {
		if (asprintf(&temp_name, "%s/%s", repository, path_name) == -1) {
			ALLOC_CHECK(temp_name, done);
		}
	} else {
		temp_name = SMB_STRDUP(repository);
	}

	ALLOC_CHECK(temp_name, done);
	exist = vfs_my_module_directory_exist(handle, temp_name);
	if (exist) {
		DEBUG(10, ("file transaction: Directory already exists\n"));
	} else {
		DEBUG(10, ("file transaction: Creating directory %s\n", temp_name));
		count = vfs_my_module_create_dir(handle, temp_name, smb_fname);
	}
	if (asprintf(&final_name, "%s/%s", temp_name, base) == -1) {
		ALLOC_CHECK(final_name, done);
	}

	/* Create smb_fname with final base name and orig stream name. */
	status = create_synthetic_smb_fname(talloc_tos(), final_name,
					    smb_fname->stream_name, NULL,
					    &smb_fname_final);
	if (!NT_STATUS_IS_OK(status)) {
		rc = SMB_VFS_NEXT_PWRITE(handle, fsp,data,n,offset);
		goto done;
	}

		TALLOC_FREE(smb_fname_final->base_name);
		smb_fname_final->base_name = talloc_strdup(smb_fname_final,
							   final_name);
		if (smb_fname_final->base_name == NULL) {
			rc = SMB_VFS_NEXT_PWRITE(handle, fsp,data,n,offset);
			goto done;
		}

	SMB_VFS_NEXT_RENAME(handle, smb_fname, smb_fname_final);
	rc = SMB_VFS_NEXT_PWRITE(handle, fsp,data,n,offset);

	if (rc != 0) {
		rc = SMB_VFS_NEXT_PWRITE(handle, fsp,data,n,offset);
		goto done;
	}

done:
    vfs_my_module_delete_dir(handle,path_name,smb_fname);
    while(count !=0){
    vfs_my_module_delete_dir(handle,path_name,smb_fname);
    SMB_VFS_NEXT_RMDIR(handle, path_name);
    count--;
    }
	SAFE_FREE(path_name);
	SAFE_FREE(temp_name);
	SAFE_FREE(final_name);
	TALLOC_FREE(smb_fname_final);
	TALLOC_FREE(repository);
	return rc;
}
コード例 #17
0
ファイル: vfs_cap.c プロジェクト: Nymphetaminer/dsl-n55u
static int cap_rmdir(vfs_handle_struct *handle, connection_struct *conn, const char *path)
{
        pstring cappath;
        capencode(cappath, path);
	return SMB_VFS_NEXT_RMDIR(handle, conn, cappath);
}