Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

Location:
vendor/current/source4/ntvfs
Files:
10 added
8 deleted
48 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source4/ntvfs/cifs/vfs_cifs.c

    r414 r740  
    232232        /* connect to the server, using the smbd event context */
    233233        io.in.dest_host = host;
    234         io.in.dest_ports = lp_smb_ports(ntvfs->ctx->lp_ctx);
    235         io.in.socket_options = lp_socket_options(ntvfs->ctx->lp_ctx);
     234        io.in.dest_ports = lpcfg_smb_ports(ntvfs->ctx->lp_ctx);
     235        io.in.socket_options = lpcfg_socket_options(ntvfs->ctx->lp_ctx);
    236236        io.in.called_name = host;
    237237        io.in.credentials = credentials;
    238238        io.in.fallback_to_anonymous = false;
    239         io.in.workgroup = lp_workgroup(ntvfs->ctx->lp_ctx);
     239        io.in.workgroup = lpcfg_workgroup(ntvfs->ctx->lp_ctx);
    240240        io.in.service = remote_share;
    241241        io.in.service_type = "?????";
    242         io.in.iconv_convenience = lp_iconv_convenience(ntvfs->ctx->lp_ctx);
    243         io.in.gensec_settings = lp_gensec_settings(p, ntvfs->ctx->lp_ctx);
    244         lp_smbcli_options(ntvfs->ctx->lp_ctx, &io.in.options);
    245         lp_smbcli_session_options(ntvfs->ctx->lp_ctx, &io.in.session_options);
     242        io.in.gensec_settings = lpcfg_gensec_settings(p, ntvfs->ctx->lp_ctx);
     243        lpcfg_smbcli_options(ntvfs->ctx->lp_ctx, &io.in.options);
     244        lpcfg_smbcli_session_options(ntvfs->ctx->lp_ctx, &io.in.session_options);
    246245
    247246        if (!(ntvfs->ctx->client_caps & NTVFS_CLIENT_CAP_LEVEL_II_OPLOCKS)) {
     
    250249
    251250        creq = smb_composite_connect_send(&io, p,
    252                                           lp_resolve_context(ntvfs->ctx->lp_ctx),
     251                                          lpcfg_resolve_context(ntvfs->ctx->lp_ctx),
    253252                                          ntvfs->ctx->event_ctx);
    254253        status = smb_composite_connect_recv(creq, p);
  • vendor/current/source4/ntvfs/cifs_posix_cli/svfs_util.c

    r414 r740  
    6767        DIR *odir;
    6868        struct dirent *dent;
    69         uint_t allocated = 0;
     69        unsigned int allocated = 0;
    7070        char *low_mask;
    7171
     
    9494
    9595        while ((dent = readdir(odir))) {
    96                 uint_t i = dir->count;
     96                unsigned int i = dir->count;
    9797                char *full_name;
    9898                char *low_name;
  • vendor/current/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c

    r414 r740  
    837837        fs->generic.out.fs_type = talloc_strdup(req, "NTFS");
    838838        fs->generic.out.volume_name = talloc_strdup(req,
    839                                                     lp_servicename(req->tcon->service));
     839                                                    lpcfg_servicename(req->tcon->service));
    840840
    841841        return NT_STATUS_OK;
     
    865865        struct search_state *search;
    866866        union smb_search_data file;
    867         uint_t max_count;
     867        unsigned int max_count;
    868868
    869869        if (io->generic.level != RAW_SEARCH_TRANS2) {
     
    939939        struct search_state *search;
    940940        union smb_search_data file;
    941         uint_t max_count;
     941        unsigned int max_count;
    942942
    943943        if (io->generic.level != RAW_SEARCH_TRANS2) {
  • vendor/current/source4/ntvfs/common/brlock.c

    r414 r740  
    2727#include "includes.h"
    2828#include "system/filesys.h"
    29 #include "../tdb/include/tdb.h"
     29#include <tdb.h>
    3030#include "messaging/messaging.h"
    3131#include "lib/messaging/irpc.h"
     
    126126        return ops->brl_close(brl, brlh);
    127127}
     128
     129/*
     130 Get a number of locks associated with a open file.
     131*/
     132NTSTATUS brl_count(struct brl_context *brl,
     133                   struct brl_handle *brlh,
     134                   int *count)
     135{
     136        return ops->brl_count(brl, brlh, count);
     137}
  • vendor/current/source4/ntvfs/common/brlock.h

    r414 r740  
    4747        NTSTATUS (*brl_close)(struct brl_context *,
    4848                              struct brl_handle *);
     49        NTSTATUS (*brl_count)(struct brl_context *,
     50                              struct brl_handle *,
     51                              int *count);
    4952};
    5053
  • vendor/current/source4/ntvfs/common/brlock_tdb.c

    r414 r740  
    2727#include "includes.h"
    2828#include "system/filesys.h"
    29 #include "../tdb/include/tdb.h"
     29#include <tdb.h>
    3030#include "messaging/messaging.h"
    31 #include "tdb_wrap.h"
     31#include "lib/util/tdb_wrap.h"
    3232#include "lib/messaging/irpc.h"
    3333#include "libcli/libcli.h"
     
    8181};
    8282
     83/* see if we have wrapped locks, which are no longer allowed (windows
     84 * changed this in win7 */
     85static bool brl_invalid_lock_range(uint64_t start, uint64_t size)
     86{
     87        return (size > 1 && (start + size < start));
     88}
     89
    8390/*
    8491  Open up the brlock.tdb database. Close it down using
     
    299306        kbuf.dptr = brlh->key.data;
    300307        kbuf.dsize = brlh->key.length;
     308
     309        if (brl_invalid_lock_range(start, size)) {
     310                return NT_STATUS_INVALID_LOCK_RANGE;
     311        }
    301312
    302313        if (tdb_chainlock(brl->w->tdb, kbuf) != 0) {
     
    449460        kbuf.dptr = brlh->key.data;
    450461        kbuf.dsize = brlh->key.length;
     462
     463        if (brl_invalid_lock_range(start, size)) {
     464                return NT_STATUS_INVALID_LOCK_RANGE;
     465        }
    451466
    452467        if (tdb_chainlock(brl->w->tdb, kbuf) != 0) {
     
    621636        kbuf.dsize = brlh->key.length;
    622637
     638        if (brl_invalid_lock_range(start, size)) {
     639                return NT_STATUS_INVALID_LOCK_RANGE;
     640        }
     641
    623642        dbuf = tdb_fetch(brl->w->tdb, kbuf);
    624643        if (dbuf.dptr == NULL) {
     
    720739}
    721740
     741static NTSTATUS brl_tdb_count(struct brl_context *brl, struct brl_handle *brlh,
     742                              int *count)
     743{
     744        TDB_DATA kbuf, dbuf;
     745
     746        kbuf.dptr = brlh->key.data;
     747        kbuf.dsize = brlh->key.length;
     748        *count = 0;
     749
     750        if (tdb_chainlock(brl->w->tdb, kbuf) != 0) {
     751                return NT_STATUS_INTERNAL_DB_CORRUPTION;
     752        }
     753
     754        dbuf = tdb_fetch(brl->w->tdb, kbuf);
     755        if (!dbuf.dptr) {
     756                tdb_chainunlock(brl->w->tdb, kbuf);
     757                return NT_STATUS_OK;
     758        }
     759
     760        *count = dbuf.dsize / sizeof(struct lock_struct);
     761
     762        free(dbuf.dptr);
     763        tdb_chainunlock(brl->w->tdb, kbuf);
     764
     765        return NT_STATUS_OK;
     766}
    722767
    723768static const struct brlock_ops brlock_tdb_ops = {
     
    728773        .brl_remove_pending = brl_tdb_remove_pending,
    729774        .brl_locktest       = brl_tdb_locktest,
    730         .brl_close          = brl_tdb_close
     775        .brl_close          = brl_tdb_close,
     776        .brl_count          = brl_tdb_count
    731777};
    732778
  • vendor/current/source4/ntvfs/common/notify.c

    r414 r740  
    2626#include "includes.h"
    2727#include "system/filesys.h"
    28 #include "../tdb/include/tdb.h"
     28#include <tdb.h>
    2929#include "../lib/util/util_tdb.h"
    3030#include "messaging/messaging.h"
    31 #include "tdb_wrap.h"
     31#include "lib/util/tdb_wrap.h"
    3232#include "lib/messaging/irpc.h"
    33 #include "librpc/gen_ndr/ndr_notify.h"
     33#include "librpc/gen_ndr/ndr_s4_notify.h"
    3434#include "../lib/util/dlinklist.h"
    3535#include "ntvfs/common/ntvfs_common.h"
     
    3737#include "cluster/cluster.h"
    3838#include "param/param.h"
     39#include "lib/util/tsort.h"
    3940
    4041struct notify_context {
     
    4647        int seqnum;
    4748        struct sys_notify_context *sys_notify_ctx;
    48         struct smb_iconv_convenience *iconv_convenience;
    4949};
    5050
     
    113113        notify->list = NULL;
    114114        notify->array = NULL;
    115         notify->iconv_convenience = lp_iconv_convenience(lp_ctx);
    116115        notify->seqnum = tdb_get_seqnum(notify->w->tdb);
    117116
     
    178177        blob.length = dbuf.dsize;
    179178
    180         ndr_err = ndr_pull_struct_blob(&blob, notify->array, notify->iconv_convenience,
    181                                        notify->array,
     179        ndr_err = ndr_pull_struct_blob(&blob, notify->array, notify->array,
    182180                                       (ndr_pull_flags_fn_t)ndr_pull_notify_array);
    183181        free(dbuf.dptr);
     
    227225        NT_STATUS_HAVE_NO_MEMORY(tmp_ctx);
    228226
    229         ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, notify->iconv_convenience, notify->array,
     227        ndr_err = ndr_push_struct_blob(&blob, tmp_ctx, notify->array,
    230228                                       (ndr_push_flags_fn_t)ndr_push_notify_array);
    231229        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    263261        }
    264262
    265         ndr_err = ndr_pull_struct_blob(data, tmp_ctx, notify->iconv_convenience, &ev,
     263        ndr_err = ndr_pull_struct_blob(data, tmp_ctx, &ev,
    266264                                      (ndr_pull_flags_fn_t)ndr_pull_notify_event);
    267265        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    329327        d->max_mask_subdir |= e->subdir_filter;
    330328
    331         if (d->num_entries > 1) {
    332                 qsort(d->entries, d->num_entries, sizeof(d->entries[0]), notify_compare);
    333         }
     329        TYPESAFE_QSORT(d->entries, d->num_entries, notify_compare);
    334330
    335331        /* recalculate the maximum masks */
     
    562558        tmp_ctx = talloc_new(notify);
    563559
    564         ndr_err = ndr_push_struct_blob(&data, tmp_ctx, notify->iconv_convenience, &ev, (ndr_push_flags_fn_t)ndr_push_notify_event);
     560        ndr_err = ndr_push_struct_blob(&data, tmp_ctx, &ev, (ndr_push_flags_fn_t)ndr_push_notify_event);
    565561        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
    566562                talloc_free(tmp_ctx);
  • vendor/current/source4/ntvfs/common/opendb_tdb.c

    r414 r740  
    4141#include "includes.h"
    4242#include "system/filesys.h"
    43 #include "../tdb/include/tdb.h"
     43#include <tdb.h>
    4444#include "messaging/messaging.h"
    45 #include "tdb_wrap.h"
     45#include "lib/util/tdb_wrap.h"
    4646#include "lib/messaging/irpc.h"
    4747#include "librpc/gen_ndr/ndr_opendb.h"
     
    247247        blob.length = dbuf.dsize;
    248248
    249         ndr_err = ndr_pull_struct_blob(&blob, lck, lp_iconv_convenience(lck->odb->ntvfs_ctx->lp_ctx), file, (ndr_pull_flags_fn_t)ndr_pull_opendb_file);
     249        ndr_err = ndr_pull_struct_blob(&blob, lck, file, (ndr_pull_flags_fn_t)ndr_pull_opendb_file);
    250250        free(dbuf.dptr);
    251251        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
     
    275275        }
    276276
    277         ndr_err = ndr_push_struct_blob(&blob, lck, lp_iconv_convenience(lck->odb->ntvfs_ctx->lp_ctx), file, (ndr_push_flags_fn_t)ndr_push_opendb_file);
     277        ndr_err = ndr_push_struct_blob(&blob, lck, file, (ndr_push_flags_fn_t)ndr_push_opendb_file);
    278278        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
    279279                return ndr_map_error2ntstatus(ndr_err);
  • vendor/current/source4/ntvfs/ipc/ipc_rap.c

    r414 r740  
    2121#include "includes.h"
    2222#include "libcli/raw/interfaces.h"
    23 #include "libcli/rap/rap.h"
     23#include "../librpc/gen_ndr/rap.h"
    2424#include "events/events.h"
    2525#include "ntvfs/ipc/proto.h"
     
    125125        call->mem_ctx = mem_ctx;
    126126
    127         call->ndr_pull_param = ndr_pull_init_blob(&trans->in.params, mem_ctx, lp_iconv_convenience(lp_ctx));
     127        call->ndr_pull_param = ndr_pull_init_blob(&trans->in.params, mem_ctx);
    128128        call->ndr_pull_param->flags = RAPNDR_FLAGS;
    129129
    130         call->ndr_pull_data = ndr_pull_init_blob(&trans->in.data, mem_ctx, lp_iconv_convenience(lp_ctx));
     130        call->ndr_pull_data = ndr_pull_init_blob(&trans->in.data, mem_ctx);
    131131        call->ndr_pull_data->flags = RAPNDR_FLAGS;
    132132
     
    292292                case 0:
    293293                        NDR_GOTO(ndr_push_bytes(call->ndr_push_data,
    294                                               (const uint8_t *)r.out.info[i].info0.name,
    295                                               sizeof(r.out.info[i].info0.name)));
     294                                              (const uint8_t *)r.out.info[i].info0.share_name,
     295                                              sizeof(r.out.info[i].info0.share_name)));
    296296                        break;
    297297                case 1:
    298298                        NDR_GOTO(ndr_push_bytes(call->ndr_push_data,
    299                                               (const uint8_t *)r.out.info[i].info1.name,
    300                                               sizeof(r.out.info[i].info1.name)));
     299                                              (const uint8_t *)r.out.info[i].info1.share_name,
     300                                              sizeof(r.out.info[i].info1.share_name)));
    301301                        NDR_GOTO(ndr_push_uint8(call->ndr_push_data,
    302                                               NDR_SCALARS, r.out.info[i].info1.pad));
     302                                              NDR_SCALARS, r.out.info[i].info1.reserved1));
    303303                        NDR_GOTO(ndr_push_uint16(call->ndr_push_data,
    304                                                NDR_SCALARS, r.out.info[i].info1.type));
     304                                               NDR_SCALARS, r.out.info[i].info1.share_type));
    305305
    306306                        RAP_GOTO(rap_push_string(call->ndr_push_data,
     
    455455                                  &call->datadesc));
    456456
    457         call->ndr_push_param = ndr_push_init_ctx(call, lp_iconv_convenience(lp_ctx));
    458         call->ndr_push_data = ndr_push_init_ctx(call, lp_iconv_convenience(lp_ctx));
     457        call->ndr_push_param = ndr_push_init_ctx(call);
     458        call->ndr_push_data = ndr_push_init_ctx(call);
    459459
    460460        if ((call->ndr_push_param == NULL) || (call->ndr_push_data == NULL))
     
    481481        result_data = ndr_push_blob(call->ndr_push_data);
    482482
    483         final_param = ndr_push_init_ctx(call, lp_iconv_convenience(lp_ctx));
    484         final_data = ndr_push_init_ctx(call, lp_iconv_convenience(lp_ctx));
     483        final_param = ndr_push_init_ctx(call);
     484        final_data = ndr_push_init_ctx(call);
    485485
    486486        if ((final_param == NULL) || (final_data == NULL))
  • vendor/current/source4/ntvfs/ipc/rap_server.c

    r414 r740  
    2121#include "includes.h"
    2222#include "param/share.h"
    23 #include "libcli/rap/rap.h"
     23#include "../librpc/gen_ndr/rap.h"
    2424#include "libcli/raw/interfaces.h"
    2525#include "librpc/gen_ndr/srvsvc.h"
     26#include "librpc/gen_ndr/dcerpc.h"
    2627#include "rpc_server/common/common.h"
     28#include "rpc_server/common/share.h"
    2729#include "param/param.h"
    2830#include "ntvfs/ipc/ipc.h"
     
    4749        r->out.info = NULL;
    4850
    49         nterr = share_get_context_by_name(mem_ctx, lp_share_backend(lp_ctx), event_ctx, lp_ctx, &sctx);
     51        nterr = share_get_context_by_name(mem_ctx, lpcfg_share_backend(lp_ctx), event_ctx, lp_ctx, &sctx);
    5052        if (!NT_STATUS_IS_OK(nterr)) {
    5153                return nterr;
     
    5961        r->out.available = count;
    6062        r->out.info = talloc_array(mem_ctx,
    61                                    union rap_shareenum_info, r->out.available);
     63                                   union rap_share_info, r->out.available);
    6264
    6365        for (i = 0, j = 0; i < r->out.available; i++) {
     
    6668                        continue;
    6769                }
    68                 strncpy(r->out.info[j].info1.name,
     70                strncpy((char *)r->out.info[j].info1.share_name,
    6971                        snames[i],
    70                         sizeof(r->out.info[0].info1.name));
    71                 r->out.info[i].info1.pad = 0;
    72                 r->out.info[i].info1.type = dcesrv_common_get_share_type(mem_ctx, NULL, scfg);
     72                        sizeof(r->out.info[0].info1.share_name));
     73                r->out.info[i].info1.reserved1 = 0;
     74                r->out.info[i].info1.share_type = dcesrv_common_get_share_type(mem_ctx, NULL, scfg);
    7375                r->out.info[i].info1.comment = talloc_strdup(mem_ctx, share_string_option(scfg, SHARE_COMMENT, ""));
    7476                talloc_free(scfg);
  • vendor/current/source4/ntvfs/ipc/vfs_ipc.c

    r414 r740  
    2828#include "../lib/util/dlinklist.h"
    2929#include "ntvfs/ntvfs.h"
    30 #include "libcli/rap/rap.h"
     30#include "../librpc/gen_ndr/rap.h"
    3131#include "ntvfs/ipc/proto.h"
    3232#include "libcli/raw/ioctl.h"
     
    218218        struct ntvfs_request *req;
    219219        union smb_open *oi;
    220         struct netr_SamInfo3 *info3;
     220        struct auth_session_info_transport *session_info_transport;
    221221};
    222222
     
    229229{
    230230        while (*name) {
    231                 if (!isalnum(*name)) return NT_STATUS_INVALID_PARAMETER;
     231                if (!isalnum(*name) && *name != '_') {
     232                        return NT_STATUS_INVALID_PARAMETER;
     233                }
    232234                name++;
    233235        }
     
    245247        struct ipc_private *ipriv = talloc_get_type_abort(ntvfs->private_data,
    246248                                    struct ipc_private);
    247         struct smb_iconv_convenience *smb_ic
    248                 = lp_iconv_convenience(ipriv->ntvfs->ctx->lp_ctx);
    249249        struct ntvfs_handle *h;
    250250        struct ipc_open_state *state;
     
    252252        const char *fname;
    253253        const char *directory;
    254         struct socket_address *client_sa;
    255         struct tsocket_address *client_addr;
    256         struct socket_address *server_sa;
    257         struct tsocket_address *server_addr;
    258         int ret;
    259         DATA_BLOB delegated_creds = data_blob_null;
     254        const struct tsocket_address *client_addr;
     255        const struct tsocket_address *server_addr;
    260256
    261257        switch (oi->generic.level) {
    262258        case RAW_OPEN_NTCREATEX:
     259        case RAW_OPEN_NTTRANS_CREATE:
    263260                fname = oi->ntcreatex.in.fname;
    264261                break;
     
    270267                break;
    271268        default:
    272                 status = NT_STATUS_NOT_SUPPORTED;
    273                 break;
     269                return NT_STATUS_NOT_SUPPORTED;
    274270        }
    275271
    276272        directory = talloc_asprintf(req, "%s/np",
    277                                     lp_ncalrpc_dir(ipriv->ntvfs->ctx->lp_ctx));
     273                                    lpcfg_ncalrpc_dir(ipriv->ntvfs->ctx->lp_ctx));
    278274        NT_STATUS_HAVE_NO_MEMORY(directory);
    279275
     
    312308        state->oi = oi;
    313309
    314         status = auth_convert_server_info_saminfo3(state,
    315                                                    req->session_info->server_info,
    316                                                    &state->info3);
     310        status = auth_session_info_transport_from_session(state,
     311                                                          req->session_info,
     312                                                          ipriv->ntvfs->ctx->event_ctx,
     313                                                          ipriv->ntvfs->ctx->lp_ctx,
     314                                                          &state->session_info_transport);
     315
    317316        NT_STATUS_NOT_OK_RETURN(status);
    318317
    319         client_sa = ntvfs_get_peer_addr(ntvfs, state);
    320         if (!client_sa) {
    321                 return NT_STATUS_INTERNAL_ERROR;
    322         }
    323 
    324         server_sa = ntvfs_get_my_addr(ntvfs, state);
    325         if (!server_sa) {
    326                 return NT_STATUS_INTERNAL_ERROR;
    327         }
    328 
    329         ret = tsocket_address_inet_from_strings(state, "ip",
    330                                                 client_sa->addr,
    331                                                 client_sa->port,
    332                                                 &client_addr);
    333         if (ret == -1) {
    334                 status = map_nt_error_from_unix(errno);
    335                 return status;
    336         }
    337 
    338         ret = tsocket_address_inet_from_strings(state, "ip",
    339                                                 server_sa->addr,
    340                                                 server_sa->port,
    341                                                 &server_addr);
    342         if (ret == -1) {
    343                 status = map_nt_error_from_unix(errno);
    344                 return status;
    345         }
    346 
    347         if (req->session_info->credentials) {
    348                 struct gssapi_creds_container *gcc;
    349                 OM_uint32 gret;
    350                 OM_uint32 minor_status;
    351                 gss_buffer_desc cred_token;
    352 
    353                 ret = cli_credentials_get_client_gss_creds(req->session_info->credentials,
    354                                                            ipriv->ntvfs->ctx->event_ctx,
    355                                                            ipriv->ntvfs->ctx->lp_ctx,
    356                                                            &gcc);
    357                 if (ret) {
    358                         goto skip;
    359                 }
    360 
    361                 gret = gss_export_cred(&minor_status,
    362                                        gcc->creds,
    363                                        &cred_token);
    364                 if (gret != GSS_S_COMPLETE) {
    365                         return NT_STATUS_INTERNAL_ERROR;
    366                 }
    367 
    368                 if (cred_token.length) {
    369                         delegated_creds = data_blob_talloc(req,
    370                                                            cred_token.value,
    371                                                            cred_token.length);
    372                         gss_release_buffer(&minor_status, &cred_token);
    373                         NT_STATUS_HAVE_NO_MEMORY(delegated_creds.data);
    374                 }
    375         }
    376 
    377 skip:
     318        client_addr = ntvfs_get_local_address(ipriv->ntvfs);
     319        server_addr = ntvfs_get_remote_address(ipriv->ntvfs);
    378320
    379321        subreq = tstream_npa_connect_send(p,
    380322                                          ipriv->ntvfs->ctx->event_ctx,
    381                                           smb_ic,
    382323                                          directory,
    383324                                          fname,
     
    386327                                          server_addr,
    387328                                          NULL,
    388                                           state->info3,
    389                                           req->session_info->session_key,
    390                                           delegated_creds);
     329                                          state->session_info_transport);
    391330        NT_STATUS_HAVE_NO_MEMORY(subreq);
    392331        tevent_req_set_callback(subreq, ipc_open_done, state);
     
    531470        s->buf = buf;
    532471        s->len = MIN(len, UINT16_MAX);
    533         //DEBUG(0,("readv_next_vector_init[%u 0x%04X]\n", s->len, s->len));
    534472}
    535473
     
    549487                *_vector = NULL;
    550488                *count = 0;
    551 //              DEBUG(0,("readv_next_vector done ofs[%u 0x%04X]\n",
    552 //                      state->ofs, state->ofs));
    553489                return 0;
    554490        }
     
    563499                *_vector = NULL;
    564500                *count = 0;
    565 //              DEBUG(0,("readv_next_vector short read ofs[%u 0x%04X]\n",
    566 //                      state->ofs, state->ofs));
    567501                return 0;
    568502        }
     
    588522        }
    589523
    590         vector[0].iov_base = state->buf + state->ofs;
     524        vector[0].iov_base = (char *) (state->buf + state->ofs);
    591525        vector[0].iov_len = wanted;
    592526
     
    928862                return ntvfs_map_qfileinfo(ntvfs, req, info);
    929863        }
    930        
    931         return NT_STATUS_ACCESS_DENIED;
    932864}
    933865
     
    1041973        state->req = req;
    1042974        state->trans = trans;
    1043         state->writev_iov.iov_base = trans->in.data.data;
     975        state->writev_iov.iov_base = (char *) trans->in.data.data;
    1044976        state->writev_iov.iov_len = trans->in.data.length;
    1045977
     
    12501182        state->req = req;
    12511183        state->io = io;
    1252         state->writev_iov.iov_base = io->smb2.in.out.data;
     1184        state->writev_iov.iov_base = (char *) io->smb2.in.out.data;
    12531185        state->writev_iov.iov_len = io->smb2.in.out.length;
    12541186
     
    13521284                return NT_STATUS_ACCESS_DENIED;
    13531285        }
    1354 
    1355         return NT_STATUS_ACCESS_DENIED;
    13561286}
    13571287
  • vendor/current/source4/ntvfs/nbench/vfs_nbench.c

    r414 r740  
    124124        }
    125125
    126         asprintf(&logname, "/tmp/nbenchlog%d.%u", ntvfs->depth, getpid());
     126        logname = talloc_asprintf(req, "/tmp/nbenchlog%d.%u", ntvfs->depth,
     127                                  getpid());
     128        NT_STATUS_HAVE_NO_MEMORY(logname);
    127129        nprivates->log_fd = open(logname, O_WRONLY|O_CREAT|O_APPEND, 0644);
    128         free(logname);
     130        talloc_free(logname);
    129131
    130132        if (nprivates->log_fd == -1) {
  • vendor/current/source4/ntvfs/ntvfs.h

    r414 r740  
    2525#include "param/share.h"
    2626#include "librpc/gen_ndr/security.h"
    27 #include "librpc/gen_ndr/server_id.h"
     27#include "librpc/gen_ndr/server_id4.h"
    2828
    2929/* modules can use the following to determine if the interface has changed */
     
    210210
    211211        struct {
    212                 void *private_data;
    213                 struct socket_address *(*get_my_addr)(void *private_data, TALLOC_CTX *mem_ctx);
    214                 struct socket_address *(*get_peer_addr)(void *private_data, TALLOC_CTX *mem_ctx);
     212                const struct tsocket_address *local_address;
     213                const struct tsocket_address *remote_address;
    215214        } client;
    216215
     
    334333struct messaging_context;
    335334#include "librpc/gen_ndr/security.h"
    336 #include "librpc/gen_ndr/notify.h"
     335#include "librpc/gen_ndr/s4_notify.h"
    337336#include "ntvfs/ntvfs_proto.h"
    338337
  • vendor/current/source4/ntvfs/ntvfs_base.c

    r414 r740  
    201201}
    202202
     203/*
     204  adds the IPC$ share, needed for RPC calls
     205 */
     206static NTSTATUS ntvfs_add_ipc_share(struct loadparm_context *lp_ctx)
     207{
     208        struct loadparm_service *ipc;
     209
     210        if (lpcfg_service(lp_ctx, "IPC$")) {
     211                /* it has already been defined in smb.conf or elsewhere */
     212                return NT_STATUS_OK;
     213        }
     214
     215        ipc = lpcfg_add_service(lp_ctx, NULL, "IPC$");
     216        NT_STATUS_HAVE_NO_MEMORY(ipc);
     217
     218        lpcfg_do_service_parameter(lp_ctx, ipc, "comment", "IPC Service");
     219        lpcfg_do_service_parameter(lp_ctx, ipc, "path", "/dev/null");
     220        lpcfg_do_service_parameter(lp_ctx, ipc, "ntvfs handler", "default");
     221        lpcfg_do_service_parameter(lp_ctx, ipc, "browseable", "No");
     222        lpcfg_do_service_parameter(lp_ctx, ipc, "fstype", "IPC");
     223
     224        return NT_STATUS_OK;
     225}
     226
    203227NTSTATUS ntvfs_init(struct loadparm_context *lp_ctx)
    204228{
    205229        static bool initialized = false;
    206         extern NTSTATUS ntvfs_posix_init(void);
    207         extern NTSTATUS ntvfs_cifs_init(void);
    208         extern NTSTATUS ntvfs_smb2_init(void);
    209         extern NTSTATUS ntvfs_nbench_init(void);
    210         extern NTSTATUS ntvfs_unixuid_init(void);
    211         extern NTSTATUS ntvfs_ipc_init(void);
    212         extern NTSTATUS ntvfs_print_init(void);
    213         extern NTSTATUS ntvfs_simple_init(void);
    214         extern NTSTATUS ntvfs_cifs_posix_init(void);
     230#define _MODULE_PROTO(init) extern NTSTATUS init(void);
     231        STATIC_ntvfs_MODULES_PROTO;
    215232        init_module_fn static_init[] = { STATIC_ntvfs_MODULES };
    216233        init_module_fn *shared_init;
     
    225242
    226243        talloc_free(shared_init);
     244
     245        ntvfs_add_ipc_share(lp_ctx);
    227246       
    228247        return NT_STATUS_OK;
  • vendor/current/source4/ntvfs/ntvfs_generic.c

    r414 r740  
    149149        uint32_t set_size = 0;
    150150        union smb_setfileinfo *sf;
    151         uint_t state;
     151        unsigned int state;
    152152
    153153        if (!NT_STATUS_IS_OK(status)) {
     
    285285{
    286286        io2->generic.in.create_options = NTCREATEX_OPTIONS_NON_DIRECTORY_FILE;
     287        io2->generic.in.private_flags = 0;
    287288
    288289        if (flags & OPENX_FLAGS_REQUEST_OPLOCK) {
     
    328329        case OPENX_MODE_DENY_DOS:
    329330                /* DENY_DOS is quite strange - it depends on the filename! */
    330                 io2->generic.in.create_options |=
     331                io2->generic.in.private_flags |=
    331332                        NTCREATEX_OPTIONS_PRIVATE_DENY_DOS;
    332333                if (is_exe_filename(fname)) {
     
    343344                break;
    344345        case OPENX_MODE_DENY_FCB:
    345                 io2->generic.in.create_options |= NTCREATEX_OPTIONS_PRIVATE_DENY_FCB;
     346                io2->generic.in.private_flags |= NTCREATEX_OPTIONS_PRIVATE_DENY_FCB;
    346347                io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
    347348                break;
     
    516517                        break;
    517518                }
    518                 io2->generic.in.root_fid        = 0;
     519                io2->generic.in.root_fid.fnum   = 0;
    519520                io2->generic.in.access_mask     = io->smb2.in.desired_access;
    520521                io2->generic.in.alloc_size      = io->smb2.in.alloc_size;
     
    529530                io2->generic.in.ea_list         = &io->smb2.in.eas;
    530531                io2->generic.in.query_maximal_access = io->smb2.in.query_maximal_access;
     532                io2->generic.in.private_flags   = 0;
    531533
    532534                /* we don't support timewarp yet */
     
    580582        case RAW_QFS_DSKATTR: {
    581583                /* map from generic to DSKATTR */
    582                 uint_t bpunit = 64;
     584                unsigned int bpunit = 64;
    583585
    584586                /* we need to scale the sizes to fit */
     
    11071109                   MS-SMB2 3.3.5.14 */
    11081110                if (lck->smb2.in.locks[0].flags & SMB2_LOCK_FLAG_UNLOCK) {
     1111                        if (lck->smb2.in.locks[0].flags & SMB2_LOCK_FLAG_FAIL_IMMEDIATELY) {
     1112                                return NT_STATUS_INVALID_PARAMETER;
     1113                        }
    11091114                        lck2->generic.in.ulock_cnt = lck->smb2.in.lock_count;
    11101115                        isunlock = true;
     
    11141119                }
    11151120                for (i=0;i<lck->smb2.in.lock_count;i++) {
     1121                        if (!isunlock &&
     1122                            lck->smb2.in.locks[i].flags == SMB2_LOCK_FLAG_NONE) {
     1123                                return NT_STATUS_INVALID_PARAMETER;
     1124                        }
     1125
     1126                        if (lck->smb2.in.locks[i].flags & ~SMB2_LOCK_FLAG_ALL_MASK) {
     1127                                return NT_STATUS_INVALID_PARAMETER;
     1128                        }
     1129
    11161130                        if (isunlock &&
    11171131                            (lck->smb2.in.locks[i].flags &
     
    11761190        union smb_lock *lck;
    11771191        union smb_close *cl;
    1178         uint_t state;
     1192        unsigned int state;
    11791193
    11801194        if (NT_STATUS_IS_ERR(status)) {
     
    13701384        union smb_lock *lck;
    13711385        NTSTATUS status;
    1372         uint_t state;
     1386        unsigned int state;
    13731387
    13741388        rd2 = talloc(req, union smb_read);
  • vendor/current/source4/ntvfs/ntvfs_interface.c

    r414 r740  
    2121#include "includes.h"
    2222#include "ntvfs/ntvfs.h"
     23#include "lib/tsocket/tsocket.h"
    2324
    2425/* connect/disconnect */
     
    667668}
    668669
     670/* client connection callback */
     671NTSTATUS ntvfs_set_addresses(struct ntvfs_context *ntvfs,
     672                             const struct tsocket_address *local_address,
     673                             const struct tsocket_address *remote_address)
     674{
     675        ntvfs->client.local_address = tsocket_address_copy(local_address, ntvfs);
     676        NT_STATUS_HAVE_NO_MEMORY(ntvfs->client.local_address);
     677
     678        ntvfs->client.remote_address = tsocket_address_copy(remote_address, ntvfs);
     679        NT_STATUS_HAVE_NO_MEMORY(ntvfs->client.remote_address);
     680
     681        return NT_STATUS_OK;
     682}
     683
     684const struct tsocket_address *ntvfs_get_local_address(struct ntvfs_module_context *ntvfs)
     685{
     686        return ntvfs->ctx->client.local_address;
     687}
     688
     689const struct tsocket_address *ntvfs_get_remote_address(struct ntvfs_module_context *ntvfs)
     690{
     691        return ntvfs->ctx->client.remote_address;
     692}
     693
    669694/* oplock helpers */
    670695NTSTATUS ntvfs_set_oplock_handler(struct ntvfs_context *ntvfs,
     
    687712}
    688713
    689 /* client connection callback */
    690 NTSTATUS ntvfs_set_addr_callbacks(struct ntvfs_context *ntvfs,
    691                                            struct socket_address *(*my_addr)(void *private_data, TALLOC_CTX *mem_ctx),
    692                                            struct socket_address *(*peer_addr)(void *private_data, TALLOC_CTX *mem_ctx),
    693                                            void *private_data)
    694 {
    695         ntvfs->client.get_peer_addr     = my_addr;
    696         ntvfs->client.get_my_addr       = peer_addr;
    697         ntvfs->client.private_data      = private_data;
    698         return NT_STATUS_OK;
    699 }
    700 
    701 struct socket_address *ntvfs_get_my_addr(struct ntvfs_module_context *ntvfs, TALLOC_CTX *mem_ctx)
    702 {
    703         if (!ntvfs->ctx->client.get_my_addr) {
    704                 return NULL;
    705         }
    706 
    707         return ntvfs->ctx->client.get_my_addr(ntvfs->ctx->client.private_data, mem_ctx);
    708 }
    709 
    710 struct socket_address *ntvfs_get_peer_addr(struct ntvfs_module_context *ntvfs, TALLOC_CTX *mem_ctx)
    711 {
    712         if (!ntvfs->ctx->client.get_peer_addr) {
    713                 return NULL;
    714         }
    715 
    716         return ntvfs->ctx->client.get_peer_addr(ntvfs->ctx->client.private_data, mem_ctx);
    717 }
  • vendor/current/source4/ntvfs/posix/pvfs_acl.c

    r414 r740  
    2626#include "libcli/security/security.h"
    2727#include "param/param.h"
    28 
     28#include "../lib/util/unix_privs.h"
     29
     30#if defined(UID_WRAPPER)
     31#if !defined(UID_WRAPPER_REPLACE) && !defined(UID_WRAPPER_NOT_REPLACE)
     32#define UID_WRAPPER_REPLACE
     33#include "../uid_wrapper/uid_wrapper.h"
     34#endif
     35#else
     36#define uwrap_enabled() 0
     37#endif
    2938
    3039/* the list of currently registered ACL backends */
     
    8493{
    8594        static bool initialized = false;
    86         extern NTSTATUS pvfs_acl_nfs4_init(void);
    87         extern NTSTATUS pvfs_acl_xattr_init(void);
     95#define _MODULE_PROTO(init) extern NTSTATUS init(void);
     96        STATIC_pvfs_acl_MODULES_PROTO;
    8897        init_module_fn static_init[] = { STATIC_pvfs_acl_MODULES };
    8998        init_module_fn *shared_init;
     
    149158        struct security_ace ace;
    150159        mode_t mode;
    151         struct id_mapping *ids;
     160        struct id_map *ids;
    152161        struct composite_context *ctx;
    153162
     
    158167        sd = *psd;
    159168
    160         ids = talloc_zero_array(sd, struct id_mapping, 2);
     169        ids = talloc_zero_array(sd, struct id_map, 2);
    161170        NT_STATUS_HAVE_NO_MEMORY(ids);
    162171
    163         ids[0].unixid = talloc(ids, struct unixid);
    164         NT_STATUS_HAVE_NO_MEMORY(ids[0].unixid);
    165 
    166         ids[0].unixid->id = name->st.st_uid;
    167         ids[0].unixid->type = ID_TYPE_UID;
     172        ids[0].xid.id = name->st.st_uid;
     173        ids[0].xid.type = ID_TYPE_UID;
    168174        ids[0].sid = NULL;
    169175
    170         ids[1].unixid = talloc(ids, struct unixid);
    171         NT_STATUS_HAVE_NO_MEMORY(ids[1].unixid);
    172 
    173         ids[1].unixid->id = name->st.st_gid;
    174         ids[1].unixid->type = ID_TYPE_GID;
     176        ids[1].xid.id = name->st.st_gid;
     177        ids[1].xid.type = ID_TYPE_GID;
    175178        ids[1].sid = NULL;
    176179
     
    291294        uid_t new_uid = -1;
    292295        gid_t new_gid = -1;
    293         struct id_mapping *ids;
     296        struct id_map *ids;
    294297        struct composite_context *ctx;
    295298
     
    304307        }
    305308
    306         ids = talloc(req, struct id_mapping);
     309        ids = talloc(req, struct id_map);
    307310        NT_STATUS_HAVE_NO_MEMORY(ids);
    308         ids->unixid = NULL;
     311        ZERO_STRUCT(ids->xid);
    309312        ids->sid = NULL;
    310         ids->status = NT_STATUS_NONE_MAPPED;
     313        ids->status = ID_UNKNOWN;
    311314
    312315        new_sd = info->set_secdesc.in.sd;
     
    328331                        NT_STATUS_NOT_OK_RETURN(status);
    329332
    330                         if (ids->unixid->type == ID_TYPE_BOTH ||
    331                             ids->unixid->type == ID_TYPE_UID) {
    332                                 new_uid = ids->unixid->id;
     333                        if (ids->xid.type == ID_TYPE_BOTH ||
     334                            ids->xid.type == ID_TYPE_UID) {
     335                                new_uid = ids->xid.id;
    333336                        }
    334337                }
     
    346349                        NT_STATUS_NOT_OK_RETURN(status);
    347350
    348                         if (ids->unixid->type == ID_TYPE_BOTH ||
    349                             ids->unixid->type == ID_TYPE_GID) {
    350                                 new_gid = ids->unixid->id;
     351                        if (ids->xid.type == ID_TYPE_BOTH ||
     352                            ids->xid.type == ID_TYPE_GID) {
     353                                new_gid = ids->xid.id;
    351354                        }
    352355
     
    384387                } else {
    385388                        ret = fchown(fd, new_uid, new_gid);
     389                }
     390                if (errno == EPERM) {
     391                        if (uwrap_enabled()) {
     392                                ret = 0;
     393                        } else {
     394                                /* try again as root if we have SEC_PRIV_RESTORE or
     395                                   SEC_PRIV_TAKE_OWNERSHIP */
     396                                if (security_token_has_privilege(req->session_info->security_token,
     397                                                                 SEC_PRIV_RESTORE) ||
     398                                    security_token_has_privilege(req->session_info->security_token,
     399                                                                 SEC_PRIV_TAKE_OWNERSHIP)) {
     400                                        void *privs;
     401                                        privs = root_privileges();
     402                                        if (fd == -1) {
     403                                                ret = chown(name->full_name, new_uid, new_gid);
     404                                        } else {
     405                                                ret = fchown(fd, new_uid, new_gid);
     406                                        }
     407                                        talloc_free(privs);
     408                                }
     409                        }
    386410                }
    387411                if (ret == -1) {
     
    483507  for the common case of access check on files with no
    484508  specific NT ACL
    485 */
    486 NTSTATUS pvfs_access_check_unix(struct pvfs_state *pvfs,
    487                                 struct ntvfs_request *req,
    488                                 struct pvfs_filename *name,
    489                                 uint32_t *access_mask)
     509
     510  If name is NULL then treat as a new file creation
     511*/
     512static NTSTATUS pvfs_access_check_unix(struct pvfs_state *pvfs,
     513                                       struct ntvfs_request *req,
     514                                       struct pvfs_filename *name,
     515                                       uint32_t *access_mask)
    490516{
    491517        uid_t uid = geteuid();
    492518        uint32_t max_bits = SEC_RIGHTS_FILE_READ | SEC_FILE_ALL;
     519        struct security_token *token = req->session_info->security_token;
    493520
    494521        if (pvfs_read_only(pvfs, *access_mask)) {
     
    496523        }
    497524
    498         /* owner and root get extra permissions */
    499         if (uid == 0) {
    500                 max_bits |= SEC_STD_ALL | SEC_FLAG_SYSTEM_SECURITY;
    501         } else if (uid == name->st.st_uid) {
     525        if (name == NULL || uid == name->st.st_uid) {
    502526                max_bits |= SEC_STD_ALL;
    503         }
    504 
    505         if ((name->st.st_mode & S_IWOTH) ||
     527        } else if (security_token_has_privilege(token, SEC_PRIV_RESTORE)) {
     528                max_bits |= SEC_STD_DELETE;
     529        }
     530
     531        if (name == NULL ||
     532            (name->st.st_mode & S_IWOTH) ||
    506533            ((name->st.st_mode & S_IWGRP) &&
    507534             pvfs_group_member(pvfs, name->st.st_gid))) {
     
    517544        }
    518545
    519         if (*access_mask == SEC_FLAG_MAXIMUM_ALLOWED) {
    520                 *access_mask = max_bits;
    521                 return NT_STATUS_OK;
    522         }
    523 
    524         if (uid != 0 && (*access_mask & SEC_FLAG_SYSTEM_SECURITY)) {
    525                 return NT_STATUS_ACCESS_DENIED;
     546        if (*access_mask & SEC_FLAG_MAXIMUM_ALLOWED) {
     547                *access_mask |= max_bits;
     548                *access_mask &= ~SEC_FLAG_MAXIMUM_ALLOWED;
     549        }
     550
     551        if ((*access_mask & SEC_FLAG_SYSTEM_SECURITY) &&
     552            security_token_has_privilege(token, SEC_PRIV_SECURITY)) {
     553                max_bits |= SEC_FLAG_SYSTEM_SECURITY;
     554        }
     555       
     556        if (((*access_mask & ~max_bits) & SEC_RIGHTS_PRIV_RESTORE) &&
     557            security_token_has_privilege(token, SEC_PRIV_RESTORE)) {
     558                max_bits |= ~(SEC_RIGHTS_PRIV_RESTORE);
     559        }
     560        if (((*access_mask & ~max_bits) & SEC_RIGHTS_PRIV_BACKUP) &&
     561            security_token_has_privilege(token, SEC_PRIV_BACKUP)) {
     562                max_bits |= ~(SEC_RIGHTS_PRIV_BACKUP);
    526563        }
    527564
    528565        if (*access_mask & ~max_bits) {
    529566                DEBUG(0,(__location__ " denied access to '%s' - wanted 0x%08x but got 0x%08x (missing 0x%08x)\n",
    530                          name->full_name, *access_mask, max_bits, *access_mask & ~max_bits));
     567                         name?name->full_name:"(new file)", *access_mask, max_bits, *access_mask & ~max_bits));
    531568                return NT_STATUS_ACCESS_DENIED;
    532569        }
     
    556593        NTSTATUS status;
    557594        struct security_descriptor *sd;
     595        bool allow_delete = false;
    558596
    559597        /* on SMB2 a blank access mask is always denied */
     
    567605        }
    568606
     607        if (*access_mask & SEC_FLAG_MAXIMUM_ALLOWED ||
     608            *access_mask & SEC_STD_DELETE) {
     609                status = pvfs_access_check_parent(pvfs, req,
     610                                                  name, SEC_DIR_DELETE_CHILD);
     611                if (NT_STATUS_IS_OK(status)) {
     612                        allow_delete = true;
     613                        *access_mask &= ~SEC_STD_DELETE;
     614                }
     615        }
     616
    569617        acl = talloc(req, struct xattr_NTACL);
    570618        if (acl == NULL) {
     
    581629        if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
    582630                talloc_free(acl);
    583                 return pvfs_access_check_unix(pvfs, req, name, access_mask);
     631                status = pvfs_access_check_unix(pvfs, req, name, access_mask);
     632                goto done;
    584633        }
    585634        if (!NT_STATUS_IS_OK(status)) {
     
    596645
    597646        /* check the acl against the required access mask */
    598         status = sec_access_check(sd, token, *access_mask, access_mask);
    599 
     647        status = se_access_check(sd, token, *access_mask, access_mask);
     648        talloc_free(acl);
     649done:
    600650        if (pvfs->ntvfs->ctx->protocol != PROTOCOL_SMB2) {
    601651                /* on SMB, this bit is always granted, even if not
     
    604654        }
    605655
    606         talloc_free(acl);
    607        
     656        if (allow_delete) {
     657                *access_mask |= SEC_STD_DELETE;
     658        }
     659
    608660        return status;
    609661}
     
    631683                                  struct ntvfs_request *req,
    632684                                  struct pvfs_filename *name,
    633                                   uint32_t *access_mask)
     685                                  uint32_t *access_mask,
     686                                  bool container,
     687                                  struct security_descriptor **sd)
    634688{
    635689        struct pvfs_filename *parent;
    636690        NTSTATUS status;
     691        uint32_t parent_mask;
     692        bool allow_delete = false;
     693
     694        if (pvfs_read_only(pvfs, *access_mask)) {
     695                return NT_STATUS_ACCESS_DENIED;
     696        }
    637697
    638698        status = pvfs_resolve_parent(pvfs, req, name, &parent);
     699        NT_STATUS_NOT_OK_RETURN(status);
     700
     701        if (container) {
     702                parent_mask = SEC_DIR_ADD_SUBDIR;
     703        } else {
     704                parent_mask = SEC_DIR_ADD_FILE;
     705        }
     706        if (*access_mask & SEC_FLAG_MAXIMUM_ALLOWED ||
     707            *access_mask & SEC_STD_DELETE) {
     708                parent_mask |= SEC_DIR_DELETE_CHILD;
     709        }
     710
     711        status = pvfs_access_check(pvfs, req, parent, &parent_mask);
     712        if (NT_STATUS_IS_OK(status)) {
     713                if (parent_mask & SEC_DIR_DELETE_CHILD) {
     714                        allow_delete = true;
     715                }
     716        } else if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) {
     717                /*
     718                 * on ACCESS_DENIED we get the rejected bits
     719                 * remove the non critical SEC_DIR_DELETE_CHILD
     720                 * and check if something else was rejected.
     721                 */
     722                parent_mask &= ~SEC_DIR_DELETE_CHILD;
     723                if (parent_mask != 0) {
     724                        return NT_STATUS_ACCESS_DENIED;
     725                }
     726                status = NT_STATUS_OK;
     727        } else {
     728                return status;
     729        }
     730
     731        if (*sd == NULL) {
     732                status = pvfs_acl_inherited_sd(pvfs, req, req, parent, container, sd);
     733        }
     734
     735        talloc_free(parent);
    639736        if (!NT_STATUS_IS_OK(status)) {
    640737                return status;
    641738        }
    642739
    643         status = pvfs_access_check(pvfs, req, parent, access_mask);
    644         if (!NT_STATUS_IS_OK(status)) {
    645                 return status;
    646         }
    647 
    648         if (! ((*access_mask) & SEC_DIR_ADD_FILE)) {
    649                 return pvfs_access_check_simple(pvfs, req, parent, SEC_DIR_ADD_FILE);
    650         }
    651 
    652         return status;
     740        /* expand the generic access bits to file specific bits */
     741        *access_mask = pvfs_translate_mask(*access_mask);
     742
     743        if (*access_mask & SEC_FLAG_MAXIMUM_ALLOWED) {
     744                *access_mask |= SEC_RIGHTS_FILE_ALL;
     745                *access_mask &= ~SEC_FLAG_MAXIMUM_ALLOWED;
     746        }
     747
     748        if (pvfs->ntvfs->ctx->protocol != PROTOCOL_SMB2) {
     749                /* on SMB, this bit is always granted, even if not
     750                   asked for */
     751                *access_mask |= SEC_FILE_READ_ATTRIBUTE;
     752        }
     753
     754        if (allow_delete) {
     755                *access_mask |= SEC_STD_DELETE;
     756        }
     757
     758        return NT_STATUS_OK;
    653759}
    654760
     
    778884
    779885/*
    780   setup an ACL on a new file/directory based on the inherited ACL from
    781   the parent. If there is no inherited ACL then we don't set anything,
    782   as the default ACL applies anyway
    783 */
    784 NTSTATUS pvfs_acl_inherit(struct pvfs_state *pvfs,
    785                           struct ntvfs_request *req,
    786                           struct pvfs_filename *name,
    787                           int fd)
     886  calculate the ACL on a new file/directory based on the inherited ACL
     887  from the parent. If there is no inherited ACL then return a NULL
     888  ACL, which means the default ACL should be used
     889*/
     890NTSTATUS pvfs_acl_inherited_sd(struct pvfs_state *pvfs,
     891                               TALLOC_CTX *mem_ctx,
     892                               struct ntvfs_request *req,
     893                               struct pvfs_filename *parent,
     894                               bool container,
     895                               struct security_descriptor **ret_sd)
    788896{
    789897        struct xattr_NTACL *acl;
    790898        NTSTATUS status;
    791         struct pvfs_filename *parent;
    792899        struct security_descriptor *parent_sd, *sd;
    793         bool container;
    794         struct id_mapping *ids;
     900        struct id_map *ids;
    795901        struct composite_context *ctx;
    796 
    797         /* form the parents path */
    798         status = pvfs_resolve_parent(pvfs, req, name, &parent);
    799         if (!NT_STATUS_IS_OK(status)) {
    800                 return status;
    801         }
     902        TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
     903
     904        *ret_sd = NULL;
    802905
    803906        acl = talloc(req, struct xattr_NTACL);
    804         if (acl == NULL) {
    805                 return NT_STATUS_NO_MEMORY;
    806         }
     907        NT_STATUS_HAVE_NO_MEMORY_AND_FREE(acl, tmp_ctx);
    807908
    808909        status = pvfs_acl_load(pvfs, parent, -1, acl);
    809910        if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
     911                talloc_free(tmp_ctx);
    810912                return NT_STATUS_OK;
    811913        }
    812         if (!NT_STATUS_IS_OK(status)) {
    813                 return status;
    814         }
     914        NT_STATUS_NOT_OK_RETURN_AND_FREE(status, tmp_ctx);
    815915
    816916        switch (acl->version) {
     
    819919                break;
    820920        default:
     921                talloc_free(tmp_ctx);
    821922                return NT_STATUS_INVALID_ACL;
    822923        }
     
    826927            parent_sd->dacl->num_aces == 0) {
    827928                /* go with the default ACL */
     929                talloc_free(tmp_ctx);
    828930                return NT_STATUS_OK;
    829931        }
     
    831933        /* create the new sd */
    832934        sd = security_descriptor_initialise(req);
    833         if (sd == NULL) {
    834                 return NT_STATUS_NO_MEMORY;
    835         }
    836 
    837         ids = talloc_array(sd, struct id_mapping, 2);
    838         NT_STATUS_HAVE_NO_MEMORY(ids);
    839 
    840         ids[0].unixid = talloc(ids, struct unixid);
    841         NT_STATUS_HAVE_NO_MEMORY(ids[0].unixid);
    842         ids[0].unixid->id = name->st.st_uid;
    843         ids[0].unixid->type = ID_TYPE_UID;
     935        NT_STATUS_HAVE_NO_MEMORY_AND_FREE(sd, tmp_ctx);
     936
     937        ids = talloc_array(sd, struct id_map, 2);
     938        NT_STATUS_HAVE_NO_MEMORY_AND_FREE(ids, tmp_ctx);
     939
     940        ids[0].xid.id = geteuid();
     941        ids[0].xid.type = ID_TYPE_UID;
    844942        ids[0].sid = NULL;
    845         ids[0].status = NT_STATUS_NONE_MAPPED;
    846 
    847         ids[1].unixid = talloc(ids, struct unixid);
    848         NT_STATUS_HAVE_NO_MEMORY(ids[1].unixid);
    849         ids[1].unixid->id = name->st.st_gid;
    850         ids[1].unixid->type = ID_TYPE_GID;
     943        ids[0].status = ID_UNKNOWN;
     944
     945        ids[1].xid.id = getegid();
     946        ids[1].xid.type = ID_TYPE_GID;
    851947        ids[1].sid = NULL;
    852         ids[1].status = NT_STATUS_NONE_MAPPED;
     948        ids[1].status = ID_UNKNOWN;
    853949
    854950        ctx = wbc_xids_to_sids_send(pvfs->wbc_ctx, ids, 2, ids);
    855         NT_STATUS_HAVE_NO_MEMORY(ctx);
     951        NT_STATUS_HAVE_NO_MEMORY_AND_FREE(ctx, tmp_ctx);
    856952
    857953        status = wbc_xids_to_sids_recv(ctx, &ids);
    858         NT_STATUS_NOT_OK_RETURN(status);
     954        NT_STATUS_NOT_OK_RETURN_AND_FREE(status, tmp_ctx);
    859955
    860956        sd->owner_sid = talloc_steal(sd, ids[0].sid);
     
    863959        sd->type |= SEC_DESC_DACL_PRESENT;
    864960
    865         container = (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) ? true:false;
    866 
    867961        /* fill in the aces from the parent */
    868962        status = pvfs_acl_inherit_aces(pvfs, parent_sd, sd, container);
    869         if (!NT_STATUS_IS_OK(status)) {
    870                 return status;
    871         }
     963        NT_STATUS_NOT_OK_RETURN_AND_FREE(status, tmp_ctx);
    872964
    873965        /* if there is nothing to inherit then we fallback to the
    874966           default acl */
    875967        if (sd->dacl == NULL || sd->dacl->num_aces == 0) {
     968                talloc_free(tmp_ctx);
    876969                return NT_STATUS_OK;
    877970        }
    878971
    879         acl->info.sd = sd;
    880 
    881         status = pvfs_acl_save(pvfs, name, fd, acl);
    882        
     972        *ret_sd = talloc_steal(mem_ctx, sd);
     973
     974        talloc_free(tmp_ctx);
     975        return NT_STATUS_OK;
     976}
     977
     978
     979/*
     980  setup an ACL on a new file/directory based on the inherited ACL from
     981  the parent. If there is no inherited ACL then we don't set anything,
     982  as the default ACL applies anyway
     983*/
     984NTSTATUS pvfs_acl_inherit(struct pvfs_state *pvfs,
     985                          struct ntvfs_request *req,
     986                          struct pvfs_filename *name,
     987                          int fd)
     988{
     989        struct xattr_NTACL acl;
     990        NTSTATUS status;
     991        struct security_descriptor *sd;
     992        struct pvfs_filename *parent;
     993        bool container;
     994
     995        /* form the parents path */
     996        status = pvfs_resolve_parent(pvfs, req, name, &parent);
     997        NT_STATUS_NOT_OK_RETURN(status);
     998
     999        container = (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) ? true:false;
     1000
     1001        status = pvfs_acl_inherited_sd(pvfs, req, req, parent, container, &sd);
     1002        if (!NT_STATUS_IS_OK(status)) {
     1003                talloc_free(parent);
     1004                return status;
     1005        }
     1006
     1007        if (sd == NULL) {
     1008                return NT_STATUS_OK;
     1009        }
     1010
     1011        acl.version = 1;
     1012        acl.info.sd = sd;
     1013
     1014        status = pvfs_acl_save(pvfs, name, fd, &acl);
     1015        talloc_free(sd);
     1016        talloc_free(parent);
     1017
    8831018        return status;
    8841019}
  • vendor/current/source4/ntvfs/posix/pvfs_acl_nfs4.c

    r414 r740  
    4040        struct security_descriptor *sd;
    4141        int i, num_ids;
    42         struct id_mapping *ids;
     42        struct id_map *ids;
    4343        struct composite_context *ctx;
    4444
     
    4848        status = pvfs_xattr_ndr_load(pvfs, mem_ctx, name->full_name, fd,
    4949                                     NFS4ACL_XATTR_NAME,
    50                                      acl, ndr_pull_nfs4acl);
     50                                     acl, (void *) ndr_pull_nfs4acl);
    5151        if (!NT_STATUS_IS_OK(status)) {
    5252                talloc_free(acl);
     
    6363        /* the number of ids to map is the acl count plus uid and gid */
    6464        num_ids = acl->a_count +2;
    65         ids = talloc_array(sd, struct id_mapping, num_ids);
     65        ids = talloc_array(sd, struct id_map, num_ids);
    6666        NT_STATUS_HAVE_NO_MEMORY(ids);
    6767
    68         ids[0].unixid = talloc(ids, struct unixid);
    69         NT_STATUS_HAVE_NO_MEMORY(ids[0].unixid);
    70         ids[0].unixid->id = name->st.st_uid;
    71         ids[0].unixid->type = ID_TYPE_UID;
     68        ids[0].xid.id = name->st.st_uid;
     69        ids[0].xid.type = ID_TYPE_UID;
    7270        ids[0].sid = NULL;
    73         ids[0].status = NT_STATUS_NONE_MAPPED;
    74 
    75         ids[1].unixid = talloc(ids, struct unixid);
    76         NT_STATUS_HAVE_NO_MEMORY(ids[1].unixid);
    77         ids[1].unixid->id = name->st.st_gid;
    78         ids[1].unixid->type = ID_TYPE_GID;
     71        ids[0].status = ID_UNKNOWN;
     72
     73        ids[1].xid.id = name->st.st_gid;
     74        ids[1].xid.type = ID_TYPE_GID;
    7975        ids[1].sid = NULL;
    80         ids[1].status = NT_STATUS_NONE_MAPPED;
     76        ids[1].status = ID_UNKNOWN;
    8177
    8278        for (i=0;i<acl->a_count;i++) {
    8379                struct nfs4ace *a = &acl->ace[i];
    84                 ids[i+2].unixid = talloc(ids, struct unixid);
    85                 NT_STATUS_HAVE_NO_MEMORY(ids[i+2].unixid);
    86                 ids[i+2].unixid->id = a->e_id;
     80                ids[i+2].xid.id = a->e_id;
    8781                if (a->e_flags & ACE4_IDENTIFIER_GROUP) {
    88                         ids[i+2].unixid->type = ID_TYPE_GID;
     82                        ids[i+2].xid.type = ID_TYPE_GID;
    8983                } else {
    90                         ids[i+2].unixid->type = ID_TYPE_UID;
     84                        ids[i+2].xid.type = ID_TYPE_UID;
    9185                }
    9286                ids[i+2].sid = NULL;
    93                 ids[i+2].status = NT_STATUS_NONE_MAPPED;
     87                ids[i+2].status = ID_UNKNOWN;
    9488        }
    9589
     
    128122        int i;
    129123        TALLOC_CTX *tmp_ctx;
    130         struct id_mapping *ids;
     124        struct id_map *ids;
    131125        struct composite_context *ctx;
    132126
     
    147141        }
    148142
    149         ids = talloc_array(tmp_ctx, struct id_mapping, acl.a_count);
     143        ids = talloc_array(tmp_ctx, struct id_map, acl.a_count);
    150144        if (ids == NULL) {
    151145                talloc_free(tmp_ctx);
     
    155149        for (i=0;i<acl.a_count;i++) {
    156150                struct security_ace *ace = &sd->dacl->aces[i];
    157                 ids[i].unixid = NULL;
     151                ZERO_STRUCT(ids[i].xid);
    158152                ids[i].sid = dom_sid_dup(ids, &ace->trustee);
    159153                if (ids[i].sid == NULL) {
     
    161155                        return NT_STATUS_NO_MEMORY;
    162156                }
    163                 ids[i].status = NT_STATUS_NONE_MAPPED;
     157                ids[i].status = ID_UNKNOWN;
    164158        }
    165159
     
    181175                a->e_flags = ace->flags;
    182176                a->e_mask  = ace->access_mask;
    183                 if (ids[i].unixid->type != ID_TYPE_UID) {
     177                if (ids[i].xid.type != ID_TYPE_UID) {
    184178                        a->e_flags |= ACE4_IDENTIFIER_GROUP;
    185179                }
    186                 a->e_id = ids[i].unixid->id;
     180                a->e_id = ids[i].xid.id;
    187181                a->e_who   = "";
    188182        }
     
    191185        status = pvfs_xattr_ndr_save(pvfs, name->full_name, fd,
    192186                                     NFS4ACL_XATTR_NAME,
    193                                      &acl, ndr_push_nfs4acl);
     187                                     &acl, (void *) ndr_push_nfs4acl);
    194188        talloc_free(privs);
    195189
  • vendor/current/source4/ntvfs/posix/pvfs_acl_xattr.c

    r414 r740  
    4444        status = pvfs_xattr_ndr_load(pvfs, mem_ctx, name->full_name, fd,
    4545                                     XATTR_NTACL_NAME,
    46                                      acl,
    47                                      (ndr_pull_flags_fn_t)ndr_pull_xattr_NTACL);
     46                                     acl, (void *) ndr_pull_xattr_NTACL);
    4847
    4948        if (!NT_STATUS_IS_OK(status)) {
     
    8483        status = pvfs_xattr_ndr_save(pvfs, name->full_name, fd,
    8584                                     XATTR_NTACL_NAME,
    86                                      &acl,
    87                                      (ndr_push_flags_fn_t)ndr_push_xattr_NTACL);
     85                                     &acl, (void *) ndr_push_xattr_NTACL);
    8886        talloc_free(privs);
    8987        return status;
  • vendor/current/source4/ntvfs/posix/pvfs_fileinfo.c

    r414 r740  
    5454*/
    5555NTSTATUS pvfs_fill_dos_info(struct pvfs_state *pvfs, struct pvfs_filename *name,
    56                             uint_t flags, int fd)
     56                            unsigned int flags, int fd)
    5757{
    5858        NTSTATUS status;
  • vendor/current/source4/ntvfs/posix/pvfs_fsinfo.c

    r414 r740  
    8989                                  struct pvfs_state);
    9090        uint64_t blocks_free, blocks_total;
    91         uint_t bpunit;
     91        unsigned int bpunit;
    9292        struct stat st;
    9393        const uint16_t block_size = 512;
  • vendor/current/source4/ntvfs/posix/pvfs_lock.c

    r414 r740  
    117117        /* we don't retry on a cancel */
    118118        if (reason == PVFS_WAIT_CANCEL) {
    119                 status = NT_STATUS_FILE_LOCK_CONFLICT;
     119                if (pvfs->ntvfs->ctx->protocol != PROTOCOL_SMB2) {
     120                        status = NT_STATUS_FILE_LOCK_CONFLICT;
     121                } else {
     122                        status = NT_STATUS_CANCELLED;
     123                }
    120124        } else {
    121125                /*
  • vendor/current/source4/ntvfs/posix/pvfs_mkdir.c

    r414 r740  
    5252        mode = pvfs_fileperms(pvfs, FILE_ATTRIBUTE_DIRECTORY);
    5353
    54         if (mkdir(name->full_name, mode) == -1) {
     54        if (pvfs_sys_mkdir(pvfs, name->full_name, mode) == -1) {
    5555                return pvfs_map_errno(pvfs, errno);
    5656        }
     
    7070        status = pvfs_acl_inherit(pvfs, req, name, -1);
    7171        if (!NT_STATUS_IS_OK(status)) {
    72                 rmdir(name->full_name);
     72                pvfs_sys_rmdir(pvfs, name->full_name);
    7373                return status;
    7474        }
     
    7979                                         md->t2mkdir.in.eas);
    8080        if (!NT_STATUS_IS_OK(status)) {
    81                 rmdir(name->full_name);
     81                pvfs_sys_rmdir(pvfs, name->full_name);
    8282                return status;
    8383        }
     
    128128        mode = pvfs_fileperms(pvfs, FILE_ATTRIBUTE_DIRECTORY);
    129129
    130         if (mkdir(name->full_name, mode) == -1) {
     130        if (pvfs_sys_mkdir(pvfs, name->full_name, mode) == -1) {
    131131                return pvfs_map_errno(pvfs, errno);
    132132        }
     
    137137        status = pvfs_acl_inherit(pvfs, req, name, -1);
    138138        if (!NT_STATUS_IS_OK(status)) {
    139                 rmdir(name->full_name);
     139                pvfs_sys_rmdir(pvfs, name->full_name);
    140140                return status;
    141141        }
     
    180180        }
    181181
    182         if (rmdir(name->full_name) == -1) {
     182        if (pvfs_sys_rmdir(pvfs, name->full_name) == -1) {
    183183                /* some olders systems don't return ENOTEMPTY to rmdir() */
    184184                if (errno == EEXIST) {
  • vendor/current/source4/ntvfs/posix/pvfs_notify.c

    r414 r740  
    180180        NTSTATUS status;
    181181        struct notify_entry e;
     182       
     183        /* We may not fill in all the elements in this entry -
     184         * structure may in future be shared with Samba3 */
     185        ZERO_STRUCT(e);
     186
     187        /* We may not fill in all the elements in this entry -
     188         * structure may in future be shared with Samba3 */
     189        ZERO_STRUCT(e);
    182190
    183191        f->notify_buffer = talloc_zero(f, struct pvfs_notify_buffer);
  • vendor/current/source4/ntvfs/posix/pvfs_open.c

    r414 r740  
    7474                                         delete_path, nt_errstr(status)));
    7575                        }
    76                         if (rmdir(delete_path) != 0) {
     76                        if (pvfs_sys_rmdir(h->pvfs, delete_path) != 0) {
    7777                                DEBUG(0,("pvfs_dir_handle_destructor: failed to rmdir '%s' - %s\n",
    7878                                         delete_path, strerror(errno)));
     
    104104                                        struct pvfs_filename *name,
    105105                                        int fd, struct pvfs_file *f,
    106                                         union smb_open *io)
    107 {
    108         NTSTATUS status;
    109         struct security_descriptor *sd;
     106                                        union smb_open *io,
     107                                        struct security_descriptor *sd)
     108{
     109        NTSTATUS status = NT_STATUS_OK;
    110110
    111111        /* setup any EAs that were asked for */
     
    119119        }
    120120
    121         sd = io->ntcreatex.in.sec_desc;
    122121        /* setup an initial sec_desc if requested */
    123122        if (sd && (sd->type & SEC_DESC_DACL_PRESENT)) {
     
    135134
    136135                status = pvfs_acl_set(pvfs, req, name, fd, SEC_STD_WRITE_DAC, &set);
    137         } else {
    138                 /* otherwise setup an inherited acl from the parent */
    139                 status = pvfs_acl_inherit(pvfs, req, name, fd);
    140136        }
    141137
     
    186182        uint32_t share_access;
    187183        bool forced;
     184        struct security_descriptor *sd = NULL;
    188185
    189186        create_options = io->generic.in.create_options;
     
    210207            (io->ntcreatex.in.create_options & NTCREATEX_OPTIONS_DIRECTORY) &&
    211208            (io->ntcreatex.in.create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE)) {
     209                DEBUG(3,(__location__ ": Invalid access_mask/create_options 0x%08x 0x%08x for %s\n",
     210                         io->ntcreatex.in.access_mask, io->ntcreatex.in.create_options, name->original_name));
    212211                return NT_STATUS_INVALID_PARAMETER;
    213212        }
     
    233232        case NTCREATEX_DISP_SUPERSEDE:
    234233        default:
     234                DEBUG(3,(__location__ ": Invalid open disposition 0x%08x for %s\n",
     235                         io->generic.in.open_disposition, name->original_name));
    235236                return NT_STATUS_INVALID_PARAMETER;
    236237        }
     
    252253                /* check the security descriptor */
    253254                status = pvfs_access_check(pvfs, req, name, &access_mask);
    254         } else {
    255                 status = pvfs_access_check_create(pvfs, req, name, &access_mask);
     255        } else {               
     256                sd = io->ntcreatex.in.sec_desc;
     257                status = pvfs_access_check_create(pvfs, req, name, &access_mask, true, &sd);
    256258        }
    257259        NT_STATUS_NOT_OK_RETURN(status);
     
    279281        f->handle->odb_locking_key   = data_blob(NULL, 0);
    280282        f->handle->create_options    = io->generic.in.create_options;
     283        f->handle->private_flags     = io->generic.in.private_flags;
    281284        f->handle->seek_offset       = 0;
    282285        f->handle->position          = 0;
     
    342345                mode_t mode = pvfs_fileperms(pvfs, attrib);
    343346
    344                 if (mkdir(name->full_name, mode) == -1) {
     347                if (pvfs_sys_mkdir(pvfs, name->full_name, mode) == -1) {
    345348                        return pvfs_map_errno(pvfs,errno);
    346349                }
     
    353356                }
    354357
    355                 status = pvfs_open_setup_eas_acl(pvfs, req, name, -1, f, io);
     358                status = pvfs_open_setup_eas_acl(pvfs, req, name, -1, f, io, sd);
    356359                if (!NT_STATUS_IS_OK(status)) {
    357360                        goto cleanup_delete;
     
    430433
    431434cleanup_delete:
    432         rmdir(name->full_name);
     435        pvfs_sys_rmdir(pvfs, name->full_name);
    433436        return status;
    434437}
     
    512515                                         delete_path, nt_errstr(status)));
    513516                        }
    514                         if (unlink(delete_path) != 0) {
     517                        if (pvfs_sys_unlink(h->pvfs, delete_path) != 0) {
    515518                                DEBUG(0,("pvfs_close: failed to delete '%s' - %s\n",
    516519                                         delete_path, strerror(errno)));
     
    617620        uint32_t oplock_level = OPLOCK_NONE, oplock_granted;
    618621        bool allow_level_II_oplock = false;
     622        struct security_descriptor *sd = NULL;
    619623
    620624        if (io->ntcreatex.in.file_attr & ~FILE_ATTRIBUTE_ALL_MASK) {
     625                DEBUG(3,(__location__ ": Invalid file_attr 0x%08x for %s\n",
     626                         io->ntcreatex.in.file_attr, name->original_name));
    621627                return NT_STATUS_INVALID_PARAMETER;
    622628        }
    623629
    624630        if (io->ntcreatex.in.file_attr & FILE_ATTRIBUTE_ENCRYPTED) {
     631                DEBUG(3,(__location__ ": Invalid encryption request for %s\n",
     632                         name->original_name));
    625633                return NT_STATUS_ACCESS_DENIED;
    626634        }
     
    628636        if ((io->ntcreatex.in.file_attr & FILE_ATTRIBUTE_READONLY) &&
    629637            (create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE)) {
     638                DEBUG(4,(__location__ ": Invalid delete on close for readonly file %s\n",
     639                         name->original_name));
    630640                return NT_STATUS_CANNOT_DELETE;
    631641        }
    632642
    633         status = pvfs_access_check_create(pvfs, req, name, &access_mask);
     643        sd = io->ntcreatex.in.sec_desc;
     644        status = pvfs_access_check_create(pvfs, req, name, &access_mask, false, &sd);
    634645        NT_STATUS_NOT_OK_RETURN(status);
    635646
     
    667678
    668679        /* create the file */
    669         fd = open(name->full_name, flags | O_CREAT | O_EXCL| O_NONBLOCK, mode);
     680        fd = pvfs_sys_open(pvfs, name->full_name, flags | O_CREAT | O_EXCL| O_NONBLOCK, mode);
    670681        if (fd == -1) {
    671682                return pvfs_map_errno(pvfs, errno);
     
    699710
    700711
    701         status = pvfs_open_setup_eas_acl(pvfs, req, name, fd, f, io);
     712        status = pvfs_open_setup_eas_acl(pvfs, req, name, fd, f, io, sd);
    702713        if (!NT_STATUS_IS_OK(status)) {
    703714                goto cleanup_delete;
     
    777788        f->handle->fd                = fd;
    778789        f->handle->create_options    = io->generic.in.create_options;
     790        f->handle->private_flags     = io->generic.in.private_flags;
    779791        f->handle->seek_offset       = 0;
    780792        f->handle->position          = 0;
     
    845857cleanup_delete:
    846858        close(fd);
    847         unlink(name->full_name);
     859        pvfs_sys_unlink(pvfs, name->full_name);
    848860        return status;
    849861}
     
    10621074                    f2->ntvfs->session_info == req->session_info &&
    10631075                    f2->ntvfs->smbpid == req->smbpid &&
    1064                     (f2->handle->create_options &
     1076                    (f2->handle->private_flags &
    10651077                     (NTCREATEX_OPTIONS_PRIVATE_DENY_DOS |
    10661078                      NTCREATEX_OPTIONS_PRIVATE_DENY_FCB)) &&
     
    10781090        /* quite an insane set of semantics ... */
    10791091        if (is_exe_filename(io->generic.in.fname) &&
    1080             (f2->handle->create_options & NTCREATEX_OPTIONS_PRIVATE_DENY_DOS)) {
     1092            (f2->handle->private_flags & NTCREATEX_OPTIONS_PRIVATE_DENY_DOS)) {
    10811093                return NT_STATUS_SHARING_VIOLATION;
    10821094        }
     
    11301142        struct timeval *final_timeout = NULL;
    11311143
    1132         if (io->generic.in.create_options &
     1144        if (io->generic.in.private_flags &
    11331145            (NTCREATEX_OPTIONS_PRIVATE_DENY_DOS | NTCREATEX_OPTIONS_PRIVATE_DENY_FCB)) {
    11341146                /* see if we can satisfy the request using the special DENY_DOS
     
    11861198        struct ntvfs_handle *h;
    11871199        NTSTATUS status;
    1188         int fd;
     1200        int fd, count;
    11891201        struct odb_lock *lck;
    11901202        uint32_t create_options;
     
    12121224
    12131225        if (share_access & ~NTCREATEX_SHARE_ACCESS_MASK) {
     1226                DEBUG(3,(__location__ ": Invalid share_access 0x%08x for %s\n",
     1227                         share_access, io->ntcreatex.in.fname));
    12141228                return NT_STATUS_INVALID_PARAMETER;
    12151229        }
     
    12201234         */
    12211235        create_options_must_ignore_mask = NTCREATEX_OPTIONS_MUST_IGNORE_MASK;
    1222         create_options_must_ignore_mask &= ~NTCREATEX_OPTIONS_PRIVATE_MASK;
    12231236        create_options &= ~create_options_must_ignore_mask;
    12241237
     
    12301243
    12311244        if (create_options & NTCREATEX_OPTIONS_INVALID_PARAM_MASK) {
     1245                DEBUG(3,(__location__ ": Invalid create_options 0x%08x for %s\n",
     1246                         create_options, io->ntcreatex.in.fname));
    12321247                return NT_STATUS_INVALID_PARAMETER;
    12331248        }
     
    12601275        if ((create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE) &&
    12611276            !(access_mask & SEC_STD_DELETE)) {
     1277                DEBUG(3,(__location__ ": Invalid delete_on_close option 0x%08x with access_mask 0x%08x for %s\n",
     1278                         create_options, access_mask, io->ntcreatex.in.fname));
    12621279                return NT_STATUS_INVALID_PARAMETER;
    12631280        }
     
    12731290        }
    12741291
     1292        /* cope with non-zero root_fid */
     1293        if (io->ntcreatex.in.root_fid.ntvfs != NULL) {
     1294                f = pvfs_find_fd(pvfs, req, io->ntcreatex.in.root_fid.ntvfs);
     1295                if (f == NULL) {
     1296                        return NT_STATUS_INVALID_HANDLE;
     1297                }
     1298                if (f->handle->fd != -1) {
     1299                        return NT_STATUS_INVALID_DEVICE_REQUEST;
     1300                }
     1301                io->ntcreatex.in.fname = talloc_asprintf(req, "%s\\%s",
     1302                                                         f->handle->name->original_name,
     1303                                                         io->ntcreatex.in.fname);
     1304                NT_STATUS_HAVE_NO_MEMORY(io->ntcreatex.in.fname);                       
     1305        }
     1306
    12751307        if (io->ntcreatex.in.file_attr & (FILE_ATTRIBUTE_DEVICE|
    12761308                                          FILE_ATTRIBUTE_VOLUME|
    12771309                                          (~FILE_ATTRIBUTE_ALL_MASK))) {
     1310                DEBUG(3,(__location__ ": Invalid file_attr 0x%08x for %s\n",
     1311                         io->ntcreatex.in.file_attr, io->ntcreatex.in.fname));
    12781312                return NT_STATUS_INVALID_PARAMETER;
    12791313        }
     
    13591393
    13601394        default:
     1395                DEBUG(3,(__location__ ": Invalid open disposition 0x%08x for %s\n",
     1396                         io->generic.in.open_disposition, name->original_name));
    13611397                return NT_STATUS_INVALID_PARAMETER;
    13621398        }
     
    14241460        f->handle->name              = talloc_steal(f->handle, name);
    14251461        f->handle->create_options    = io->generic.in.create_options;
     1462        f->handle->private_flags     = io->generic.in.private_flags;
    14261463        f->handle->seek_offset       = 0;
    14271464        f->handle->position          = 0;
     
    15131550
    15141551        /* do the actual open */
    1515         fd = open(f->handle->name->full_name, flags | O_NONBLOCK);
     1552        fd = pvfs_sys_open(pvfs, f->handle->name->full_name, flags | O_NONBLOCK, 0);
    15161553        if (fd == -1) {
    15171554                status = pvfs_map_errno(f->pvfs, errno);
     
    15331570        f->handle->fd = fd;
    15341571
     1572        status = brl_count(f->pvfs->brl_context, f->brl_handle, &count);
     1573        if (!NT_STATUS_IS_OK(status)) {
     1574                talloc_free(lck);
     1575                return status;
     1576        }
     1577
     1578        if (count != 0) {
     1579                oplock_level = OPLOCK_NONE;
     1580        }
     1581
    15351582        /* now really mark the file as open */
    15361583        status = odb_open_file(lck, f->handle, name->full_name,
     
    15891636                if (f->handle->name->st.st_mode != mode &&
    15901637                    f->handle->name->dos.attrib != attrib &&
    1591                     fchmod(fd, mode) == -1) {
     1638                    pvfs_sys_fchmod(pvfs, fd, mode) == -1) {
    15921639                        talloc_free(lck);
    15931640                        return pvfs_map_errno(pvfs, errno);
     
    16991746        struct pvfs_file *f, *next;
    17001747
     1748        /* If pvfs is NULL, we never logged on, and no files are open. */
     1749        if(pvfs == NULL) {
     1750                return NT_STATUS_OK;
     1751        }
     1752
    17011753        for (f=pvfs->files.list;f;f=next) {
    17021754                next = f->next;
     
    19271979                          NTCREATEX_SHARE_ACCESS_DELETE;
    19281980        /*
    1929          * I would have thought that we would need to pass
    1930          * SEC_FILE_WRITE_DATA | SEC_FILE_APPEND_DATA here too
    1931          *
    1932          * But you only need SEC_FILE_WRITE_ATTRIBUTE permissions
    1933          * to set the filesize.
    1934          *
    1935          * --metze
     1981         * this code previous set only SEC_FILE_WRITE_ATTRIBUTE, with
     1982         * a comment that this seemed to be wrong, but matched windows
     1983         * behaviour. It now appears that this windows behaviour is
     1984         * just a bug.
    19361985         */
    1937         access_mask     = SEC_FILE_WRITE_ATTRIBUTE;
     1986        access_mask     = SEC_FILE_WRITE_ATTRIBUTE | SEC_FILE_WRITE_DATA | SEC_FILE_APPEND_DATA;
    19381987        delete_on_close = false;
    19391988        break_to_none   = true;
  • vendor/current/source4/ntvfs/posix/pvfs_qfileinfo.c

    r414 r740  
    4646                break;
    4747
     48        case RAW_FILEINFO_STREAM_INFO:
     49        case RAW_FILEINFO_STREAM_INFORMATION:
     50                needed = 0;
     51                break;
     52
    4853        case RAW_FILEINFO_SEC_DESC:
    4954                needed = 0;
     
    7277NTSTATUS pvfs_query_ea_list(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
    7378                            struct pvfs_filename *name, int fd,
    74                             uint_t num_names,
     79                            unsigned int num_names,
    7580                            struct ea_name *names,
    7681                            struct smb_ea_list *eas)
     
    319324                info->all_info2.out.position       = 0; /* only set by qfileinfo */
    320325                info->all_info2.out.mode           = 0; /* only set by qfileinfo */
     326                info->all_info2.out.alignment_requirement = 0;
    321327                /* windows wants the full path on disk for this
    322328                   result, but I really don't want to expose that on
  • vendor/current/source4/ntvfs/posix/pvfs_read.c

    r414 r740  
    6161        maxcnt = rd->readx.in.maxcnt;
    6262        if (maxcnt > 2*UINT16_MAX && req->ctx->protocol < PROTOCOL_SMB2) {
     63                DEBUG(3,(__location__ ": Invalid SMB maxcnt 0x%x\n", maxcnt));
    6364                return NT_STATUS_INVALID_PARAMETER;
    6465        }
  • vendor/current/source4/ntvfs/posix/pvfs_rename.c

    r414 r740  
    3838        NTSTATUS status;
    3939
    40         if (rename(name1->full_name, name2) == -1) {
     40        if (pvfs_sys_rename(pvfs, name1->full_name, name2) == -1) {
    4141                return pvfs_map_errno(pvfs, errno);
    4242        }
     
    9696*/
    9797static const char *pvfs_resolve_wildcard_component(TALLOC_CTX *mem_ctx,
    98                                                    struct smb_iconv_convenience *iconv_convenience,
    9998                                                   const char *fname,
    10099                                                   const char *pattern)
     
    116115                codepoint_t c1, c2;
    117116                size_t c_size1, c_size2;
    118                 c1 = next_codepoint_convenience(iconv_convenience, p1, &c_size1);
    119                 c2 = next_codepoint_convenience(iconv_convenience, p2, &c_size2);
     117                c1 = next_codepoint(p1, &c_size1);
     118                c2 = next_codepoint(p2, &c_size2);
    120119                if (c2 == '?') {
    121                         d += push_codepoint_convenience(iconv_convenience, d, c1);
     120                        d += push_codepoint(d, c1);
    122121                } else if (c2 == '*') {
    123122                        memcpy(d, p1, strlen(p1));
     
    125124                        break;
    126125                } else {
    127                         d += push_codepoint_convenience(iconv_convenience, d, c2);
     126                        d += push_codepoint(d, c2);
    128127                }
    129128
     
    143142*/
    144143static const char *pvfs_resolve_wildcard(TALLOC_CTX *mem_ctx,
    145                                          struct smb_iconv_convenience *iconv_convenience,
    146144                                         const char *fname,
    147145                                         const char *pattern)
     
    176174        }
    177175
    178         base1 = pvfs_resolve_wildcard_component(mem_ctx, iconv_convenience, base1, base2);
    179         ext1 = pvfs_resolve_wildcard_component(mem_ctx, iconv_convenience, ext1, ext2);
     176        base1 = pvfs_resolve_wildcard_component(mem_ctx, base1, base2);
     177        ext1 = pvfs_resolve_wildcard_component(mem_ctx, ext1, ext2);
    180178        if (base1 == NULL || ext1 == NULL) {
    181179                return NULL;
     
    284282
    285283        /* resolve the wildcard pattern for this name */
    286         fname2 = pvfs_resolve_wildcard(mem_ctx, lp_iconv_convenience(pvfs->ntvfs->ctx->lp_ctx), fname1, fname2);
     284        fname2 = pvfs_resolve_wildcard(mem_ctx, fname1, fname2);
    287285        if (fname2 == NULL) {
    288286                return NT_STATUS_NO_MEMORY;
     
    367365            name2->full_name[strlen(dir_path)] != '/' ||
    368366            strchr(name2->full_name + strlen(dir_path) + 1, '/')) {
     367                DEBUG(3,(__location__ ": Invalid rename for %s -> %s\n",
     368                         name1->original_name, name2->original_name));
    369369                return NT_STATUS_INVALID_PARAMETER;
    370370        }
     
    481481
    482482        if (name1->has_wildcard) {
     483                DEBUG(3,(__location__ ": Invalid wildcard rename for %s\n",
     484                         name1->original_name));
    483485                return NT_STATUS_INVALID_PARAMETER;
    484486        }
    485487
    486488        if (ren->ntrename.in.new_name[0] != ':') {
     489                DEBUG(3,(__location__ ": Invalid rename for %s\n",
     490                         ren->ntrename.in.new_name));
    487491                return NT_STATUS_INVALID_PARAMETER;
    488492        }
     
    493497
    494498        if (ren->ntrename.in.flags != RENAME_FLAG_RENAME) {
     499                DEBUG(3,(__location__ ": Invalid rename flags 0x%x for %s\n",
     500                         ren->ntrename.in.flags, ren->ntrename.in.new_name));
    495501                return NT_STATUS_INVALID_PARAMETER;
    496502        }
     
    516522
    517523        status = pvfs_stream_rename(pvfs, name1, -1,
    518                                     ren->ntrename.in.new_name+1);
     524                                    ren->ntrename.in.new_name+1,
     525                                    true);
    519526        NT_STATUS_NOT_OK_RETURN(status);
    520527       
     
    621628
    622629        case RENAME_FLAG_MOVE_CLUSTER_INFORMATION:
     630                DEBUG(3,(__location__ ": Invalid rename cluster for %s\n",
     631                         name1->original_name));
    623632                return NT_STATUS_INVALID_PARAMETER;
    624633
  • vendor/current/source4/ntvfs/posix/pvfs_resolve.c

    r414 r740  
    6060static NTSTATUS pvfs_case_search(struct pvfs_state *pvfs,
    6161                                 struct pvfs_filename *name,
    62                                  uint_t flags)
     62                                 unsigned int flags)
    6363{
    6464        /* break into a series of components */
     
    187187  parse a alternate data stream name
    188188*/
    189 static NTSTATUS parse_stream_name(struct smb_iconv_convenience *ic,
    190                                   struct pvfs_filename *name,
     189static NTSTATUS parse_stream_name(struct pvfs_filename *name,
    191190                                  const char *s)
    192191{
     
    204203        while (*p) {
    205204                size_t c_size;
    206                 codepoint_t c = next_codepoint_convenience(ic, p, &c_size);
     205                codepoint_t c = next_codepoint(p, &c_size);
    207206
    208207                switch (c) {
     
    257256*/
    258257static NTSTATUS pvfs_unix_path(struct pvfs_state *pvfs, const char *cifs_name,
    259                                uint_t flags, struct pvfs_filename *name)
     258                               unsigned int flags, struct pvfs_filename *name)
    260259{
    261260        char *ret, *p, *p_start;
    262         struct smb_iconv_convenience *ic = NULL;
    263261        NTSTATUS status;
    264262
    265263        name->original_name = talloc_strdup(name, cifs_name);
     264
     265        /* remove any :$DATA */
     266        p = strrchr(name->original_name, ':');
     267        if (p && strcasecmp_m(p, ":$DATA") == 0) {
     268                if (p > name->original_name && p[-1] == ':') {
     269                        p--;
     270                }
     271                *p = 0;
     272        }
     273
    266274        name->stream_name = NULL;
    267275        name->stream_id = 0;
     
    291299        p_start = p;
    292300
    293         ic = lp_iconv_convenience(pvfs->ntvfs->ctx->lp_ctx);
    294301        while (*p) {
    295302                size_t c_size;
    296                 codepoint_t c = next_codepoint_convenience(ic, p, &c_size);
     303                codepoint_t c = next_codepoint(p, &c_size);
    297304
    298305                if (c <= 0x1F) {
     
    327334                                return NT_STATUS_OBJECT_NAME_INVALID;
    328335                        }
    329                         status = parse_stream_name(ic, name, p);
     336                        status = parse_stream_name(name, p);
    330337                        if (!NT_STATUS_IS_OK(status)) {
    331338                                return status;
     
    379386*/
    380387static NTSTATUS pvfs_reduce_name(TALLOC_CTX *mem_ctx,
    381                                  struct smb_iconv_convenience *iconv_convenience,
    382                                  const char **fname, uint_t flags)
     388                                 const char **fname, unsigned int flags)
    383389{
    384390        codepoint_t c;
     
    392398
    393399        for (num_components=1, p=s; *p; p += c_size) {
    394                 c = next_codepoint_convenience(iconv_convenience, p, &c_size);
     400                c = next_codepoint(p, &c_size);
    395401                if (c == '\\') num_components++;
    396402        }
     
    404410        components[0] = s;
    405411        for (i=0, p=s; *p; p += c_size) {
    406                 c = next_codepoint_convenience(iconv_convenience, p, &c_size);
     412                c = next_codepoint(p, &c_size);
    407413                if (c == '\\') {
    408414                        *p = 0;
     
    499505     TODO: ../ collapsing, and outside share checking
    500506*/
    501 NTSTATUS pvfs_resolve_name(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
     507NTSTATUS pvfs_resolve_name(struct pvfs_state *pvfs,
     508                           struct ntvfs_request *req,
    502509                           const char *cifs_name,
    503                            uint_t flags, struct pvfs_filename **name)
     510                           unsigned int flags, struct pvfs_filename **name)
    504511{
    505512        NTSTATUS status;
    506513
    507         *name = talloc(mem_ctx, struct pvfs_filename);
     514        *name = talloc(req, struct pvfs_filename);
    508515        if (*name == NULL) {
    509516                return NT_STATUS_NO_MEMORY;
     
    515522        if (!(pvfs->fs_attribs & FS_ATTR_NAMED_STREAMS)) {
    516523                flags &= ~PVFS_RESOLVE_STREAMS;
     524        }
     525
     526        /* SMB2 doesn't allow a leading slash */
     527        if (req->ctx->protocol == PROTOCOL_SMB2 &&
     528            *cifs_name == '\\') {
     529                return NT_STATUS_INVALID_PARAMETER;
    517530        }
    518531
     
    523536        if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_PATH_SYNTAX_BAD)) {
    524537                /* it might contain .. components which need to be reduced */
    525                 status = pvfs_reduce_name(*name, lp_iconv_convenience(pvfs->ntvfs->ctx->lp_ctx), &cifs_name, flags);
     538                status = pvfs_reduce_name(*name, &cifs_name, flags);
    526539                if (!NT_STATUS_IS_OK(status)) {
    527540                        return status;
     
    594607NTSTATUS pvfs_resolve_partial(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
    595608                              const char *unix_dir, const char *fname,
    596                               uint_t flags, struct pvfs_filename **name)
     609                              unsigned int flags, struct pvfs_filename **name)
    597610{
    598611        NTSTATUS status;
     
    631644*/
    632645NTSTATUS pvfs_resolve_name_fd(struct pvfs_state *pvfs, int fd,
    633                               struct pvfs_filename *name, uint_t flags)
     646                              struct pvfs_filename *name, unsigned int flags)
    634647{
    635648        dev_t device = (dev_t)0;
     
    680693        if (h->have_opendb_entry) {
    681694                struct odb_lock *lck;
    682                 const char *name = NULL;
     695                char *name = NULL;
    683696
    684697                lck = odb_lock(h, h->pvfs->odb_context, &h->odb_locking_key);
     
    691704                }
    692705
    693                 status = odb_get_path(lck, &name);
     706                status = odb_get_path(lck, (const char **) &name);
    694707                if (NT_STATUS_IS_OK(status)) {
    695708                        /*
     
    703716                                const char *orig_dir;
    704717                                const char *new_file;
    705                                 const char *new_orig;
     718                                char *new_orig;
    706719                                char *delim;
    707720
  • vendor/current/source4/ntvfs/posix/pvfs_search.c

    r414 r740  
    233233*/
    234234static NTSTATUS pvfs_search_fill(struct pvfs_state *pvfs, TALLOC_CTX *mem_ctx,
    235                                  uint_t max_count,
     235                                 unsigned int max_count,
    236236                                 struct pvfs_search_state *search,
    237237                                 enum smb_search_data_level level,
    238                                  uint_t *reply_count,
     238                                 unsigned int *reply_count,
    239239                                 void *search_private,
    240240                                 bool (*callback)(void *, const union smb_search_data *))
     
    292292{
    293293        int i;
    294         time_t t = time(NULL);
     294        time_t t = time_mono(NULL);
    295295
    296296        for (i=0;i<MAX_OLD_SEARCHES;i++) {
     
    324324                                  struct pvfs_state);
    325325        struct pvfs_search_state *search;
    326         uint_t reply_count;
     326        unsigned int reply_count;
    327327        uint16_t search_attrib;
    328328        const char *pattern;
     
    380380        search->search_attrib = search_attrib & 0xFF;
    381381        search->must_attrib = (search_attrib>>8) & 0xFF;
    382         search->last_used = time(NULL);
     382        search->last_used = time_mono(NULL);
    383383        search->te = NULL;
    384384
     
    416416        struct pvfs_search_state *search;
    417417        struct pvfs_dir *dir;
    418         uint_t reply_count, max_count;
     418        unsigned int reply_count, max_count;
    419419        uint16_t handle;
    420420        NTSTATUS status;
     
    438438                return status;
    439439        }
    440         search->last_used = time(NULL);
     440        search->last_used = time_mono(NULL);
    441441
    442442        status = pvfs_search_fill(pvfs, req, max_count, search, io->generic.data_level,
     
    468468                                  struct pvfs_state);
    469469        struct pvfs_search_state *search;
    470         uint_t reply_count;
     470        unsigned int reply_count;
    471471        uint16_t search_attrib, max_count;
    472472        const char *pattern;
     
    566566        struct pvfs_search_state *search;
    567567        struct pvfs_dir *dir;
    568         uint_t reply_count;
     568        unsigned int reply_count;
    569569        uint16_t handle;
    570570        NTSTATUS status;
     
    630630                                  struct pvfs_state);
    631631        struct pvfs_search_state *search;
    632         uint_t reply_count;
     632        unsigned int reply_count;
    633633        uint16_t max_count;
    634634        const char *pattern;
     
    667667
    668668        if (strequal("", f->handle->name->original_name)) {
    669                 pattern = talloc_asprintf(req, "\\%s", io->in.pattern);
     669                pattern = talloc_asprintf(req, "%s", io->in.pattern);
    670670                NT_STATUS_HAVE_NO_MEMORY(pattern);
    671671        } else {
    672                 pattern = talloc_asprintf(req, "\\%s\\%s",
     672                pattern = talloc_asprintf(req, "%s\\%s",
    673673                                          f->handle->name->original_name,
    674674                                          io->in.pattern);
     
    733733                                  struct pvfs_state);
    734734        struct pvfs_search_state *search;
    735         uint_t reply_count;
     735        unsigned int reply_count;
    736736        uint16_t max_count;
    737737        NTSTATUS status;
  • vendor/current/source4/ntvfs/posix/pvfs_setfileinfo.c

    r414 r740  
    9090        struct odb_lock *lck = NULL;
    9191
     92        /* strangely, this gives a sharing violation, not invalid
     93           parameter */
    9294        if (info->rename_information.in.new_name[0] != ':') {
    93                 return NT_STATUS_INVALID_PARAMETER;
     95                return NT_STATUS_SHARING_VIOLATION;
    9496        }
    9597
     
    107109
    108110        status = pvfs_stream_rename(pvfs, name, fd,
    109                                     info->rename_information.in.new_name+1);
     111                                    info->rename_information.in.new_name+1,
     112                                    info->rename_information.in.overwrite);
    110113        return status;
    111114}
     
    169172
    170173        /* resolve the new name */
    171         status = pvfs_resolve_name(pvfs, name, new_name, 0, &name2);
     174        status = pvfs_resolve_name(pvfs, req, new_name, 0, &name2);
    172175        if (!NT_STATUS_IS_OK(status)) {
    173176                return status;
     
    532535                mode = pvfs_fileperms(pvfs, newstats.dos.attrib);
    533536                if (!(h->name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY)) {
    534                         if (fchmod(h->fd, mode) == -1) {
     537                        if (pvfs_sys_fchmod(pvfs, h->fd, mode) == -1) {
    535538                                return pvfs_map_errno(pvfs, errno);
    536539                        }
     
    857860        if (newstats.dos.attrib != name->dos.attrib) {
    858861                mode_t mode = pvfs_fileperms(pvfs, newstats.dos.attrib);
    859                 if (chmod(name->full_name, mode) == -1) {
     862                if (pvfs_sys_chmod(pvfs, name->full_name, mode) == -1) {
    860863                        return pvfs_map_errno(pvfs, errno);
    861864                }
  • vendor/current/source4/ntvfs/posix/pvfs_shortname.c

    r414 r740  
    105105        /* this is used to reverse the base 36 mapping */
    106106        unsigned char base_reverse[256];
    107 
    108         struct smb_iconv_convenience *iconv_convenience;
    109107};
    110108
     
    391389        while (*name) {
    392390                size_t c_size;
    393                 codepoint_t c = next_codepoint_convenience(ctx->iconv_convenience, name, &c_size);
     391                codepoint_t c = next_codepoint(name, &c_size);
    394392                if (c == INVALID_CODEPOINT) {
    395393                        return false;
     
    616614        }
    617615
    618         ctx->iconv_convenience = lp_iconv_convenience(pvfs->ntvfs->ctx->lp_ctx);
    619 
    620616        /* by default have a max of 512 entries in the cache. */
    621         ctx->cache_size = lp_parm_int(pvfs->ntvfs->ctx->lp_ctx, NULL, "mangle", "cachesize", 512);
     617        ctx->cache_size = lpcfg_parm_int(pvfs->ntvfs->ctx->lp_ctx, NULL, "mangle", "cachesize", 512);
    622618
    623619        ctx->prefix_cache = talloc_array(ctx, char *, ctx->cache_size);
     
    633629        memset(ctx->prefix_cache_hashes, 0, sizeof(uint32_t) * ctx->cache_size);
    634630
    635         ctx->mangle_prefix = lp_parm_int(pvfs->ntvfs->ctx->lp_ctx, NULL, "mangle", "prefix", -1);
     631        ctx->mangle_prefix = lpcfg_parm_int(pvfs->ntvfs->ctx->lp_ctx, NULL, "mangle", "prefix", -1);
    636632        if (ctx->mangle_prefix < 0 || ctx->mangle_prefix > 6) {
    637633                ctx->mangle_prefix = DEFAULT_MANGLE_PREFIX;
  • vendor/current/source4/ntvfs/posix/pvfs_streams.c

    r414 r740  
    241241*/
    242242NTSTATUS pvfs_stream_rename(struct pvfs_state *pvfs, struct pvfs_filename *name, int fd,
    243                             const char *new_name)
     243                            const char *new_name, bool overwrite)
    244244{
    245245        struct xattr_DosStreams *streams;
     
    290290                s->name = new_name;
    291291        } else {
    292                 /* remove the old one and replace with the new one */
    293                 streams->streams[found_old].name = new_name;
    294                 memmove(&streams->streams[found_new],
    295                         &streams->streams[found_new+1],
    296                         sizeof(streams->streams[0]) *
    297                         (streams->num_streams - (found_new+1)));
     292                if (!overwrite) {
     293                        return NT_STATUS_OBJECT_NAME_COLLISION;
     294                }
     295                if (found_old != found_new) {
     296                        /* remove the old one and replace with the new one */
     297                        streams->streams[found_old].name = new_name;
     298                        memmove(&streams->streams[found_new],
     299                                &streams->streams[found_new+1],
     300                                sizeof(streams->streams[0]) *
     301                                (streams->num_streams - (found_new+1)));
     302                        streams->num_streams--;
     303                }
    298304        }
    299305
    300306        status = pvfs_streams_save(pvfs, name, fd, streams);
    301         talloc_free(streams);
     307
     308        if (NT_STATUS_IS_OK(status)) {
     309
     310                /* update the in-memory copy of the name of the open file */
     311                talloc_free(name->stream_name);
     312                name->stream_name = talloc_strdup(name, new_name);
     313
     314                talloc_free(streams);
     315        }
    302316
    303317        return status;
     
    533547        status = pvfs_xattr_save(pvfs, name->full_name, fd, XATTR_DOSSTREAM_PREFIX,
    534548                                 name->stream_name, &blob);
    535         data_blob_free(&blob);
    536549
    537550        if (NT_STATUS_IS_OK(status)) {
    538551                status = pvfs_stream_update_size(pvfs, name, fd, blob.length);
    539552        }
     553        data_blob_free(&blob);
    540554
    541555        return status;
  • vendor/current/source4/ntvfs/posix/pvfs_unlink.c

    r414 r740  
    110110                                 struct pvfs_filename *name)
    111111{
    112         NTSTATUS status;
     112        NTSTATUS status = NT_STATUS_OK;
    113113
    114114        if (name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY) {
     
    124124
    125125        /* finally try the actual unlink */
    126         if (unlink(name->full_name) == -1) {
     126        if (pvfs_sys_unlink(pvfs, name->full_name) == -1) {
    127127                status = pvfs_map_errno(pvfs, errno);
    128128        }
  • vendor/current/source4/ntvfs/posix/pvfs_util.c

    r414 r740  
    103103        }
    104104
    105         fd1 = open(name1->full_name, O_RDONLY);
     105        fd1 = pvfs_sys_open(pvfs, name1->full_name, O_RDONLY, 0);
    106106        if (fd1 == -1) {
    107107                talloc_free(buf);
     
    109109        }
    110110
    111         fd2 = open(name2->full_name, O_CREAT|O_EXCL|O_WRONLY, 0);
     111        fd2 = pvfs_sys_open(pvfs, name2->full_name, O_CREAT|O_EXCL|O_WRONLY, 0);
    112112        if (fd2 == -1) {
    113113                close(fd1);
     
    134134                        close(fd2);
    135135                        talloc_free(buf);
    136                         unlink(name2->full_name);
     136                        pvfs_sys_unlink(pvfs, name2->full_name);
    137137                        if (ret2 == -1) {
    138138                                return pvfs_map_errno(pvfs, errno);
     
    146146
    147147        mode = pvfs_fileperms(pvfs, name1->dos.attrib);
    148         if (fchmod(fd2, mode) == -1) {
     148        if (pvfs_sys_fchmod(pvfs, fd2, mode) == -1) {
    149149                status = pvfs_map_errno(pvfs, errno);
    150150                close(fd2);
    151                 unlink(name2->full_name);
     151                pvfs_sys_unlink(pvfs, name2->full_name);
    152152                return status;
    153153        }
     
    159159        if (!NT_STATUS_IS_OK(status)) {
    160160                close(fd2);
    161                 unlink(name2->full_name);
     161                pvfs_sys_unlink(pvfs, name2->full_name);
    162162                return status;
    163163        }
  • vendor/current/source4/ntvfs/posix/pvfs_wait.c

    r414 r740  
    103103        pwait->reason = PVFS_WAIT_TIMEOUT;
    104104
    105         talloc_increase_ref_count(req);
    106         ntvfs_async_setup(pwait->req, pwait);
    107         talloc_free(req);
     105        req = talloc_reference(ev, req);
     106        if (req != NULL) {
     107                ntvfs_async_setup(req, pwait);
     108                talloc_unlink(ev, req);
     109        }
    108110}
    109111
  • vendor/current/source4/ntvfs/posix/pvfs_xattr.c

    r414 r740  
    118118
    119119        /* pull the blob */
    120         ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, lp_iconv_convenience(pvfs->ntvfs->ctx->lp_ctx),
    121                                        p, (ndr_pull_flags_fn_t)pull_fn);
     120        ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, p,
     121                                                                  (ndr_pull_flags_fn_t)pull_fn);
    122122        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
    123123                return ndr_map_error2ntstatus(ndr_err);
     
    141141        enum ndr_err_code ndr_err;
    142142
    143         ndr_err = ndr_push_struct_blob(&blob, mem_ctx, lp_iconv_convenience(pvfs->ntvfs->ctx->lp_ctx), p, (ndr_push_flags_fn_t)push_fn);
     143        ndr_err = ndr_push_struct_blob(&blob, mem_ctx, p, (ndr_push_flags_fn_t)push_fn);
    144144        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
    145145                talloc_free(mem_ctx);
     
    177177        status = pvfs_xattr_ndr_load(pvfs, mem_ctx, name->full_name,
    178178                                     fd, XATTR_DOSATTRIB_NAME,
    179                                      &attrib, 
    180                                      (ndr_pull_flags_fn_t)ndr_pull_xattr_DosAttrib);
     179                                     &attrib,
     180                                     (void *) ndr_pull_xattr_DosAttrib);
    181181
    182182        /* not having a DosAttrib is not an error */
     
    272272        return pvfs_xattr_ndr_save(pvfs, name->full_name, fd,
    273273                                   XATTR_DOSATTRIB_NAME, &attrib,
    274                                    (ndr_push_flags_fn_t)ndr_push_xattr_DosAttrib);
     274                                   (void *) ndr_push_xattr_DosAttrib);
    275275}
    276276
     
    288288        }
    289289        status = pvfs_xattr_ndr_load(pvfs, eas, name->full_name, fd, XATTR_DOSEAS_NAME,
    290                                      eas, (ndr_pull_flags_fn_t)ndr_pull_xattr_DosEAs);
     290                                     eas, (void *) ndr_pull_xattr_DosEAs);
    291291        if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
    292292                return NT_STATUS_OK;
     
    305305        }
    306306        return pvfs_xattr_ndr_save(pvfs, name->full_name, fd, XATTR_DOSEAS_NAME, eas,
    307                                    (ndr_push_flags_fn_t)ndr_push_xattr_DosEAs);
     307                                   (void *) ndr_push_xattr_DosEAs);
    308308}
    309309
     
    323323                                     XATTR_DOSSTREAMS_NAME,
    324324                                     streams,
    325                                      (ndr_pull_flags_fn_t)ndr_pull_xattr_DosStreams);
     325                                     (void *) ndr_pull_xattr_DosStreams);
    326326        if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
    327327                return NT_STATUS_OK;
     
    342342                                   XATTR_DOSSTREAMS_NAME,
    343343                                   streams,
    344                                    (ndr_push_flags_fn_t)ndr_push_xattr_DosStreams);
     344                                   (void *) ndr_push_xattr_DosStreams);
    345345}
    346346
     
    360360                                     XATTR_NTACL_NAME,
    361361                                     acl,
    362                                      (ndr_pull_flags_fn_t)ndr_pull_xattr_NTACL);
     362                                     (void *) ndr_pull_xattr_NTACL);
    363363        return status;
    364364}
     
    383383                                     XATTR_NTACL_NAME,
    384384                                     acl,
    385                                      (ndr_push_flags_fn_t)ndr_push_xattr_NTACL);
     385                                     (void *) ndr_push_xattr_NTACL);
    386386        talloc_free(privs);
    387387        return status;
  • vendor/current/source4/ntvfs/posix/vfs_posix.c

    r414 r740  
    2727#include "vfs_posix.h"
    2828#include "librpc/gen_ndr/security.h"
    29 #include "../tdb/include/tdb.h"
    30 #include "tdb_wrap.h"
     29#include <tdb.h>
     30#include "lib/util/tdb_wrap.h"
    3131#include "libcli/security/security.h"
    3232#include "lib/events/events.h"
     
    4040        struct share_config *scfg = pvfs->ntvfs->ctx->config;
    4141        const char *eadb;
     42        bool def_perm_override = false;
    4243
    4344        if (share_bool_option(scfg, SHARE_MAP_HIDDEN, SHARE_MAP_HIDDEN_DEFAULT))
     
    6061                pvfs->flags |= PVFS_FLAG_LINUX_AIO;
    6162
     63#if defined(O_DIRECTORY) && defined(O_NOFOLLOW)
     64        /* set PVFS_PERM_OVERRIDE by default only if the system
     65         * supports the necessary capabilities to make it secure
     66         */
     67        def_perm_override = true;
     68#endif
     69        if (share_bool_option(scfg, PVFS_PERM_OVERRIDE, def_perm_override))
     70                pvfs->flags |= PVFS_FLAG_PERM_OVERRIDE;
     71
    6272        /* file perm options */
    6373        pvfs->options.create_mask       = share_int_option(scfg,
     
    257267                                           pvfs->ntvfs->ctx->server_id, 
    258268                                           pvfs->ntvfs->ctx->msg_ctx,
    259                                            pvfs->ntvfs->ctx->lp_ctx, 
     269                                           pvfs->ntvfs->ctx->lp_ctx,
    260270                                           pvfs->ntvfs->ctx->event_ctx,
    261271                                           pvfs->ntvfs->ctx->config);
  • vendor/current/source4/ntvfs/posix/vfs_posix.h

    r414 r740  
    4141
    4242        const char *share_name;
    43         uint_t flags;
     43        unsigned int flags;
    4444
    4545        struct pvfs_mangle_context *mangle_ctx;
     
    5555
    5656        /* the sharing violation timeout (nsecs) */
    57         uint_t sharing_violation_delay;
     57        unsigned int sharing_violation_delay;
    5858
    5959        /* the oplock break timeout (secs) */
    60         uint_t oplock_break_timeout;
     60        unsigned int oplock_break_timeout;
    6161
    6262        /* the write time update delay (nsecs) */
    63         uint_t writetime_delay;
     63        unsigned int writetime_delay;
    6464
    6565        /* filesystem attributes (see FS_ATTR_*) */
     
    8585
    8686                /* how long to keep inactive searches around for */
    87                 uint_t inactivity_time;
     87                unsigned int inactivity_time;
    8888        } search;
    8989
     
    125125*/
    126126struct pvfs_filename {
    127         const char *original_name;
     127        char *original_name;
    128128        char *full_name;
    129         const char *stream_name; /* does not include :$DATA suffix */
     129        char *stream_name; /* does not include :$DATA suffix */
    130130        uint32_t stream_id;      /* this uses a hash, so is probabilistic */
    131131        bool has_wildcard;
     
    183183        /* the open went through to completion */
    184184        bool open_completed;
     185
     186        uint8_t private_flags;
    185187};
    186188
     
    223225        uint16_t must_attrib;
    224226        struct pvfs_dir *dir;
    225         time_t last_used;
    226         uint_t num_ea_names;
     227        time_t last_used; /* monotonic clock time */
     228        unsigned int num_ea_names;
    227229        struct ea_name *ea_names;
    228230        struct tevent_timer *te;
     
    245247#define PVFS_FLAG_FAKE_OPLOCKS   (1<<8)
    246248#define PVFS_FLAG_LINUX_AIO      (1<<9)
     249#define PVFS_FLAG_PERM_OVERRIDE  (1<<10)
    247250
    248251/* forward declare some anonymous structures */
     
    267270#define PVFS_ACL                        "posix:acl"
    268271#define PVFS_AIO                        "posix:aio"
     272#define PVFS_PERM_OVERRIDE              "posix:permission override"
    269273
    270274#define PVFS_XATTR_DEFAULT                      true
  • vendor/current/source4/ntvfs/posix/xattr_tdb.c

    r414 r740  
    2121
    2222#include "includes.h"
     23#include "lib/util/tdb_wrap.h"
     24#include <tdb.h>
    2325#include "vfs_posix.h"
    24 #include "../tdb/include/tdb.h"
    25 #include "tdb_wrap.h"
    2626
    2727#define XATTR_LIST_ATTR ".xattr_list"
     
    3131  can automatically clean them up
    3232*/
    33 static NTSTATUS xattr_tdb_add_list(struct pvfs_state *pvfs, const char *attr_name,
     33static NTSTATUS xattr_tdb_add_list(struct tdb_wrap *ea_tdb, TALLOC_CTX *ctx, const char *attr_name,
    3434                                   const char *fname, int fd)
    3535{
     
    4444        }
    4545
    46         mem_ctx = talloc_new(pvfs);
    47 
    48         status = pull_xattr_blob_tdb(pvfs, mem_ctx, XATTR_LIST_ATTR,
     46        mem_ctx = talloc_new(ctx);
     47
     48        status = pull_xattr_blob_tdb_raw(ea_tdb, mem_ctx, XATTR_LIST_ATTR,
    4949                                     fname, fd, 100, &blob);
    5050        if (!NT_STATUS_IS_OK(status)) {
     
    6969        blob.length += len;
    7070
    71         status = push_xattr_blob_tdb(pvfs, XATTR_LIST_ATTR, fname, fd, &blob);
     71        status = push_xattr_blob_tdb_raw(ea_tdb,ctx, XATTR_LIST_ATTR, fname, fd, &blob);
    7272        talloc_free(mem_ctx);
    7373
     
    7676
    7777/*
    78   form a key for using in the ea_db
    79 */
    80 static NTSTATUS get_ea_db_key(TALLOC_CTX *mem_ctx,
     78  form a key for using in the ea_tdb
     79*/
     80static NTSTATUS get_ea_tdb_key(TALLOC_CTX *mem_ctx,
    8181                              const char *attr_name,
    8282                              const char *fname, int fd,
     
    109109}
    110110
    111 /*
    112   pull a xattr as a blob, using the ea_db tdb
    113 */
    114 NTSTATUS pull_xattr_blob_tdb(struct pvfs_state *pvfs,
     111
     112
     113/*
     114  pull a xattr as a blob, using the ea_tdb_context tdb
     115*/
     116NTSTATUS pull_xattr_blob_tdb_raw(struct tdb_wrap *ea_tdb,
    115117                             TALLOC_CTX *mem_ctx,
    116                              const char *attr_name, 
    117                              const char *fname, 
    118                              int fd, 
     118                             const char *attr_name,
     119                             const char *fname,
     120                             int fd,
    119121                             size_t estimated_size,
    120122                             DATA_BLOB *blob)
     
    123125        NTSTATUS status;
    124126
    125         status = get_ea_db_key(mem_ctx, attr_name, fname, fd, &tkey);
     127        status = get_ea_tdb_key(mem_ctx, attr_name, fname, fd, &tkey);
    126128        if (!NT_STATUS_IS_OK(status)) {
    127129                return status;
    128130        }
    129131
    130         tdata = tdb_fetch(pvfs->ea_db->tdb, tkey);
     132        tdata = tdb_fetch(ea_tdb->tdb, tkey);
    131133        if (tdata.dptr == NULL) {
    132134                return NT_STATUS_NOT_FOUND;
     
    142144}
    143145
    144 /*
    145   push a xattr as a blob, using ea_db
    146 */
    147 NTSTATUS push_xattr_blob_tdb(struct pvfs_state *pvfs,
    148                              const char *attr_name,
    149                              const char *fname,
    150                              int fd,
     146NTSTATUS pull_xattr_blob_tdb(struct pvfs_state *pvfs,
     147                             TALLOC_CTX *mem_ctx,
     148                             const char *attr_name,
     149                             const char *fname,
     150                             int fd,
     151                             size_t estimated_size,
     152                             DATA_BLOB *blob)
     153{
     154        return pull_xattr_blob_tdb_raw(pvfs->ea_db,mem_ctx,attr_name,fname,fd,estimated_size,blob);
     155}
     156
     157/*
     158  push a xattr as a blob, using ea_tdb
     159*/
     160NTSTATUS push_xattr_blob_tdb_raw(struct tdb_wrap *ea_tdb,
     161                             TALLOC_CTX *mem_ctx,
     162                             const char *attr_name,
     163                             const char *fname,
     164                             int fd,
    151165                             const DATA_BLOB *blob)
    152166{
     
    154168        NTSTATUS status;
    155169
    156         status = get_ea_db_key(pvfs, attr_name, fname, fd, &tkey);
     170        status = get_ea_tdb_key(mem_ctx, attr_name, fname, fd, &tkey);
    157171        if (!NT_STATUS_IS_OK(status)) {
    158172                return status;
     
    162176        tdata.dsize = blob->length;
    163177
    164         if (tdb_chainlock(pvfs->ea_db->tdb, tkey) != 0) {
     178        if (tdb_chainlock(ea_tdb->tdb, tkey) != 0) {
    165179                talloc_free(tkey.dptr);
    166180                return NT_STATUS_INTERNAL_DB_CORRUPTION;
    167181        }
    168182
    169         status = xattr_tdb_add_list(pvfs, attr_name, fname, fd);
     183        status = xattr_tdb_add_list(ea_tdb,mem_ctx, attr_name, fname, fd);
    170184        if (!NT_STATUS_IS_OK(status)) {
    171185                goto done;
    172186        }
    173187
    174         if (tdb_store(pvfs->ea_db->tdb, tkey, tdata, TDB_REPLACE) == -1) {
     188        if (tdb_store(ea_tdb->tdb, tkey, tdata, TDB_REPLACE) == -1) {
    175189                status = NT_STATUS_INTERNAL_DB_CORRUPTION;
    176190        }
    177191
    178192done:
    179         tdb_chainunlock(pvfs->ea_db->tdb, tkey);
     193        tdb_chainunlock(ea_tdb->tdb, tkey);
    180194        talloc_free(tkey.dptr);
    181195        return status; 
    182196}
     197NTSTATUS push_xattr_blob_tdb(struct pvfs_state *pvfs,
     198                             const char *attr_name,
     199                             const char *fname,
     200                             int fd,
     201                             const DATA_BLOB *blob)
     202{
     203        return push_xattr_blob_tdb_raw(pvfs->ea_db,pvfs,attr_name,fname,fd,blob);
     204}
    183205
    184206
     
    192214        NTSTATUS status;
    193215
    194         status = get_ea_db_key(NULL, attr_name, fname, fd, &tkey);
     216        status = get_ea_tdb_key(NULL, attr_name, fname, fd, &tkey);
    195217        if (!NT_STATUS_IS_OK(status)) {
    196218                return status;
     
    218240        NTSTATUS status;
    219241
    220         status = pull_xattr_blob_tdb(pvfs, mem_ctx, XATTR_LIST_ATTR, 
     242        status = pull_xattr_blob_tdb(pvfs, mem_ctx, XATTR_LIST_ATTR,
    221243                                     fname, -1, 100, &blob);
    222244        if (!NT_STATUS_IS_OK(status)) {
  • vendor/current/source4/ntvfs/print/vfs_print.c

    r414 r740  
    8989                p = (char *)io->ioctl.out.blob.data;
    9090                SSVAL(p,0, 1 /* REWRITE: fsp->rap_print_jobid */);
    91                 push_string(p+2, lp_netbios_name(ntvfs->ctx->lp_ctx), 15, STR_TERMINATE|STR_ASCII);
     91                push_string(p+2, lpcfg_netbios_name(ntvfs->ctx->lp_ctx), 15, STR_TERMINATE|STR_ASCII);
    9292                push_string(p+18, ntvfs->ctx->config->name, 13, STR_TERMINATE|STR_ASCII);
    9393                return NT_STATUS_OK;
  • vendor/current/source4/ntvfs/simple/svfs_util.c

    r414 r740  
    6464        DIR *odir;
    6565        struct dirent *dent;
    66         uint_t allocated = 0;
     66        unsigned int allocated = 0;
    6767        char *low_mask;
    6868
     
    9191
    9292        while ((dent = readdir(odir))) {
    93                 uint_t i = dir->count;
     93                unsigned int i = dir->count;
    9494                char *full_name;
    9595                char *low_name;
     
    121121                if (!dir->files[i].name) { continue; }
    122122
    123                 asprintf(&full_name, "%s/%s", dir->unix_dir, dir->files[i].name);
     123                full_name = talloc_asprintf(mem_ctx, "%s/%s", dir->unix_dir,
     124                                            dir->files[i].name);
    124125                if (!full_name) { continue; }
    125126
     
    128129                }
    129130
    130                 free(full_name);
     131                talloc_free(full_name);
    131132        }
    132133
  • vendor/current/source4/ntvfs/simple/vfs_simple.c

    r414 r740  
    7171
    7272        if (strncmp(sharename, "\\\\", 2) == 0) {
    73                 char *p = strchr(sharename+2, '\\');
    74                 if (p) {
    75                         sharename = p + 1;
     73                char *p2 = strchr(sharename+2, '\\');
     74                if (p2) {
     75                        sharename = p2 + 1;
    7676                }
    7777        }
     
    834834        fs->generic.out.fs_type = talloc_strdup(req, "NTFS");
    835835        fs->generic.out.volume_name = talloc_strdup(req,
    836                                                     lp_servicename(req->tcon->service));
     836                                                    lpcfg_servicename(req->tcon->service));
    837837
    838838        return NT_STATUS_OK;
     
    862862        struct search_state *search;
    863863        union smb_search_data file;
    864         uint_t max_count;
     864        unsigned int max_count;
    865865
    866866        if (io->generic.level != RAW_SEARCH_TRANS2) {
     
    936936        struct search_state *search;
    937937        union smb_search_data file;
    938         uint_t max_count;
     938        unsigned int max_count;
    939939
    940940        if (io->generic.level != RAW_SEARCH_TRANS2) {
  • vendor/current/source4/ntvfs/smb2/vfs_smb2.c

    r414 r740  
    247247        }
    248248
    249         lp_smbcli_options(ntvfs->ctx->lp_ctx, &options);
     249        lpcfg_smbcli_options(ntvfs->ctx->lp_ctx, &options);
    250250
    251251        creq = smb2_connect_send(p, host,
    252                         lp_parm_string_list(p, ntvfs->ctx->lp_ctx, NULL, "smb2", "ports", NULL),
     252                        lpcfg_parm_string_list(p, ntvfs->ctx->lp_ctx, NULL, "smb2", "ports", NULL),
    253253                                remote_share,
    254                                  lp_resolve_context(ntvfs->ctx->lp_ctx),
     254                                 lpcfg_resolve_context(ntvfs->ctx->lp_ctx),
    255255                                 credentials,
    256256                                 ntvfs->ctx->event_ctx, &options,
    257                                  lp_socket_options(ntvfs->ctx->lp_ctx),
    258                                  lp_gensec_settings(p, ntvfs->ctx->lp_ctx)
     257                                 lpcfg_socket_options(ntvfs->ctx->lp_ctx),
     258                                 lpcfg_gensec_settings(p, ntvfs->ctx->lp_ctx)
    259259                                 );
    260260
     
    722722        struct smb2_find f;
    723723        enum smb_search_data_level smb2_level;
    724         uint_t count, i;
     724        unsigned int count, i;
    725725        union smb_search_data *data;
    726726        NTSTATUS status;
  • vendor/current/source4/ntvfs/sysdep/sys_lease.c

    r414 r740  
    108108}
    109109
    110 #ifndef STATIC_sys_lease_MODULES
    111 #define STATIC_sys_lease_MODULES NULL
    112 #endif
    113 
    114110_PUBLIC_ NTSTATUS sys_lease_init(void)
    115111{
    116112        static bool initialized = false;
    117         extern NTSTATUS sys_lease_linux_init(void);
    118 
     113#define _MODULE_PROTO(init) extern NTSTATUS init(void);
     114        STATIC_sys_lease_MODULES_PROTO;
    119115        init_module_fn static_init[] = { STATIC_sys_lease_MODULES };
    120116
  • vendor/current/source4/ntvfs/sysdep/sys_notify.c

    r414 r740  
    2626#include "system/filesys.h"
    2727#include "ntvfs/sysdep/sys_notify.h"
    28 #include "../lib/tevent/tevent.h"
     28#include <tevent.h>
    2929#include "../lib/util/dlinklist.h"
    3030#include "param/param.h"
     
    135135{
    136136        static bool initialized = false;
    137         extern NTSTATUS sys_notify_inotify_init(void);
    138 
     137#define _MODULE_PROTO(init) extern NTSTATUS init(void);
     138        STATIC_sys_notify_MODULES_PROTO;
    139139        init_module_fn static_init[] = { STATIC_sys_notify_MODULES };
    140140
  • vendor/current/source4/ntvfs/sysdep/sys_notify.h

    r414 r740  
    1818*/
    1919
    20 #include "librpc/gen_ndr/notify.h"
     20#include "librpc/gen_ndr/s4_notify.h"
    2121#include "param/share.h"
    2222
  • vendor/current/source4/ntvfs/unixuid/vfs_unixuid.c

    r414 r740  
    3030#include <tevent.h>
    3131
     32#if defined(UID_WRAPPER)
     33#if !defined(UID_WRAPPER_REPLACE) && !defined(UID_WRAPPER_NOT_REPLACE)
     34#define UID_WRAPPER_REPLACE
     35#include "../uid_wrapper/uid_wrapper.h"
     36#endif
     37#else
     38#define uwrap_enabled() 0
     39#endif
     40
     41
    3242struct unixuid_private {
    3343        struct wbc_context *wbc_ctx;
     
    4151        uid_t uid;
    4252        gid_t gid;
    43         uint_t ngroups;
     53        unsigned int ngroups;
    4454        gid_t *groups;
    4555};
     
    163173        int i;
    164174        NTSTATUS status;
    165         struct id_mapping *ids;
     175        struct id_map *ids;
    166176        struct composite_context *ctx;
    167177        *sec = talloc(req, struct unix_sec_ctx);
     
    172182        }
    173183
    174         ids = talloc_array(req, struct id_mapping, token->num_sids);
     184        ids = talloc_array(req, struct id_map, token->num_sids);
    175185        NT_STATUS_HAVE_NO_MEMORY(ids);
    176 
    177         ids[0].unixid = NULL;
    178         ids[0].sid = token->user_sid;
    179         ids[0].status = NT_STATUS_NONE_MAPPED;
    180 
    181         ids[1].unixid = NULL;
    182         ids[1].sid = token->group_sid;
    183         ids[1].status = NT_STATUS_NONE_MAPPED;
    184186
    185187        (*sec)->ngroups = token->num_sids - 2;
     
    187189        NT_STATUS_HAVE_NO_MEMORY((*sec)->groups);
    188190
    189         for (i=0;i<(*sec)->ngroups;i++) {
    190                 ids[i+2].unixid = NULL;
    191                 ids[i+2].sid = token->sids[i+2];
    192                 ids[i+2].status = NT_STATUS_NONE_MAPPED;
     191        for (i=0;i<token->num_sids;i++) {
     192                ZERO_STRUCT(ids[i].xid);
     193                ids[i].sid = &token->sids[i];
     194                ids[i].status = ID_UNKNOWN;
    193195        }
    194196
     
    199201        NT_STATUS_NOT_OK_RETURN(status);
    200202
    201         if (ids[0].unixid->type == ID_TYPE_BOTH ||
    202             ids[0].unixid->type == ID_TYPE_UID) {
    203                 (*sec)->uid = ids[0].unixid->id;
     203        if (ids[0].xid.type == ID_TYPE_BOTH ||
     204            ids[0].xid.type == ID_TYPE_UID) {
     205                (*sec)->uid = ids[0].xid.id;
    204206        } else {
    205207                return NT_STATUS_INVALID_SID;
    206208        }
    207209
    208         if (ids[1].unixid->type == ID_TYPE_BOTH ||
    209             ids[1].unixid->type == ID_TYPE_GID) {
    210                 (*sec)->gid = ids[1].unixid->id;
     210        if (ids[1].xid.type == ID_TYPE_BOTH ||
     211            ids[1].xid.type == ID_TYPE_GID) {
     212                (*sec)->gid = ids[1].xid.id;
    211213        } else {
    212214                return NT_STATUS_INVALID_SID;
     
    214216
    215217        for (i=0;i<(*sec)->ngroups;i++) {
    216                 if (ids[i+2].unixid->type == ID_TYPE_BOTH ||
    217                     ids[i+2].unixid->type == ID_TYPE_GID) {
    218                         (*sec)->groups[i] = ids[i+2].unixid->id;
     218                if (ids[i+2].xid.type == ID_TYPE_BOTH ||
     219                    ids[i+2].xid.type == ID_TYPE_GID) {
     220                        (*sec)->groups[i] = ids[i+2].xid.id;
    219221                } else {
    220222                        return NT_STATUS_INVALID_SID;
     
    236238        NTSTATUS status;
    237239
    238         if (req->session_info == NULL) {
     240        /* If we are asked to set up, but have not had a successful
     241         * session setup or tree connect, then these may not be filled
     242         * in.  ACCESS_DENIED is the right error code here */
     243        if (req->session_info == NULL || priv == NULL) {
    239244                return NT_STATUS_ACCESS_DENIED;
    240245        }
Note: See TracChangeset for help on using the changeset viewer.