Ignore:
Timestamp:
May 24, 2009, 7:51:24 AM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Update Samba 3.3 branch to 3.3.3

Location:
branches/samba-3.3.x/source/lib
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • branches/samba-3.3.x/source/lib/charcnv.c

    r206 r223  
    243243                                if (allow_bad_conv)
    244244                                        goto use_as_is;
    245                                 break;
     245                                return (size_t)-1;
    246246                        case E2BIG:
    247247                                reason="No more room";
     
    264264                                if (allow_bad_conv)
    265265                                        goto use_as_is;
    266                                 break;
     266                               
     267                                return (size_t)-1;
    267268                        default:
    268269                                if (!conv_silent)
    269270                                        DEBUG(0,("convert_string_internal: Conversion error: %s(%s)\n",reason,inbuf));
    270                                 break;
     271                                return (size_t)-1;
    271272                }
    272273                /* smb_panic(reason); */
     
    413414                                goto general_case;
    414415#else
    415                                 return retval + convert_string_internal(from, to, p, slen, q, dlen, allow_bad_conv);
     416                                size_t ret = convert_string_internal(from, to, p, slen, q, dlen, allow_bad_conv);
     417                                if (ret == (size_t)-1) {
     418                                        return ret;
     419                                }
     420                                return retval + ret;
    416421#endif
    417422                        }
     
    449454                                goto general_case;
    450455#else
    451                                 return retval + convert_string_internal(from, to, p, slen, q, dlen, allow_bad_conv);
     456                                size_t ret = convert_string_internal(from, to, p, slen, q, dlen, allow_bad_conv);
     457                                if (ret == (size_t)-1) {
     458                                        return ret;
     459                                }
     460                                return retval + ret;
    452461#endif
    453462                        }
     
    485494                                goto general_case;
    486495#else
    487                                 return retval + convert_string_internal(from, to, p, slen, q, dlen, allow_bad_conv);
     496                                size_t ret = convert_string_internal(from, to, p, slen, q, dlen, allow_bad_conv);
     497                                if (ret == (size_t)-1) {
     498                                        return ret;
     499                                }
     500                                return retval + ret;
    488501#endif
    489502                        }
  • branches/samba-3.3.x/source/lib/dbwrap.c

    r206 r223  
    4343}
    4444
     45/*
     46 * Fall back using fetch if no genuine parse operation is provided
     47 */
     48
     49static int dbwrap_fallback_parse_record(struct db_context *db, TDB_DATA key,
     50                                        int (*parser)(TDB_DATA key,
     51                                                      TDB_DATA data,
     52                                                      void *private_data),
     53                                        void *private_data)
     54{
     55        TDB_DATA data;
     56        int res;
     57
     58        res = db->fetch(db, talloc_tos(), key, &data);
     59        if (res != 0) {
     60                return res;
     61        }
     62
     63        res = parser(key, data, private_data);
     64        TALLOC_FREE(data.dptr);
     65        return res;
     66}
     67
     68bool db_is_local(const char *name)
     69{
     70#ifdef CLUSTER_SUPPORT
     71        const char *sockname = lp_ctdbd_socket();
     72
     73        if(!sockname || !*sockname) {
     74                sockname = CTDB_PATH;
     75        }
     76
     77        if (lp_clustering() && socket_exist(sockname)) {
     78                const char *partname;
     79                /* ctdb only wants the file part of the name */
     80                partname = strrchr(name, '/');
     81                if (partname) {
     82                        partname++;
     83                } else {
     84                        partname = name;
     85                }
     86                /* allow ctdb for individual databases to be disabled */
     87                if (lp_parm_bool(-1, "ctdb", partname, True)) {
     88                        return false;
     89                }
     90        }
     91#endif
     92        return true;
     93}
     94
    4595/**
    4696 * open a database
     
    102152                result->fetch = dbwrap_fallback_fetch;
    103153        }
     154        if ((result != NULL) && (result->parse_record == NULL)) {
     155                result->parse_record = dbwrap_fallback_parse_record;
     156        }
    104157
    105158        return result;
  • branches/samba-3.3.x/source/lib/dbwrap_ctdb.c

    r206 r223  
    122122        struct ctdb_rec_data *r;
    123123        size_t m_size, r_size;
    124         struct ctdb_marshall_buffer *m2;
    125 
    126         r = db_ctdb_marshall_record(mem_ctx, reqid, key, header, data);
     124        struct ctdb_marshall_buffer *m2 = NULL;
     125
     126        r = db_ctdb_marshall_record(talloc_tos(), reqid, key, header, data);
    127127        if (r == NULL) {
    128128                talloc_free(m);
     
    134134                        mem_ctx, offsetof(struct ctdb_marshall_buffer, data));
    135135                if (m == NULL) {
    136                         return NULL;
     136                        goto done;
    137137                }
    138138                m->db_id = db_id;
     
    146146        if (m2 == NULL) {
    147147                talloc_free(m);
    148                 return NULL;
     148                goto done;
    149149        }
    150150
    151151        memcpy(m_size + (uint8_t *)m2, r, r_size);
    152152
     153        m2->count++;
     154
     155done:
    153156        talloc_free(r);
    154 
    155         m2->count++;
    156 
    157157        return m2;
    158158}
  • branches/samba-3.3.x/source/lib/dbwrap_rbt.c

    r206 r223  
    132132        }
    133133
    134         node = (struct db_rbt_node *)SMB_MALLOC(
     134        node = (struct db_rbt_node *)talloc_size(rec_priv->db_ctx,
    135135                offsetof(struct db_rbt_node, data) + rec->key.dsize
    136136                + data.dsize);
    137137
    138138        if (node == NULL) {
    139                 SAFE_FREE(rec_priv->node);
     139                TALLOC_FREE(rec_priv->node);
    140140                return NT_STATUS_NO_MEMORY;
    141141        }
     
    149149
    150150        memcpy(this_key.dptr, rec->key.dptr, node->keysize);
    151         SAFE_FREE(rec_priv->node);
     151        TALLOC_FREE(rec_priv->node);
    152152
    153153        memcpy(this_val.dptr, data.dptr, node->valuesize);
     
    195195
    196196        rb_erase(&rec_priv->node->rb_node, &rec_priv->db_ctx->tree);
    197         SAFE_FREE(rec_priv->node);
     197        TALLOC_FREE(rec_priv->node);
    198198
    199199        return NT_STATUS_OK;
  • branches/samba-3.3.x/source/lib/dbwrap_tdb.c

    r206 r223  
    177177}
    178178
     179static int db_tdb_parse(struct db_context *db, TDB_DATA key,
     180                        int (*parser)(TDB_DATA key, TDB_DATA data,
     181                                      void *private_data),
     182                        void *private_data)
     183{
     184        struct db_tdb_ctx *ctx = talloc_get_type_abort(
     185                db->private_data, struct db_tdb_ctx);
     186
     187        return tdb_parse_record(ctx->wtdb->tdb, key, parser, private_data);
     188}
     189
    179190static NTSTATUS db_tdb_store(struct db_record *rec, TDB_DATA data, int flag)
    180191{
     
    344355        result->traverse = db_tdb_traverse;
    345356        result->traverse_read = db_tdb_traverse_read;
     357        result->parse_record = db_tdb_parse;
    346358        result->get_seqnum = db_tdb_get_seqnum;
    347359        result->persistent = ((tdb_flags & TDB_CLEAR_IF_FIRST) == 0);
  • branches/samba-3.3.x/source/lib/netapi/group.c

    r206 r223  
    13201320        *r->out.buffer = NULL;
    13211321        *r->out.entries_read = 0;
     1322        *r->out.total_entries = 0;
    13221323
    13231324        switch (r->in.level) {
     
    14091410        }
    14101411
    1411         if (r->out.entries_read) {
    1412                 *r->out.entries_read = entries_read;
    1413         }
    1414 
    1415         if (r->out.total_entries) {
    1416                 *r->out.total_entries = entries_read;
    1417         }
     1412        *r->out.entries_read = entries_read;
     1413        *r->out.total_entries = entries_read;
    14181414
    14191415        werr = WERR_OK;
  • branches/samba-3.3.x/source/lib/netapi/user.c

    r206 r223  
    15111511        NTSTATUS status = NT_STATUS_OK;
    15121512        WERROR werr;
     1513        WERROR werr_tmp;
     1514
     1515        *r->out.entries_read = 0;
    15131516
    15141517        ZERO_STRUCT(connect_handle);
     
    15551558                                               &returned_size,
    15561559                                               &info);
    1557         if (!NT_STATUS_IS_OK(status)) {
    1558                 werr = ntstatus_to_werror(status);
    1559                 goto done;
    1560         }
    1561 
    1562         werr = convert_samr_dispinfo_to_NET_DISPLAY(ctx, &info,
    1563                                                     r->in.level,
    1564                                                     r->out.entries_read,
    1565                                                     r->out.buffer);
     1560        werr = ntstatus_to_werror(status);
     1561        if (NT_STATUS_IS_ERR(status)) {
     1562                goto done;
     1563        }
     1564
     1565        werr_tmp = convert_samr_dispinfo_to_NET_DISPLAY(ctx, &info,
     1566                                                        r->in.level,
     1567                                                        r->out.entries_read,
     1568                                                        r->out.buffer);
     1569        if (!W_ERROR_IS_OK(werr_tmp)) {
     1570                werr = werr_tmp;
     1571        }
    15661572 done:
    15671573        if (!cli) {
     
    28502856        *r->out.buffer = NULL;
    28512857        *r->out.entries_read = 0;
     2858        *r->out.total_entries = 0;
    28522859
    28532860        switch (r->in.level) {
     
    29442951        }
    29452952
    2946         if (r->out.entries_read) {
    2947                 *r->out.entries_read = entries_read;
    2948         }
    2949         if (r->out.total_entries) {
    2950                 *r->out.total_entries = entries_read;
    2951         }
     2953        *r->out.entries_read = entries_read;
     2954        *r->out.total_entries = entries_read;
    29522955
    29532956 done:
     
    32983301        *r->out.buffer = NULL;
    32993302        *r->out.entries_read = 0;
     3303        *r->out.total_entries = 0;
    33003304
    33013305        switch (r->in.level) {
     
    34593463        }
    34603464
    3461         if (r->out.entries_read) {
    3462                 *r->out.entries_read = entries_read;
    3463         }
    3464         if (r->out.total_entries) {
    3465                 *r->out.total_entries = entries_read;
    3466         }
     3465        *r->out.entries_read = entries_read;
     3466        *r->out.total_entries = entries_read;
    34673467
    34683468 done:
  • branches/samba-3.3.x/source/lib/replace/libreplace_network.m4

    r221 r223  
    99AC_CHECK_HEADERS(sys/socket.h netinet/in.h netdb.h arpa/inet.h)
    1010AC_CHECK_HEADERS(netinet/in_systm.h)
    11 AC_CHECK_HEADERS([netinet/ip.h], [], [], [#ifdef HAVE_NETINET_IN_H
    12 #include <netinet/in.h>
    13 #endif
    14 #ifdef HAVE_NETINET_IN_SYSTM_H
    15 #include <netinet/in_systm.h>
    16 #endif])
     11AC_CHECK_HEADERS([netinet/ip.h], [], [],[
     12        #include <sys/types.h>
     13        #ifdef HAVE_NETINET_IN_H
     14        #include <netinet/in.h>
     15        #endif
     16        #ifdef HAVE_NETINET_IN_SYSTM_H
     17        #include <netinet/in_systm.h>
     18        #endif
     19])
    1720AC_CHECK_HEADERS(netinet/tcp.h netinet/in_ip.h)
    1821AC_CHECK_HEADERS(sys/sockio.h sys/un.h)
  • branches/samba-3.3.x/source/lib/smbconf/smbconf.c

    r206 r223  
    4444
    4545/**
     46 * Tell whether the backend requires messaging to be set up
     47 * for the backend to work correctly.
     48 */
     49bool smbconf_backend_requires_messaging(struct smbconf_ctx *ctx)
     50{
     51        return ctx->ops->requires_messaging(ctx);
     52}
     53
     54/**
     55 * Tell whether the source is writeable.
     56 */
     57bool smbconf_is_writeable(struct smbconf_ctx *ctx)
     58{
     59        return ctx->ops->is_writeable(ctx);
     60}
     61
     62/**
    4663 * Close the configuration.
    4764 */
    4865void smbconf_shutdown(struct smbconf_ctx *ctx)
    4966{
    50         TALLOC_FREE(ctx);
     67        talloc_free(ctx);
    5168}
    5269
     
    141158
    142159done:
    143         TALLOC_FREE(tmp_ctx);
     160        talloc_free(tmp_ctx);
    144161        return werr;
    145162}
     
    187204                         struct smbconf_service **service)
    188205{
    189         if (!smbconf_share_exists(ctx, servicename)) {
    190                 return WERR_NO_SUCH_SERVICE;
    191         }
    192 
    193206        return ctx->ops->get_share(ctx, mem_ctx, servicename, service);
    194207}
     
    214227                             const char *valstr)
    215228{
    216         if (!smbconf_share_exists(ctx, service)) {
    217                 return WERR_NO_SUCH_SERVICE;
    218         }
    219 
    220229        return ctx->ops->set_parameter(ctx, service, param, valstr);
    221230}
     
    253262        }
    254263
    255         if (!smbconf_share_exists(ctx, service)) {
    256                 return WERR_NO_SUCH_SERVICE;
    257         }
    258 
    259264        return ctx->ops->get_parameter(ctx, mem_ctx, service, param, valstr);
    260265}
     
    287292                                const char *service, const char *param)
    288293{
    289         if (!smbconf_share_exists(ctx, service)) {
    290                 return WERR_NO_SUCH_SERVICE;
    291         }
    292 
    293294        return ctx->ops->delete_parameter(ctx, service, param);
    294295}
     
    317318                            uint32_t *num_includes, char ***includes)
    318319{
    319         if (!smbconf_share_exists(ctx, service)) {
    320                 return WERR_NO_SUCH_SERVICE;
    321         }
    322 
    323320        return ctx->ops->get_includes(ctx, mem_ctx, service, num_includes,
    324321                                      includes);
     
    344341                            uint32_t num_includes, const char **includes)
    345342{
    346         if (!smbconf_share_exists(ctx, service)) {
    347                 return WERR_NO_SUCH_SERVICE;
    348         }
    349 
    350343        return ctx->ops->set_includes(ctx, service, num_includes, includes);
    351344}
     
    369362WERROR smbconf_delete_includes(struct smbconf_ctx *ctx, const char *service)
    370363{
    371         if (!smbconf_share_exists(ctx, service)) {
    372                 return WERR_NO_SUCH_SERVICE;
    373         }
    374 
    375364        return ctx->ops->delete_includes(ctx, service);
    376365}
     
    387376        return werr;
    388377}
     378
     379WERROR smbconf_transaction_start(struct smbconf_ctx *ctx)
     380{
     381        return ctx->ops->transaction_start(ctx);
     382}
     383
     384WERROR smbconf_transaction_commit(struct smbconf_ctx *ctx)
     385{
     386        return ctx->ops->transaction_commit(ctx);
     387}
     388
     389WERROR smbconf_transaction_cancel(struct smbconf_ctx *ctx)
     390{
     391        return ctx->ops->transaction_cancel(ctx);
     392}
  • branches/samba-3.3.x/source/lib/smbconf/smbconf.h

    r206 r223  
    3535};
    3636
    37 
    38 /**
    39  * intialization dispatcher function.
    40  * takes source string in the form of "backend:path"
    41  */
    42 WERROR smbconf_init(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
    43                     const char *source);
    44 
    45 /**
    46  * initialization functions for the available modules
    47  */
    48 
    49 WERROR smbconf_init_reg(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
    50                         const char *path);
    51 
    52 WERROR smbconf_init_txt(TALLOC_CTX *mem_ctx,
    53                         struct smbconf_ctx **conf_ctx,
    54                         const char *path);
    55 
    5637/*
    5738 * the smbconf API functions
    5839 */
     40bool smbconf_backend_requires_messaging(struct smbconf_ctx *ctx);
     41bool smbconf_is_writeable(struct smbconf_ctx *ctx);
    5942void smbconf_shutdown(struct smbconf_ctx *ctx);
    6043bool smbconf_changed(struct smbconf_ctx *ctx, struct smbconf_csn *csn,
     
    11295WERROR smbconf_delete_global_includes(struct smbconf_ctx *ctx);
    11396
     97WERROR smbconf_transaction_start(struct smbconf_ctx *ctx);
     98WERROR smbconf_transaction_commit(struct smbconf_ctx *ctx);
     99WERROR smbconf_transaction_cancel(struct smbconf_ctx *ctx);
     100
    114101#endif /*  _LIBSMBCONF_H_  */
  • branches/samba-3.3.x/source/lib/smbconf/smbconf_init.c

    r206 r223  
    1919
    2020#include "includes.h"
    21 #include "smbconf_private.h"
    22 
    23 #define INCLUDES_VALNAME "includes"
    24 
     21#include "lib/smbconf/smbconf_private.h"
     22#include "lib/smbconf/smbconf_txt.h"
     23#include "lib/smbconf/smbconf_reg.h"
    2524
    2625/**
     
    7675                /*
    7776                 * If no separator was given in the source, and the string is
    78                  * not a know backend, assume file backend and use the source
     77                 * not a known backend, assume file backend and use the source
    7978                 * string as a path argument.
    8079                 */
     
    8382                /*
    8483                 * Separator was specified but this is not a known backend.
    85                  * Can't handle this.
     84                 * As a last resort, try to interpret the original source
     85                 * string as a file name that contains a ":" sign.
     86                 * This may occur with an include directive like this:
     87                 * 'include = /path/to/file.%T'
    8688                 */
    87                 DEBUG(1, ("smbconf_init: ERROR - unknown backend '%s' given\n",
    88                           backend));
    89                 werr = WERR_INVALID_PARAM;
     89                werr = smbconf_init_txt(mem_ctx, conf_ctx, source);
    9090        }
    9191
    9292done:
    93         TALLOC_FREE(tmp_ctx);
     93        talloc_free(tmp_ctx);
    9494        return werr;
    9595}
  • branches/samba-3.3.x/source/lib/smbconf/smbconf_private.h

    r206 r223  
    2424        WERROR (*init)(struct smbconf_ctx *ctx, const char *path);
    2525        int (*shutdown)(struct smbconf_ctx *ctx);
     26        bool (*requires_messaging)(struct smbconf_ctx *ctx);
     27        bool (*is_writeable)(struct smbconf_ctx *ctx);
    2628        WERROR (*open_conf)(struct smbconf_ctx *ctx);
    2729        int (*close_conf)(struct smbconf_ctx *ctx);
     
    6163        WERROR (*delete_includes)(struct smbconf_ctx *ctx,
    6264                                  const char *service);
     65        WERROR (*transaction_start)(struct smbconf_ctx *ctx);
     66        WERROR (*transaction_commit)(struct smbconf_ctx *ctx);
     67        WERROR (*transaction_cancel)(struct smbconf_ctx *ctx);
    6368};
    6469
  • branches/samba-3.3.x/source/lib/smbconf/smbconf_reg.c

    r206 r223  
    1919
    2020#include "includes.h"
    21 #include "smbconf_private.h"
     21#include "lib/smbconf/smbconf_private.h"
    2222
    2323#define INCLUDES_VALNAME "includes"
    2424
    2525struct reg_private_data {
    26         NT_USER_TOKEN *token;
     26        struct registry_key *base_key;
    2727        bool open;              /* did _we_ open the registry? */
    2828};
     
    7373
    7474/**
    75  * Open a registry key specified by "path"
    76  */
    77 static WERROR smbconf_reg_open_path(TALLOC_CTX *mem_ctx,
    78                                     struct smbconf_ctx *ctx,
    79                                     const char *path,
    80                                     uint32 desired_access,
    81                                     struct registry_key **key)
    82 {
    83         WERROR werr = WERR_OK;
    84 
    85         if (ctx == NULL) {
    86                 DEBUG(1, ("Error: configuration is not open!\n"));
    87                 werr = WERR_INVALID_PARAM;
    88                 goto done;
    89         }
    90 
    91         if (rpd(ctx)->token == NULL) {
    92                 DEBUG(1, ("Error: token missing from smbconf_ctx. "
    93                           "was smbconf_init() called?\n"));
    94                 werr = WERR_INVALID_PARAM;
    95                 goto done;
    96         }
    97 
    98         werr = ctx->ops->open_conf(ctx);
    99         if (!W_ERROR_IS_OK(werr)) {
    100                 DEBUG(1, ("Error opening the registry.\n"));
    101                 goto done;
    102         }
    103 
    104         if (path == NULL) {
    105                 DEBUG(1, ("Error: NULL path string given\n"));
    106                 werr = WERR_INVALID_PARAM;
    107                 goto done;
    108         }
    109 
    110         werr = reg_open_path(mem_ctx, path, desired_access, rpd(ctx)->token,
    111                              key);
    112 
    113         if (!W_ERROR_IS_OK(werr)) {
    114                 DEBUG(5, ("Error opening registry path '%s': %s\n",
    115                           path, dos_errstr(werr)));
    116         }
    117 
    118 done:
    119         return werr;
    120 }
    121 
    122 /**
    12375 * Open a subkey of the base key (i.e a service)
    12476 */
     
    12981                                           struct registry_key **key)
    13082{
    131         WERROR werr = WERR_OK;
    132         char *path = NULL;
     83        WERROR werr;
    13384
    13485        if (servicename == NULL) {
    135                 path = talloc_strdup(mem_ctx, ctx->path);
    136         } else {
    137                 path = talloc_asprintf(mem_ctx, "%s\\%s", ctx->path,
    138                                        servicename);
    139         }
    140         if (path == NULL) {
    141                 werr = WERR_NOMEM;
    142                 goto done;
    143         }
    144 
    145         werr = smbconf_reg_open_path(mem_ctx, ctx, path, desired_access, key);
    146 
    147 done:
    148         TALLOC_FREE(path);
    149         return werr;
    150 }
    151 
    152 /**
    153  * open the base key
    154  */
    155 static WERROR smbconf_reg_open_base_key(TALLOC_CTX *mem_ctx,
    156                                         struct smbconf_ctx *ctx,
    157                                         uint32 desired_access,
    158                                         struct registry_key **key)
    159 {
    160         return smbconf_reg_open_path(mem_ctx, ctx, ctx->path, desired_access,
    161                                      key);
     86                *key = rpd(ctx)->base_key;
     87                return WERR_OK;
     88        }
     89        werr = reg_openkey(mem_ctx, rpd(ctx)->base_key, servicename,
     90                           desired_access, key);
     91
     92        if (W_ERROR_EQUAL(werr, WERR_BADFILE)) {
     93                werr = WERR_NO_SUCH_SERVICE;
     94        }
     95
     96        return werr;
    16297}
    16398
     
    177112        }
    178113
    179         TALLOC_FREE(ctx);
     114        talloc_free(ctx);
    180115        return ret;
    181116}
     
    190125{
    191126        WERROR werr = WERR_OK;
    192         struct registry_key *create_parent = NULL;
    193127        TALLOC_CTX *create_ctx;
    194128        enum winreg_CreateAction action = REG_ACTION_NONE;
     
    199133        create_ctx = talloc_stackframe();
    200134
    201         werr = smbconf_reg_open_base_key(create_ctx, ctx, REG_KEY_WRITE,
    202                                          &create_parent);
    203         if (!W_ERROR_IS_OK(werr)) {
    204                 goto done;
    205         }
    206 
    207         werr = reg_createkey(mem_ctx, create_parent, subkeyname,
     135        werr = reg_createkey(mem_ctx, rpd(ctx)->base_key, subkeyname,
    208136                             REG_KEY_WRITE, newkey, &action);
    209137        if (W_ERROR_IS_OK(werr) && (action != REG_CREATED_NEW_KEY)) {
     
    216144        }
    217145
    218 done:
    219         TALLOC_FREE(create_ctx);
     146        talloc_free(create_ctx);
    220147        return werr;
    221148}
     
    332259
    333260done:
    334         TALLOC_FREE(tmp_ctx);
     261        talloc_free(tmp_ctx);
    335262        return werr;
    336263}
     
    437364
    438365done:
    439         TALLOC_FREE(tmp_ctx);
     366        talloc_free(tmp_ctx);
    440367        return werr;
    441368}
     
    534461
    535462done:
    536         TALLOC_FREE(tmp_ctx);
     463        talloc_free(tmp_ctx);
    537464        return werr;
    538465}
     
    593520
    594521done:
    595         TALLOC_FREE(mem_ctx);
     522        talloc_free(mem_ctx);
    596523        return werr;
    597524}
     
    609536{
    610537        WERROR werr = WERR_OK;
     538        struct nt_user_token *token;
    611539
    612540        if (path == NULL) {
     
    621549        ctx->data = TALLOC_ZERO_P(ctx, struct reg_private_data);
    622550
    623         werr = ntstatus_to_werror(registry_create_admin_token(ctx,
    624                                                         &(rpd(ctx)->token)));
     551        werr = ntstatus_to_werror(registry_create_admin_token(ctx, &token));
    625552        if (!W_ERROR_IS_OK(werr)) {
    626553                DEBUG(1, ("Error creating admin token\n"));
     
    634561        }
    635562
     563        werr = ctx->ops->open_conf(ctx);
     564        if (!W_ERROR_IS_OK(werr)) {
     565                DEBUG(1, ("Error opening the registry.\n"));
     566                goto done;
     567        }
     568
     569        werr = reg_open_path(ctx, ctx->path,
     570                             SEC_RIGHTS_ENUM_SUBKEYS | REG_KEY_WRITE,
     571                             token, &rpd(ctx)->base_key);
     572        if (!W_ERROR_IS_OK(werr)) {
     573                goto done;
     574        }
     575
    636576done:
    637577        return werr;
     
    641581{
    642582        return ctx->ops->close_conf(ctx);
     583}
     584
     585static bool smbconf_reg_requires_messaging(struct smbconf_ctx *ctx)
     586{
     587#ifdef CLUSTER_SUPPORT
     588        if (lp_clustering() && lp_parm_bool(-1, "ctdb", "registry.tdb", true)) {
     589                return true;
     590        }
     591#endif
     592        return false;
     593}
     594
     595static bool smbconf_reg_is_writeable(struct smbconf_ctx *ctx)
     596{
     597        /*
     598         * The backend has write support.
     599         *
     600         *  TODO: add access checks whether the concrete
     601         *  config source is really writeable by the calling user.
     602         */
     603        return true;
    643604}
    644605
     
    703664        TALLOC_CTX* mem_ctx = talloc_stackframe();
    704665        enum winreg_CreateAction action;
     666        struct nt_user_token *token;
     667
     668        werr = ntstatus_to_werror(registry_create_admin_token(ctx, &token));
     669        if (!W_ERROR_IS_OK(werr)) {
     670                DEBUG(1, ("Error creating admin token\n"));
     671                goto done;
     672        }
    705673
    706674        path = talloc_strdup(mem_ctx, ctx->path);
     
    711679        p = strrchr(path, '\\');
    712680        *p = '\0';
    713         werr = smbconf_reg_open_path(mem_ctx, ctx, path, REG_KEY_WRITE,
    714                                      &parent_key);
     681        werr = reg_open_path(mem_ctx, path, REG_KEY_WRITE, token,
     682                             &parent_key);
    715683
    716684        if (!W_ERROR_IS_OK(werr)) {
     
    728696
    729697done:
    730         TALLOC_FREE(mem_ctx);
     698        talloc_free(mem_ctx);
    731699        return werr;
    732700}
     
    745713        TALLOC_CTX *tmp_ctx = NULL;
    746714        WERROR werr = WERR_OK;
    747         struct registry_key *key = NULL;
    748715        char *subkey_name = NULL;
    749716        char **tmp_share_names = NULL;
     
    757724
    758725        /* if there are values in the base key, return NULL as share name */
    759         werr = smbconf_reg_open_base_key(tmp_ctx, ctx,
    760                                          SEC_RIGHTS_ENUM_SUBKEYS, &key);
    761         if (!W_ERROR_IS_OK(werr)) {
    762                 goto done;
    763         }
    764 
    765         if (smbconf_reg_key_has_values(key)) {
     726
     727        if (smbconf_reg_key_has_values(rpd(ctx)->base_key)) {
    766728                werr = smbconf_add_string_to_array(tmp_ctx, &tmp_share_names,
    767729                                                   0, NULL);
     
    783745
    784746        for (count = 0;
    785              werr = reg_enumkey(tmp_ctx, key, count, &subkey_name, NULL),
     747             werr = reg_enumkey(tmp_ctx, rpd(ctx)->base_key, count,
     748                                &subkey_name, NULL),
    786749             W_ERROR_IS_OK(werr);
    787750             count++)
     
    813776
    814777done:
    815         TALLOC_FREE(tmp_ctx);
     778        talloc_free(tmp_ctx);
    816779        return werr;
    817780}
     
    834797        }
    835798
    836         TALLOC_FREE(mem_ctx);
     799        talloc_free(mem_ctx);
    837800        return ret;
    838801}
     
    845808{
    846809        WERROR werr;
    847         TALLOC_CTX *mem_ctx = talloc_stackframe();
    848810        struct registry_key *key = NULL;
    849811
    850812        if (servicename == NULL) {
    851                 werr = smbconf_reg_open_base_key(mem_ctx, ctx, REG_KEY_WRITE,
    852                                                  &key);
    853         } else {
    854                 werr = smbconf_reg_create_service_key(mem_ctx, ctx,
    855                                                       servicename, &key);
    856         }
    857 
    858         TALLOC_FREE(mem_ctx);
     813                return WERR_OK;
     814        }
     815
     816        werr = smbconf_reg_create_service_key(talloc_tos(), ctx,
     817                                              servicename, &key);
     818
     819        talloc_free(key);
    859820        return werr;
    860821}
     
    903864
    904865done:
    905         TALLOC_FREE(tmp_ctx);
     866        talloc_free(tmp_ctx);
    906867        return werr;
    907868}
     
    914875{
    915876        WERROR werr = WERR_OK;
    916         struct registry_key *key = NULL;
    917877        TALLOC_CTX *mem_ctx = talloc_stackframe();
    918878
    919         werr = smbconf_reg_open_base_key(mem_ctx, ctx, REG_KEY_WRITE, &key);
    920         if (!W_ERROR_IS_OK(werr)) {
    921                 goto done;
    922         }
    923 
    924879        if (servicename != NULL) {
    925                 werr = reg_deletekey_recursive(key, key, servicename);
     880                werr = reg_deletekey_recursive(mem_ctx, rpd(ctx)->base_key,
     881                                               servicename);
    926882        } else {
    927                 werr = smbconf_reg_delete_values(key);
    928         }
    929 
    930 done:
    931         TALLOC_FREE(mem_ctx);
     883                werr = smbconf_reg_delete_values(rpd(ctx)->base_key);
     884        }
     885
     886        talloc_free(mem_ctx);
    932887        return werr;
    933888}
     
    954909
    955910done:
    956         TALLOC_FREE(mem_ctx);
     911        talloc_free(mem_ctx);
    957912        return werr;
    958913}
     
    999954
    1000955done:
    1001         TALLOC_FREE(key);
    1002         TALLOC_FREE(value);
     956        talloc_free(key);
     957        talloc_free(value);
    1003958        return werr;
    1004959}
     
    1034989
    1035990done:
    1036         TALLOC_FREE(mem_ctx);
     991        talloc_free(mem_ctx);
    1037992        return werr;
    1038993}
     
    10581013
    10591014done:
    1060         TALLOC_FREE(tmp_ctx);
     1015        talloc_free(tmp_ctx);
    10611016        return werr;
    10621017}
     
    10881043
    10891044done:
    1090         TALLOC_FREE(tmp_ctx);
     1045        talloc_free(tmp_ctx);
    10911046        return werr;
    10921047}
     
    11131068
    11141069done:
    1115         TALLOC_FREE(tmp_ctx);
    1116         return werr;
     1070        talloc_free(tmp_ctx);
     1071        return werr;
     1072}
     1073
     1074static WERROR smbconf_reg_transaction_start(struct smbconf_ctx *ctx)
     1075{
     1076        return regdb_transaction_start();
     1077}
     1078
     1079static WERROR smbconf_reg_transaction_commit(struct smbconf_ctx *ctx)
     1080{
     1081        return regdb_transaction_commit();
     1082}
     1083
     1084static WERROR smbconf_reg_transaction_cancel(struct smbconf_ctx *ctx)
     1085{
     1086        return regdb_transaction_cancel();
    11171087}
    11181088
     
    11201090        .init                   = smbconf_reg_init,
    11211091        .shutdown               = smbconf_reg_shutdown,
     1092        .requires_messaging     = smbconf_reg_requires_messaging,
     1093        .is_writeable           = smbconf_reg_is_writeable,
    11221094        .open_conf              = smbconf_reg_open,
    11231095        .close_conf             = smbconf_reg_close,
     
    11351107        .set_includes           = smbconf_reg_set_includes,
    11361108        .delete_includes        = smbconf_reg_delete_includes,
     1109        .transaction_start      = smbconf_reg_transaction_start,
     1110        .transaction_commit     = smbconf_reg_transaction_commit,
     1111        .transaction_cancel     = smbconf_reg_transaction_cancel,
    11371112};
    11381113
  • branches/samba-3.3.x/source/lib/smbconf/smbconf_txt.c

    r206 r223  
    139139            smbconf_find_in_array(param_name, param_names, num_params, &idx))
    140140        {
    141                 TALLOC_FREE(param_values[idx]);
     141                talloc_free(param_values[idx]);
    142142                param_values[idx] = talloc_strdup(cache, param_value);
    143143                if (param_values[idx] == NULL) {
     
    161161static void smbconf_txt_flush_cache(struct smbconf_ctx *ctx)
    162162{
    163         TALLOC_FREE(pd(ctx)->cache);
     163        talloc_free(pd(ctx)->cache);
     164        pd(ctx)->cache = NULL;
    164165}
    165166
     
    222223{
    223224        if (path == NULL) {
    224                 path = get_dyn_CONFIGFILE();
     225                return WERR_BADFILE;
    225226        }
    226227        ctx->path = talloc_strdup(ctx, path);
     
    242243{
    243244        return ctx->ops->close_conf(ctx);
     245}
     246
     247static bool smbconf_txt_requires_messaging(struct smbconf_ctx *ctx)
     248{
     249        return false;
     250}
     251
     252static bool smbconf_txt_is_writeable(struct smbconf_ctx *ctx)
     253{
     254        /* no write support in this backend yet... */
     255        return false;
    244256}
    245257
     
    349361
    350362done:
    351         TALLOC_FREE(tmp_ctx);
     363        talloc_free(tmp_ctx);
    352364        return werr;
    353365}
     
    448460
    449461done:
    450         TALLOC_FREE(tmp_ctx);
     462        talloc_free(tmp_ctx);
    451463        return werr;
    452464}
     
    583595
    584596done:
    585         TALLOC_FREE(tmp_ctx);
     597        talloc_free(tmp_ctx);
    586598        return werr;
    587599}
     
    601613}
    602614
     615static WERROR smbconf_txt_transaction_start(struct smbconf_ctx *ctx)
     616{
     617        return WERR_OK;
     618}
     619
     620static WERROR smbconf_txt_transaction_commit(struct smbconf_ctx *ctx)
     621{
     622        return WERR_OK;
     623}
     624
     625static WERROR smbconf_txt_transaction_cancel(struct smbconf_ctx *ctx)
     626{
     627        return WERR_OK;
     628}
    603629
    604630static struct smbconf_ops smbconf_ops_txt = {
    605631        .init                   = smbconf_txt_init,
    606632        .shutdown               = smbconf_txt_shutdown,
     633        .requires_messaging     = smbconf_txt_requires_messaging,
     634        .is_writeable           = smbconf_txt_is_writeable,
    607635        .open_conf              = smbconf_txt_open,
    608636        .close_conf             = smbconf_txt_close,
     
    620648        .set_includes           = smbconf_txt_set_includes,
    621649        .delete_includes        = smbconf_txt_delete_includes,
     650        .transaction_start      = smbconf_txt_transaction_start,
     651        .transaction_commit     = smbconf_txt_transaction_commit,
     652        .transaction_cancel     = smbconf_txt_transaction_cancel,
    622653};
    623654
  • branches/samba-3.3.x/source/lib/smbconf/smbconf_util.c

    r206 r223  
    6868
    6969fail:
    70         TALLOC_FREE(ctx);
     70        talloc_free(ctx);
    7171        return werr;
    7272}
     
    9797                new_array[count] = talloc_strdup(new_array, string);
    9898                if (new_array[count] == NULL) {
    99                         TALLOC_FREE(new_array);
     99                        talloc_free(new_array);
    100100                        return WERR_NOMEM;
    101101                }
  • branches/samba-3.3.x/source/lib/smbconf/testsuite.c

    r206 r223  
    4242        TALLOC_CTX *mem_ctx = talloc_stackframe();
    4343
    44         printf("test: get_includes\n");
     44        printf("TEST: get_includes\n");
    4545        werr = smbconf_get_global_includes(ctx, mem_ctx,
    4646                                           &num_includes, &includes);
    4747        if (!W_ERROR_IS_OK(werr)) {
    48                 printf("failure: get_includes - %s\n", dos_errstr(werr));
     48                printf("FAIL: get_includes - %s\n", dos_errstr(werr));
    4949                goto done;
    5050        }
     
    5454        print_strings("", num_includes, (const char **)includes);
    5555
    56         printf("success: get_includes\n");
     56        printf("OK: get_includes\n");
    5757        ret = true;
    5858
    5959done:
    60         TALLOC_FREE(mem_ctx);
     60        talloc_free(mem_ctx);
    6161        return ret;
    6262}
     
    7676        TALLOC_CTX *mem_ctx = talloc_stackframe();
    7777
    78         printf("test: set_get_includes\n");
     78        printf("TEST: set_get_includes\n");
    7979
    8080        werr = smbconf_set_global_includes(ctx, set_num_includes, set_includes);
    8181        if (!W_ERROR_IS_OK(werr)) {
    82                 printf("failure: get_set_includes (setting includes) - %s\n",
     82                printf("FAIL: get_set_includes (setting includes) - %s\n",
    8383                       dos_errstr(werr));
    8484                goto done;
     
    8888                                           &get_includes);
    8989        if (!W_ERROR_IS_OK(werr)) {
    90                 printf("failure: get_set_includes (getting includes) - %s\n",
     90                printf("FAIL: get_set_includes (getting includes) - %s\n",
    9191                       dos_errstr(werr));
    9292                goto done;
     
    9494
    9595        if (get_num_includes != set_num_includes) {
    96                 printf("failure: get_set_includes - set %d includes, got %d\n",
     96                printf("FAIL: get_set_includes - set %d includes, got %d\n",
    9797                       set_num_includes, get_num_includes);
    9898                goto done;
     
    106106                        print_strings("* ", get_num_includes,
    107107                                      (const char **)get_includes);
    108                         printf("failure: get_set_includes - data mismatch:\n");
     108                        printf("FAIL: get_set_includes - data mismatch:\n");
    109109                        goto done;
    110110                }
    111111        }
    112112
    113         printf("success: set_includes\n");
     113        printf("OK: set_includes\n");
    114114        ret = true;
    115115
    116116done:
    117         TALLOC_FREE(mem_ctx);
     117        talloc_free(mem_ctx);
    118118        return ret;
    119119}
     
    131131        TALLOC_CTX *mem_ctx = talloc_stackframe();
    132132
    133         printf("test: delete_includes\n");
     133        printf("TEST: delete_includes\n");
    134134
    135135        werr = smbconf_set_global_includes(ctx, set_num_includes, set_includes);
    136136        if (!W_ERROR_IS_OK(werr)) {
    137                 printf("failure: delete_includes (setting includes) - %s\n",
     137                printf("FAIL: delete_includes (setting includes) - %s\n",
    138138                       dos_errstr(werr));
    139139                goto done;
     
    142142        werr = smbconf_delete_global_includes(ctx);
    143143        if (!W_ERROR_IS_OK(werr)) {
    144                 printf("failure: delete_includes (deleting includes) - %s\n",
     144                printf("FAIL: delete_includes (deleting includes) - %s\n",
    145145                       dos_errstr(werr));
    146146                goto done;
     
    150150                                           &get_includes);
    151151        if (!W_ERROR_IS_OK(werr)) {
    152                 printf("failure: delete_includes (getting includes) - %s\n",
     152                printf("FAIL: delete_includes (getting includes) - %s\n",
    153153                       dos_errstr(werr));
    154154                goto done;
     
    156156
    157157        if (get_num_includes != 0) {
    158                 printf("failure: delete_includes (not empty after delete)\n");
     158                printf("FAIL: delete_includes (not empty after delete)\n");
    159159                goto done;
    160160        }
     
    162162        werr = smbconf_delete_global_includes(ctx);
    163163        if (!W_ERROR_IS_OK(werr)) {
    164                 printf("failuer: delete_includes (delete empty includes) - "
     164                printf("FAIL: delete_includes (delete empty includes) - "
    165165                       "%s\n", dos_errstr(werr));
    166166                goto done;
    167167        }
    168168
    169         printf("success: delete_includes\n");
     169        printf("OK: delete_includes\n");
    170170        ret = true;
    171171
     
    174174}
    175175
     176static bool create_conf_file(const char *filename)
     177{
     178        FILE *f;
     179
     180        printf("TEST: creating file\n");
     181        f = sys_fopen(filename, "w");
     182        if (!f) {
     183                printf("failure: failed to open %s for writing: %s\n",
     184                       filename, strerror(errno));
     185                return false;
     186        }
     187
     188        fprintf(f, "[global]\n");
     189        fprintf(f, "\tserver string = smbconf testsuite\n");
     190        fprintf(f, "\tworkgroup = SAMBA\n");
     191        fprintf(f, "\tsecurity = user\n");
     192
     193        fclose(f);
     194
     195        printf("OK: create file\n");
     196        return true;
     197}
     198
    176199static bool torture_smbconf_txt(void)
     200{
     201        WERROR werr;
     202        bool ret = true;
     203        const char *filename = "/tmp/smb.conf.smbconf_testsuite";
     204        struct smbconf_ctx *conf_ctx = NULL;
     205        TALLOC_CTX *mem_ctx = talloc_stackframe();
     206
     207        printf("test: text backend\n");
     208
     209        if (!create_conf_file(filename)) {
     210                ret = false;
     211                goto done;
     212        }
     213
     214        printf("TEST: init\n");
     215        werr = smbconf_init_txt(mem_ctx, &conf_ctx, filename);
     216        if (!W_ERROR_IS_OK(werr)) {
     217                printf("FAIL: text backend\[ failed: %s\n", dos_errstr(werr));
     218                ret = false;
     219                goto done;
     220        }
     221        printf("OK: init\n");
     222
     223        ret &= test_get_includes(conf_ctx);
     224
     225        smbconf_shutdown(conf_ctx);
     226
     227        printf("TEST: unlink file\n");
     228        if (unlink(filename) != 0) {
     229                printf("OK: unlink failed: %s\n", strerror(errno));
     230                ret = false;
     231                goto done;
     232        }
     233        printf("OK: unlink file\n");
     234
     235done:
     236        printf("%s: text backend\n", ret ? "success" : "failure");
     237        talloc_free(mem_ctx);
     238        return ret;
     239}
     240
     241static bool torture_smbconf_reg(void)
    177242{
    178243        WERROR werr;
     
    181246        TALLOC_CTX *mem_ctx = talloc_stackframe();
    182247
    183         printf("test: text backend\n");
    184 
    185         printf("test: init\n");
    186         werr = smbconf_init_txt(mem_ctx, &conf_ctx, NULL);
    187         if (!W_ERROR_IS_OK(werr)) {
    188                 printf("failure: init failed: %s\n", dos_errstr(werr));
     248        printf("test: registry backend\n");
     249
     250        printf("TEST: init\n");
     251        werr = smbconf_init_reg(mem_ctx, &conf_ctx, NULL);
     252        if (!W_ERROR_IS_OK(werr)) {
     253                printf("FAIL: init failed: %s\n", dos_errstr(werr));
    189254                ret = false;
    190255                goto done;
    191256        }
    192         printf("success: init\n");
    193 
    194         ret &= test_get_includes(conf_ctx);
    195 
    196         smbconf_shutdown(conf_ctx);
    197 
    198         printf("%s: text backend\n", ret ? "success" : "failure");
    199 
    200 done:
    201         TALLOC_FREE(mem_ctx);
    202         return ret;
    203 }
    204 
    205 static bool torture_smbconf_reg(void)
    206 {
    207         WERROR werr;
    208         bool ret = true;
    209         struct smbconf_ctx *conf_ctx = NULL;
    210         TALLOC_CTX *mem_ctx = talloc_stackframe();
    211 
    212         printf("test: registry backend\n");
    213 
    214         printf("test: init\n");
    215         werr = smbconf_init_reg(mem_ctx, &conf_ctx, NULL);
    216         if (!W_ERROR_IS_OK(werr)) {
    217                 printf("failure: init failed: %s\n", dos_errstr(werr));
    218                 ret = false;
    219                 goto done;
    220         }
    221         printf("success: init\n");
     257        printf("OK: init\n");
    222258
    223259        ret &= test_get_includes(conf_ctx);
     
    227263        smbconf_shutdown(conf_ctx);
    228264
     265done:
    229266        printf("%s: registry backend\n", ret ? "success" : "failure");
    230 
    231 done:
    232         TALLOC_FREE(mem_ctx);
     267        talloc_free(mem_ctx);
    233268        return ret;
    234269}
     
    279314
    280315done:
    281         TALLOC_FREE(mem_ctx);
     316        talloc_free(mem_ctx);
    282317        return ret ? 0 : -1;
    283318}
  • branches/samba-3.3.x/source/lib/version.c

    r206 r223  
    3030  #ifdef SAMBA_VERSION_VENDOR_PATCH
    3131        return SAMBA_VERSION_OFFICIAL_STRING "-" SAMBA_VERSION_VENDOR_SUFFIX \
    32                 "-" SAMBA_VERSION_VENDOR_PATCH;
     32                "-" SAMBA_VERSION_VENDOR_PATCH_STRING;
    3333  #endif /* SAMBA_VERSION_VENDOR_PATCH */
    3434        return SAMBA_VERSION_OFFICIAL_STRING "-" SAMBA_VERSION_VENDOR_SUFFIX;
Note: See TracChangeset for help on using the changeset viewer.