fss: use UNC parser for Get/DeleteShareMapping RPCs
authorDavid Disseldorp <ddiss@samba.org>
Tue, 30 Apr 2013 22:19:37 +0000 (00:19 +0200)
committerDavid Disseldorp <ddiss@samba.org>
Wed, 8 May 2013 10:21:38 +0000 (12:21 +0200)
source3/rpc_server/fss/srv_fss_agent.c

index 4bd31fb6126a9357598c7e5dfda0ff974dc71c0c..14829ccc1d1ea409d3b54dc8547a80f2041bd0b0 100644 (file)
@@ -1230,6 +1230,7 @@ uint32_t _fss_IsPathShadowCopied(struct pipes_struct *p,
 uint32_t _fss_GetShareMapping(struct pipes_struct *p,
                              struct fss_GetShareMapping *r)
 {
+       NTSTATUS status;
        struct fss_sc_set *sc_set;
        struct fss_sc *sc;
        struct fss_sc_smap *sc_smap;
@@ -1237,36 +1238,47 @@ uint32_t _fss_GetShareMapping(struct pipes_struct *p,
        char *share;
        struct fssagent_share_mapping_1 *sm_out;
 
+       TALLOC_CTX *tmp_ctx = talloc_new(p->mem_ctx);
+       if (tmp_ctx == NULL) {
+               return E_OUTOFMEMORY;
+       }
 
        if (!fss_permitted(p)) {
+               talloc_free(tmp_ctx);
                return E_ACCESSDENIED;
        }
 
        sc_set = sc_set_lookup(fss_global.sc_sets, &r->in.ShadowCopySetId);
        if (sc_set == NULL) {
+               talloc_free(tmp_ctx);
                return E_INVALIDARG;
        }
 
        sc = sc_lookup(sc_set->scs, &r->in.ShadowCopyId);
        if (sc == NULL) {
+               talloc_free(tmp_ctx);
                return E_INVALIDARG;
        }
 
-       share = strrchr(r->in.ShareName, '\\');
-       if (share++ == NULL) {
-               return E_INVALIDARG;
+       status = fss_unc_parse(tmp_ctx, r->in.ShareName, NULL, &share);
+       if (!NT_STATUS_IS_OK(status)) {
+               talloc_free(tmp_ctx);
+               return fss_ntstatus_map(status);
        }
 
        sc_smap = sc_smap_lookup(sc->smaps, share);
        if (sc_smap == NULL) {
+               talloc_free(tmp_ctx);
                return E_INVALIDARG;
        }
 
        if (r->in.Level != 1) {
+               talloc_free(tmp_ctx);
                return E_INVALIDARG;
        }
        addr = tsocket_address_inet_addr_string(p->local_address, p->mem_ctx);
        if (addr == NULL) {
+               talloc_free(tmp_ctx);
                return E_OUTOFMEMORY;
        }
 
@@ -1278,6 +1290,7 @@ uint32_t _fss_GetShareMapping(struct pipes_struct *p,
        sm_out->ShadowCopyShareName = sc_smap->sc_share_name;
        unix_to_nt_time(&sm_out->tstamp, sc->create_ts);
        r->out.ShareMapping->ShareMapping1 = sm_out;
+       talloc_free(tmp_ctx);
 
        return 0;
 }
@@ -1402,9 +1415,9 @@ struct tevent_req *_fss_DeleteShareMapping_send(struct tevent_context *ev,
        delete_state->sc = sc;
        delete_state->snum = sc->smaps->snum;
 
-       share = strrchr(r->in.ShareName, '\\');
-       if (share++ == NULL) {
-               tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
+       status = fss_unc_parse(delete_state, r->in.ShareName, NULL, &share);
+       if (!NT_STATUS_IS_OK(status)) {
+               tevent_req_nterror(req, status);
                return tevent_req_post(req, ev);
        }