LCOV - code coverage report
Current view: top level - lib/smbconf - smbconf_txt.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 155 257 60.3 %
Date: 2021-09-23 10:06:22 Functions: 14 29 48.3 %

          Line data    Source code
       1             : /*
       2             :  *  Unix SMB/CIFS implementation.
       3             :  *  libsmbconf - Samba configuration library, text backend
       4             :  *  Copyright (C) Michael Adam 2008
       5             :  *
       6             :  *  This program is free software; you can redistribute it and/or modify
       7             :  *  it under the terms of the GNU General Public License as published by
       8             :  *  the Free Software Foundation; either version 3 of the License, or
       9             :  *  (at your option) any later version.
      10             :  *
      11             :  *  This program is distributed in the hope that it will be useful,
      12             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             :  *  GNU General Public License for more details.
      15             :  *
      16             :  *  You should have received a copy of the GNU General Public License
      17             :  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
      18             :  */
      19             : 
      20             : /*
      21             :  * This is a sample implementation of a libsmbconf text backend
      22             :  * using the params.c parser.
      23             :  *
      24             :  * It is read only.
      25             :  * Don't expect brilliant performance, since it is not hashing the lists.
      26             :  */
      27             : 
      28             : #include "includes.h"
      29             : #include "smbconf_private.h"
      30             : #include "lib/smbconf/smbconf_txt.h"
      31             : 
      32             : struct txt_cache {
      33             :         uint32_t current_share;
      34             :         uint32_t num_shares;
      35             :         char **share_names;
      36             :         uint32_t *num_params;
      37             :         char ***param_names;
      38             :         char ***param_values;
      39             : };
      40             : 
      41             : struct txt_private_data {
      42             :         struct txt_cache *cache;
      43             :         uint64_t csn;
      44             :         bool verbatim;
      45             : };
      46             : 
      47             : /**********************************************************************
      48             :  *
      49             :  * helper functions
      50             :  *
      51             :  **********************************************************************/
      52             : 
      53             : /**
      54             :  * a convenience helper to cast the private data structure
      55             :  */
      56       13054 : static struct txt_private_data *pd(struct smbconf_ctx *ctx)
      57             : {
      58       13054 :         return (struct txt_private_data *)(ctx->data);
      59             : }
      60             : 
      61        1860 : static bool smbconf_txt_do_section(const char *section, void *private_data)
      62             : {
      63             :         sbcErr err;
      64             :         uint32_t idx;
      65        1860 :         struct txt_private_data *tpd = (struct txt_private_data *)private_data;
      66        1860 :         struct txt_cache *cache = tpd->cache;
      67             : 
      68        1860 :         if (smbconf_find_in_array(section, cache->share_names,
      69             :                                   cache->num_shares, &idx))
      70             :         {
      71           0 :                 cache->current_share = idx;
      72           0 :                 return true;
      73             :         }
      74             : 
      75        1860 :         err = smbconf_add_string_to_array(cache, &(cache->share_names),
      76             :                                           cache->num_shares, section);
      77        1860 :         if (!SBC_ERROR_IS_OK(err)) {
      78           0 :                 return false;
      79             :         }
      80        1860 :         cache->current_share = cache->num_shares;
      81        1860 :         cache->num_shares++;
      82             : 
      83        1860 :         cache->param_names = talloc_realloc(cache,
      84             :                                                   cache->param_names,
      85             :                                                   char **,
      86             :                                                   cache->num_shares);
      87        1860 :         if (cache->param_names == NULL) {
      88           0 :                 return false;
      89             :         }
      90        1860 :         cache->param_names[cache->current_share] = NULL;
      91             : 
      92        1860 :         cache->param_values = talloc_realloc(cache,
      93             :                                                    cache->param_values,
      94             :                                                    char **,
      95             :                                                    cache->num_shares);
      96        1860 :         if (cache->param_values == NULL) {
      97           0 :                 return false;
      98             :         }
      99        1860 :         cache->param_values[cache->current_share] = NULL;
     100             : 
     101        1860 :         cache->num_params = talloc_realloc(cache,
     102             :                                                  cache->num_params,
     103             :                                                  uint32_t,
     104             :                                                  cache->num_shares);
     105        1860 :         if (cache->num_params == NULL) {
     106           0 :                 return false;
     107             :         }
     108        1860 :         cache->num_params[cache->current_share] = 0;
     109             : 
     110        1860 :         return true;
     111             : }
     112             : 
     113        9156 : static bool smbconf_txt_do_parameter(const char *param_name,
     114             :                                      const char *param_value,
     115             :                                      void *private_data)
     116             : {
     117             :         sbcErr err;
     118             :         char **param_names, **param_values;
     119             :         uint32_t num_params;
     120             :         uint32_t idx;
     121        9156 :         struct txt_private_data *tpd = (struct txt_private_data *)private_data;
     122        9156 :         struct txt_cache *cache = tpd->cache;
     123             : 
     124        9156 :         if (cache->num_shares == 0) {
     125             :                 /*
     126             :                  * not in any share yet,
     127             :                  * initialize the "empty" section (NULL):
     128             :                  * parameters without a previous [section] are stored here.
     129             :                  */
     130           0 :                 if (!smbconf_txt_do_section(NULL, private_data)) {
     131           0 :                         return false;
     132             :                 }
     133             :         }
     134             : 
     135        9156 :         param_names  = cache->param_names[cache->current_share];
     136        9156 :         param_values = cache->param_values[cache->current_share];
     137        9156 :         num_params   = cache->num_params[cache->current_share];
     138             : 
     139        9156 :         if (!(tpd->verbatim) &&
     140           0 :             smbconf_find_in_array(param_name, param_names, num_params, &idx))
     141             :         {
     142           0 :                 talloc_free(param_values[idx]);
     143           0 :                 param_values[idx] = talloc_strdup(cache, param_value);
     144           0 :                 if (param_values[idx] == NULL) {
     145           0 :                         return false;
     146             :                 }
     147           0 :                 return true;
     148             :         }
     149        9156 :         err = smbconf_add_string_to_array(cache,
     150        9156 :                                 &(cache->param_names[cache->current_share]),
     151             :                                 num_params, param_name);
     152        9156 :         if (!SBC_ERROR_IS_OK(err)) {
     153           0 :                 return false;
     154             :         }
     155        9156 :         err = smbconf_add_string_to_array(cache,
     156        9156 :                                 &(cache->param_values[cache->current_share]),
     157             :                                 num_params, param_value);
     158        9156 :         cache->num_params[cache->current_share]++;
     159        9156 :         return SBC_ERROR_IS_OK(err);
     160             : }
     161             : 
     162          24 : static void smbconf_txt_flush_cache(struct smbconf_ctx *ctx)
     163             : {
     164          24 :         talloc_free(pd(ctx)->cache);
     165          24 :         pd(ctx)->cache = NULL;
     166          24 : }
     167             : 
     168          24 : static sbcErr smbconf_txt_init_cache(struct smbconf_ctx *ctx)
     169             : {
     170          24 :         if (pd(ctx)->cache != NULL) {
     171           0 :                 smbconf_txt_flush_cache(ctx);
     172             :         }
     173             : 
     174          24 :         pd(ctx)->cache = talloc_zero(pd(ctx), struct txt_cache);
     175             : 
     176          24 :         if (pd(ctx)->cache == NULL) {
     177           0 :                 return SBC_ERR_NOMEM;
     178             :         }
     179             : 
     180          24 :         return SBC_ERR_OK;
     181             : }
     182             : 
     183         650 : static sbcErr smbconf_txt_load_file(struct smbconf_ctx *ctx)
     184             : {
     185             :         sbcErr err;
     186             :         uint64_t new_csn;
     187             : 
     188         650 :         if (!file_exist(ctx->path)) {
     189           0 :                 return SBC_ERR_BADFILE;
     190             :         }
     191             : 
     192         650 :         new_csn = (uint64_t)file_modtime(ctx->path);
     193         650 :         if (new_csn == pd(ctx)->csn) {
     194         626 :                 return SBC_ERR_OK;
     195             :         }
     196             : 
     197          24 :         err = smbconf_txt_init_cache(ctx);
     198          24 :         if (!SBC_ERROR_IS_OK(err)) {
     199           0 :                 return err;
     200             :         }
     201             : 
     202          24 :         if (!pm_process(ctx->path, smbconf_txt_do_section,
     203          24 :                         smbconf_txt_do_parameter, pd(ctx)))
     204             :         {
     205           0 :                 return SBC_ERR_CAN_NOT_COMPLETE;
     206             :         }
     207             : 
     208          24 :         pd(ctx)->csn = new_csn;
     209             : 
     210          24 :         return SBC_ERR_OK;
     211             : }
     212             : 
     213             : 
     214             : /**********************************************************************
     215             :  *
     216             :  * smbconf operations: text backend implementations
     217             :  *
     218             :  **********************************************************************/
     219             : 
     220             : /**
     221             :  * initialize the text based smbconf backend
     222             :  */
     223          24 : static sbcErr smbconf_txt_init(struct smbconf_ctx *ctx, const char *path)
     224             : {
     225          24 :         if (path == NULL) {
     226           0 :                 return SBC_ERR_BADFILE;
     227             :         }
     228          24 :         ctx->path = talloc_strdup(ctx, path);
     229          24 :         if (ctx->path == NULL) {
     230           0 :                 return SBC_ERR_NOMEM;
     231             :         }
     232             : 
     233          24 :         ctx->data = talloc_zero(ctx, struct txt_private_data);
     234          24 :         if (ctx->data == NULL) {
     235           0 :                 return SBC_ERR_NOMEM;
     236             :         }
     237             : 
     238          24 :         pd(ctx)->verbatim = true;
     239             : 
     240          24 :         return SBC_ERR_OK;
     241             : }
     242             : 
     243          24 : static int smbconf_txt_shutdown(struct smbconf_ctx *ctx)
     244             : {
     245          24 :         return ctx->ops->close_conf(ctx);
     246             : }
     247             : 
     248           0 : static bool smbconf_txt_requires_messaging(struct smbconf_ctx *ctx)
     249             : {
     250           0 :         return false;
     251             : }
     252             : 
     253           0 : static bool smbconf_txt_is_writeable(struct smbconf_ctx *ctx)
     254             : {
     255             :         /* no write support in this backend yet... */
     256           0 :         return false;
     257             : }
     258             : 
     259           0 : static sbcErr smbconf_txt_open(struct smbconf_ctx *ctx)
     260             : {
     261           0 :         return smbconf_txt_load_file(ctx);
     262             : }
     263             : 
     264          24 : static int smbconf_txt_close(struct smbconf_ctx *ctx)
     265             : {
     266          24 :         smbconf_txt_flush_cache(ctx);
     267          24 :         return 0;
     268             : }
     269             : 
     270             : /**
     271             :  * Get the change sequence number of the given service/parameter.
     272             :  * service and parameter strings may be NULL.
     273             :  */
     274           0 : static void smbconf_txt_get_csn(struct smbconf_ctx *ctx,
     275             :                                 struct smbconf_csn *csn,
     276             :                                 const char *service, const char *param)
     277             : {
     278           0 :         if (csn == NULL) {
     279           0 :                 return;
     280             :         }
     281             : 
     282           0 :         csn->csn = (uint64_t)file_modtime(ctx->path);
     283             : }
     284             : 
     285             : /**
     286             :  * Drop the whole configuration (restarting empty)
     287             :  */
     288           0 : static sbcErr smbconf_txt_drop(struct smbconf_ctx *ctx)
     289             : {
     290           0 :         return SBC_ERR_NOT_SUPPORTED;
     291             : }
     292             : 
     293             : /**
     294             :  * get the list of share names defined in the configuration.
     295             :  */
     296           8 : static sbcErr smbconf_txt_get_share_names(struct smbconf_ctx *ctx,
     297             :                                           TALLOC_CTX *mem_ctx,
     298             :                                           uint32_t *num_shares,
     299             :                                           char ***share_names)
     300             : {
     301             :         uint32_t count;
     302           8 :         uint32_t added_count = 0;
     303           8 :         TALLOC_CTX *tmp_ctx = NULL;
     304           8 :         sbcErr err = SBC_ERR_OK;
     305           8 :         char **tmp_share_names = NULL;
     306             : 
     307           8 :         if ((num_shares == NULL) || (share_names == NULL)) {
     308           0 :                 return SBC_ERR_INVALID_PARAM;
     309             :         }
     310             : 
     311           8 :         err = smbconf_txt_load_file(ctx);
     312           8 :         if (!SBC_ERROR_IS_OK(err)) {
     313           0 :                 return err;
     314             :         }
     315             : 
     316           8 :         tmp_ctx = talloc_stackframe();
     317             : 
     318             :         /* make sure "global" is always listed first,
     319             :          * possibly after NULL section */
     320             : 
     321           8 :         if (smbconf_share_exists(ctx, NULL)) {
     322           0 :                 err = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
     323             :                                                   0, NULL);
     324           0 :                 if (!SBC_ERROR_IS_OK(err)) {
     325           0 :                         goto done;
     326             :                 }
     327           0 :                 added_count++;
     328             :         }
     329             : 
     330           8 :         if (smbconf_share_exists(ctx, GLOBAL_NAME)) {
     331           4 :                 err = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
     332             :                                                    added_count, GLOBAL_NAME);
     333           4 :                 if (!SBC_ERROR_IS_OK(err)) {
     334           0 :                         goto done;
     335             :                 }
     336           4 :                 added_count++;
     337             :         }
     338             : 
     339         592 :         for (count = 0; count < pd(ctx)->cache->num_shares; count++) {
     340        1164 :                 if (strequal(pd(ctx)->cache->share_names[count], GLOBAL_NAME) ||
     341         580 :                     (pd(ctx)->cache->share_names[count] == NULL))
     342             :                 {
     343           4 :                         continue;
     344             :                 }
     345             : 
     346         580 :                 err = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
     347             :                                         added_count,
     348         580 :                                         pd(ctx)->cache->share_names[count]);
     349         580 :                 if (!SBC_ERROR_IS_OK(err)) {
     350           0 :                         goto done;
     351             :                 }
     352         580 :                 added_count++;
     353             :         }
     354             : 
     355           8 :         *num_shares = added_count;
     356           8 :         if (added_count > 0) {
     357           8 :                 *share_names = talloc_move(mem_ctx, &tmp_share_names);
     358             :         } else {
     359           0 :                 *share_names = NULL;
     360             :         }
     361             : 
     362           8 : done:
     363           8 :         talloc_free(tmp_ctx);
     364           8 :         return err;
     365             : }
     366             : 
     367             : /**
     368             :  * check if a share/service of a given name exists
     369             :  */
     370          18 : static bool smbconf_txt_share_exists(struct smbconf_ctx *ctx,
     371             :                                      const char *servicename)
     372             : {
     373             :         sbcErr err;
     374             : 
     375          18 :         err = smbconf_txt_load_file(ctx);
     376          18 :         if (!SBC_ERROR_IS_OK(err)) {
     377           0 :                 return false;
     378             :         }
     379             : 
     380          36 :         return smbconf_find_in_array(servicename,
     381          18 :                                      pd(ctx)->cache->share_names,
     382          18 :                                      pd(ctx)->cache->num_shares, NULL);
     383             : }
     384             : 
     385             : /**
     386             :  * Add a service if it does not already exist
     387             :  */
     388           0 : static sbcErr smbconf_txt_create_share(struct smbconf_ctx *ctx,
     389             :                                        const char *servicename)
     390             : {
     391           0 :         return SBC_ERR_NOT_SUPPORTED;
     392             : }
     393             : 
     394             : /**
     395             :  * get a definition of a share (service) from configuration.
     396             :  */
     397         598 : static sbcErr smbconf_txt_get_share(struct smbconf_ctx *ctx,
     398             :                                     TALLOC_CTX *mem_ctx,
     399             :                                     const char *servicename,
     400             :                                     struct smbconf_service **service)
     401             : {
     402             :         sbcErr err;
     403             :         uint32_t sidx, count;
     404             :         bool found;
     405         598 :         TALLOC_CTX *tmp_ctx = NULL;
     406         598 :         struct smbconf_service *tmp_service = NULL;
     407             : 
     408         598 :         err = smbconf_txt_load_file(ctx);
     409         598 :         if (!SBC_ERROR_IS_OK(err)) {
     410           0 :                 return err;
     411             :         }
     412             : 
     413        1196 :         found = smbconf_find_in_array(servicename,
     414         598 :                                       pd(ctx)->cache->share_names,
     415         598 :                                       pd(ctx)->cache->num_shares,
     416             :                                       &sidx);
     417         598 :         if (!found) {
     418           0 :                 return SBC_ERR_NO_SUCH_SERVICE;
     419             :         }
     420             : 
     421         598 :         tmp_ctx = talloc_stackframe();
     422             : 
     423         598 :         tmp_service = talloc_zero(tmp_ctx, struct smbconf_service);
     424         598 :         if (tmp_service == NULL) {
     425           0 :                 err = SBC_ERR_NOMEM;
     426           0 :                 goto done;
     427             :         }
     428             : 
     429         598 :         if (servicename != NULL) {
     430         598 :                 tmp_service->name = talloc_strdup(tmp_service, servicename);
     431         598 :                 if (tmp_service->name == NULL) {
     432           0 :                         err = SBC_ERR_NOMEM;
     433           0 :                         goto done;
     434             :                 }
     435             :         }
     436             : 
     437        3266 :         for (count = 0; count < pd(ctx)->cache->num_params[sidx]; count++) {
     438        5336 :                 err = smbconf_add_string_to_array(tmp_service,
     439        2668 :                                 &(tmp_service->param_names),
     440             :                                 count,
     441        2668 :                                 pd(ctx)->cache->param_names[sidx][count]);
     442        2668 :                 if (!SBC_ERROR_IS_OK(err)) {
     443           0 :                         goto done;
     444             :                 }
     445        5336 :                 err = smbconf_add_string_to_array(tmp_service,
     446        2668 :                                 &(tmp_service->param_values),
     447             :                                 count,
     448        2668 :                                 pd(ctx)->cache->param_values[sidx][count]);
     449        2668 :                 if (!SBC_ERROR_IS_OK(err)) {
     450           0 :                         goto done;
     451             :                 }
     452             :         }
     453             : 
     454         598 :         tmp_service->num_params = count;
     455         598 :         *service = talloc_move(mem_ctx, &tmp_service);
     456             : 
     457         598 : done:
     458         598 :         talloc_free(tmp_ctx);
     459         598 :         return err;
     460             : }
     461             : 
     462             : /**
     463             :  * delete a service from configuration
     464             :  */
     465           0 : static sbcErr smbconf_txt_delete_share(struct smbconf_ctx *ctx,
     466             :                                        const char *servicename)
     467             : {
     468           0 :         return SBC_ERR_NOT_SUPPORTED;
     469             : }
     470             : 
     471             : /**
     472             :  * set a configuration parameter to the value provided.
     473             :  */
     474           0 : static sbcErr smbconf_txt_set_parameter(struct smbconf_ctx *ctx,
     475             :                                         const char *service,
     476             :                                         const char *param,
     477             :                                         const char *valstr)
     478             : {
     479           0 :         return SBC_ERR_NOT_SUPPORTED;
     480             : }
     481             : 
     482             : /**
     483             :  * get the value of a configuration parameter as a string
     484             :  */
     485           0 : static sbcErr smbconf_txt_get_parameter(struct smbconf_ctx *ctx,
     486             :                                         TALLOC_CTX *mem_ctx,
     487             :                                         const char *service,
     488             :                                         const char *param,
     489             :                                         char **valstr)
     490             : {
     491             :         sbcErr err;
     492             :         bool found;
     493             :         uint32_t share_index, param_index;
     494             : 
     495           0 :         err = smbconf_txt_load_file(ctx);
     496           0 :         if (!SBC_ERROR_IS_OK(err)) {
     497           0 :                 return err;
     498             :         }
     499             : 
     500           0 :         found = smbconf_find_in_array(service,
     501           0 :                                       pd(ctx)->cache->share_names,
     502           0 :                                       pd(ctx)->cache->num_shares,
     503             :                                       &share_index);
     504           0 :         if (!found) {
     505           0 :                 return SBC_ERR_NO_SUCH_SERVICE;
     506             :         }
     507             : 
     508           0 :         found = smbconf_reverse_find_in_array(param,
     509           0 :                                 pd(ctx)->cache->param_names[share_index],
     510           0 :                                 pd(ctx)->cache->num_params[share_index],
     511             :                                 &param_index);
     512           0 :         if (!found) {
     513           0 :                 return SBC_ERR_INVALID_PARAM;
     514             :         }
     515             : 
     516           0 :         *valstr = talloc_strdup(mem_ctx,
     517           0 :                         pd(ctx)->cache->param_values[share_index][param_index]);
     518             : 
     519           0 :         if (*valstr == NULL) {
     520           0 :                 return SBC_ERR_NOMEM;
     521             :         }
     522             : 
     523           0 :         return SBC_ERR_OK;
     524             : }
     525             : 
     526             : /**
     527             :  * delete a parameter from configuration
     528             :  */
     529           0 : static sbcErr smbconf_txt_delete_parameter(struct smbconf_ctx *ctx,
     530             :                                            const char *service,
     531             :                                            const char *param)
     532             : {
     533           0 :         return SBC_ERR_NOT_SUPPORTED;
     534             : }
     535             : 
     536           2 : static sbcErr smbconf_txt_get_includes(struct smbconf_ctx *ctx,
     537             :                                        TALLOC_CTX *mem_ctx,
     538             :                                        const char *service,
     539             :                                        uint32_t *num_includes,
     540             :                                        char ***includes)
     541             : {
     542             :         sbcErr err;
     543             :         bool found;
     544             :         uint32_t sidx, count;
     545           2 :         TALLOC_CTX *tmp_ctx = NULL;
     546           2 :         uint32_t tmp_num_includes = 0;
     547           2 :         char **tmp_includes = NULL;
     548             : 
     549           2 :         err = smbconf_txt_load_file(ctx);
     550           2 :         if (!SBC_ERROR_IS_OK(err)) {
     551           0 :                 return err;
     552             :         }
     553             : 
     554           4 :         found = smbconf_find_in_array(service,
     555           2 :                                       pd(ctx)->cache->share_names,
     556           2 :                                       pd(ctx)->cache->num_shares,
     557             :                                       &sidx);
     558           2 :         if (!found) {
     559           0 :                 return SBC_ERR_NO_SUCH_SERVICE;
     560             :         }
     561             : 
     562           2 :         tmp_ctx = talloc_stackframe();
     563             : 
     564           8 :         for (count = 0; count < pd(ctx)->cache->num_params[sidx]; count++) {
     565           6 :                 if (strequal(pd(ctx)->cache->param_names[sidx][count],
     566             :                              "include"))
     567             :                 {
     568           0 :                         err = smbconf_add_string_to_array(tmp_ctx,
     569             :                                 &tmp_includes,
     570             :                                 tmp_num_includes,
     571           0 :                                 pd(ctx)->cache->param_values[sidx][count]);
     572           0 :                         if (!SBC_ERROR_IS_OK(err)) {
     573           0 :                                 goto done;
     574             :                         }
     575           0 :                         tmp_num_includes++;
     576             :                 }
     577             :         }
     578             : 
     579           2 :         *num_includes = tmp_num_includes;
     580           2 :         if (*num_includes > 0) {
     581           0 :                 *includes = talloc_move(mem_ctx, &tmp_includes);
     582           0 :                 if (*includes == NULL) {
     583           0 :                         err = SBC_ERR_NOMEM;
     584           0 :                         goto done;
     585             :                 }
     586             :         } else {
     587           2 :                 *includes = NULL;
     588             :         }
     589             : 
     590           2 :         err = SBC_ERR_OK;
     591             : 
     592           2 : done:
     593           2 :         talloc_free(tmp_ctx);
     594           2 :         return err;
     595             : }
     596             : 
     597           0 : static sbcErr smbconf_txt_set_includes(struct smbconf_ctx *ctx,
     598             :                                        const char *service,
     599             :                                        uint32_t num_includes,
     600             :                                        const char **includes)
     601             : {
     602           0 :         return SBC_ERR_NOT_SUPPORTED;
     603             : }
     604             : 
     605           0 : static sbcErr smbconf_txt_delete_includes(struct smbconf_ctx *ctx,
     606             :                                           const char *service)
     607             : {
     608           0 :         return SBC_ERR_NOT_SUPPORTED;
     609             : }
     610             : 
     611           0 : static sbcErr smbconf_txt_transaction_start(struct smbconf_ctx *ctx)
     612             : {
     613           0 :         return SBC_ERR_OK;
     614             : }
     615             : 
     616           0 : static sbcErr smbconf_txt_transaction_commit(struct smbconf_ctx *ctx)
     617             : {
     618           0 :         return SBC_ERR_OK;
     619             : }
     620             : 
     621           0 : static sbcErr smbconf_txt_transaction_cancel(struct smbconf_ctx *ctx)
     622             : {
     623           0 :         return SBC_ERR_OK;
     624             : }
     625             : 
     626             : static struct smbconf_ops smbconf_ops_txt = {
     627             :         .init                   = smbconf_txt_init,
     628             :         .shutdown               = smbconf_txt_shutdown,
     629             :         .requires_messaging     = smbconf_txt_requires_messaging,
     630             :         .is_writeable           = smbconf_txt_is_writeable,
     631             :         .open_conf              = smbconf_txt_open,
     632             :         .close_conf             = smbconf_txt_close,
     633             :         .get_csn                = smbconf_txt_get_csn,
     634             :         .drop                   = smbconf_txt_drop,
     635             :         .get_share_names        = smbconf_txt_get_share_names,
     636             :         .share_exists           = smbconf_txt_share_exists,
     637             :         .create_share           = smbconf_txt_create_share,
     638             :         .get_share              = smbconf_txt_get_share,
     639             :         .delete_share           = smbconf_txt_delete_share,
     640             :         .set_parameter          = smbconf_txt_set_parameter,
     641             :         .get_parameter          = smbconf_txt_get_parameter,
     642             :         .delete_parameter       = smbconf_txt_delete_parameter,
     643             :         .get_includes           = smbconf_txt_get_includes,
     644             :         .set_includes           = smbconf_txt_set_includes,
     645             :         .delete_includes        = smbconf_txt_delete_includes,
     646             :         .transaction_start      = smbconf_txt_transaction_start,
     647             :         .transaction_commit     = smbconf_txt_transaction_commit,
     648             :         .transaction_cancel     = smbconf_txt_transaction_cancel,
     649             : };
     650             : 
     651             : 
     652             : /**
     653             :  * initialize the smbconf text backend
     654             :  * the only function that is exported from this module
     655             :  */
     656          24 : sbcErr smbconf_init_txt(TALLOC_CTX *mem_ctx,
     657             :                         struct smbconf_ctx **conf_ctx,
     658             :                         const char *path)
     659             : {
     660             :         sbcErr err;
     661             : 
     662          24 :         err = smbconf_init_internal(mem_ctx, conf_ctx, path, &smbconf_ops_txt);
     663          24 :         if (!SBC_ERROR_IS_OK(err)) {
     664           0 :                 return err;
     665             :         }
     666             : 
     667          24 :         return smbconf_txt_load_file(*conf_ctx);
     668             : }

Generated by: LCOV version 1.13