#include "../lib/smbconf/smbconf.h"
#include "smbd/proto.h"
#include "lib/smbconf/smbconf_init.h"
-#include "librpc/gen_ndr/srv_fsrvp.h"
+#include "librpc/rpc/dcesrv_core.h"
+#include "librpc/gen_ndr/ndr_fsrvp_scompat.h"
+#include "librpc/gen_ndr/ndr_fsrvp.h"
+#include "rpc_server/rpc_server.h"
#include "srv_fss_private.h"
-#include "srv_fss_agent.h"
+#include "lib/global_contexts.h"
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
goto out;
}
- smb_fname = synthetic_smb_fname(service, sc->sc_path, NULL, NULL, 0);
+ smb_fname = synthetic_smb_fname(service,
+ sc->sc_path,
+ NULL,
+ NULL,
+ 0,
+ 0);
if (smb_fname == NULL) {
goto out;
}
int snum,
struct connection_struct **conn_out)
{
+ const struct loadparm_substitution *lp_sub =
+ loadparm_s3_global_substitution();
struct conn_struct_tos *c = NULL;
NTSTATUS status;
status = create_conn_struct_tos(msg_ctx,
snum,
- lp_path(talloc_tos(), snum),
+ lp_path(talloc_tos(), lp_sub, snum),
session_info,
&c);
if (!NT_STATUS_IS_OK(status)) {
return NULL;
}
-void srv_fssa_cleanup(void)
+static void srv_fssa_cleanup(void)
{
talloc_free(fss_global.db_path);
talloc_free(fss_global.mem_ctx);
ZERO_STRUCT(fss_global);
}
-NTSTATUS srv_fssa_start(struct messaging_context *msg_ctx)
+static NTSTATUS srv_fssa_start(struct messaging_context *msg_ctx)
{
NTSTATUS status;
fss_global.mem_ctx = talloc_named_const(NULL, 0,
*/
static bool fss_permitted(struct pipes_struct *p)
{
- if (p->session_info->unix_token->uid == sec_initial_uid()) {
+ struct dcesrv_call_state *dce_call = p->dce_call;
+ struct auth_session_info *session_info =
+ dcesrv_call_session_info(dce_call);
+
+ if (session_info->unix_token->uid == sec_initial_uid()) {
DEBUG(6, ("Granting FSRVP op, user started smbd\n"));
return true;
}
if (nt_token_check_sid(&global_sid_Builtin_Administrators,
- p->session_info->security_token)) {
+ session_info->security_token)) {
DEBUG(6, ("Granting FSRVP op, administrators group member\n"));
return true;
}
if (nt_token_check_sid(&global_sid_Builtin_Backup_Operators,
- p->session_info->security_token)) {
+ session_info->security_token)) {
DEBUG(6, ("Granting FSRVP op, backup operators group member\n"));
return true;
}
- if (security_token_has_privilege(p->session_info->security_token,
+ if (security_token_has_privilege(session_info->security_token,
SEC_PRIV_BACKUP)) {
DEBUG(6, ("Granting FSRVP op, backup privilege present\n"));
return true;
uint32_t _fss_AddToShadowCopySet(struct pipes_struct *p,
struct fss_AddToShadowCopySet *r)
{
+ struct dcesrv_call_state *dce_call = p->dce_call;
+ struct auth_session_info *session_info =
+ dcesrv_call_session_info(dce_call);
uint32_t ret;
struct fss_sc_set *sc_set;
struct fss_sc *sc;
struct connection_struct *conn;
NTSTATUS status;
TALLOC_CTX *frame = talloc_stackframe();
+ const struct loadparm_substitution *lp_sub =
+ loadparm_s3_global_substitution();
if (!fss_permitted(p)) {
ret = HRES_ERROR_V(HRES_E_ACCESSDENIED);
goto err_tmp_free;
}
- path_name = lp_path(frame, snum);
+ path_name = lp_path(frame, lp_sub, snum);
if (path_name == NULL) {
ret = HRES_ERROR_V(HRES_E_OUTOFMEMORY);
goto err_tmp_free;
}
- status = fss_conn_create_tos(p->msg_ctx, p->session_info, snum, &conn);
+ status = fss_conn_create_tos(p->msg_ctx, session_info, snum, &conn);
if (!NT_STATUS_IS_OK(status)) {
ret = HRES_ERROR_V(HRES_E_ACCESSDENIED);
goto err_tmp_free;
}
- if (!become_user_without_service_by_session(conn, p->session_info)) {
+ if (!become_user_without_service_by_session(conn, session_info)) {
DEBUG(0, ("failed to become user\n"));
ret = HRES_ERROR_V(HRES_E_ACCESSDENIED);
goto err_tmp_free;
uint32_t _fss_CommitShadowCopySet(struct pipes_struct *p,
struct fss_CommitShadowCopySet *r)
{
+ struct dcesrv_call_state *dce_call = p->dce_call;
+ struct auth_session_info *session_info =
+ dcesrv_call_session_info(dce_call);
struct fss_sc_set *sc_set;
struct fss_sc *sc;
uint32_t commit_count;
char *base_path;
char *snap_path;
status = commit_sc_with_conn(frame, global_event_context(),
- p->msg_ctx, p->session_info, sc,
+ p->msg_ctx, session_info, sc,
&base_path, &snap_path);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("snap create failed for shadow copy of "
DEBUG(2, ("no share SD to clone for %s snapshot\n",
sc_smap->share_name));
} else {
- bool ok;
- ok = set_share_security(sc_smap->sc_share_name, sd);
+ NTSTATUS status;
+ status = set_share_security(sc_smap->sc_share_name, sd);
TALLOC_FREE(sd);
- if (!ok) {
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("failed to set %s share SD\n",
sc_smap->sc_share_name));
err = HRES_ERROR_V(HRES_E_FAIL);
uint32_t _fss_IsPathSupported(struct pipes_struct *p,
struct fss_IsPathSupported *r)
{
+ struct dcesrv_call_state *dce_call = p->dce_call;
+ struct auth_session_info *session_info =
+ dcesrv_call_session_info(dce_call);
int snum;
char *service;
char *base_vol;
struct connection_struct *conn;
char *share;
TALLOC_CTX *frame = talloc_stackframe();
+ const struct loadparm_substitution *lp_sub =
+ loadparm_s3_global_substitution();
if (!fss_permitted(p)) {
TALLOC_FREE(frame);
return HRES_ERROR_V(HRES_E_INVALIDARG);
}
- status = fss_conn_create_tos(p->msg_ctx, p->session_info, snum, &conn);
+ status = fss_conn_create_tos(p->msg_ctx, session_info, snum, &conn);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(frame);
return HRES_ERROR_V(HRES_E_ACCESSDENIED);
}
- if (!become_user_without_service_by_session(conn, p->session_info)) {
+ if (!become_user_without_service_by_session(conn, session_info)) {
DEBUG(0, ("failed to become user\n"));
TALLOC_FREE(frame);
return HRES_ERROR_V(HRES_E_ACCESSDENIED);
}
status = SMB_VFS_SNAP_CHECK_PATH(conn, frame,
- lp_path(frame, snum),
+ lp_path(frame, lp_sub, snum),
&base_vol);
unbecome_user_without_service();
if (!NT_STATUS_IS_OK(status)) {
uint32_t _fss_DeleteShareMapping(struct pipes_struct *p,
struct fss_DeleteShareMapping *r)
{
+ struct dcesrv_call_state *dce_call = p->dce_call;
+ struct auth_session_info *session_info =
+ dcesrv_call_session_info(dce_call);
struct fss_sc_set *sc_set;
struct fss_sc *sc;
struct fss_sc_smap *sc_smap;
goto err_tmp_free;
}
- status = fss_conn_create_tos(p->msg_ctx, p->session_info, snum, &conn);
+ status = fss_conn_create_tos(p->msg_ctx, session_info, snum, &conn);
if (!NT_STATUS_IS_OK(status)) {
goto err_tmp_free;
}
- if (!become_user_without_service_by_session(conn, p->session_info)) {
+ if (!become_user_without_service_by_session(conn, session_info)) {
DEBUG(0, ("failed to become user\n"));
status = NT_STATUS_ACCESS_DENIED;
goto err_tmp_free;
return 0;
}
+
+static NTSTATUS FileServerVssAgent__op_init_server(
+ struct dcesrv_context *dce_ctx,
+ const struct dcesrv_endpoint_server *ep_server);
+
+static NTSTATUS FileServerVssAgent__op_shutdown_server(
+ struct dcesrv_context *dce_ctx,
+ const struct dcesrv_endpoint_server *ep_server);
+
+#define DCESRV_INTERFACE_FILESERVERVSSAGENT_INIT_SERVER \
+ fileservervssagent_init_server
+
+#define DCESRV_INTERFACE_FILESERVERVSSAGENT_SHUTDOWN_SERVER \
+ fileservervssagent_shutdown_server
+
+static NTSTATUS fileservervssagent_shutdown_server(
+ struct dcesrv_context *dce_ctx,
+ const struct dcesrv_endpoint_server *ep_server)
+{
+ srv_fssa_cleanup();
+ return FileServerVssAgent__op_shutdown_server(dce_ctx, ep_server);
+}
+
+static NTSTATUS fileservervssagent_init_server(
+ struct dcesrv_context *dce_ctx,
+ const struct dcesrv_endpoint_server *ep_server)
+{
+ NTSTATUS status;
+ struct messaging_context *msg_ctx = global_messaging_context();
+
+ status = srv_fssa_start(msg_ctx);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ return FileServerVssAgent__op_init_server(dce_ctx, ep_server);
+}
+
+/* include the generated boilerplate */
+#include "librpc/gen_ndr/ndr_fsrvp_scompat.c"