Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/libsmb/smb_share_modes.c

    r740 r988  
    22   Samba share mode database library external interface library.
    33   Used by non-Samba products needing access to the Samba share mode db.
     4
     5
     6
     7
     8
     9
     10
     11
    412
    513   Copyright (C) Jeremy Allison 2005 - 2006
     
    2937#include "smb_share_modes.h"
    3038#include <tdb.h>
     39
    3140
    3241/* Database context handle. */
     
    4049#endif
    4150
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
    4280int smb_create_share_mode_entry_ex(struct smbdb_ctx *db_ctx, uint64_t dev,
    4381                                uint64_t ino, uint64_t extid,
     
    69107        memset(smb_db, '\0', sizeof(struct smbdb_ctx));
    70108
     109
    71110        smb_db->smb_tdb = tdb_open(db_path,
    72                                 0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
    73                                 O_RDWR|O_CREAT,
    74                                 0644);
     111                                0, TDB_DEFAULT|TDB_CLEAR_IF_FIRST|TDB_INCOMPATIBLE_HASH,
     112                                O_RDWR|O_CREAT,
     113                                0644);
    75114
    76115        if (!smb_db->smb_tdb) {
     
    106145        lk->inode = (SMB_INO_T)ino;
    107146        lk->extid = extid;
    108         ld.dptr = (uint8 *)lk;
     147        ld.dptr = (uint8 *)lk;
    109148        ld.dsize = sizeof(*lk);
    110149        return ld;
     
    122161        struct locking_key lk;
    123162        return tdb_chainlock(db_ctx->smb_tdb, get_locking_key(&lk, dev, ino,
    124                                                               extid));
     163                                                              extid));
    125164}
    126165
     
    131170{
    132171        struct locking_key lk;
    133         return tdb_chainunlock(db_ctx->smb_tdb,
    134                                get_locking_key(&lk, dev, ino, extid));
     172        tdb_chainunlock(db_ctx->smb_tdb,
     173                        get_locking_key(&lk, dev, ino, extid));
     174        return 0;
    135175}
    136176
     
    172212        out->id.inode = in->ino;
    173213        out->id.extid = in->extid;
    174         out->uid = (uint32)geteuid();
     214        out->uid = (uint32)geteuid();
    175215        out->flags = 0;
    176216        out->name_hash = name_hash;
     
    201241        *p_delete_on_close = 0;
    202242
    203         db_data = tdb_fetch(db_ctx->smb_tdb, get_locking_key(&lk, dev, ino,
    204                                                             extid));
     243        db_data = tdb_fetch(db_ctx->smb_tdb,
     244                        extid));
    205245        if (!db_data.dptr) {
    206246                return 0;
     
    234274                if (kill(sharemodes_procid_to_pid(&pid), 0) == -1 && (errno == ESRCH)) {
    235275                        continue; /* No longer exists. */
    236                 }
    237 
    238                 /* Ignore deferred open entries. */
    239                 if (share->op_type == DEFERRED_OPEN_ENTRY) {
    240                         continue;
    241276                }
    242277
     
    268303static uint32_t smb_name_hash(const char *sharepath, const char *filename, int *err)
    269304{
    270         TDB_DATA key;
    271305        char *fullpath = NULL;
    272306        size_t sharepath_size = strlen(sharepath);
    273307        size_t filename_size = strlen(filename);
    274308        uint32_t name_hash;
     309
    275310
    276311        *err = 0;
     
    284319        memcpy(&fullpath[sharepath_size + 1], filename, filename_size + 1);
    285320
    286         key.dptr = (uint8_t *)fullpath;
    287         key.dsize = strlen(fullpath) + 1;
     321        key
     322        ;
    288323        name_hash = tdb_jenkins_hash(&key);
    289324        free(fullpath);
     
    309344        struct locking_data *ld = NULL; /* internal samba db state. */
    310345        struct share_mode_entry *shares = NULL;
    311         uint8 *new_data_p = NULL;
     346        uint8 *new_data_p = NULL;
    312347        size_t new_data_size = 0;
    313348        int err = 0;
     
    321356        if (!db_data.dptr) {
    322357                /* We must create the entry. */
    323                 db_data.dptr = (uint8 *)malloc(
     358                db_data.dptr = (uint8 *)malloc(
    324359                        sizeof(struct locking_data) +
    325360                        sizeof(struct share_mode_entry) +
     
    347382                                        strlen(sharepath) + 1 +
    348383                                        strlen(filename) + 1;
    349                 if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_INSERT) == -1) {
     384                if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_INSERT) ) {
    350385                        free(db_data.dptr);
    351386                        return -1;
     
    356391
    357392        /* Entry exists, we must add a new entry. */
    358         new_data_p = (uint8 *)malloc(
     393        new_data_p = (uint8 *)malloc(
    359394                db_data.dsize + sizeof(struct share_mode_entry));
    360395        if (!new_data_p) {
     
    390425        db_data.dsize = new_data_size;
    391426
    392         if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_REPLACE) == -1) {
     427        if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_REPLACE) ) {
    393428                free(db_data.dptr);
    394429                return -1;
     
    430465        struct locking_data *ld = NULL; /* internal samba db state. */
    431466        struct share_mode_entry *shares = NULL;
    432         uint8 *new_data_p = NULL;
     467        uint8 *new_data_p = NULL;
    433468        size_t remaining_size = 0;
    434469        size_t i, num_share_modes;
    435         const uint8 *remaining_ptr = NULL;
     470        const uint8 *remaining_ptr = NULL;
    436471
    437472        db_data = tdb_fetch(db_ctx->smb_tdb, locking_key);
     
    453488                /* It's ours - just remove the entire record. */
    454489                free(db_data.dptr);
    455                 return tdb_delete(db_ctx->smb_tdb, locking_key);
     490                return tdb_delete(db_ctx->smb_tdb, locking_key);
    456491        }
    457492
    458493        /* More than one - allocate a new record minus the one we'll delete. */
    459         new_data_p = (uint8 *)malloc(
     494        new_data_p = (uint8 *)malloc(
    460495                db_data.dsize - sizeof(struct share_mode_entry));
    461496        if (!new_data_p) {
     
    492527                free(db_data.dptr);
    493528                free(new_data_p);
    494                 return tdb_delete(db_ctx->smb_tdb, locking_key);
     529                return tdb_delete(db_ctx->smb_tdb, locking_key);
    495530        }
    496531
     
    513548        db_data.dsize = sizeof(struct locking_data) + (num_share_modes * sizeof(struct share_mode_entry)) + remaining_size;
    514549
    515         if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_REPLACE) == -1) {
     550        if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_REPLACE) ) {
    516551                free(db_data.dptr);
    517552                return -1;
     
    568603
    569604        /* Save modified data. */
    570         if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_REPLACE) == -1) {
     605        if (tdb_store(db_ctx->smb_tdb, locking_key, db_data, TDB_REPLACE) ) {
    571606                free(db_data.dptr);
    572607                return -1;
Note: See TracChangeset for help on using the changeset viewer.