Ejemplo n.º 1
0
static NTSTATUS fss_vfs_conn_create(TALLOC_CTX *mem_ctx,
				    struct tevent_context *ev,
				    struct messaging_context *msg_ctx,
				    struct auth_session_info *session_info,
				    int snum,
				    struct connection_struct **conn_out)
{
	struct connection_struct *conn = NULL;
	NTSTATUS status;

	status = create_conn_struct(mem_ctx, ev, msg_ctx, &conn,
				    snum, lp_path(mem_ctx, snum),
				    session_info);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0,("failed to create conn for vfs: %s\n",
			 nt_errstr(status)));
		return status;
	}

	status = set_conn_force_user_group(conn, snum);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("failed set force user / group\n"));
		goto err_free_conn;
	}

	*conn_out = conn;

	return NT_STATUS_OK;

err_free_conn:
	SMB_VFS_DISCONNECT(conn);
	conn_free(conn);
	return status;
}
Ejemplo n.º 2
0
NTSTATUS create_conn_struct_cwd(TALLOC_CTX *ctx,
				struct tevent_context *ev,
				struct messaging_context *msg,
				connection_struct **pconn,
				int snum,
				const char *path,
				const struct auth_session_info *session_info,
				char **poldcwd)
{
	connection_struct *conn;
	char *oldcwd;

	NTSTATUS status = create_conn_struct(ctx, ev,
					     msg, &conn,
					     snum, path,
					     session_info);
	if (!NT_STATUS_IS_OK(status)) {
		return status;
	}

	/*
	 * Windows seems to insist on doing trans2getdfsreferral() calls on
	 * the IPC$ share as the anonymous user. If we try to chdir as that
	 * user we will fail.... WTF ? JRA.
	 */

	oldcwd = vfs_GetWd(ctx, conn);
	if (oldcwd == NULL) {
		status = map_nt_error_from_unix(errno);
		DEBUG(3, ("vfs_GetWd failed: %s\n", strerror(errno)));
		conn_free(conn);
		return status;
	}

	if (vfs_ChDir(conn,conn->connectpath) != 0) {
		status = map_nt_error_from_unix(errno);
		DEBUG(3,("create_conn_struct: Can't ChDir to new conn path %s. "
			"Error was %s\n",
			conn->connectpath, strerror(errno) ));
		conn_free(conn);
		return status;
	}

	*pconn = conn;
	*poldcwd = oldcwd;

	return NT_STATUS_OK;
}