/** * This functions process a service previously loaded with libsmbconf. */ static sbcErr import_process_service(struct net_context *c, struct smbconf_ctx *conf_ctx, struct smbconf_service *service) { sbcErr err = SBC_ERR_OK; if (c->opt_testmode) { uint32_t idx; const char *indent = ""; if (service->name != NULL) { d_printf("[%s]\n", service->name); indent = "\t"; } for (idx = 0; idx < service->num_params; idx++) { d_printf("%s%s = %s\n", indent, service->param_names[idx], service->param_values[idx]); } d_printf("\n"); goto done; } if (smbconf_share_exists(conf_ctx, service->name)) { err = smbconf_delete_share(conf_ctx, service->name); if (!SBC_ERROR_IS_OK(err)) { goto done; } } err = smbconf_create_set_share(conf_ctx, service); done: return err; }
/* * Expose a new share using libsmbconf, cloning the existing configuration * from the base share. The base share may be defined in either the registry * or smb.conf. * XXX this is called as root */ static uint32_t fss_sc_expose(struct smbconf_ctx *fconf_ctx, struct smbconf_ctx *rconf_ctx, TALLOC_CTX *mem_ctx, struct fss_sc *sc) { struct fss_sc_smap *sc_smap; uint32_t err = 0; for (sc_smap = sc->smaps; sc_smap; sc_smap = sc_smap->next) { sbcErr cerr; struct smbconf_service *base_service = NULL; struct security_descriptor *sd; size_t sd_size; cerr = fss_conf_get_share_def(fconf_ctx, rconf_ctx, mem_ctx, sc_smap->share_name, &base_service); if (!SBC_ERROR_IS_OK(cerr)) { DEBUG(0, ("failed to get base share %s definition: " "%s\n", sc_smap->share_name, sbcErrorString(cerr))); err = HRES_ERROR_V(HRES_E_FAIL); break; } /* smap share name already defined when added */ err = map_share_comment(sc_smap, sc); if (err) { DEBUG(0, ("failed to map share comment\n")); break; } base_service->name = sc_smap->sc_share_name; cerr = smbconf_create_set_share(rconf_ctx, base_service); if (!SBC_ERROR_IS_OK(cerr)) { DEBUG(0, ("failed to create share %s: %s\n", base_service->name, sbcErrorString(cerr))); err = HRES_ERROR_V(HRES_E_FAIL); break; } cerr = smbconf_set_parameter(rconf_ctx, sc_smap->sc_share_name, "path", sc->sc_path); if (!SBC_ERROR_IS_OK(cerr)) { DEBUG(0, ("failed to set path param: %s\n", sbcErrorString(cerr))); err = HRES_ERROR_V(HRES_E_FAIL); break; } if (sc_smap->sc_share_comment != NULL) { cerr = smbconf_set_parameter(rconf_ctx, sc_smap->sc_share_name, "comment", sc_smap->sc_share_comment); if (!SBC_ERROR_IS_OK(cerr)) { DEBUG(0, ("failed to set comment param: %s\n", sbcErrorString(cerr))); err = HRES_ERROR_V(HRES_E_FAIL); break; } } talloc_free(base_service); /* * Obtain the base share SD, which also needs to be cloned. * Share SDs are stored in share_info.tdb, so are not covered by * the registry transaction. * The base share SD should be cloned at the time of exposure, * rather than when the snapshot is taken. This matches Windows * Server 2012 behaviour. */ sd = get_share_security(mem_ctx, sc_smap->share_name, &sd_size); if (sd == NULL) { 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); TALLOC_FREE(sd); if (!ok) { DEBUG(0, ("failed to set %s share SD\n", sc_smap->sc_share_name)); err = HRES_ERROR_V(HRES_E_FAIL); break; } } } return err; }