Changeset 988 for vendor/current/lib/smbconf/smbconf.c
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/lib/smbconf/smbconf.c
r740 r988 232 232 233 233 /** 234 * create and set the definition for a new share (service). 235 */ 236 sbcErr smbconf_create_set_share(struct smbconf_ctx *ctx, 237 struct smbconf_service *service) 238 { 239 sbcErr err, err2; 240 int i; 241 uint32_t num_includes = 0; 242 char **includes = NULL; 243 TALLOC_CTX *tmp_ctx = NULL; 244 245 if ((service->name != NULL) && smbconf_share_exists(ctx, service->name)) 246 { 247 return SBC_ERR_FILE_EXISTS; 248 } 249 250 err = smbconf_transaction_start(ctx); 251 if (!SBC_ERROR_IS_OK(err)) { 252 return err; 253 } 254 255 tmp_ctx = talloc_stackframe(); 256 257 err = smbconf_create_share(ctx, service->name); 258 if (!SBC_ERROR_IS_OK(err)) { 259 goto cancel; 260 } 261 262 for (i = 0; i < service->num_params; i++) { 263 if (strequal(service->param_names[i], "include")) { 264 includes = talloc_realloc(tmp_ctx, includes, char *, 265 num_includes+1); 266 if (includes == NULL) { 267 err = SBC_ERR_NOMEM; 268 goto cancel; 269 } 270 includes[num_includes] = talloc_strdup(includes, 271 service->param_values[i]); 272 if (includes[num_includes] == NULL) { 273 err = SBC_ERR_NOMEM; 274 goto cancel; 275 } 276 num_includes++; 277 } else { 278 err = smbconf_set_parameter(ctx, 279 service->name, 280 service->param_names[i], 281 service->param_values[i]); 282 if (!SBC_ERROR_IS_OK(err)) { 283 goto cancel; 284 } 285 } 286 } 287 288 err = smbconf_set_includes(ctx, service->name, num_includes, 289 discard_const_p(const char *, includes)); 290 if (!SBC_ERROR_IS_OK(err)) { 291 goto cancel; 292 } 293 294 err = smbconf_transaction_commit(ctx); 295 296 goto done; 297 298 cancel: 299 err2 = smbconf_transaction_cancel(ctx); 300 if (!SBC_ERROR_IS_OK(err2)) { 301 DEBUG(5, (__location__ ": Error cancelling transaction: %s\n", 302 sbcErrorString(err2))); 303 } 304 305 done: 306 talloc_free(tmp_ctx); 307 return err; 308 } 309 310 /** 234 311 * get a definition of a share (service) from configuration. 235 312 */
Note:
See TracChangeset
for help on using the changeset viewer.