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

Samba Server: update vendor to version 4.4.3

Location:
vendor/current/source4/ntvfs
Files:
3 added
1 deleted
65 edited

Legend:

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

    r740 r988  
    3535#include "param/param.h"
    3636#include "libcli/resolve/resolve.h"
     37#include "../libcli/smb/smbXcli_base.h"
    3738
    3839struct cvfs_file {
     
    6465};
    6566
     67NTSTATUS ntvfs_cifs_init(void);
     68
    6669#define CHECK_UPSTREAM_OPEN do { \
    67         if (! p->transport->socket->sock) { \
     70        if (!smbXcli_conn_is_connected(p->transport->conn)) { \
    6871                req->async_states->state|=NTVFS_ASYNC_STATE_CLOSE; \
    6972                return NT_STATUS_CONNECTION_DISCONNECTED; \
     
    98101#define CIFS_SHARE              "cifs:share"
    99102#define CIFS_USE_MACHINE_ACCT   "cifs:use-machine-account"
     103#define CIFS_USE_S4U2PROXY      "cifs:use-s4u2proxy"
    100104#define CIFS_MAP_GENERIC        "cifs:map-generic"
    101105#define CIFS_MAP_TRANS2         "cifs:map-trans2"
    102106
    103107#define CIFS_USE_MACHINE_ACCT_DEFAULT   false
     108#define CIFS_USE_S4U2PROXY_DEFAULT      false
    104109#define CIFS_MAP_GENERIC_DEFAULT        false
    105110#define CIFS_MAP_TRANS2_DEFAULT         true
     
    149154        struct cli_credentials *credentials;
    150155        bool machine_account;
     156        bool s4u2proxy;
    151157        const char* sharename;
     158        TALLOC_CTX *tmp_ctx;
     159
     160        tmp_ctx = talloc_new(req);
     161        if (tmp_ctx == NULL) {
     162                return NT_STATUS_NO_MEMORY;
     163        }
    152164
    153165        switch (tcon->generic.level) {
     
    162174                break;
    163175        default:
    164                 return NT_STATUS_INVALID_LEVEL;
     176                status = NT_STATUS_INVALID_LEVEL;
     177                goto out;
    165178        }
    166179
     
    174187        /* Here we need to determine which server to connect to.
    175188         * For now we use parametric options, type cifs.
    176          * Later we will use security=server and auth_server.c.
    177189         */
    178         host = share_string_option(scfg, CIFS_SERVER, NULL);
    179         user = share_string_option(scfg, CIFS_USER, NULL);
    180         pass = share_string_option(scfg, CIFS_PASSWORD, NULL);
    181         domain = share_string_option(scfg, CIFS_DOMAIN, NULL);
    182         remote_share = share_string_option(scfg, CIFS_SHARE, NULL);
     190        host = share_string_option(tmp_ctx, scfg, CIFS_SERVER, NULL);
     191        user = share_string_option(tmp_ctx, scfg, CIFS_USER, NULL);
     192        pass = share_string_option(tmp_ctx, scfg, CIFS_PASSWORD, NULL);
     193        domain = share_string_option(tmp_ctx, scfg, CIFS_DOMAIN, NULL);
     194        remote_share = share_string_option(tmp_ctx, scfg, CIFS_SHARE, NULL);
    183195        if (!remote_share) {
    184196                remote_share = sharename;
     
    186198
    187199        machine_account = share_bool_option(scfg, CIFS_USE_MACHINE_ACCT, CIFS_USE_MACHINE_ACCT_DEFAULT);
     200        s4u2proxy = share_bool_option(scfg, CIFS_USE_S4U2PROXY, CIFS_USE_S4U2PROXY_DEFAULT);
    188201
    189202        p = talloc_zero(ntvfs, struct cvfs_private);
    190203        if (!p) {
    191                 return NT_STATUS_NO_MEMORY;
     204                status = NT_STATUS_NO_MEMORY;
     205                goto out;
    192206        }
    193207
     
    196210        if (!host) {
    197211                DEBUG(1,("CIFS backend: You must supply server\n"));
    198                 return NT_STATUS_INVALID_PARAMETER;
     212                status = NT_STATUS_INVALID_PARAMETER;
     213                goto out;
    199214        }
    200215       
     
    203218                credentials = cli_credentials_init(p);
    204219                if (!credentials) {
    205                         return NT_STATUS_NO_MEMORY;
     220                        status = NT_STATUS_NO_MEMORY;
     221                        goto out;
    206222                }
    207223                cli_credentials_set_conf(credentials, ntvfs->ctx->lp_ctx);
     
    220236                status = cli_credentials_set_machine_account(credentials, ntvfs->ctx->lp_ctx);
    221237                if (!NT_STATUS_IS_OK(status)) {
    222                         return status;
     238                        goto out;
    223239                }
    224240        } else if (req->session_info->credentials) {
    225241                DEBUG(5, ("CIFS backend: Using delegated credentials\n"));
    226242                credentials = req->session_info->credentials;
     243        } else if (s4u2proxy) {
     244                struct ccache_container *ccc = NULL;
     245                const char *err_str = NULL;
     246                int ret;
     247                char *impersonate_principal;
     248                char *self_service;
     249                char *target_service;
     250
     251                impersonate_principal = talloc_asprintf(req, "%s@%s",
     252                                                req->session_info->info->account_name,
     253                                                req->session_info->info->domain_name);
     254
     255                self_service = talloc_asprintf(req, "cifs/%s",
     256                                               lpcfg_netbios_name(ntvfs->ctx->lp_ctx));
     257
     258                target_service = talloc_asprintf(req, "cifs/%s", host);
     259
     260                DEBUG(5, ("CIFS backend: Using S4U2Proxy credentials\n"));
     261
     262                credentials = cli_credentials_init(p);
     263                cli_credentials_set_conf(credentials, ntvfs->ctx->lp_ctx);
     264                if (domain) {
     265                        cli_credentials_set_domain(credentials, domain, CRED_SPECIFIED);
     266                }
     267                status = cli_credentials_set_machine_account(credentials, ntvfs->ctx->lp_ctx);
     268                if (!NT_STATUS_IS_OK(status)) {
     269                        goto out;
     270                }
     271                cli_credentials_invalidate_ccache(credentials, CRED_SPECIFIED);
     272                cli_credentials_set_impersonate_principal(credentials,
     273                                                          impersonate_principal,
     274                                                          self_service);
     275                cli_credentials_set_target_service(credentials, target_service);
     276                ret = cli_credentials_get_ccache(credentials,
     277                                                 ntvfs->ctx->event_ctx,
     278                                                 ntvfs->ctx->lp_ctx,
     279                                                 &ccc,
     280                                                 &err_str);
     281                if (ret != 0) {
     282                        status = NT_STATUS_CROSSREALM_DELEGATION_FAILURE;
     283                        DEBUG(1,("S4U2Proxy: cli_credentials_get_ccache() gave: ret[%d] str[%s] - %s\n",
     284                                ret, err_str, nt_errstr(status)));
     285                        goto out;
     286                }
     287
    227288        } else {
    228289                DEBUG(1,("CIFS backend: NO delegated credentials found: You must supply server, user and password or the client must supply delegated credentials\n"));
    229                 return NT_STATUS_INVALID_PARAMETER;
     290                status = NT_STATUS_INTERNAL_ERROR;
     291                goto out;
    230292        }
    231293
     
    252314                                          ntvfs->ctx->event_ctx);
    253315        status = smb_composite_connect_recv(creq, p);
    254         NT_STATUS_NOT_OK_RETURN(status);
     316        if (!NT_STATUS_IS_OK(status)) {
     317                goto out;
     318        }
    255319
    256320        p->tree = io.out.tree;
     
    261325
    262326        ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS");
    263         NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type);
     327        if (ntvfs->ctx->fs_type == NULL) {
     328                status = NT_STATUS_NO_MEMORY;
     329                goto out;
     330        }
    264331        ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "A:");
    265         NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type);
     332        if (ntvfs->ctx->dev_type == NULL) {
     333                status = NT_STATUS_NO_MEMORY;
     334                goto out;
     335        }
    266336
    267337        if (tcon->generic.level == RAW_TCON_TCONX) {
     
    277347        p->map_trans2 = share_bool_option(scfg, CIFS_MAP_TRANS2, CIFS_MAP_TRANS2_DEFAULT);
    278348
    279         return NT_STATUS_OK;
     349        status = NT_STATUS_OK;
     350
     351out:
     352        TALLOC_FREE(tmp_ctx);
     353        return status;
    280354}
    281355
     
    11411215       
    11421216        /* fill in all the operations */
    1143         ops.connect = cvfs_connect;
    1144         ops.disconnect = cvfs_disconnect;
    1145         ops.unlink = cvfs_unlink;
    1146         ops.chkpath = cvfs_chkpath;
    1147         ops.qpathinfo = cvfs_qpathinfo;
    1148         ops.setpathinfo = cvfs_setpathinfo;
    1149         ops.open = cvfs_open;
    1150         ops.mkdir = cvfs_mkdir;
    1151         ops.rmdir = cvfs_rmdir;
    1152         ops.rename = cvfs_rename;
    1153         ops.copy = cvfs_copy;
    1154         ops.ioctl = cvfs_ioctl;
    1155         ops.read = cvfs_read;
    1156         ops.write = cvfs_write;
    1157         ops.seek = cvfs_seek;
    1158         ops.flush = cvfs_flush;
    1159         ops.close = cvfs_close;
    1160         ops.exit = cvfs_exit;
    1161         ops.lock = cvfs_lock;
    1162         ops.setfileinfo = cvfs_setfileinfo;
    1163         ops.qfileinfo = cvfs_qfileinfo;
    1164         ops.fsinfo = cvfs_fsinfo;
    1165         ops.lpq = cvfs_lpq;
    1166         ops.search_first = cvfs_search_first;
    1167         ops.search_next = cvfs_search_next;
    1168         ops.search_close = cvfs_search_close;
    1169         ops.trans = cvfs_trans;
    1170         ops.logoff = cvfs_logoff;
    1171         ops.async_setup = cvfs_async_setup;
    1172         ops.cancel = cvfs_cancel;
    1173         ops.notify = cvfs_notify;
    1174         ops.trans2 = cvfs_trans2;
     1217        ops.connect_fn = cvfs_connect;
     1218        ops.disconnect_fn = cvfs_disconnect;
     1219        ops.unlink_fn = cvfs_unlink;
     1220        ops.chkpath_fn = cvfs_chkpath;
     1221        ops.qpathinfo_fn = cvfs_qpathinfo;
     1222        ops.setpathinfo_fn = cvfs_setpathinfo;
     1223        ops.open_fn = cvfs_open;
     1224        ops.mkdir_fn = cvfs_mkdir;
     1225        ops.rmdir_fn = cvfs_rmdir;
     1226        ops.rename_fn = cvfs_rename;
     1227        ops.copy_fn = cvfs_copy;
     1228        ops.ioctl_fn = cvfs_ioctl;
     1229        ops.read_fn = cvfs_read;
     1230        ops.write_fn = cvfs_write;
     1231        ops.seek_fn = cvfs_seek;
     1232        ops.flush_fn = cvfs_flush;
     1233        ops.close_fn = cvfs_close;
     1234        ops.exit_fn = cvfs_exit;
     1235        ops.lock_fn = cvfs_lock;
     1236        ops.setfileinfo_fn = cvfs_setfileinfo;
     1237        ops.qfileinfo_fn = cvfs_qfileinfo;
     1238        ops.fsinfo_fn = cvfs_fsinfo;
     1239        ops.lpq_fn = cvfs_lpq;
     1240        ops.search_first_fn = cvfs_search_first;
     1241        ops.search_next_fn = cvfs_search_next;
     1242        ops.search_close_fn = cvfs_search_close;
     1243        ops.trans_fn = cvfs_trans;
     1244        ops.logoff_fn = cvfs_logoff;
     1245        ops.async_setup_fn = cvfs_async_setup;
     1246        ops.cancel_fn = cvfs_cancel;
     1247        ops.notify_fn = cvfs_notify;
     1248        ops.trans2_fn = cvfs_trans2;
    11751249
    11761250        /* register ourselves with the NTVFS subsystem. We register
  • vendor/current/source4/ntvfs/cifs_posix_cli/svfs_util.c

    r740 r988  
    4242        struct cifspsx_private *p = ntvfs->private_data;
    4343        char *ret;
     44        char *name_lower = strlower_talloc(p, name);
    4445
    4546        if (*name != '\\') {
    46                 ret = talloc_asprintf(req, "%s/%s", p->connectpath, name);
     47                ret = talloc_asprintf(req, "%s/%s", p->connectpath, name_lower);
    4748        } else {
    48                 ret = talloc_asprintf(req, "%s%s", p->connectpath, name);
     49                ret = talloc_asprintf(req, "%s%s", p->connectpath, name_lower);
    4950        }
    5051        all_string_sub(ret, "\\", "/", 0);
    51 
    52         strlower(ret + strlen(p->connectpath));
    53 
     52        talloc_free(name_lower);
    5453        return ret;
    5554}
     
    8685        mask = p+1;
    8786
    88         low_mask = talloc_strdup(mem_ctx, mask);
     87        low_mask = strlower_talloc(mem_ctx, mask);
    8988        if (!low_mask) { return NULL; }
    90         strlower(low_mask);
    9189
    9290        odir = opendir(dir->unix_dir);
     
    103101                }
    104102
    105                 low_name = talloc_strdup(mem_ctx, dent->d_name);
     103                low_name = strlower_talloc(mem_ctx, dent->d_name);
    106104                if (!low_name) { continue; }
    107                 strlower(low_name);
    108105
    109106                /* check it matches the wildcard pattern */
    110                 if (ms_fnmatch(low_mask, low_name, PROTOCOL_NT1) != 0) {
     107                if (ms_fnmatch_protocol(low_mask, low_name, PROTOCOL_NT1) != 0) {
    111108                        continue;
    112109                }
  • vendor/current/source4/ntvfs/cifs_posix_cli/vfs_cifs_posix.c

    r740 r988  
    8282        p->ntvfs = ntvfs;
    8383        p->next_search_handle = 0;
    84         p->connectpath = talloc_strdup(p, share_string_option(scfg, SHARE_PATH, ""));
     84        p->connectpath = share_string_option(p, scfg, SHARE_PATH, "");
    8585        p->open_files = NULL;
    8686        p->search = NULL;
     
    151151        /* ignoring wildcards ... */
    152152        if (unlink(unix_path) == -1) {
    153                 return map_nt_error_from_unix(errno);
     153                return map_nt_error_from_unix_common(errno);
    154154        }
    155155
     
    180180
    181181        if (stat(unix_path, &st) == -1) {
    182                 return map_nt_error_from_unix(errno);
     182                return map_nt_error_from_unix_common(errno);
    183183        }
    184184
     
    295295        if (stat(unix_path, &st) == -1) {
    296296                DEBUG(19,("cifspsx_qpathinfo: file %s errno=%d\n", unix_path, errno));
    297                 return map_nt_error_from_unix(errno);
     297                return map_nt_error_from_unix_common(errno);
    298298        }
    299299        DEBUG(19,("cifspsx_qpathinfo: file %s, stat done\n", unix_path));
     
    321321       
    322322        if (fstat(f->fd, &st) == -1) {
    323                 return map_nt_error_from_unix(errno);
     323                return map_nt_error_from_unix_common(errno);
    324324        }
    325325
     
    390390                        if (mkdir(unix_path, 0755) == -1) {
    391391                                DEBUG(9,("cifspsx_open: mkdir %s errno=%d\n", unix_path, errno));
    392                                 return map_nt_error_from_unix(errno);
     392                                return map_nt_error_from_unix_common(errno);
    393393                        }
    394394                        break;
     
    396396                        if (mkdir(unix_path, 0755) == -1 && errno != EEXIST) {
    397397                                DEBUG(9,("cifspsx_open: mkdir %s errno=%d\n", unix_path, errno));
    398                                 return map_nt_error_from_unix(errno);
     398                                return map_nt_error_from_unix_common(errno);
    399399                        }
    400400                        break;
     
    405405        fd = open(unix_path, flags, 0644);
    406406        if (fd == -1) {
    407                 return map_nt_error_from_unix(errno);
     407                return map_nt_error_from_unix_common(errno);
    408408        }
    409409
     
    411411                DEBUG(9,("cifspsx_open: fstat errno=%d\n", errno));
    412412                close(fd);
    413                 return map_nt_error_from_unix(errno);
     413                return map_nt_error_from_unix_common(errno);
    414414        }
    415415
     
    460460
    461461        if (mkdir(unix_path, 0777) == -1) {
    462                 return map_nt_error_from_unix(errno);
     462                return map_nt_error_from_unix_common(errno);
    463463        }
    464464
     
    479479
    480480        if (rmdir(unix_path) == -1) {
    481                 return map_nt_error_from_unix(errno);
     481                return map_nt_error_from_unix_common(errno);
    482482        }
    483483
     
    503503
    504504        if (rename(unix_path1, unix_path2) == -1) {
    505                 return map_nt_error_from_unix(errno);
     505                return map_nt_error_from_unix_common(errno);
    506506        }
    507507       
     
    542542                    rd->readx.in.offset);
    543543        if (ret == -1) {
    544                 return map_nt_error_from_unix(errno);
     544                return map_nt_error_from_unix_common(errno);
    545545        }
    546546
     
    578578                     wr->writex.in.offset);
    579579        if (ret == -1) {
    580                 return map_nt_error_from_unix(errno);
     580                return map_nt_error_from_unix_common(errno);
    581581        }
    582582               
     
    649649
    650650        if (close(f->fd) == -1) {
    651                 return map_nt_error_from_unix(errno);
     651                return map_nt_error_from_unix_common(errno);
    652652        }
    653653
     
    739739                if (ftruncate(f->fd,
    740740                              info->end_of_file_info.in.size) == -1) {
    741                         return map_nt_error_from_unix(errno);
     741                        return map_nt_error_from_unix_common(errno);
    742742                }
    743743                break;
     
    785785                        &fs->generic.out.blocks_free,
    786786                        &fs->generic.out.blocks_total) == -1) {
    787                 return map_nt_error_from_unix(errno);
     787                return map_nt_error_from_unix_common(errno);
    788788        }
    789789
     
    825825
    826826        if (stat(p->connectpath, &st) == -1) {
    827                 return map_nt_error_from_unix(errno);
     827                return map_nt_error_from_unix_common(errno);
    828828        }
    829829
     
    10621062
    10631063        /* fill in all the operations */
    1064         ops.connect = cifspsx_connect;
    1065         ops.disconnect = cifspsx_disconnect;
    1066         ops.unlink = cifspsx_unlink;
    1067         ops.chkpath = cifspsx_chkpath;
    1068         ops.qpathinfo = cifspsx_qpathinfo;
    1069         ops.setpathinfo = cifspsx_setpathinfo;
    1070         ops.open = cifspsx_open;
    1071         ops.mkdir = cifspsx_mkdir;
    1072         ops.rmdir = cifspsx_rmdir;
    1073         ops.rename = cifspsx_rename;
    1074         ops.copy = cifspsx_copy;
    1075         ops.ioctl = cifspsx_ioctl;
    1076         ops.read = cifspsx_read;
    1077         ops.write = cifspsx_write;
    1078         ops.seek = cifspsx_seek;
    1079         ops.flush = cifspsx_flush;     
    1080         ops.close = cifspsx_close;
    1081         ops.exit = cifspsx_exit;
    1082         ops.lock = cifspsx_lock;
    1083         ops.setfileinfo = cifspsx_setfileinfo;
    1084         ops.qfileinfo = cifspsx_qfileinfo;
    1085         ops.fsinfo = cifspsx_fsinfo;
    1086         ops.lpq = cifspsx_lpq;
    1087         ops.search_first = cifspsx_search_first;
    1088         ops.search_next = cifspsx_search_next;
    1089         ops.search_close = cifspsx_search_close;
    1090         ops.trans = cifspsx_trans;
    1091         ops.logoff = cifspsx_logoff;
    1092         ops.async_setup = cifspsx_async_setup;
    1093         ops.cancel = cifspsx_cancel;
     1064        ops.connect_fn = cifspsx_connect;
     1065        ops.disconnect_fn = cifspsx_disconnect;
     1066        ops.unlink_fn = cifspsx_unlink;
     1067        ops.chkpath_fn = cifspsx_chkpath;
     1068        ops.qpathinfo_fn = cifspsx_qpathinfo;
     1069        ops.setpathinfo_fn = cifspsx_setpathinfo;
     1070        ops.open_fn = cifspsx_open;
     1071        ops.mkdir_fn = cifspsx_mkdir;
     1072        ops.rmdir_fn = cifspsx_rmdir;
     1073        ops.rename_fn = cifspsx_rename;
     1074        ops.copy_fn = cifspsx_copy;
     1075        ops.ioctl_fn = cifspsx_ioctl;
     1076        ops.read_fn = cifspsx_read;
     1077        ops.write_fn = cifspsx_write;
     1078        ops.seek_fn = cifspsx_seek;
     1079        ops.flush_fn = cifspsx_flush;
     1080        ops.close_fn = cifspsx_close;
     1081        ops.exit_fn = cifspsx_exit;
     1082        ops.lock_fn = cifspsx_lock;
     1083        ops.setfileinfo_fn = cifspsx_setfileinfo;
     1084        ops.qfileinfo_fn = cifspsx_qfileinfo;
     1085        ops.fsinfo_fn = cifspsx_fsinfo;
     1086        ops.lpq_fn = cifspsx_lpq;
     1087        ops.search_first_fn = cifspsx_search_first;
     1088        ops.search_next_fn = cifspsx_search_next;
     1089        ops.search_close_fn = cifspsx_search_close;
     1090        ops.trans_fn = cifspsx_trans;
     1091        ops.logoff_fn = cifspsx_logoff;
     1092        ops.async_setup_fn = cifspsx_async_setup;
     1093        ops.cancel_fn = cifspsx_cancel;
    10941094
    10951095        /* register ourselves with the NTVFS subsystem. We register
  • vendor/current/source4/ntvfs/common/brlock.c

    r740 r988  
    2727#include "includes.h"
    2828#include "system/filesys.h"
    29 #include <tdb.h>
    3029#include "messaging/messaging.h"
    3130#include "lib/messaging/irpc.h"
     
    3938  set the brl backend ops
    4039*/
    41 void brl_set_ops(const struct brlock_ops *new_ops)
     40void brlock_set_ops(const struct brlock_ops *new_ops)
    4241{
    4342        ops = new_ops;
     
    4645/*
    4746  Open up the brlock database. Close it down using talloc_free(). We
    48   need the messaging_ctx to allow for pending lock notifications.
     47  need the imessaging_ctx to allow for pending lock notifications.
    4948*/
    50 struct brl_context *brl_init(TALLOC_CTX *mem_ctx, struct server_id server,
     49struct brl_context *brlock_init(TALLOC_CTX *mem_ctx, struct server_id server,
    5150                             struct loadparm_context *lp_ctx,
    52                              struct messaging_context *messaging_ctx)
     51                             struct imessaging_context *imessaging_ctx)
    5352{
    5453        if (ops == NULL) {
    5554                brl_tdb_init_ops();
    5655        }
    57         return ops->brl_init(mem_ctx, server, lp_ctx, messaging_ctx);
     56        return ops->brl_init(mem_ctx, server, lp_ctx, imessaging_ctx);
    5857}
    5958
    60 struct brl_handle *brl_create_handle(TALLOC_CTX *mem_ctx, struct ntvfs_handle *ntvfs, DATA_BLOB *file_key)
     59struct brl_handle *brlock_create_handle(TALLOC_CTX *mem_ctx, struct ntvfs_handle *ntvfs, DATA_BLOB *file_key)
    6160{
    6261        return ops->brl_create_handle(mem_ctx, ntvfs, file_key);
     
    7069  notification is sent, identified by the notify_ptr
    7170*/
    72 NTSTATUS brl_lock(struct brl_context *brl,
     71NTSTATUS brlock_lock(struct brl_context *brl,
    7372                  struct brl_handle *brlh,
    7473                  uint32_t smbpid,
     
    8483 Unlock a range of bytes.
    8584*/
    86 NTSTATUS brl_unlock(struct brl_context *brl,
     85NTSTATUS brlock_unlock(struct brl_context *brl,
    8786                    struct brl_handle *brlh,
    8887                    uint32_t smbpid,
     
    9796  getting it. In either case they no longer need to be notified.
    9897*/
    99 NTSTATUS brl_remove_pending(struct brl_context *brl,
     98NTSTATUS brlock_remove_pending(struct brl_context *brl,
    10099                            struct brl_handle *brlh,
    101100                            void *notify_ptr)
     
    108107  Test if we are allowed to perform IO on a region of an open file
    109108*/
    110 NTSTATUS brl_locktest(struct brl_context *brl,
     109NTSTATUS brlock_locktest(struct brl_context *brl,
    111110                      struct brl_handle *brlh,
    112111                      uint32_t smbpid,
     
    121120 Remove any locks associated with a open file.
    122121*/
    123 NTSTATUS brl_close(struct brl_context *brl,
     122NTSTATUS brlock_close(struct brl_context *brl,
    124123                   struct brl_handle *brlh)
    125124{
     
    130129 Get a number of locks associated with a open file.
    131130*/
    132 NTSTATUS brl_count(struct brl_context *brl,
     131NTSTATUS brlock_count(struct brl_context *brl,
    133132                   struct brl_handle *brlh,
    134133                   int *count)
  • vendor/current/source4/ntvfs/common/brlock.h

    r740 r988  
    2525        struct brl_context *(*brl_init)(TALLOC_CTX *, struct server_id ,
    2626                                        struct loadparm_context *lp_ctx,
    27                                         struct messaging_context *);
     27                                        struct imessaging_context *);
    2828        struct brl_handle *(*brl_create_handle)(TALLOC_CTX *, struct ntvfs_handle *, DATA_BLOB *);
    2929        NTSTATUS (*brl_lock)(struct brl_context *,
     
    5252};
    5353
    54 
    55 void brl_set_ops(const struct brlock_ops *new_ops);
     54void brlock_set_ops(const struct brlock_ops *new_ops);
    5655void brl_tdb_init_ops(void);
    57 void brl_ctdb_init_ops(void);
    58 
  • vendor/current/source4/ntvfs/common/brlock_tdb.c

    r740 r988  
    2727#include "includes.h"
    2828#include "system/filesys.h"
    29 #include <tdb.h>
    3029#include "messaging/messaging.h"
    31 #include "lib/util/tdb_wrap.h"
    3230#include "lib/messaging/irpc.h"
    3331#include "libcli/libcli.h"
     
    3634#include "ntvfs/ntvfs.h"
    3735#include "param/param.h"
     36#include "dbwrap/dbwrap.h"
    3837
    3938/*
     
    4746/* this struct is typicaly attached to tcon */
    4847struct brl_context {
    49         struct tdb_wrap *w;
     48        struct db_context *db;
    5049        struct server_id server;
    51         struct messaging_context *messaging_ctx;
     50        struct imessaging_context *imessaging_ctx;
    5251};
    5352
     
    9089/*
    9190  Open up the brlock.tdb database. Close it down using
    92   talloc_free(). We need the messaging_ctx to allow for
     91  talloc_free(). We need the imessaging_ctx to allow for
    9392  pending lock notifications.
    9493*/
    9594static struct brl_context *brl_tdb_init(TALLOC_CTX *mem_ctx, struct server_id server,
    9695                                        struct loadparm_context *lp_ctx,
    97                                     struct messaging_context *messaging_ctx)
     96                                    struct imessaging_context *imessaging_ctx)
    9897{
    9998        struct brl_context *brl;
     
    104103        }
    105104
    106         brl->w = cluster_tdb_tmp_open(brl, lp_ctx, "brlock.tdb", TDB_DEFAULT);
    107         if (brl->w == NULL) {
     105        brl->db = cluster_db_tmp_open(brl, lp_ctx, "brlock", TDB_DEFAULT);
     106        if (brl->db == NULL) {
    108107                talloc_free(brl);
    109108                return NULL;
     
    111110
    112111        brl->server = server;
    113         brl->messaging_ctx = messaging_ctx;
     112        brl->imessaging_ctx = imessaging_ctx;
    114113
    115114        return brl;
     
    152151                            struct lock_struct *lck2)
    153152{
    154         /* this extra check is not redundent - it copes with locks
     153        /* this extra check is not redundant - it copes with locks
    155154           that go beyond the end of 64 bit file space */
    156155        if (lck1->size != 0 &&
     
    243242
    244243        /* in SMB2 mode always return NT_STATUS_LOCK_NOT_GRANTED! */
    245         if (lock->ntvfs->ctx->protocol == PROTOCOL_SMB2) {
     244        if (lock->ntvfs->ctx->protocol >= PROTOCOL_SMB2_02) {
    246245                return NT_STATUS_LOCK_NOT_GRANTED;
    247246        }
     
    303302        struct lock_struct lock, *locks=NULL;
    304303        NTSTATUS status;
     304        struct db_record *locked;
    305305
    306306        kbuf.dptr = brlh->key.data;
     
    311311        }
    312312
    313         if (tdb_chainlock(brl->w->tdb, kbuf) != 0) {
     313        locked = dbwrap_fetch_locked(brl->db, brl, kbuf);
     314        if (!locked) {
    314315                return NT_STATUS_INTERNAL_DB_CORRUPTION;
    315316        }
     
    329330
    330331                if (NT_STATUS_IS_OK(status)) {
    331                         tdb_chainunlock(brl->w->tdb, kbuf);
     332                        talloc_free(locked);
    332333                        return NT_STATUS_OK;
    333334                }
    334335        }
    335336
    336         dbuf = tdb_fetch(brl->w->tdb, kbuf);
     337        dbuf = dbwrap_record_get_value(locked);
    337338
    338339        lock.context.smbpid = smbpid;
     
    359360
    360361        /* no conflicts - add it to the list of locks */
    361         locks = realloc_p(locks, struct lock_struct, count+1);
     362        /* FIXME: a dbwrap_record_append() would help here! */
     363        locks = talloc_array(locked, struct lock_struct, count+1);
    362364        if (!locks) {
    363365                status = NT_STATUS_NO_MEMORY;
    364366                goto fail;
    365         } else {
    366                 dbuf.dptr = (uint8_t *)locks;
    367         }
     367        }
     368        memcpy(locks, dbuf.dptr, dbuf.dsize);
    368369        locks[count] = lock;
     370
     371        dbuf.dptr = (unsigned char *)locks;
    369372        dbuf.dsize += sizeof(lock);
    370373
    371         if (tdb_store(brl->w->tdb, kbuf, dbuf, TDB_REPLACE) != 0) {
    372                 status = NT_STATUS_INTERNAL_DB_CORRUPTION;
     374        status = dbwrap_record_store(locked, dbuf, TDB_REPLACE);
     375        if (!NT_STATUS_IS_OK(status)) {
    373376                goto fail;
    374377        }
    375378
    376         free(dbuf.dptr);
    377         tdb_chainunlock(brl->w->tdb, kbuf);
     379        talloc_free(locked);
    378380
    379381        /* the caller needs to know if the real lock was granted. If
     
    387389
    388390 fail:
    389 
    390         free(dbuf.dptr);
    391         tdb_chainunlock(brl->w->tdb, kbuf);
     391        talloc_free(locked);
    392392        return status;
    393393}
     
    420420                                last_notice = i;
    421421                        }
    422                         messaging_send_ptr(brl->messaging_ctx, locks[i].context.server,
     422                        imessaging_send_ptr(brl->imessaging_ctx, locks[i].context.server,
    423423                                           MSG_BRL_RETRY, locks[i].notify_ptr);
    424424                }
     
    456456        struct lock_struct *locks, *lock;
    457457        struct lock_context context;
     458        struct db_record *locked;
    458459        NTSTATUS status;
    459460
     
    465466        }
    466467
    467         if (tdb_chainlock(brl->w->tdb, kbuf) != 0) {
     468        locked = dbwrap_fetch_locked(brl->db, brl, kbuf);
     469        if (!locked) {
    468470                return NT_STATUS_INTERNAL_DB_CORRUPTION;
    469471        }
    470 
    471         dbuf = tdb_fetch(brl->w->tdb, kbuf);
    472         if (!dbuf.dptr) {
    473                 tdb_chainunlock(brl->w->tdb, kbuf);
    474                 return NT_STATUS_RANGE_NOT_LOCKED;
    475         }
     472        dbuf = dbwrap_record_get_value(locked);
    476473
    477474        context.smbpid = smbpid;
     
    510507                /* found it - delete it */
    511508                if (count == 1) {
    512                         if (tdb_delete(brl->w->tdb, kbuf) != 0) {
    513                                 status = NT_STATUS_INTERNAL_DB_CORRUPTION;
     509                        status = dbwrap_record_delete(locked);
     510                        if (!NT_STATUS_IS_OK(status)) {
    514511                                goto fail;
    515512                        }
     
    526523                       
    527524                        dbuf.dsize = count * sizeof(*locks);
    528                        
    529                         if (tdb_store(brl->w->tdb, kbuf, dbuf, TDB_REPLACE) != 0) {
    530                                 status = NT_STATUS_INTERNAL_DB_CORRUPTION;
     525
     526                        status = dbwrap_record_store(locked, dbuf, TDB_REPLACE);
     527                        if (!NT_STATUS_IS_OK(status)) {
    531528                                goto fail;
    532529                        }
    533530                }
    534                
    535                 free(dbuf.dptr);
    536                 tdb_chainunlock(brl->w->tdb, kbuf);
     531
     532                talloc_free(locked);
    537533                return NT_STATUS_OK;
    538534        }
     
    542538
    543539 fail:
    544         free(dbuf.dptr);
    545         tdb_chainunlock(brl->w->tdb, kbuf);
     540        talloc_free(locked);
    546541        return status;
    547542}
     
    561556        struct lock_struct *locks;
    562557        NTSTATUS status;
     558        struct db_record *locked;
    563559
    564560        kbuf.dptr = brlh->key.data;
    565561        kbuf.dsize = brlh->key.length;
    566562
    567         if (tdb_chainlock(brl->w->tdb, kbuf) != 0) {
     563        locked = dbwrap_fetch_locked(brl->db, brl, kbuf);
     564        if (!locked) {
    568565                return NT_STATUS_INTERNAL_DB_CORRUPTION;
    569566        }
    570567
    571         dbuf = tdb_fetch(brl->w->tdb, kbuf);
     568        dbuf = dbwrap_record_get_value(locked);
    572569        if (!dbuf.dptr) {
    573                 tdb_chainunlock(brl->w->tdb, kbuf);
     570                talloc_free(locked);
    574571                return NT_STATUS_RANGE_NOT_LOCKED;
    575572        }
     
    587584                        /* found it - delete it */
    588585                        if (count == 1) {
    589                                 if (tdb_delete(brl->w->tdb, kbuf) != 0) {
    590                                         status = NT_STATUS_INTERNAL_DB_CORRUPTION;
     586                                status = dbwrap_record_delete(locked);
     587                                if (!NT_STATUS_IS_OK(status)) {
    591588                                        goto fail;
    592589                                }
     
    598595                                count--;
    599596                                dbuf.dsize = count * sizeof(*locks);
    600                                 if (tdb_store(brl->w->tdb, kbuf, dbuf, TDB_REPLACE) != 0) {
    601                                         status = NT_STATUS_INTERNAL_DB_CORRUPTION;
     597                                status = dbwrap_record_store(locked, dbuf,
     598                                                             TDB_REPLACE);
     599                                if (!NT_STATUS_IS_OK(status)) {
    602600                                        goto fail;
    603601                                }
    604602                        }
    605603                       
    606                         free(dbuf.dptr);
    607                         tdb_chainunlock(brl->w->tdb, kbuf);
     604                        talloc_free(locked);
    608605                        return NT_STATUS_OK;
    609606                }
     
    614611
    615612 fail:
    616         free(dbuf.dptr);
    617         tdb_chainunlock(brl->w->tdb, kbuf);
     613        talloc_free(locked);
    618614        return status;
    619615}
     
    632628        int count, i;
    633629        struct lock_struct lock, *locks;
     630        NTSTATUS status;
    634631
    635632        kbuf.dptr = brlh->key.data;
     
    640637        }
    641638
    642         dbuf = tdb_fetch(brl->w->tdb, kbuf);
    643         if (dbuf.dptr == NULL) {
     639        status = dbwrap_fetch(brl->db, brl, kbuf, &dbuf);
     640        if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
    644641                return NT_STATUS_OK;
     642        } else if (!NT_STATUS_IS_OK(status)) {
     643                return status;
    645644        }
    646645
     
    659658        for (i=0; i<count; i++) {
    660659                if (brl_tdb_conflict_other(&locks[i], &lock)) {
    661                         free(dbuf.dptr);
     660                        talloc_free(dbuf.dptr);
    662661                        return NT_STATUS_FILE_LOCK_CONFLICT;
    663662                }
    664663        }
    665664
    666         free(dbuf.dptr);
     665        talloc_free(dbuf.dptr);
    667666        return NT_STATUS_OK;
    668667}
     
    678677        int count, i, dcount=0;
    679678        struct lock_struct *locks;
     679        struct db_record *locked;
    680680        NTSTATUS status;
    681681
     
    683683        kbuf.dsize = brlh->key.length;
    684684
    685         if (tdb_chainlock(brl->w->tdb, kbuf) != 0) {
     685        locked = dbwrap_fetch_locked(brl->db, brl, kbuf);
     686        if (!locked) {
    686687                return NT_STATUS_INTERNAL_DB_CORRUPTION;
    687688        }
    688 
    689         dbuf = tdb_fetch(brl->w->tdb, kbuf);
     689        dbuf = dbwrap_record_get_value(locked);
    690690        if (!dbuf.dptr) {
    691                 tdb_chainunlock(brl->w->tdb, kbuf);
     691                talloc_free(locked);
    692692                return NT_STATUS_OK;
    693693        }
     
    717717
    718718        if (count == 0) {
    719                 if (tdb_delete(brl->w->tdb, kbuf) != 0) {
    720                         status = NT_STATUS_INTERNAL_DB_CORRUPTION;
    721                 }
     719                status = dbwrap_record_delete(locked);
    722720        } else if (dcount != 0) {
    723721                /* tell all pending lock holders for this file that
     
    728726                dbuf.dsize = count * sizeof(*locks);
    729727
    730                 if (tdb_store(brl->w->tdb, kbuf, dbuf, TDB_REPLACE) != 0) {
    731                         status = NT_STATUS_INTERNAL_DB_CORRUPTION;
    732                 }
    733         }
    734 
    735         free(dbuf.dptr);
    736         tdb_chainunlock(brl->w->tdb, kbuf);
     728                status = dbwrap_record_store(locked, dbuf, TDB_REPLACE);
     729        }
     730        talloc_free(locked);
    737731
    738732        return status;
     
    743737{
    744738        TDB_DATA kbuf, dbuf;
     739        NTSTATUS status;
    745740
    746741        kbuf.dptr = brlh->key.data;
     
    748743        *count = 0;
    749744
    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);
     745        status = dbwrap_fetch(brl->db, brl, kbuf, &dbuf);
     746        if (NT_STATUS_EQUAL(status, NT_STATUS_NOT_FOUND)) {
    757747                return NT_STATUS_OK;
    758         }
    759 
     748        } else if (!NT_STATUS_IS_OK(status)) {
     749                return status;
     750        }
    760751        *count = dbuf.dsize / sizeof(struct lock_struct);
    761752
    762         free(dbuf.dptr);
    763         tdb_chainunlock(brl->w->tdb, kbuf);
     753        talloc_free(dbuf.dptr);
    764754
    765755        return NT_STATUS_OK;
     
    780770void brl_tdb_init_ops(void)
    781771{
    782         brl_set_ops(&brlock_tdb_ops);
    783 }
     772        brlock_set_ops(&brlock_tdb_ops);
     773}
  • vendor/current/source4/ntvfs/common/init.c

    r414 r988  
    2727#include "ntvfs/sysdep/sys_notify.h"
    2828
     29NTSTATUS ntvfs_common_init(void);
     30
    2931NTSTATUS ntvfs_common_init(void)
    3032{
  • vendor/current/source4/ntvfs/common/notify.c

    r740 r988  
    2626#include "includes.h"
    2727#include "system/filesys.h"
    28 #include <tdb.h>
    29 #include "../lib/util/util_tdb.h"
    3028#include "messaging/messaging.h"
    31 #include "lib/util/tdb_wrap.h"
    3229#include "lib/messaging/irpc.h"
    33 #include "librpc/gen_ndr/ndr_s4_notify.h"
     30#include "librpc/gen_ndr/ndr_notify.h"
    3431#include "../lib/util/dlinklist.h"
    3532#include "ntvfs/common/ntvfs_common.h"
     
    3835#include "param/param.h"
    3936#include "lib/util/tsort.h"
     37#include "lib/dbwrap/dbwrap.h"
     38#include "../lib/util/util_tdb.h"
    4039
    4140struct notify_context {
    42         struct tdb_wrap *w;
     41        struct db_context *db;
    4342        struct server_id server;
    44         struct messaging_context *messaging_ctx;
     43        struct imessaging_context *imessaging_ctx;
    4544        struct notify_list *list;
    4645        struct notify_array *array;
    47         int seqnum;
     46        int64_t seqnum;
    4847        struct sys_notify_context *sys_notify_ctx;
    4948};
     
    6463
    6564static NTSTATUS notify_remove_all(struct notify_context *notify);
    66 static void notify_handler(struct messaging_context *msg_ctx, void *private_data,
     65static void notify_handler(struct imessaging_context *msg_ctx, void *private_data,
    6766                           uint32_t msg_type, struct server_id server_id, DATA_BLOB *data);
    6867
     
    7271static int notify_destructor(struct notify_context *notify)
    7372{
    74         messaging_deregister(notify->messaging_ctx, MSG_PVFS_NOTIFY, notify);
     73        imessaging_deregister(notify->imessaging_ctx, MSG_PVFS_NOTIFY, notify);
    7574        notify_remove_all(notify);
    7675        return 0;
     
    7978/*
    8079  Open up the notify.tdb database. You should close it down using
    81   talloc_free(). We need the messaging_ctx to allow for notifications
     80  talloc_free(). We need the imessaging_ctx to allow for notifications
    8281  via internal messages
    8382*/
    8483struct notify_context *notify_init(TALLOC_CTX *mem_ctx, struct server_id server,
    85                                    struct messaging_context *messaging_ctx,
     84                                   struct imessaging_context *imessaging_ctx,
    8685                                   struct loadparm_context *lp_ctx,
    8786                                   struct tevent_context *ev,
     
    103102        }
    104103
    105         notify->w = cluster_tdb_tmp_open(notify, lp_ctx, "notify.tdb", TDB_SEQNUM);
    106         if (notify->w == NULL) {
     104        notify->db = cluster_db_tmp_open(notify, lp_ctx, "notify", TDB_SEQNUM);
     105        if (notify->db == NULL) {
    107106                talloc_free(notify);
    108107                return NULL;
     
    110109
    111110        notify->server = server;
    112         notify->messaging_ctx = messaging_ctx;
     111        notify->imessaging_ctx = imessaging_ctx;
    113112        notify->list = NULL;
    114113        notify->array = NULL;
    115         notify->seqnum = tdb_get_seqnum(notify->w->tdb);
     114        notify->seqnum = dbwrap_get_seqnum(notify->db);
    116115
    117116        talloc_set_destructor(notify, notify_destructor);
     
    119118        /* register with the messaging subsystem for the notify
    120119           message type */
    121         messaging_register(notify->messaging_ctx, notify,
     120        imessaging_register(notify->imessaging_ctx, notify,
    122121                           MSG_PVFS_NOTIFY, notify_handler);
    123122
     
    131130  lock the notify db
    132131*/
    133 static NTSTATUS notify_lock(struct notify_context *notify)
    134 {
    135         if (tdb_lock_bystring(notify->w->tdb, NOTIFY_KEY) != 0) {
    136                 return NT_STATUS_INTERNAL_DB_CORRUPTION;
    137         }
    138         return NT_STATUS_OK;
    139 }
    140 
    141 /*
    142   unlock the notify db
    143 */
    144 static void notify_unlock(struct notify_context *notify)
    145 {
    146         tdb_unlock_bystring(notify->w->tdb, NOTIFY_KEY);
     132static struct db_record *notify_lock(struct notify_context *notify)
     133{
     134        TDB_DATA key = string_term_tdb_data(NOTIFY_KEY);
     135
     136        return dbwrap_fetch_locked(notify->db, notify, key);
     137}
     138
     139static void notify_unlock(struct db_record *lock)
     140{
     141        talloc_free(lock);
    147142}
    148143
     
    156151        enum ndr_err_code ndr_err;
    157152        int seqnum;
    158 
    159         seqnum = tdb_get_seqnum(notify->w->tdb);
     153        NTSTATUS status;
     154
     155        seqnum = dbwrap_get_seqnum(notify->db);
    160156
    161157        if (seqnum == notify->seqnum && notify->array != NULL) {
     
    169165        NT_STATUS_HAVE_NO_MEMORY(notify->array);
    170166
    171         dbuf = tdb_fetch_bystring(notify->w->tdb, NOTIFY_KEY);
    172         if (dbuf.dptr == NULL) {
     167        status = dbwrap_fetch_bystring(notify->db, notify, NOTIFY_KEY, &dbuf);
     168        if (!NT_STATUS_IS_OK(status)) {
    173169                return NT_STATUS_OK;
    174170        }
     
    179175        ndr_err = ndr_pull_struct_blob(&blob, notify->array, notify->array,
    180176                                       (ndr_pull_flags_fn_t)ndr_pull_notify_array);
    181         free(dbuf.dptr);
     177        talloc_free(dbuf.dptr);
    182178        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
    183179                return ndr_map_error2ntstatus(ndr_err);
     
    204200        DATA_BLOB blob;
    205201        enum ndr_err_code ndr_err;
    206         int ret;
    207202        TALLOC_CTX *tmp_ctx;
     203        NTSTATUS status;
    208204
    209205        /* if possible, remove some depth arrays */
     
    215211        /* we might just be able to delete the record */
    216212        if (notify->array->num_depths == 0) {
    217                 ret = tdb_delete_bystring(notify->w->tdb, NOTIFY_KEY);
    218                 if (ret != 0) {
    219                         return NT_STATUS_INTERNAL_DB_CORRUPTION;
    220                 }
    221                 return NT_STATUS_OK;
     213                return dbwrap_delete_bystring(notify->db, NOTIFY_KEY);
    222214        }
    223215
     
    234226        dbuf.dptr = blob.data;
    235227        dbuf.dsize = blob.length;
    236                
    237         ret = tdb_store_bystring(notify->w->tdb, NOTIFY_KEY, dbuf, TDB_REPLACE);
     228
     229        status = dbwrap_store_bystring(notify->db, NOTIFY_KEY, dbuf,
     230                                       TDB_REPLACE);
    238231        talloc_free(tmp_ctx);
    239         if (ret != 0) {
    240                 return NT_STATUS_INTERNAL_DB_CORRUPTION;
    241         }
    242 
    243         return NT_STATUS_OK;
     232        return status;
    244233}
    245234
     
    248237  handle incoming notify messages
    249238*/
    250 static void notify_handler(struct messaging_context *msg_ctx, void *private_data,
     239static void notify_handler(struct imessaging_context *msg_ctx, void *private_data,
    251240                           uint32_t msg_type, struct server_id server_id, DATA_BLOB *data)
    252241{
     
    355344        size_t len;
    356345        int depth;
     346        struct db_record *locked;
    357347
    358348        /* see if change notify is enabled at all */
     
    361351        }
    362352
    363         status = notify_lock(notify);
    364         NT_STATUS_NOT_OK_RETURN(status);
     353        locked = notify_lock(notify);
     354        if (!locked) {
     355                return NT_STATUS_INTERNAL_DB_CORRUPTION;
     356        }
    365357
    366358        status = notify_load(notify);
     
    416408
    417409done:
    418         notify_unlock(notify);
     410        notify_unlock(locked);
    419411        talloc_free(tmp_path);
    420412
     
    431423        int i, depth;
    432424        struct notify_depth *d;
     425        struct db_record *locked;
    433426
    434427        /* see if change notify is enabled at all */
     
    451444        talloc_free(listel);
    452445
    453         status = notify_lock(notify);
    454         NT_STATUS_NOT_OK_RETURN(status);
     446        locked = notify_lock(notify);
     447        if (!locked) {
     448                return NT_STATUS_INTERNAL_DB_CORRUPTION;
     449        }
    455450
    456451        status = notify_load(notify);
    457452        if (!NT_STATUS_IS_OK(status)) {
    458                 notify_unlock(notify);
     453                notify_unlock(locked);
    459454                return status;
    460455        }
    461456
    462457        if (depth >= notify->array->num_depths) {
    463                 notify_unlock(notify);
     458                notify_unlock(locked);
    464459                return NT_STATUS_OBJECT_NAME_NOT_FOUND;
    465460        }
     
    475470        }
    476471        if (i == d->num_entries) {
    477                 notify_unlock(notify);
     472                notify_unlock(locked);
    478473                return NT_STATUS_OBJECT_NAME_NOT_FOUND;
    479474        }
     
    487482        status = notify_save(notify);
    488483
    489         notify_unlock(notify);
     484        notify_unlock(locked);
    490485
    491486        return status;
     
    499494        NTSTATUS status;
    500495        int i, depth, del_count=0;
     496        struct db_record *locked;
    501497
    502498        if (notify->list == NULL) {
     
    504500        }
    505501
    506         status = notify_lock(notify);
    507         NT_STATUS_NOT_OK_RETURN(status);
     502        locked = notify_lock(notify);
     503        if (!locked) {
     504                return NT_STATUS_INTERNAL_DB_CORRUPTION;
     505        }
    508506
    509507        status = notify_load(notify);
    510508        if (!NT_STATUS_IS_OK(status)) {
    511                 notify_unlock(notify);
     509                notify_unlock(locked);
    512510                return status;
    513511        }
     
    534532        }
    535533
    536         notify_unlock(notify);
     534        notify_unlock(locked);
    537535
    538536        return status;
     
    553551
    554552        ev.action = action;
     553        ev.dir = discard_const_p(char, "");
    555554        ev.path = path;
    556555        ev.private_data = e->private_data;
     
    564563        }
    565564
    566         status = messaging_send(notify->messaging_ctx, e->server,
     565        status = imessaging_send(notify->imessaging_ctx, e->server,
    567566                                MSG_PVFS_NOTIFY, &data);
     567        if (!NT_STATUS_IS_OK(status)) {
     568                talloc_free(tmp_ctx);
     569                return;
     570        }
     571
    568572        talloc_free(tmp_ctx);
    569573}
  • vendor/current/source4/ntvfs/common/opendb.c

    r414 r988  
    5656/*
    5757  Open up the openfiles.tdb database. Close it down using
    58   talloc_free(). We need the messaging_ctx to allow for pending open
     58  talloc_free(). We need the imessaging_ctx to allow for pending open
    5959  notifications.
    6060*/
  • vendor/current/source4/ntvfs/common/opendb.h

    r414 r988  
    5858void odb_set_ops(const struct opendb_ops *new_ops);
    5959void odb_tdb_init_ops(void);
    60 void odb_ctdb_init_ops(void);
  • vendor/current/source4/ntvfs/common/opendb_tdb.c

    r740 r988  
    4141#include "includes.h"
    4242#include "system/filesys.h"
    43 #include <tdb.h>
     43#include "lib/dbwrap/dbwrap.h"
    4444#include "messaging/messaging.h"
    45 #include "lib/util/tdb_wrap.h"
    4645#include "lib/messaging/irpc.h"
    4746#include "librpc/gen_ndr/ndr_opendb.h"
     
    5352
    5453struct odb_context {
    55         struct tdb_wrap *w;
     54        struct db_context *db;
    5655        struct ntvfs_context *ntvfs_ctx;
    5756        bool oplocks;
     
    6564struct odb_lock {
    6665        struct odb_context *odb;
    67         TDB_DATA key;
     66        struct db_record *locked;
    6867
    6968        struct opendb_file file;
     
    7574};
    7675
    77 static NTSTATUS odb_oplock_break_send(struct messaging_context *msg_ctx,
     76static NTSTATUS odb_oplock_break_send(struct imessaging_context *msg_ctx,
    7877                                      struct opendb_entry *e,
    7978                                      uint8_t level);
     
    8180/*
    8281  Open up the openfiles.tdb database. Close it down using
    83   talloc_free(). We need the messaging_ctx to allow for pending open
     82  talloc_free(). We need the imessaging_ctx to allow for pending open
    8483  notifications.
    8584*/
     
    9493        }
    9594
    96         odb->w = cluster_tdb_tmp_open(odb, ntvfs_ctx->lp_ctx, "openfiles.tdb", TDB_DEFAULT);
    97         if (odb->w == NULL) {
     95        odb->db = cluster_db_tmp_open(odb, ntvfs_ctx->lp_ctx,
     96                                      "openfiles", TDB_DEFAULT);
     97        if (odb->db == NULL) {
    9898                talloc_free(odb);
    9999                return NULL;
     
    112112}
    113113
    114 /*
    115   destroy a lock on the database
    116 */
    117 static int odb_lock_destructor(struct odb_lock *lck)
    118 {
    119         tdb_chainunlock(lck->odb->w->tdb, lck->key);
    120         return 0;
    121 }
    122 
    123114static NTSTATUS odb_pull_record(struct odb_lock *lck, struct opendb_file *file);
    124115
     
    132123        struct odb_lock *lck;
    133124        NTSTATUS status;
     125        TDB_DATA key;
    134126
    135127        lck = talloc(mem_ctx, struct odb_lock);
     
    139131
    140132        lck->odb = talloc_reference(lck, odb);
    141         lck->key.dptr = talloc_memdup(lck, file_key->data, file_key->length);
    142         lck->key.dsize = file_key->length;
    143         if (lck->key.dptr == NULL) {
     133        key.dptr = talloc_memdup(lck, file_key->data, file_key->length);
     134        key.dsize = file_key->length;
     135        if (key.dptr == NULL) {
    144136                talloc_free(lck);
    145137                return NULL;
    146138        }
    147139
    148         if (tdb_chainlock(odb->w->tdb, lck->key) != 0) {
     140        lck->locked = dbwrap_fetch_locked(odb->db, lck, key);
     141        if (!lck->locked) {
    149142                talloc_free(lck);
    150143                return NULL;
     
    152145
    153146        ZERO_STRUCT(lck->can_open);
    154 
    155         talloc_set_destructor(lck, odb_lock_destructor);
    156147
    157148        status = odb_pull_record(lck, &lck->file);
     
    169160static DATA_BLOB odb_tdb_get_key(TALLOC_CTX *mem_ctx, struct odb_lock *lck)
    170161{
    171         return data_blob_talloc(mem_ctx, lck->key.dptr, lck->key.dsize);
     162        TDB_DATA key = dbwrap_record_get_key(lck->locked);
     163        return data_blob_talloc(mem_ctx, key.dptr, key.dsize);
    172164}
    173165
     
    234226static NTSTATUS odb_pull_record(struct odb_lock *lck, struct opendb_file *file)
    235227{
    236         struct odb_context *odb = lck->odb;
    237228        TDB_DATA dbuf;
    238229        DATA_BLOB blob;
    239230        enum ndr_err_code ndr_err;
    240231
    241         dbuf = tdb_fetch(odb->w->tdb, lck->key);
    242         if (dbuf.dptr == NULL) {
     232        dbuf = dbwrap_record_get_value(lck->locked);
     233        if (!dbuf.dptr) {
    243234                return NT_STATUS_OBJECT_NAME_NOT_FOUND;
    244235        }
     
    248239
    249240        ndr_err = ndr_pull_struct_blob(&blob, lck, file, (ndr_pull_flags_fn_t)ndr_pull_opendb_file);
    250         free(dbuf.dptr);
    251241        if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
    252242                return ndr_map_error2ntstatus(ndr_err);
     
    261251static NTSTATUS odb_push_record(struct odb_lock *lck, struct opendb_file *file)
    262252{
    263         struct odb_context *odb = lck->odb;
    264253        TDB_DATA dbuf;
    265254        DATA_BLOB blob;
    266255        enum ndr_err_code ndr_err;
    267         int ret;
     256        NTSTATUS status;
    268257
    269258        if (file->num_entries == 0) {
    270                 ret = tdb_delete(odb->w->tdb, lck->key);
    271                 if (ret != 0) {
    272                         return NT_STATUS_INTERNAL_DB_CORRUPTION;
    273                 }
    274                 return NT_STATUS_OK;
     259                return dbwrap_record_delete(lck->locked);
    275260        }
    276261
     
    283268        dbuf.dsize = blob.length;
    284269               
    285         ret = tdb_store(odb->w->tdb, lck->key, dbuf, TDB_REPLACE);
     270        status = dbwrap_record_store(lck->locked, dbuf, TDB_REPLACE);
    286271        data_blob_free(&blob);
    287         if (ret != 0) {
    288                 return NT_STATUS_INTERNAL_DB_CORRUPTION;
    289         }
    290 
    291         return NT_STATUS_OK;
     272        return status;
    292273}
    293274
     
    295276  send an oplock break to a client
    296277*/
    297 static NTSTATUS odb_oplock_break_send(struct messaging_context *msg_ctx,
     278static NTSTATUS odb_oplock_break_send(struct imessaging_context *msg_ctx,
    298279                                      struct opendb_entry *e,
    299280                                      uint8_t level)
     
    312293        blob = data_blob_const(&op_break, sizeof(op_break));
    313294
    314         status = messaging_send(msg_ctx, e->server,
     295        status = imessaging_send(msg_ctx, e->server,
    315296                                MSG_NTVFS_OPLOCK_BREAK, &blob);
    316297        NT_STATUS_NOT_OK_RETURN(status);
     
    612593        /* send any pending notifications, removing them once sent */
    613594        for (i=0;i<lck->file.num_pending;i++) {
    614                 messaging_send_ptr(odb->ntvfs_ctx->msg_ctx,
     595                imessaging_send_ptr(odb->ntvfs_ctx->msg_ctx,
    615596                                   lck->file.pending[i].server,
    616597                                   MSG_PVFS_RETRY_OPEN,
     
    667648        /* send any pending notifications, removing them once sent */
    668649        for (i=0;i<lck->file.num_pending;i++) {
    669                 messaging_send_ptr(odb->ntvfs_ctx->msg_ctx,
     650                imessaging_send_ptr(odb->ntvfs_ctx->msg_ctx,
    670651                                   lck->file.pending[i].server,
    671652                                   MSG_PVFS_RETRY_OPEN,
  • vendor/current/source4/ntvfs/common/wscript_build

    r740 r988  
    44        source='init.c brlock.c brlock_tdb.c opendb.c opendb_tdb.c notify.c',
    55        autoproto='proto.h',
     6        deps='util_tdb tdb-wrap',
    67        public_deps='NDR_OPENDB NDR_NOTIFY sys_notify sys_lease share'
    78        )
  • vendor/current/source4/ntvfs/ipc/ipc_rap.c

    r740 r988  
    256256        struct rap_NetShareEnum r;
    257257        NTSTATUS result;
     258        uint32_t offset_save = 0;
     259        struct rap_heap_save heap_save = {0};
    258260
    259261        RAP_GOTO(rap_srv_pull_word(call, &r.in.level));
     
    283285
    284286                int i = r.out.count;
    285                 uint32_t offset_save;
    286                 struct rap_heap_save heap_save;
    287287
    288288                offset_save = call->ndr_push_data->offset;
     
    336336        struct rap_NetServerEnum2 r;
    337337        NTSTATUS result;
     338        uint32_t offset_save = 0;
     339        struct rap_heap_save heap_save = {0};
    338340
    339341        RAP_GOTO(rap_srv_pull_word(call, &r.in.level));
     
    365367
    366368                int i = r.out.count;
    367                 uint32_t offset_save;
    368                 struct rap_heap_save heap_save;
    369369
    370370                offset_save = call->ndr_push_data->offset;
  • vendor/current/source4/ntvfs/ipc/rap_server.c

    r740 r988  
    7373                r->out.info[i].info1.reserved1 = 0;
    7474                r->out.info[i].info1.share_type = dcesrv_common_get_share_type(mem_ctx, NULL, scfg);
    75                 r->out.info[i].info1.comment = talloc_strdup(mem_ctx, share_string_option(scfg, SHARE_COMMENT, ""));
     75                r->out.info[i].info1.comment = share_string_option(mem_ctx, scfg, SHARE_COMMENT, "");
    7676                talloc_free(scfg);
    7777                j++;
  • vendor/current/source4/ntvfs/ipc/vfs_ipc.c

    r740 r988  
    3030#include "../librpc/gen_ndr/rap.h"
    3131#include "ntvfs/ipc/proto.h"
    32 #include "libcli/raw/ioctl.h"
     32#include "../libcli/smb/smb_constants.h"
    3333#include "param/param.h"
    3434#include "../lib/tsocket/tsocket.h"
     
    3939#include "auth/credentials/credentials.h"
    4040#include "auth/credentials/credentials_krb5.h"
    41 #include <gssapi/gssapi.h>
     41#include "system/kerberos.h"
     42#include "system/gssapi.h"
    4243#include "system/locale.h"
     44#include "system/filesys.h"
    4345
    4446/* this is the private structure used to keep the state of an open
     
    259261        case RAW_OPEN_NTTRANS_CREATE:
    260262                fname = oi->ntcreatex.in.fname;
     263                while (fname[0] == '\\') fname++;
    261264                break;
    262265        case RAW_OPEN_OPENX:
    263266                fname = oi->openx.in.fname;
     267                while (fname[0] == '\\') fname++;
     268                if (strncasecmp(fname, "PIPE\\", 5) != 0) {
     269                        return NT_STATUS_OBJECT_PATH_SYNTAX_BAD;
     270                }
     271                while (fname[0] == '\\') fname++;
    264272                break;
    265273        case RAW_OPEN_SMB2:
     
    282290        p = talloc(h, struct pipe_state);
    283291        NT_STATUS_HAVE_NO_MEMORY(p);
    284 
    285         while (fname[0] == '\\') fname++;
    286292
    287293        /* check for valid characters in name */
     
    354360        TALLOC_FREE(subreq);
    355361        if (ret == -1) {
    356                 status = map_nt_error_from_unix(sys_errno);
     362                status = map_nt_error_from_unix_common(sys_errno);
    357363                goto reply;
    358364        }
     
    603609        TALLOC_FREE(subreq);
    604610        if (ret == -1) {
    605                 status = map_nt_error_from_unix(sys_errno);
     611                status = map_nt_error_from_unix_common(sys_errno);
    606612                goto reply;
    607613        }
     
    688694        TALLOC_FREE(subreq);
    689695        if (ret == -1) {
    690                 status = map_nt_error_from_unix(sys_errno);
     696                status = map_nt_error_from_unix_common(sys_errno);
    691697                goto reply;
    692698        }
     
    732738        struct pipe_state *p;
    733739
    734         if (io->generic.level != RAW_CLOSE_CLOSE) {
     740        if (io->generic.level != RAW_CLOSE_GENERIC) {
    735741                return ntvfs_map_close(ntvfs, req, io);
    736742        }
    737743
    738         p = pipe_state_find(ipriv, io->close.in.file.ntvfs);
     744        ZERO_STRUCT(io->generic.out);
     745
     746        p = pipe_state_find(ipriv, io->generic.in.file.ntvfs);
    739747        if (!p) {
    740748                return NT_STATUS_INVALID_HANDLE;
     
    10101018                goto reply;
    10111019        } else if (ret == -1) {
    1012                 status = map_nt_error_from_unix(sys_errno);
     1020                status = map_nt_error_from_unix_common(sys_errno);
    10131021                goto reply;
    10141022        }
     
    10461054        TALLOC_FREE(subreq);
    10471055        if (ret == -1) {
    1048                 status = map_nt_error_from_unix(sys_errno);
     1056                status = map_nt_error_from_unix_common(sys_errno);
    10491057                goto reply;
    10501058        }
     
    11741182        io->smb2.out.unknown2   = 0;
    11751183        io->smb2.out.unknown3   = 0;
    1176         io->smb2.out.in         = io->smb2.in.out;
     1184        io->smb2.out.in         = data_blob_null;
    11771185        io->smb2.out.out = data_blob_talloc(req, NULL, io->smb2.in.max_response_size);
    11781186        NT_STATUS_HAVE_NO_MEMORY(io->smb2.out.out.data);
     
    12161224        TALLOC_FREE(subreq);
    12171225        if (ret == -1) {
    1218                 status = map_nt_error_from_unix(sys_errno);
     1226                status = map_nt_error_from_unix_common(sys_errno);
    12191227                goto reply;
    12201228        }
     
    12521260        TALLOC_FREE(subreq);
    12531261        if (ret == -1) {
    1254                 status = map_nt_error_from_unix(sys_errno);
     1262                status = map_nt_error_from_unix_common(sys_errno);
    12551263                goto reply;
    12561264        }
     
    13031311
    13041312        /* fill in all the operations */
    1305         ops.connect = ipc_connect;
    1306         ops.disconnect = ipc_disconnect;
    1307         ops.unlink = ipc_unlink;
    1308         ops.chkpath = ipc_chkpath;
    1309         ops.qpathinfo = ipc_qpathinfo;
    1310         ops.setpathinfo = ipc_setpathinfo;
    1311         ops.open = ipc_open;
    1312         ops.mkdir = ipc_mkdir;
    1313         ops.rmdir = ipc_rmdir;
    1314         ops.rename = ipc_rename;
    1315         ops.copy = ipc_copy;
    1316         ops.ioctl = ipc_ioctl;
    1317         ops.read = ipc_read;
    1318         ops.write = ipc_write;
    1319         ops.seek = ipc_seek;
    1320         ops.flush = ipc_flush; 
    1321         ops.close = ipc_close;
    1322         ops.exit = ipc_exit;
    1323         ops.lock = ipc_lock;
    1324         ops.setfileinfo = ipc_setfileinfo;
    1325         ops.qfileinfo = ipc_qfileinfo;
    1326         ops.fsinfo = ipc_fsinfo;
    1327         ops.lpq = ipc_lpq;
    1328         ops.search_first = ipc_search_first;
    1329         ops.search_next = ipc_search_next;
    1330         ops.search_close = ipc_search_close;
    1331         ops.trans = ipc_trans;
    1332         ops.logoff = ipc_logoff;
    1333         ops.async_setup = ipc_async_setup;
    1334         ops.cancel = ipc_cancel;
     1313        ops.connect_fn = ipc_connect;
     1314        ops.disconnect_fn = ipc_disconnect;
     1315        ops.unlink_fn = ipc_unlink;
     1316        ops.chkpath_fn = ipc_chkpath;
     1317        ops.qpathinfo_fn = ipc_qpathinfo;
     1318        ops.setpathinfo_fn = ipc_setpathinfo;
     1319        ops.open_fn = ipc_open;
     1320        ops.mkdir_fn = ipc_mkdir;
     1321        ops.rmdir_fn = ipc_rmdir;
     1322        ops.rename_fn = ipc_rename;
     1323        ops.copy_fn = ipc_copy;
     1324        ops.ioctl_fn = ipc_ioctl;
     1325        ops.read_fn = ipc_read;
     1326        ops.write_fn = ipc_write;
     1327        ops.seek_fn = ipc_seek;
     1328        ops.flush_fn = ipc_flush;
     1329        ops.close_fn = ipc_close;
     1330        ops.exit_fn = ipc_exit;
     1331        ops.lock_fn = ipc_lock;
     1332        ops.setfileinfo_fn = ipc_setfileinfo;
     1333        ops.qfileinfo_fn = ipc_qfileinfo;
     1334        ops.fsinfo_fn = ipc_fsinfo;
     1335        ops.lpq_fn = ipc_lpq;
     1336        ops.search_first_fn = ipc_search_first;
     1337        ops.search_next_fn = ipc_search_next;
     1338        ops.search_close_fn = ipc_search_close;
     1339        ops.trans_fn = ipc_trans;
     1340        ops.logoff_fn = ipc_logoff;
     1341        ops.async_setup_fn = ipc_async_setup;
     1342        ops.cancel_fn = ipc_cancel;
    13351343
    13361344        /* register ourselves with the NTVFS subsystem. */
  • vendor/current/source4/ntvfs/nbench/vfs_nbench.c

    r740 r988  
    2828#include "system/filesys.h"
    2929
     30NTSTATUS ntvfs_nbench_init(void);
     31
    3032/* this is stored in ntvfs_private */
    3133struct nbench_private {
     
    125127
    126128        logname = talloc_asprintf(req, "/tmp/nbenchlog%d.%u", ntvfs->depth,
    127                                   getpid());
     129                                  (unsigned int)getpid());
    128130        NT_STATUS_HAVE_NO_MEMORY(logname);
    129131        nprivates->log_fd = open(logname, O_WRONLY|O_CREAT|O_APPEND, 0644);
     
    164166{
    165167        union smb_unlink *unl = req->async_states->private_data;
    166 
    167168        nbench_log(req, "Unlink \"%s\" 0x%x %s\n",
    168169                   unl->unlink.in.pattern, unl->unlink.in.attrib,
    169                    get_nt_error_c_code(req->async_states->status));
     170                   get_nt_error_c_code(req, req->async_states->status));
    170171
    171172        PASS_THRU_REP_POST(req);
     
    212213        nbench_log(req, "Chkpath \"%s\" %s\n",
    213214                   cp->chkpath.in.path,
    214                    get_nt_error_c_code(req->async_states->status));
     215                   get_nt_error_c_code(req, req->async_states->status));
    215216
    216217        PASS_THRU_REP_POST(req);
     
    238239                   info->generic.in.file.path,
    239240                   info->generic.level,
    240                    get_nt_error_c_code(req->async_states->status));
     241                   get_nt_error_c_code(req, req->async_states->status));
    241242
    242243        PASS_THRU_REP_POST(req);
     
    263264                   nbench_ntvfs_handle_string(req, info->generic.in.file.ntvfs),
    264265                   info->generic.level,
    265                    get_nt_error_c_code(req->async_states->status));
     266                   get_nt_error_c_code(req, req->async_states->status));
    266267
    267268        PASS_THRU_REP_POST(req);
     
    288289                   st->generic.in.file.path,
    289290                   st->generic.level,
    290                    get_nt_error_c_code(req->async_states->status));
     291                   get_nt_error_c_code(req, req->async_states->status));
    291292
    292293        PASS_THRU_REP_POST(req);
     
    320321                           io->ntcreatex.in.open_disposition,
    321322                           nbench_ntvfs_handle_string(req, io->ntcreatex.out.file.ntvfs),
    322                            get_nt_error_c_code(req->async_states->status));
     323                           get_nt_error_c_code(req, req->async_states->status));
    323324                break;
    324325
     
    372373        nbench_log(req, "Rmdir \"%s\" %s\n",
    373374                   rd->in.path,
    374                    get_nt_error_c_code(req->async_states->status));
     375                   get_nt_error_c_code(req, req->async_states->status));
    375376
    376377        PASS_THRU_REP_POST(req);
     
    399400                           ren->rename.in.pattern1,
    400401                           ren->rename.in.pattern2,
    401                            get_nt_error_c_code(req->async_states->status));
     402                           get_nt_error_c_code(req, req->async_states->status));
    402403                break;
    403404
     
    458459                           rd->readx.in.maxcnt,
    459460                           rd->readx.out.nread,
    460                            get_nt_error_c_code(req->async_states->status));
     461                           get_nt_error_c_code(req, req->async_states->status));
    461462                break;
    462463        default:
     
    496497                           wr->writex.in.count,
    497498                           wr->writex.out.nwritten,
    498                            get_nt_error_c_code(req->async_states->status));
     499                           get_nt_error_c_code(req, req->async_states->status));
    499500                break;
    500501
     
    508509                           wr->write.in.count,
    509510                           wr->write.out.nwritten,
    510                            get_nt_error_c_code(req->async_states->status));
     511                           get_nt_error_c_code(req, req->async_states->status));
    511512                break;
    512513
     
    562563                nbench_log(req, "Flush %s %s\n",
    563564                           nbench_ntvfs_handle_string(req, io->flush.in.file.ntvfs),
    564                            get_nt_error_c_code(req->async_states->status));
     565                           get_nt_error_c_code(req, req->async_states->status));
    565566                break;
    566567        case RAW_FLUSH_ALL:
    567568                nbench_log(req, "Flush %d %s\n",
    568569                           0xFFFF,
    569                            get_nt_error_c_code(req->async_states->status));
     570                           get_nt_error_c_code(req, req->async_states->status));
    570571                break;
    571572        default:
     
    600601                nbench_log(req, "Close %s %s\n",
    601602                           nbench_ntvfs_handle_string(req, io->close.in.file.ntvfs),
    602                            get_nt_error_c_code(req->async_states->status));
     603                           get_nt_error_c_code(req, req->async_states->status));
    603604                break;
    604605
     
    717718                           (int)lck->lockx.in.locks[0].offset,
    718719                           (int)lck->lockx.in.locks[0].count,
    719                            get_nt_error_c_code(req->async_states->status));
     720                           get_nt_error_c_code(req, req->async_states->status));
    720721        } else if (lck->generic.level == RAW_LOCK_LOCKX &&
    721722                   lck->lockx.in.ulock_cnt == 1) {
     
    724725                           (int)lck->lockx.in.locks[0].offset,
    725726                           (int)lck->lockx.in.locks[0].count,
    726                            get_nt_error_c_code(req->async_states->status));
     727                           get_nt_error_c_code(req, req->async_states->status));
    727728        } else {
    728729                nbench_log(req, "Lock-%d - NOT HANDLED\n", lck->generic.level);
     
    752753                   nbench_ntvfs_handle_string(req, info->generic.in.file.ntvfs),
    753754                   info->generic.level,
    754                    get_nt_error_c_code(req->async_states->status));
     755                   get_nt_error_c_code(req, req->async_states->status));
    755756
    756757        PASS_THRU_REP_POST(req);
     
    777778        nbench_log(req, "QUERY_FS_INFORMATION %d %s\n",
    778779                   fs->generic.level,
    779                    get_nt_error_c_code(req->async_states->status));
     780                   get_nt_error_c_code(req, req->async_states->status));
    780781
    781782        PASS_THRU_REP_POST(req);
     
    831832                           io->t2ffirst.in.max_count,
    832833                           io->t2ffirst.out.count,
    833                            get_nt_error_c_code(req->async_states->status));
     834                           get_nt_error_c_code(req, req->async_states->status));
    834835                break;
    835836               
     
    930931       
    931932        /* fill in all the operations */
    932         ops.connect = nbench_connect;
    933         ops.disconnect = nbench_disconnect;
    934         ops.unlink = nbench_unlink;
    935         ops.chkpath = nbench_chkpath;
    936         ops.qpathinfo = nbench_qpathinfo;
    937         ops.setpathinfo = nbench_setpathinfo;
    938         ops.open = nbench_open;
    939         ops.mkdir = nbench_mkdir;
    940         ops.rmdir = nbench_rmdir;
    941         ops.rename = nbench_rename;
    942         ops.copy = nbench_copy;
    943         ops.ioctl = nbench_ioctl;
    944         ops.read = nbench_read;
    945         ops.write = nbench_write;
    946         ops.seek = nbench_seek;
    947         ops.flush = nbench_flush;       
    948         ops.close = nbench_close;
    949         ops.exit = nbench_exit;
    950         ops.lock = nbench_lock;
    951         ops.setfileinfo = nbench_setfileinfo;
    952         ops.qfileinfo = nbench_qfileinfo;
    953         ops.fsinfo = nbench_fsinfo;
    954         ops.lpq = nbench_lpq;
    955         ops.search_first = nbench_search_first;
    956         ops.search_next = nbench_search_next;
    957         ops.search_close = nbench_search_close;
    958         ops.trans = nbench_trans;
    959         ops.logoff = nbench_logoff;
    960         ops.async_setup = nbench_async_setup;
    961         ops.cancel = nbench_cancel;
     933        ops.connect_fn = nbench_connect;
     934        ops.disconnect_fn = nbench_disconnect;
     935        ops.unlink_fn = nbench_unlink;
     936        ops.chkpath_fn = nbench_chkpath;
     937        ops.qpathinfo_fn = nbench_qpathinfo;
     938        ops.setpathinfo_fn = nbench_setpathinfo;
     939        ops.open_fn = nbench_open;
     940        ops.mkdir_fn = nbench_mkdir;
     941        ops.rmdir_fn = nbench_rmdir;
     942        ops.rename_fn = nbench_rename;
     943        ops.copy_fn = nbench_copy;
     944        ops.ioctl_fn = nbench_ioctl;
     945        ops.read_fn = nbench_read;
     946        ops.write_fn = nbench_write;
     947        ops.seek_fn = nbench_seek;
     948        ops.flush_fn = nbench_flush;
     949        ops.close_fn = nbench_close;
     950        ops.exit_fn = nbench_exit;
     951        ops.lock_fn = nbench_lock;
     952        ops.setfileinfo_fn = nbench_setfileinfo;
     953        ops.qfileinfo_fn = nbench_qfileinfo;
     954        ops.fsinfo_fn = nbench_fsinfo;
     955        ops.lpq_fn = nbench_lpq;
     956        ops.search_first_fn = nbench_search_first;
     957        ops.search_next_fn = nbench_search_next;
     958        ops.search_close_fn = nbench_search_close;
     959        ops.trans_fn = nbench_trans;
     960        ops.logoff_fn = nbench_logoff;
     961        ops.async_setup_fn = nbench_async_setup;
     962        ops.cancel_fn = nbench_cancel;
    962963
    963964        /* we don't register a trans2 handler as we want to be able to
    964965           log individual trans2 requests */
    965         ops.trans2 = NULL;
     966        ops.trans2_fn = NULL;
    966967
    967968        /* register ourselves with the NTVFS subsystem. */
  • vendor/current/source4/ntvfs/ntvfs.h

    r740 r988  
    2525#include "param/share.h"
    2626#include "librpc/gen_ndr/security.h"
    27 #include "librpc/gen_ndr/server_id4.h"
     27#include "librpc/gen_ndr/server_id.h"
    2828
    2929/* modules can use the following to determine if the interface has changed */
     
    4848
    4949        /* initial setup */
    50         NTSTATUS (*connect)(struct ntvfs_module_context *ntvfs,
     50        NTSTATUS (*connect_fn)(struct ntvfs_module_context *ntvfs,
    5151                            struct ntvfs_request *req,
    5252                            union smb_tcon *tcon);
    53         NTSTATUS (*disconnect)(struct ntvfs_module_context *ntvfs);
     53        NTSTATUS (*disconnect_fn)(struct ntvfs_module_context *ntvfs);
    5454
    5555        /* async_setup - called when a backend is processing a async request */
    56         NTSTATUS (*async_setup)(struct ntvfs_module_context *ntvfs,
     56        NTSTATUS (*async_setup_fn)(struct ntvfs_module_context *ntvfs,
    5757                                struct ntvfs_request *req,
    5858                                void *private_data);
    5959
    6060        /* filesystem operations */
    61         NTSTATUS (*fsinfo)(struct ntvfs_module_context *ntvfs,
     61        NTSTATUS (*fsinfo_fn)(struct ntvfs_module_context *ntvfs,
    6262                           struct ntvfs_request *req,
    6363                           union smb_fsinfo *fs);
    6464
    6565        /* path operations */
    66         NTSTATUS (*unlink)(struct ntvfs_module_context *ntvfs,
     66        NTSTATUS (*unlink_fn)(struct ntvfs_module_context *ntvfs,
    6767                           struct ntvfs_request *req,
    6868                           union smb_unlink *unl);
    69         NTSTATUS (*chkpath)(struct ntvfs_module_context *ntvfs,
     69        NTSTATUS (*chkpath_fn)(struct ntvfs_module_context *ntvfs,
    7070                            struct ntvfs_request *req,
    7171                            union smb_chkpath *cp);
    72         NTSTATUS (*qpathinfo)(struct ntvfs_module_context *ntvfs,
     72        NTSTATUS (*qpathinfo_fn)(struct ntvfs_module_context *ntvfs,
    7373                              struct ntvfs_request *req,
    7474                              union smb_fileinfo *st);
    75         NTSTATUS (*setpathinfo)(struct ntvfs_module_context *ntvfs,
     75        NTSTATUS (*setpathinfo_fn)(struct ntvfs_module_context *ntvfs,
    7676                                struct ntvfs_request *req,
    7777                                union smb_setfileinfo *st);
    78         NTSTATUS (*mkdir)(struct ntvfs_module_context *ntvfs,
     78        NTSTATUS (*mkdir_fn)(struct ntvfs_module_context *ntvfs,
    7979                          struct ntvfs_request *req,
    8080                          union smb_mkdir *md);
    81         NTSTATUS (*rmdir)(struct ntvfs_module_context *ntvfs,
     81        NTSTATUS (*rmdir_fn)(struct ntvfs_module_context *ntvfs,
    8282                          struct ntvfs_request *req,
    8383                          struct smb_rmdir *rd);
    84         NTSTATUS (*rename)(struct ntvfs_module_context *ntvfs,
     84        NTSTATUS (*rename_fn)(struct ntvfs_module_context *ntvfs,
    8585                           struct ntvfs_request *req,
    8686                           union smb_rename *ren);
    87         NTSTATUS (*copy)(struct ntvfs_module_context *ntvfs,
     87        NTSTATUS (*copy_fn)(struct ntvfs_module_context *ntvfs,
    8888                         struct ntvfs_request *req,
    8989                         struct smb_copy *cp);
    90         NTSTATUS (*open)(struct ntvfs_module_context *ntvfs,
     90        NTSTATUS (*open_fn)(struct ntvfs_module_context *ntvfs,
    9191                         struct ntvfs_request *req,
    9292                         union smb_open *oi);
    9393
    9494        /* directory search */
    95         NTSTATUS (*search_first)(struct ntvfs_module_context *ntvfs,
     95        NTSTATUS (*search_first_fn)(struct ntvfs_module_context *ntvfs,
    9696                                 struct ntvfs_request *req,
    9797                                 union smb_search_first *io, void *private_data,
    98                                  bool (*callback)(void *private_data, const union smb_search_data *file));
    99         NTSTATUS (*search_next)(struct ntvfs_module_context *ntvfs,
     98                                 bool (*callback_fn)(void *private_data, const union smb_search_data *file));
     99        NTSTATUS (*search_next_fn)(struct ntvfs_module_context *ntvfs,
    100100                                struct ntvfs_request *req,
    101101                                union smb_search_next *io, void *private_data,
    102                                 bool (*callback)(void *private_data, const union smb_search_data *file));
    103         NTSTATUS (*search_close)(struct ntvfs_module_context *ntvfs,
     102                                bool (*callback_fn)(void *private_data, const union smb_search_data *file));
     103        NTSTATUS (*search_close_fn)(struct ntvfs_module_context *ntvfs,
    104104                                 struct ntvfs_request *req,
    105105                                 union smb_search_close *io);
    106106
    107107        /* operations on open files */
    108         NTSTATUS (*ioctl)(struct ntvfs_module_context *ntvfs,
     108        NTSTATUS (*ioctl_fn)(struct ntvfs_module_context *ntvfs,
    109109                          struct ntvfs_request *req,
    110110                          union smb_ioctl *io);
    111         NTSTATUS (*read)(struct ntvfs_module_context *ntvfs,
     111        NTSTATUS (*read_fn)(struct ntvfs_module_context *ntvfs,
    112112                         struct ntvfs_request *req,
    113113                         union smb_read *io);
    114         NTSTATUS (*write)(struct ntvfs_module_context *ntvfs,
     114        NTSTATUS (*write_fn)(struct ntvfs_module_context *ntvfs,
    115115                          struct ntvfs_request *req,
    116116                          union smb_write *io);
    117         NTSTATUS (*seek)(struct ntvfs_module_context *ntvfs,
     117        NTSTATUS (*seek_fn)(struct ntvfs_module_context *ntvfs,
    118118                         struct ntvfs_request *req,
    119119                         union smb_seek *io);
    120         NTSTATUS (*flush)(struct ntvfs_module_context *ntvfs,
     120        NTSTATUS (*flush_fn)(struct ntvfs_module_context *ntvfs,
    121121                          struct ntvfs_request *req,
    122122                          union smb_flush *flush);
    123         NTSTATUS (*lock)(struct ntvfs_module_context *ntvfs,
     123        NTSTATUS (*lock_fn)(struct ntvfs_module_context *ntvfs,
    124124                         struct ntvfs_request *req,
    125125                         union smb_lock *lck);
    126         NTSTATUS (*qfileinfo)(struct ntvfs_module_context *ntvfs,
     126        NTSTATUS (*qfileinfo_fn)(struct ntvfs_module_context *ntvfs,
    127127                              struct ntvfs_request *req,
    128128                              union smb_fileinfo *info);
    129         NTSTATUS (*setfileinfo)(struct ntvfs_module_context *ntvfs,
     129        NTSTATUS (*setfileinfo_fn)(struct ntvfs_module_context *ntvfs,
    130130                                struct ntvfs_request *req,
    131131                                union smb_setfileinfo *info);
    132         NTSTATUS (*close)(struct ntvfs_module_context *ntvfs,
     132        NTSTATUS (*close_fn)(struct ntvfs_module_context *ntvfs,
    133133                          struct ntvfs_request *req,
    134134                          union smb_close *io);
    135135
    136136        /* trans interface - used by IPC backend for pipes and RAP calls */
    137         NTSTATUS (*trans)(struct ntvfs_module_context *ntvfs,
     137        NTSTATUS (*trans_fn)(struct ntvfs_module_context *ntvfs,
    138138                          struct ntvfs_request *req,
    139139                          struct smb_trans2 *trans);
    140140
    141141        /* trans2 interface - only used by CIFS backend to prover complete passthru for testing */
    142         NTSTATUS (*trans2)(struct ntvfs_module_context *ntvfs,
     142        NTSTATUS (*trans2_fn)(struct ntvfs_module_context *ntvfs,
    143143                           struct ntvfs_request *req,
    144144                           struct smb_trans2 *trans2);
    145145
    146146        /* change notify request */
    147         NTSTATUS (*notify)(struct ntvfs_module_context *ntvfs,
     147        NTSTATUS (*notify_fn)(struct ntvfs_module_context *ntvfs,
    148148                           struct ntvfs_request *req,
    149149                           union smb_notify *info);
    150150
    151151        /* cancel - cancels any pending async request */
    152         NTSTATUS (*cancel)(struct ntvfs_module_context *ntvfs,
     152        NTSTATUS (*cancel_fn)(struct ntvfs_module_context *ntvfs,
    153153                           struct ntvfs_request *req);
    154154
    155155        /* printing specific operations */
    156         NTSTATUS (*lpq)(struct ntvfs_module_context *ntvfs,
     156        NTSTATUS (*lpq_fn)(struct ntvfs_module_context *ntvfs,
    157157                        struct ntvfs_request *req,
    158158                        union smb_lpq *lpq);
    159159
    160160        /* logoff - called when a vuid is closed */
    161         NTSTATUS (*logoff)(struct ntvfs_module_context *ntvfs,
     161        NTSTATUS (*logoff_fn)(struct ntvfs_module_context *ntvfs,
    162162                           struct ntvfs_request *req);
    163         NTSTATUS (*exit)(struct ntvfs_module_context *ntvfs,
     163        NTSTATUS (*exit_fn)(struct ntvfs_module_context *ntvfs,
    164164                         struct ntvfs_request *req);
    165165};
     
    202202        struct loadparm_context *lp_ctx;
    203203        struct tevent_context *event_ctx;
    204         struct messaging_context *msg_ctx;
     204        struct imessaging_context *msg_ctx;
    205205
    206206        struct {
     
    331331    }
    332332
    333 struct messaging_context;
     333struct imessaging_context;
    334334#include "librpc/gen_ndr/security.h"
    335 #include "librpc/gen_ndr/s4_notify.h"
     335#include "librpc/gen_ndr/notify.h"
    336336#include "ntvfs/ntvfs_proto.h"
    337337
  • vendor/current/source4/ntvfs/ntvfs_base.c

    r740 r988  
    2727#include "ntvfs/ntvfs.h"
    2828#include "param/param.h"
     29#include "lib/util/samba_modules.h"
    2930
    3031/* the list of currently registered NTVFS backends, note that there
     
    154155                               enum protocol_types protocol,
    155156                               uint64_t ntvfs_client_caps,
    156                                struct tevent_context *ev, struct messaging_context *msg,
     157                               struct tevent_context *ev, struct imessaging_context *msg,
    157158                               struct loadparm_context *lp_ctx,
    158159                               struct server_id server_id, struct ntvfs_context **_ctx)
     
    190191                }
    191192                ntvfs->depth = i;
    192                 DLIST_ADD_END(ctx->modules, ntvfs, struct ntvfs_module_context *);
     193                DLIST_ADD_END(ctx->modules, ntvfs);
    193194        }
    194195
     
    236237        initialized = true;
    237238       
    238         shared_init = load_samba_modules(NULL, lp_ctx, "ntvfs");
     239        shared_init = load_samba_modules(NULL, "ntvfs");
    239240
    240241        run_init_functions(static_init);
  • vendor/current/source4/ntvfs/ntvfs_generic.c

    r740 r988  
    256256                sf->standard.in.write_time  = write_time;
    257257                sf->standard.in.access_time = 0;
    258                 status = ntvfs->ops->setfileinfo(ntvfs, req, sf);
     258                status = ntvfs->ops->setfileinfo_fn(ntvfs, req, sf);
    259259        }
    260260
     
    265265                sf->generic.in.file.ntvfs    = io2->generic.out.file.ntvfs;
    266266                sf->end_of_file_info.in.size = set_size;
    267                 status = ntvfs->ops->setfileinfo(ntvfs, req, sf);
     267                status = ntvfs->ops->setfileinfo_fn(ntvfs, req, sf);
    268268                if (NT_STATUS_IS_OK(status)) {
    269269                        io->openx.out.size = io->openx.in.size;
     
    417417                io2->generic.in.fname = io->openx.in.fname;
    418418               
    419                 status = ntvfs->ops->open(ntvfs, req, io2);
     419                status = ntvfs->ops->open_fn(ntvfs, req, io2);
    420420                break;
    421421               
     
    434434                io2->generic.in.fname = io->openold.in.fname;
    435435
    436                 status = ntvfs->ops->open(ntvfs, req, io2);
     436                status = ntvfs->ops->open_fn(ntvfs, req, io2);
    437437                break;
    438438
     
    460460                io2->generic.in.ea_list->eas     = io->t2open.in.eas;
    461461
    462                 status = ntvfs->ops->open(ntvfs, req, io2);
     462                status = ntvfs->ops->open_fn(ntvfs, req, io2);
    463463                break;
    464464
     
    473473                        NTCREATEX_SHARE_ACCESS_READ |
    474474                        NTCREATEX_SHARE_ACCESS_WRITE;
    475                 status = ntvfs->ops->open(ntvfs, req, io2);
     475                status = ntvfs->ops->open_fn(ntvfs, req, io2);
    476476                break;
    477477
     
    486486                        NTCREATEX_SHARE_ACCESS_READ |
    487487                        NTCREATEX_SHARE_ACCESS_WRITE;
    488                 status = ntvfs->ops->open(ntvfs, req, io2);
     488                status = ntvfs->ops->open_fn(ntvfs, req, io2);
    489489                break;
    490490
     
    502502                        NTCREATEX_SHARE_ACCESS_READ |
    503503                        NTCREATEX_SHARE_ACCESS_WRITE;
    504                 status = ntvfs->ops->open(ntvfs, req, io2);
     504                status = ntvfs->ops->open_fn(ntvfs, req, io2);
    505505                break;
    506506        case RAW_OPEN_SMB2:
     
    550550                io2->generic.in.create_options &= ~NTCREATEX_OPTIONS_ASYNC_ALERT;
    551551
    552                 status = ntvfs->ops->open(ntvfs, req, io2);             
     552                status = ntvfs->ops->open_fn(ntvfs, req, io2);
    553553                break;
    554554
     
    577577        /* and convert it to the required level */
    578578        switch (fs->generic.level) {
    579         case RAW_QFS_GENERIC:
    580                 return NT_STATUS_INVALID_LEVEL;
    581 
    582579        case RAW_QFS_DSKATTR: {
    583580                /* map from generic to DSKATTR */
     
    667664                ZERO_STRUCT(fs->objectid_information.out.unknown);
    668665                return NT_STATUS_OK;
    669         }
    670 
     666
     667        case RAW_QFS_SECTOR_SIZE_INFORMATION:
     668                fs->sector_size_info.out.logical_bytes_per_sector
     669                                                = fs2->generic.out.block_size;
     670                fs->sector_size_info.out.phys_bytes_per_sector_atomic
     671                                                = fs2->generic.out.block_size;
     672                fs->sector_size_info.out.phys_bytes_per_sector_perf
     673                                                = fs2->generic.out.block_size;
     674                fs->sector_size_info.out.fs_effective_phys_bytes_per_sector_atomic
     675                                                = fs2->generic.out.block_size;
     676                fs->sector_size_info.out.flags
     677                                        = QFS_SSINFO_FLAGS_ALIGNED_DEVICE
     678                                | QFS_SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE;
     679                fs->sector_size_info.out.byte_off_sector_align = 0;
     680                fs->sector_size_info.out.byte_off_partition_align = 0;
     681                return NT_STATUS_OK;
     682
     683        case RAW_QFS_GENERIC:
     684        case RAW_QFS_UNIX_INFO:
     685                return NT_STATUS_INVALID_LEVEL;
     686        }
    671687
    672688        return NT_STATUS_INVALID_LEVEL;
     
    701717        fs2->generic.level = RAW_QFS_GENERIC;
    702718
    703         status = ntvfs->ops->fsinfo(ntvfs, req, fs2);
     719        status = ntvfs->ops->fsinfo_fn(ntvfs, req, fs2);
    704720        return ntvfs_map_async_finish(req, status);
    705721}
     
    716732        /* and convert it to the required level using results in info2 */
    717733        switch (info->generic.level) {
    718                 case RAW_FILEINFO_GENERIC:
    719                 return NT_STATUS_INVALID_LEVEL;
    720734        case RAW_FILEINFO_GETATTR:
    721735                info->getattr.out.attrib = info2->generic.out.attrib & 0xff;
     
    911925                        info2->generic.out.alignment_requirement;
    912926                return NT_STATUS_OK;
    913 #if 0   
    914927        case RAW_FILEINFO_UNIX_BASIC:
     928#if 1
     929                return NT_STATUS_INVALID_LEVEL;
     930#else
    915931                info->unix_basic_info.out.end_of_file = info2->generic.out.end_of_file;
    916932                info->unix_basic_info.out.num_bytes = info2->generic.out.size;
     
    927943                info->unix_basic_info.out.nlink = info2->generic.out.nlink;
    928944                return NT_STATUS_OK;
    929                
     945#endif
    930946        case RAW_FILEINFO_UNIX_LINK:
     947#if 1
     948                return NT_STATUS_INVALID_LEVEL;
     949#else
    931950                info->unix_link_info.out.link_dest = info2->generic.out.link_dest;
    932951                return NT_STATUS_OK;
    933952#endif
     953        case RAW_FILEINFO_GENERIC:
     954        case RAW_FILEINFO_SEC_DESC:
     955        case RAW_FILEINFO_EA_LIST:
     956        case RAW_FILEINFO_UNIX_INFO2:
     957        case RAW_FILEINFO_SMB2_ALL_EAS:
     958        case RAW_FILEINFO_SMB2_ALL_INFORMATION:
     959                return NT_STATUS_INVALID_LEVEL;
    934960        }
    935961
     
    9821008        info2->generic.in.file.ntvfs= info->generic.in.file.ntvfs;
    9831009
    984         status = ntvfs->ops->qfileinfo(ntvfs, req, info2);
     1010        status = ntvfs->ops->qfileinfo_fn(ntvfs, req, info2);
    9851011        return ntvfs_map_async_finish(req, status);
    9861012}
     
    10311057        info2->generic.in.file.path     = info->generic.in.file.path;
    10321058
    1033         status = ntvfs->ops->qpathinfo(ntvfs, req, info2);
     1059        status = ntvfs->ops->qpathinfo_fn(ntvfs, req, info2);
    10341060        return ntvfs_map_async_finish(req, status);
    10351061}
     
    11751201         */
    11761202
    1177         return ntvfs->ops->lock(ntvfs, req, lck2);
     1203        return ntvfs->ops->lock_fn(ntvfs, req, lck2);
    11781204}
    11791205
     
    12181244                        state = req->async_states->state;
    12191245                        req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC;
    1220                         status = ntvfs->ops->lock(ntvfs, req, lck);
     1246                        status = ntvfs->ops->lock_fn(ntvfs, req, lck);
    12211247                        req->async_states->state = state;
    12221248                }
     
    12391265                        state = req->async_states->state;
    12401266                        req->async_states->state &= ~NTVFS_ASYNC_STATE_MAY_ASYNC;
    1241                         status = ntvfs->ops->close(ntvfs, req, cl);
     1267                        status = ntvfs->ops->close_fn(ntvfs, req, cl);
    12421268                        req->async_states->state = state;
    12431269                }
     
    12961322                wr2->writex.in.count     = wr->write.in.count;
    12971323                wr2->writex.in.data      = wr->write.in.data;
    1298                 status = ntvfs->ops->write(ntvfs, req, wr2);
     1324                status = ntvfs->ops->write_fn(ntvfs, req, wr2);
    12991325                break;
    13001326
     
    13061332                wr2->writex.in.count     = wr->writeunlock.in.count;
    13071333                wr2->writex.in.data      = wr->writeunlock.in.data;
    1308                 status = ntvfs->ops->write(ntvfs, req, wr2);
     1334                status = ntvfs->ops->write_fn(ntvfs, req, wr2);
    13091335                break;
    13101336
     
    13161342                wr2->writex.in.count     = wr->writeclose.in.count;
    13171343                wr2->writex.in.data      = wr->writeclose.in.data;
    1318                 status = ntvfs->ops->write(ntvfs, req, wr2);
     1344                status = ntvfs->ops->write_fn(ntvfs, req, wr2);
    13191345                break;
    13201346
     
    13261352                wr2->writex.in.count     = wr->splwrite.in.count;
    13271353                wr2->writex.in.data      = wr->splwrite.in.data;
    1328                 status = ntvfs->ops->write(ntvfs, req, wr2);
     1354                status = ntvfs->ops->write_fn(ntvfs, req, wr2);
    13291355                break;
    13301356
     
    13361362                wr2->writex.in.count     = wr->smb2.in.data.length;
    13371363                wr2->writex.in.data      = wr->smb2.in.data.data;
    1338                 status = ntvfs->ops->write(ntvfs, req, wr2);
     1364                status = ntvfs->ops->write_fn(ntvfs, req, wr2);
    13391365        }
    13401366
     
    14121438                rd2->readx.in.remaining = rd->read.in.remaining;
    14131439                rd2->readx.out.data     = rd->read.out.data;
    1414                 status = ntvfs->ops->read(ntvfs, req, rd2);
     1440                status = ntvfs->ops->read_fn(ntvfs, req, rd2);
    14151441                break;
    14161442
     
    14221448                rd2->readx.in.remaining = 0;
    14231449                rd2->readx.out.data     = rd->readbraw.out.data;
    1424                 status = ntvfs->ops->read(ntvfs, req, rd2);
     1450                status = ntvfs->ops->read_fn(ntvfs, req, rd2);
    14251451                break;
    14261452
     
    14391465                lck->lock.in.count      = rd->lockread.in.count;
    14401466                lck->lock.in.offset     = rd->lockread.in.offset;
    1441                 status = ntvfs->ops->lock(ntvfs, req, lck);
     1467                status = ntvfs->ops->lock_fn(ntvfs, req, lck);
    14421468                req->async_states->state = state;
    14431469
     
    14501476
    14511477                if (NT_STATUS_IS_OK(status)) {
    1452                         status = ntvfs->ops->read(ntvfs, req, rd2);
     1478                        status = ntvfs->ops->read_fn(ntvfs, req, rd2);
    14531479                }
    14541480                break;
     
    14611487                rd2->readx.in.remaining = 0;
    14621488                rd2->readx.out.data     = rd->smb2.out.data.data;
    1463                 status = ntvfs->ops->read(ntvfs, req, rd2);
     1489                status = ntvfs->ops->read_fn(ntvfs, req, rd2);
    14641490                break;
    14651491        }
     
    15451571        NT_STATUS_NOT_OK_RETURN(status);
    15461572
    1547         status = ntvfs->ops->close(ntvfs, req, cl2);
     1573        status = ntvfs->ops->close_fn(ntvfs, req, cl2);
    15481574
    15491575        return ntvfs_map_async_finish(req, status);
     
    16071633                nt2->nttrans.in.completion_filter       = nt->smb2.in.completion_filter;
    16081634                nt2->nttrans.in.recursive               = nt->smb2.in.recursive;
    1609                 status = ntvfs->ops->notify(ntvfs, req, nt2);
     1635                status = ntvfs->ops->notify_fn(ntvfs, req, nt2);
    16101636                break;
    16111637        }
  • vendor/current/source4/ntvfs/ntvfs_interface.c

    r740 r988  
    2727{
    2828        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    29         if (!ntvfs->ops->connect) {
    30                 return NT_STATUS_NOT_IMPLEMENTED;
    31         }
    32         return ntvfs->ops->connect(ntvfs, req, tcon);
     29        if (!ntvfs->ops->connect_fn) {
     30                return NT_STATUS_NOT_IMPLEMENTED;
     31        }
     32        return ntvfs->ops->connect_fn(ntvfs, req, tcon);
    3333}
    3434
     
    4040        }
    4141        ntvfs = ntvfs_ctx->modules;
    42         if (!ntvfs->ops->disconnect) {
    43                 return NT_STATUS_NOT_IMPLEMENTED;
    44         }
    45         return ntvfs->ops->disconnect(ntvfs);
     42        if (!ntvfs->ops->disconnect_fn) {
     43                return NT_STATUS_NOT_IMPLEMENTED;
     44        }
     45        return ntvfs->ops->disconnect_fn(ntvfs);
    4646}
    4747
     
    5151{
    5252        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    53         if (!ntvfs->ops->async_setup) {
    54                 return NT_STATUS_NOT_IMPLEMENTED;
    55         }
    56         return ntvfs->ops->async_setup(ntvfs, req, private_data);
     53        if (!ntvfs->ops->async_setup_fn) {
     54                return NT_STATUS_NOT_IMPLEMENTED;
     55        }
     56        return ntvfs->ops->async_setup_fn(ntvfs, req, private_data);
    5757}
    5858
     
    6161{
    6262        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    63         if (!ntvfs->ops->fsinfo) {
    64                 return NT_STATUS_NOT_IMPLEMENTED;
    65         }
    66         return ntvfs->ops->fsinfo(ntvfs, req, fs);
     63        if (!ntvfs->ops->fsinfo_fn) {
     64                return NT_STATUS_NOT_IMPLEMENTED;
     65        }
     66        return ntvfs->ops->fsinfo_fn(ntvfs, req, fs);
    6767}
    6868
     
    7171{
    7272        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    73         if (!ntvfs->ops->unlink) {
    74                 return NT_STATUS_NOT_IMPLEMENTED;
    75         }
    76         return ntvfs->ops->unlink(ntvfs, req, unl);
     73        if (!ntvfs->ops->unlink_fn) {
     74                return NT_STATUS_NOT_IMPLEMENTED;
     75        }
     76        return ntvfs->ops->unlink_fn(ntvfs, req, unl);
    7777}
    7878
     
    8080{
    8181        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    82         if (!ntvfs->ops->chkpath) {
    83                 return NT_STATUS_NOT_IMPLEMENTED;
    84         }
    85         return ntvfs->ops->chkpath(ntvfs, req, cp);
     82        if (!ntvfs->ops->chkpath_fn) {
     83                return NT_STATUS_NOT_IMPLEMENTED;
     84        }
     85        return ntvfs->ops->chkpath_fn(ntvfs, req, cp);
    8686}
    8787
     
    8989{
    9090        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    91         if (!ntvfs->ops->qpathinfo) {
    92                 return NT_STATUS_NOT_IMPLEMENTED;
    93         }
    94         return ntvfs->ops->qpathinfo(ntvfs, req, st);
     91        if (!ntvfs->ops->qpathinfo_fn) {
     92                return NT_STATUS_NOT_IMPLEMENTED;
     93        }
     94        return ntvfs->ops->qpathinfo_fn(ntvfs, req, st);
    9595}
    9696
     
    9898{
    9999        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    100         if (!ntvfs->ops->setpathinfo) {
    101                 return NT_STATUS_NOT_IMPLEMENTED;
    102         }
    103         return ntvfs->ops->setpathinfo(ntvfs, req, st);
     100        if (!ntvfs->ops->setpathinfo_fn) {
     101                return NT_STATUS_NOT_IMPLEMENTED;
     102        }
     103        return ntvfs->ops->setpathinfo_fn(ntvfs, req, st);
    104104}
    105105
     
    107107{
    108108        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    109         if (!ntvfs->ops->open) {
    110                 return NT_STATUS_NOT_IMPLEMENTED;
    111         }
    112         return ntvfs->ops->open(ntvfs, req, oi);
     109        if (!ntvfs->ops->open_fn) {
     110                return NT_STATUS_NOT_IMPLEMENTED;
     111        }
     112        return ntvfs->ops->open_fn(ntvfs, req, oi);
    113113}
    114114
     
    116116{
    117117        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    118         if (!ntvfs->ops->mkdir) {
    119                 return NT_STATUS_NOT_IMPLEMENTED;
    120         }
    121         return ntvfs->ops->mkdir(ntvfs, req, md);
     118        if (!ntvfs->ops->mkdir_fn) {
     119                return NT_STATUS_NOT_IMPLEMENTED;
     120        }
     121        return ntvfs->ops->mkdir_fn(ntvfs, req, md);
    122122}
    123123
     
    125125{
    126126        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    127         if (!ntvfs->ops->rmdir) {
    128                 return NT_STATUS_NOT_IMPLEMENTED;
    129         }
    130         return ntvfs->ops->rmdir(ntvfs, req, rd);
     127        if (!ntvfs->ops->rmdir_fn) {
     128                return NT_STATUS_NOT_IMPLEMENTED;
     129        }
     130        return ntvfs->ops->rmdir_fn(ntvfs, req, rd);
    131131}
    132132
     
    134134{
    135135        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    136         if (!ntvfs->ops->rename) {
    137                 return NT_STATUS_NOT_IMPLEMENTED;
    138         }
    139         return ntvfs->ops->rename(ntvfs, req, ren);
     136        if (!ntvfs->ops->rename_fn) {
     137                return NT_STATUS_NOT_IMPLEMENTED;
     138        }
     139        return ntvfs->ops->rename_fn(ntvfs, req, ren);
    140140}
    141141
     
    143143{
    144144        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    145         if (!ntvfs->ops->copy) {
    146                 return NT_STATUS_NOT_IMPLEMENTED;
    147         }
    148         return ntvfs->ops->copy(ntvfs, req, cp);
     145        if (!ntvfs->ops->copy_fn) {
     146                return NT_STATUS_NOT_IMPLEMENTED;
     147        }
     148        return ntvfs->ops->copy_fn(ntvfs, req, cp);
    149149}
    150150
     
    154154{
    155155        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    156         if (!ntvfs->ops->search_first) {
    157                 return NT_STATUS_NOT_IMPLEMENTED;
    158         }
    159         return ntvfs->ops->search_first(ntvfs, req, io, private_data, ntvfs_callback);
     156        if (!ntvfs->ops->search_first_fn) {
     157                return NT_STATUS_NOT_IMPLEMENTED;
     158        }
     159        return ntvfs->ops->search_first_fn(ntvfs, req, io, private_data, ntvfs_callback);
    160160}
    161161
     
    164164{
    165165        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    166         if (!ntvfs->ops->search_next) {
    167                 return NT_STATUS_NOT_IMPLEMENTED;
    168         }
    169         return ntvfs->ops->search_next(ntvfs, req, io, private_data, ntvfs_callback);
     166        if (!ntvfs->ops->search_next_fn) {
     167                return NT_STATUS_NOT_IMPLEMENTED;
     168        }
     169        return ntvfs->ops->search_next_fn(ntvfs, req, io, private_data, ntvfs_callback);
    170170}
    171171
     
    173173{
    174174        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    175         if (!ntvfs->ops->search_close) {
    176                 return NT_STATUS_NOT_IMPLEMENTED;
    177         }
    178         return ntvfs->ops->search_close(ntvfs, req, io);
     175        if (!ntvfs->ops->search_close_fn) {
     176                return NT_STATUS_NOT_IMPLEMENTED;
     177        }
     178        return ntvfs->ops->search_close_fn(ntvfs, req, io);
    179179}
    180180
     
    183183{
    184184        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    185         if (!ntvfs->ops->ioctl) {
    186                 return NT_STATUS_NOT_IMPLEMENTED;
    187         }
    188         return ntvfs->ops->ioctl(ntvfs, req, io);
     185        if (!ntvfs->ops->ioctl_fn) {
     186                return NT_STATUS_NOT_IMPLEMENTED;
     187        }
     188        return ntvfs->ops->ioctl_fn(ntvfs, req, io);
    189189}
    190190
     
    192192{
    193193        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    194         if (!ntvfs->ops->read) {
    195                 return NT_STATUS_NOT_IMPLEMENTED;
    196         }
    197         return ntvfs->ops->read(ntvfs, req, io);
     194        if (!ntvfs->ops->read_fn) {
     195                return NT_STATUS_NOT_IMPLEMENTED;
     196        }
     197        return ntvfs->ops->read_fn(ntvfs, req, io);
    198198}
    199199
     
    201201{
    202202        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    203         if (!ntvfs->ops->write) {
    204                 return NT_STATUS_NOT_IMPLEMENTED;
    205         }
    206         return ntvfs->ops->write(ntvfs, req, io);
     203        if (!ntvfs->ops->write_fn) {
     204                return NT_STATUS_NOT_IMPLEMENTED;
     205        }
     206        return ntvfs->ops->write_fn(ntvfs, req, io);
    207207}
    208208
     
    210210{
    211211        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    212         if (!ntvfs->ops->seek) {
    213                 return NT_STATUS_NOT_IMPLEMENTED;
    214         }
    215         return ntvfs->ops->seek(ntvfs, req, io);
     212        if (!ntvfs->ops->seek_fn) {
     213                return NT_STATUS_NOT_IMPLEMENTED;
     214        }
     215        return ntvfs->ops->seek_fn(ntvfs, req, io);
    216216}
    217217
     
    220220{
    221221        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    222         if (!ntvfs->ops->flush) {
    223                 return NT_STATUS_NOT_IMPLEMENTED;
    224         }
    225         return ntvfs->ops->flush(ntvfs, req, flush);
     222        if (!ntvfs->ops->flush_fn) {
     223                return NT_STATUS_NOT_IMPLEMENTED;
     224        }
     225        return ntvfs->ops->flush_fn(ntvfs, req, flush);
    226226}
    227227
     
    229229{
    230230        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    231         if (!ntvfs->ops->lock) {
    232                 return NT_STATUS_NOT_IMPLEMENTED;
    233         }
    234         return ntvfs->ops->lock(ntvfs, req, lck);
     231        if (!ntvfs->ops->lock_fn) {
     232                return NT_STATUS_NOT_IMPLEMENTED;
     233        }
     234        return ntvfs->ops->lock_fn(ntvfs, req, lck);
    235235}
    236236
     
    238238{
    239239        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    240         if (!ntvfs->ops->qfileinfo) {
    241                 return NT_STATUS_NOT_IMPLEMENTED;
    242         }
    243         return ntvfs->ops->qfileinfo(ntvfs, req, info);
     240        if (!ntvfs->ops->qfileinfo_fn) {
     241                return NT_STATUS_NOT_IMPLEMENTED;
     242        }
     243        return ntvfs->ops->qfileinfo_fn(ntvfs, req, info);
    244244}
    245245
     
    247247{
    248248        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    249         if (!ntvfs->ops->setfileinfo) {
    250                 return NT_STATUS_NOT_IMPLEMENTED;
    251         }
    252         return ntvfs->ops->setfileinfo(ntvfs, req, info);
     249        if (!ntvfs->ops->setfileinfo_fn) {
     250                return NT_STATUS_NOT_IMPLEMENTED;
     251        }
     252        return ntvfs->ops->setfileinfo_fn(ntvfs, req, info);
    253253}
    254254
     
    256256{
    257257        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    258         if (!ntvfs->ops->close) {
    259                 return NT_STATUS_NOT_IMPLEMENTED;
    260         }
    261         return ntvfs->ops->close(ntvfs, req, io);
     258        if (!ntvfs->ops->close_fn) {
     259                return NT_STATUS_NOT_IMPLEMENTED;
     260        }
     261        return ntvfs->ops->close_fn(ntvfs, req, io);
    262262}
    263263
     
    266266{
    267267        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    268         if (!ntvfs->ops->trans) {
    269                 return NT_STATUS_NOT_IMPLEMENTED;
    270         }
    271         return ntvfs->ops->trans(ntvfs, req, trans);
     268        if (!ntvfs->ops->trans_fn) {
     269                return NT_STATUS_NOT_IMPLEMENTED;
     270        }
     271        return ntvfs->ops->trans_fn(ntvfs, req, trans);
    272272}
    273273
     
    276276{
    277277        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    278         if (!ntvfs->ops->trans2) {
    279                 return NT_STATUS_NOT_IMPLEMENTED;
    280         }
    281         return ntvfs->ops->trans2(ntvfs, req, trans2);
     278        if (!ntvfs->ops->trans2_fn) {
     279                return NT_STATUS_NOT_IMPLEMENTED;
     280        }
     281        return ntvfs->ops->trans2_fn(ntvfs, req, trans2);
    282282}
    283283
     
    286286{
    287287        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    288         if (!ntvfs->ops->lpq) {
    289                 return NT_STATUS_NOT_IMPLEMENTED;
    290         }
    291         return ntvfs->ops->lpq(ntvfs, req, lpq);
     288        if (!ntvfs->ops->lpq_fn) {
     289                return NT_STATUS_NOT_IMPLEMENTED;
     290        }
     291        return ntvfs->ops->lpq_fn(ntvfs, req, lpq);
    292292}
    293293
     
    296296{
    297297        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    298         if (!ntvfs->ops->logoff) {
    299                 return NT_STATUS_NOT_IMPLEMENTED;
    300         }
    301         return ntvfs->ops->logoff(ntvfs, req);
     298        if (!ntvfs->ops->logoff_fn) {
     299                return NT_STATUS_NOT_IMPLEMENTED;
     300        }
     301        return ntvfs->ops->logoff_fn(ntvfs, req);
    302302}
    303303
     
    305305{
    306306        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    307         if (!ntvfs->ops->exit) {
    308                 return NT_STATUS_NOT_IMPLEMENTED;
    309         }
    310         return ntvfs->ops->exit(ntvfs, req);
     307        if (!ntvfs->ops->exit_fn) {
     308                return NT_STATUS_NOT_IMPLEMENTED;
     309        }
     310        return ntvfs->ops->exit_fn(ntvfs, req);
    311311}
    312312
     
    317317{
    318318        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    319         if (!ntvfs->ops->notify) {
    320                 return NT_STATUS_NOT_IMPLEMENTED;
    321         }
    322         return ntvfs->ops->notify(ntvfs, req, info);
     319        if (!ntvfs->ops->notify_fn) {
     320                return NT_STATUS_NOT_IMPLEMENTED;
     321        }
     322        return ntvfs->ops->notify_fn(ntvfs, req, info);
    323323}
    324324
     
    329329{
    330330        struct ntvfs_module_context *ntvfs = req->ctx->modules;
    331         if (!ntvfs->ops->cancel) {
    332                 return NT_STATUS_NOT_IMPLEMENTED;
    333         }
    334         return ntvfs->ops->cancel(ntvfs, req);
     331        if (!ntvfs->ops->cancel_fn) {
     332                return NT_STATUS_NOT_IMPLEMENTED;
     333        }
     334        return ntvfs->ops->cancel_fn(ntvfs, req);
    335335}
    336336
     
    340340                                     union smb_tcon *tcon)
    341341{
    342         if (!ntvfs->next || !ntvfs->next->ops->connect) {
    343                 return NT_STATUS_NOT_IMPLEMENTED;
    344         }
    345         return ntvfs->next->ops->connect(ntvfs->next, req, tcon);
     342        if (!ntvfs->next || !ntvfs->next->ops->connect_fn) {
     343                return NT_STATUS_NOT_IMPLEMENTED;
     344        }
     345        return ntvfs->next->ops->connect_fn(ntvfs->next, req, tcon);
    346346}
    347347
    348348NTSTATUS ntvfs_next_disconnect(struct ntvfs_module_context *ntvfs)
    349349{
    350         if (!ntvfs->next || !ntvfs->next->ops->disconnect) {
    351                 return NT_STATUS_NOT_IMPLEMENTED;
    352         }
    353         return ntvfs->next->ops->disconnect(ntvfs->next);
     350        if (!ntvfs->next || !ntvfs->next->ops->disconnect_fn) {
     351                return NT_STATUS_NOT_IMPLEMENTED;
     352        }
     353        return ntvfs->next->ops->disconnect_fn(ntvfs->next);
    354354}
    355355
     
    359359                                         void *private_data)
    360360{
    361         if (!ntvfs->next || !ntvfs->next->ops->async_setup) {
    362                 return NT_STATUS_NOT_IMPLEMENTED;
    363         }
    364         return ntvfs->next->ops->async_setup(ntvfs->next, req, private_data);
     361        if (!ntvfs->next || !ntvfs->next->ops->async_setup_fn) {
     362                return NT_STATUS_NOT_IMPLEMENTED;
     363        }
     364        return ntvfs->next->ops->async_setup_fn(ntvfs->next, req, private_data);
    365365}
    366366
     
    370370                                    union smb_fsinfo *fs)
    371371{
    372         if (!ntvfs->next || !ntvfs->next->ops->fsinfo) {
    373                 return NT_STATUS_NOT_IMPLEMENTED;
    374         }
    375         return ntvfs->next->ops->fsinfo(ntvfs->next, req, fs);
     372        if (!ntvfs->next || !ntvfs->next->ops->fsinfo_fn) {
     373                return NT_STATUS_NOT_IMPLEMENTED;
     374        }
     375        return ntvfs->next->ops->fsinfo_fn(ntvfs->next, req, fs);
    376376}
    377377
     
    381381                                    union smb_unlink *unl)
    382382{
    383         if (!ntvfs->next || !ntvfs->next->ops->unlink) {
    384                 return NT_STATUS_NOT_IMPLEMENTED;
    385         }
    386         return ntvfs->next->ops->unlink(ntvfs->next, req, unl);
     383        if (!ntvfs->next || !ntvfs->next->ops->unlink_fn) {
     384                return NT_STATUS_NOT_IMPLEMENTED;
     385        }
     386        return ntvfs->next->ops->unlink_fn(ntvfs->next, req, unl);
    387387}
    388388
     
    391391                                     union smb_chkpath *cp)
    392392{
    393         if (!ntvfs->next || !ntvfs->next->ops->chkpath) {
    394                 return NT_STATUS_NOT_IMPLEMENTED;
    395         }
    396         return ntvfs->next->ops->chkpath(ntvfs->next, req, cp);
     393        if (!ntvfs->next || !ntvfs->next->ops->chkpath_fn) {
     394                return NT_STATUS_NOT_IMPLEMENTED;
     395        }
     396        return ntvfs->next->ops->chkpath_fn(ntvfs->next, req, cp);
    397397}
    398398
     
    401401                                       union smb_fileinfo *st)
    402402{
    403         if (!ntvfs->next || !ntvfs->next->ops->qpathinfo) {
    404                 return NT_STATUS_NOT_IMPLEMENTED;
    405         }
    406         return ntvfs->next->ops->qpathinfo(ntvfs->next, req, st);
     403        if (!ntvfs->next || !ntvfs->next->ops->qpathinfo_fn) {
     404                return NT_STATUS_NOT_IMPLEMENTED;
     405        }
     406        return ntvfs->next->ops->qpathinfo_fn(ntvfs->next, req, st);
    407407}
    408408
     
    411411                                         union smb_setfileinfo *st)
    412412{
    413         if (!ntvfs->next || !ntvfs->next->ops->setpathinfo) {
    414                 return NT_STATUS_NOT_IMPLEMENTED;
    415         }
    416         return ntvfs->next->ops->setpathinfo(ntvfs->next, req, st);
     413        if (!ntvfs->next || !ntvfs->next->ops->setpathinfo_fn) {
     414                return NT_STATUS_NOT_IMPLEMENTED;
     415        }
     416        return ntvfs->next->ops->setpathinfo_fn(ntvfs->next, req, st);
    417417}
    418418
     
    421421                                   union smb_mkdir *md)
    422422{
    423         if (!ntvfs->next || !ntvfs->next->ops->mkdir) {
    424                 return NT_STATUS_NOT_IMPLEMENTED;
    425         }
    426         return ntvfs->next->ops->mkdir(ntvfs->next, req, md);
     423        if (!ntvfs->next || !ntvfs->next->ops->mkdir_fn) {
     424                return NT_STATUS_NOT_IMPLEMENTED;
     425        }
     426        return ntvfs->next->ops->mkdir_fn(ntvfs->next, req, md);
    427427}
    428428
     
    431431                                   struct smb_rmdir *rd)
    432432{
    433         if (!ntvfs->next || !ntvfs->next->ops->rmdir) {
    434                 return NT_STATUS_NOT_IMPLEMENTED;
    435         }
    436         return ntvfs->next->ops->rmdir(ntvfs->next, req, rd);
     433        if (!ntvfs->next || !ntvfs->next->ops->rmdir_fn) {
     434                return NT_STATUS_NOT_IMPLEMENTED;
     435        }
     436        return ntvfs->next->ops->rmdir_fn(ntvfs->next, req, rd);
    437437}
    438438
     
    441441                                    union smb_rename *ren)
    442442{
    443         if (!ntvfs->next || !ntvfs->next->ops->rename) {
    444                 return NT_STATUS_NOT_IMPLEMENTED;
    445         }
    446         return ntvfs->next->ops->rename(ntvfs->next, req, ren);
     443        if (!ntvfs->next || !ntvfs->next->ops->rename_fn) {
     444                return NT_STATUS_NOT_IMPLEMENTED;
     445        }
     446        return ntvfs->next->ops->rename_fn(ntvfs->next, req, ren);
    447447}
    448448
     
    451451                                  struct smb_copy *cp)
    452452{
    453         if (!ntvfs->next || !ntvfs->next->ops->copy) {
    454                 return NT_STATUS_NOT_IMPLEMENTED;
    455         }
    456         return ntvfs->next->ops->copy(ntvfs->next, req, cp);
     453        if (!ntvfs->next || !ntvfs->next->ops->copy_fn) {
     454                return NT_STATUS_NOT_IMPLEMENTED;
     455        }
     456        return ntvfs->next->ops->copy_fn(ntvfs->next, req, cp);
    457457}
    458458
     
    461461                                  union smb_open *oi)
    462462{
    463         if (!ntvfs->next || !ntvfs->next->ops->open) {
    464                 return NT_STATUS_NOT_IMPLEMENTED;
    465         }
    466         return ntvfs->next->ops->open(ntvfs->next, req, oi);
     463        if (!ntvfs->next || !ntvfs->next->ops->open_fn) {
     464                return NT_STATUS_NOT_IMPLEMENTED;
     465        }
     466        return ntvfs->next->ops->open_fn(ntvfs->next, req, oi);
    467467}
    468468
     
    474474                                          bool (*callback)(void *private_data, const union smb_search_data *file))
    475475{
    476         if (!ntvfs->next || !ntvfs->next->ops->search_first) {
    477                 return NT_STATUS_NOT_IMPLEMENTED;
    478         }
    479         return ntvfs->next->ops->search_first(ntvfs->next, req, io, private_data, callback);
     476        if (!ntvfs->next || !ntvfs->next->ops->search_first_fn) {
     477                return NT_STATUS_NOT_IMPLEMENTED;
     478        }
     479        return ntvfs->next->ops->search_first_fn(ntvfs->next, req, io, private_data, callback);
    480480}
    481481
     
    485485                                         bool (*callback)(void *private_data, const union smb_search_data *file))
    486486{
    487         if (!ntvfs->next || !ntvfs->next->ops->search_next) {
    488                 return NT_STATUS_NOT_IMPLEMENTED;
    489         }
    490         return ntvfs->next->ops->search_next(ntvfs->next, req, io, private_data, callback);
     487        if (!ntvfs->next || !ntvfs->next->ops->search_next_fn) {
     488                return NT_STATUS_NOT_IMPLEMENTED;
     489        }
     490        return ntvfs->next->ops->search_next_fn(ntvfs->next, req, io, private_data, callback);
    491491}
    492492
     
    495495                                          union smb_search_close *io)
    496496{
    497         if (!ntvfs->next || !ntvfs->next->ops->search_close) {
    498                 return NT_STATUS_NOT_IMPLEMENTED;
    499         }
    500         return ntvfs->next->ops->search_close(ntvfs->next, req, io);
     497        if (!ntvfs->next || !ntvfs->next->ops->search_close_fn) {
     498                return NT_STATUS_NOT_IMPLEMENTED;
     499        }
     500        return ntvfs->next->ops->search_close_fn(ntvfs->next, req, io);
    501501}
    502502
     
    506506                                   union smb_ioctl *io)
    507507{
    508         if (!ntvfs->next || !ntvfs->next->ops->ioctl) {
    509                 return NT_STATUS_NOT_IMPLEMENTED;
    510         }
    511         return ntvfs->next->ops->ioctl(ntvfs->next, req, io);
     508        if (!ntvfs->next || !ntvfs->next->ops->ioctl_fn) {
     509                return NT_STATUS_NOT_IMPLEMENTED;
     510        }
     511        return ntvfs->next->ops->ioctl_fn(ntvfs->next, req, io);
    512512}
    513513
     
    516516                                  union smb_read *io)
    517517{
    518         if (!ntvfs->next || !ntvfs->next->ops->read) {
    519                 return NT_STATUS_NOT_IMPLEMENTED;
    520         }
    521         return ntvfs->next->ops->read(ntvfs->next, req, io);
     518        if (!ntvfs->next || !ntvfs->next->ops->read_fn) {
     519                return NT_STATUS_NOT_IMPLEMENTED;
     520        }
     521        return ntvfs->next->ops->read_fn(ntvfs->next, req, io);
    522522}
    523523
     
    526526                                   union smb_write *io)
    527527{
    528         if (!ntvfs->next || !ntvfs->next->ops->write) {
    529                 return NT_STATUS_NOT_IMPLEMENTED;
    530         }
    531         return ntvfs->next->ops->write(ntvfs->next, req, io);
     528        if (!ntvfs->next || !ntvfs->next->ops->write_fn) {
     529                return NT_STATUS_NOT_IMPLEMENTED;
     530        }
     531        return ntvfs->next->ops->write_fn(ntvfs->next, req, io);
    532532}
    533533
     
    536536                                  union smb_seek *io)
    537537{
    538         if (!ntvfs->next || !ntvfs->next->ops->seek) {
    539                 return NT_STATUS_NOT_IMPLEMENTED;
    540         }
    541         return ntvfs->next->ops->seek(ntvfs->next, req, io);
     538        if (!ntvfs->next || !ntvfs->next->ops->seek_fn) {
     539                return NT_STATUS_NOT_IMPLEMENTED;
     540        }
     541        return ntvfs->next->ops->seek_fn(ntvfs->next, req, io);
    542542}
    543543
     
    546546                                   union smb_flush *flush)
    547547{
    548         if (!ntvfs->next || !ntvfs->next->ops->flush) {
    549                 return NT_STATUS_NOT_IMPLEMENTED;
    550         }
    551         return ntvfs->next->ops->flush(ntvfs->next, req, flush);
     548        if (!ntvfs->next || !ntvfs->next->ops->flush_fn) {
     549                return NT_STATUS_NOT_IMPLEMENTED;
     550        }
     551        return ntvfs->next->ops->flush_fn(ntvfs->next, req, flush);
    552552}
    553553
     
    556556                                  union smb_lock *lck)
    557557{
    558         if (!ntvfs->next || !ntvfs->next->ops->lock) {
    559                 return NT_STATUS_NOT_IMPLEMENTED;
    560         }
    561         return ntvfs->next->ops->lock(ntvfs->next, req, lck);
     558        if (!ntvfs->next || !ntvfs->next->ops->lock_fn) {
     559                return NT_STATUS_NOT_IMPLEMENTED;
     560        }
     561        return ntvfs->next->ops->lock_fn(ntvfs->next, req, lck);
    562562}
    563563
     
    566566                                       union smb_fileinfo *info)
    567567{
    568         if (!ntvfs->next || !ntvfs->next->ops->qfileinfo) {
    569                 return NT_STATUS_NOT_IMPLEMENTED;
    570         }
    571         return ntvfs->next->ops->qfileinfo(ntvfs->next, req, info);
     568        if (!ntvfs->next || !ntvfs->next->ops->qfileinfo_fn) {
     569                return NT_STATUS_NOT_IMPLEMENTED;
     570        }
     571        return ntvfs->next->ops->qfileinfo_fn(ntvfs->next, req, info);
    572572}
    573573
     
    576576                                         union smb_setfileinfo *info)
    577577{
    578         if (!ntvfs->next || !ntvfs->next->ops->setfileinfo) {
    579                 return NT_STATUS_NOT_IMPLEMENTED;
    580         }
    581         return ntvfs->next->ops->setfileinfo(ntvfs->next, req, info);
     578        if (!ntvfs->next || !ntvfs->next->ops->setfileinfo_fn) {
     579                return NT_STATUS_NOT_IMPLEMENTED;
     580        }
     581        return ntvfs->next->ops->setfileinfo_fn(ntvfs->next, req, info);
    582582}
    583583
     
    586586                                   union smb_close *io)
    587587{
    588         if (!ntvfs->next || !ntvfs->next->ops->close) {
    589                 return NT_STATUS_NOT_IMPLEMENTED;
    590         }
    591         return ntvfs->next->ops->close(ntvfs->next, req, io);
     588        if (!ntvfs->next || !ntvfs->next->ops->close_fn) {
     589                return NT_STATUS_NOT_IMPLEMENTED;
     590        }
     591        return ntvfs->next->ops->close_fn(ntvfs->next, req, io);
    592592}
    593593
     
    597597                                   struct smb_trans2 *trans)
    598598{
    599         if (!ntvfs->next || !ntvfs->next->ops->trans) {
    600                 return NT_STATUS_NOT_IMPLEMENTED;
    601         }
    602         return ntvfs->next->ops->trans(ntvfs->next, req, trans);
     599        if (!ntvfs->next || !ntvfs->next->ops->trans_fn) {
     600                return NT_STATUS_NOT_IMPLEMENTED;
     601        }
     602        return ntvfs->next->ops->trans_fn(ntvfs->next, req, trans);
    603603}
    604604
     
    608608                                    struct smb_trans2 *trans2)
    609609{
    610         if (!ntvfs->next || !ntvfs->next->ops->trans2) {
    611                 return NT_STATUS_NOT_IMPLEMENTED;
    612         }
    613         return ntvfs->next->ops->trans2(ntvfs->next, req, trans2);
     610        if (!ntvfs->next || !ntvfs->next->ops->trans2_fn) {
     611                return NT_STATUS_NOT_IMPLEMENTED;
     612        }
     613        return ntvfs->next->ops->trans2_fn(ntvfs->next, req, trans2);
    614614}
    615615
     
    621621                                    union smb_notify *info)
    622622{
    623         if (!ntvfs->next || !ntvfs->next->ops->notify) {
    624                 return NT_STATUS_NOT_IMPLEMENTED;
    625         }
    626         return ntvfs->next->ops->notify(ntvfs->next, req, info);
     623        if (!ntvfs->next || !ntvfs->next->ops->notify_fn) {
     624                return NT_STATUS_NOT_IMPLEMENTED;
     625        }
     626        return ntvfs->next->ops->notify_fn(ntvfs->next, req, info);
    627627}
    628628
     
    631631                                    struct ntvfs_request *req)
    632632{
    633         if (!ntvfs->next || !ntvfs->next->ops->cancel) {
    634                 return NT_STATUS_NOT_IMPLEMENTED;
    635         }
    636         return ntvfs->next->ops->cancel(ntvfs->next, req);
     633        if (!ntvfs->next || !ntvfs->next->ops->cancel_fn) {
     634                return NT_STATUS_NOT_IMPLEMENTED;
     635        }
     636        return ntvfs->next->ops->cancel_fn(ntvfs->next, req);
    637637}
    638638
     
    642642                                 union smb_lpq *lpq)
    643643{
    644         if (!ntvfs->next || !ntvfs->next->ops->lpq) {
    645                 return NT_STATUS_NOT_IMPLEMENTED;
    646         }
    647         return ntvfs->next->ops->lpq(ntvfs->next, req, lpq);
     644        if (!ntvfs->next || !ntvfs->next->ops->lpq_fn) {
     645                return NT_STATUS_NOT_IMPLEMENTED;
     646        }
     647        return ntvfs->next->ops->lpq_fn(ntvfs->next, req, lpq);
    648648}
    649649
     
    653653                                    struct ntvfs_request *req)
    654654{
    655         if (!ntvfs->next || !ntvfs->next->ops->logoff) {
    656                 return NT_STATUS_NOT_IMPLEMENTED;
    657         }
    658         return ntvfs->next->ops->logoff(ntvfs->next, req);
     655        if (!ntvfs->next || !ntvfs->next->ops->logoff_fn) {
     656                return NT_STATUS_NOT_IMPLEMENTED;
     657        }
     658        return ntvfs->next->ops->logoff_fn(ntvfs->next, req);
    659659}
    660660
     
    662662                                  struct ntvfs_request *req)
    663663{
    664         if (!ntvfs->next || !ntvfs->next->ops->exit) {
    665                 return NT_STATUS_NOT_IMPLEMENTED;
    666         }
    667         return ntvfs->next->ops->exit(ntvfs->next, req);
     664        if (!ntvfs->next || !ntvfs->next->ops->exit_fn) {
     665                return NT_STATUS_NOT_IMPLEMENTED;
     666        }
     667        return ntvfs->next->ops->exit_fn(ntvfs->next, req);
    668668}
    669669
  • vendor/current/source4/ntvfs/posix/pvfs_acl.c

    r740 r988  
    2121
    2222#include "includes.h"
     23#include "system/passwd.h"
    2324#include "auth/auth.h"
    2425#include "vfs_posix.h"
     
    2728#include "param/param.h"
    2829#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
     30#include "lib/util/samba_modules.h"
    3831
    3932/* the list of currently registered ACL backends */
     
    9083}
    9184
    92 NTSTATUS pvfs_acl_init(struct loadparm_context *lp_ctx)
     85NTSTATUS pvfs_acl_init(void)
    9386{
    9487        static bool initialized = false;
     
    10194        initialized = true;
    10295
    103         shared_init = load_samba_modules(NULL, lp_ctx, "pvfs_acl");
     96        shared_init = load_samba_modules(NULL, "pvfs_acl");
    10497
    10598        run_init_functions(static_init);
     
    159152        mode_t mode;
    160153        struct id_map *ids;
    161         struct composite_context *ctx;
    162154
    163155        *psd = security_descriptor_initialise(req);
     
    178170        ids[1].sid = NULL;
    179171
    180         ctx = wbc_xids_to_sids_send(pvfs->wbc_ctx, ids, 2, ids);
    181         NT_STATUS_HAVE_NO_MEMORY(ctx);
    182 
    183         status = wbc_xids_to_sids_recv(ctx, &ids);
     172        status = wbc_xids_to_sids(pvfs->ntvfs->ctx->event_ctx, ids, 2);
    184173        NT_STATUS_NOT_OK_RETURN(status);
    185174
     
    276265                sd->sacl = NULL;
    277266        }
     267}
     268
     269static bool pvfs_privileged_access(uid_t uid)
     270{
     271        uid_t euid;
     272
     273        if (uid_wrapper_enabled()) {
     274                setenv("UID_WRAPPER_MYUID", "1", 1);
     275        }
     276
     277        euid = geteuid();
     278
     279        if (uid_wrapper_enabled()) {
     280                unsetenv("UID_WRAPPER_MYUID");
     281        }
     282
     283        return (uid == euid);
    278284}
    279285
     
    295301        gid_t new_gid = -1;
    296302        struct id_map *ids;
    297         struct composite_context *ctx;
    298303
    299304        if (pvfs->acl_ops != NULL) {
     
    326331                if (!dom_sid_equal(sd->owner_sid, new_sd->owner_sid)) {
    327332                        ids->sid = new_sd->owner_sid;
    328                         ctx = wbc_sids_to_xids_send(pvfs->wbc_ctx, ids, 1, ids);
    329                         NT_STATUS_HAVE_NO_MEMORY(ctx);
    330                         status = wbc_sids_to_xids_recv(ctx, &ids);
     333                        status = wbc_sids_to_xids(pvfs->ntvfs->ctx->event_ctx,
     334                                                  ids, 1);
    331335                        NT_STATUS_NOT_OK_RETURN(status);
    332336
     
    338342                sd->owner_sid = new_sd->owner_sid;
    339343        }
     344
    340345        if (secinfo_flags & SECINFO_GROUP) {
    341346                if (!(access_mask & SEC_STD_WRITE_OWNER)) {
     
    344349                if (!dom_sid_equal(sd->group_sid, new_sd->group_sid)) {
    345350                        ids->sid = new_sd->group_sid;
    346                         ctx = wbc_sids_to_xids_send(pvfs->wbc_ctx, ids, 1, ids);
    347                         NT_STATUS_HAVE_NO_MEMORY(ctx);
    348                         status = wbc_sids_to_xids_recv(ctx, &ids);
     351                        status = wbc_sids_to_xids(pvfs->ntvfs->ctx->event_ctx,
     352                                                  ids, 1);
    349353                        NT_STATUS_NOT_OK_RETURN(status);
    350354
     
    357361                sd->group_sid = new_sd->group_sid;
    358362        }
     363
    359364        if (secinfo_flags & SECINFO_DACL) {
    360365                if (!(access_mask & SEC_STD_WRITE_DAC)) {
     
    363368                sd->dacl = new_sd->dacl;
    364369                pvfs_translate_generic_bits(sd->dacl);
    365         }
     370                sd->type |= SEC_DESC_DACL_PRESENT;
     371        }
     372
    366373        if (secinfo_flags & SECINFO_SACL) {
    367374                if (!(access_mask & SEC_FLAG_SYSTEM_SECURITY)) {
     
    370377                sd->sacl = new_sd->sacl;
    371378                pvfs_translate_generic_bits(sd->sacl);
     379                sd->type |= SEC_DESC_SACL_PRESENT;
     380        }
     381
     382        if (secinfo_flags & SECINFO_PROTECTED_DACL) {
     383                if (new_sd->type & SEC_DESC_DACL_PROTECTED) {
     384                        sd->type |= SEC_DESC_DACL_PROTECTED;
     385                } else {
     386                        sd->type &= ~SEC_DESC_DACL_PROTECTED;
     387                }
     388        }
     389
     390        if (secinfo_flags & SECINFO_PROTECTED_SACL) {
     391                if (new_sd->type & SEC_DESC_SACL_PROTECTED) {
     392                        sd->type |= SEC_DESC_SACL_PROTECTED;
     393                } else {
     394                        sd->type &= ~SEC_DESC_SACL_PROTECTED;
     395                }
    372396        }
    373397
     
    389413                }
    390414                if (errno == EPERM) {
    391                         if (uwrap_enabled()) {
     415                        if (pvfs_privileged_access(name->st.st_uid)) {
    392416                                ret = 0;
    393417                        } else {
     
    484508        }
    485509        ngroups = getgroups(0, NULL);
    486         if (ngroups == 0) {
     510        if (ngroups <= 0) {
    487511                return false;
    488512        }
     
    515539                                       uint32_t *access_mask)
    516540{
    517         uid_t uid = geteuid();
    518         uint32_t max_bits = SEC_RIGHTS_FILE_READ | SEC_FILE_ALL;
     541        uint32_t max_bits = 0;
    519542        struct security_token *token = req->session_info->security_token;
    520543
     
    523546        }
    524547
    525         if (name == NULL || uid == name->st.st_uid) {
    526                 max_bits |= SEC_STD_ALL;
    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) ||
    533             ((name->st.st_mode & S_IWGRP) &&
    534              pvfs_group_member(pvfs, name->st.st_gid))) {
    535                 max_bits |= SEC_STD_ALL;
    536         }
    537 
    538         if (uwrap_enabled()) {
    539                 /* when running with the uid wrapper, files will be created
    540                    owned by the ruid, but we may have a different simulated
    541                    euid. We need to force the permission bits as though the
    542                    files owner matches the euid */
    543                 max_bits |= SEC_STD_ALL;
     548        if (name == NULL) {
     549                max_bits |= SEC_RIGHTS_FILE_ALL | SEC_STD_ALL;
     550        } else if (pvfs_privileged_access(name->st.st_uid)) {
     551                /* use the IxUSR bits */
     552                if ((name->st.st_mode & S_IWUSR)) {
     553                        max_bits |= SEC_RIGHTS_FILE_ALL | SEC_STD_ALL;
     554                } else if ((name->st.st_mode & (S_IRUSR | S_IXUSR))) {
     555                        max_bits |= SEC_RIGHTS_FILE_READ | SEC_RIGHTS_FILE_EXECUTE | SEC_STD_ALL;
     556                }
     557        } else if (pvfs_group_member(pvfs, name->st.st_gid)) {
     558                /* use the IxGRP bits */
     559                if ((name->st.st_mode & S_IWGRP)) {
     560                        max_bits |= SEC_RIGHTS_FILE_ALL | SEC_STD_ALL;
     561                } else if ((name->st.st_mode & (S_IRGRP | S_IXGRP))) {
     562                        max_bits |= SEC_RIGHTS_FILE_READ | SEC_RIGHTS_FILE_EXECUTE | SEC_STD_ALL;
     563                }
     564        } else {
     565                /* use the IxOTH bits */
     566                if ((name->st.st_mode & S_IWOTH)) {
     567                        max_bits |= SEC_RIGHTS_FILE_ALL | SEC_STD_ALL;
     568                } else if ((name->st.st_mode & (S_IROTH | S_IXOTH))) {
     569                        max_bits |= SEC_RIGHTS_FILE_READ | SEC_RIGHTS_FILE_EXECUTE | SEC_STD_ALL;
     570                }
    544571        }
    545572
     
    564591
    565592        if (*access_mask & ~max_bits) {
    566                 DEBUG(0,(__location__ " denied access to '%s' - wanted 0x%08x but got 0x%08x (missing 0x%08x)\n",
     593                DEBUG(5,(__location__ " denied access to '%s' - wanted 0x%08x but got 0x%08x (missing 0x%08x)\n",
    567594                         name?name->full_name:"(new file)", *access_mask, max_bits, *access_mask & ~max_bits));
    568595                return NT_STATUS_ACCESS_DENIED;
    569596        }
    570597
    571         if (pvfs->ntvfs->ctx->protocol != PROTOCOL_SMB2) {
     598        if (pvfs->ntvfs->ctx->protocol < PROTOCOL_SMB2_02) {
    572599                /* on SMB, this bit is always granted, even if not
    573600                   asked for */
     
    596623
    597624        /* on SMB2 a blank access mask is always denied */
    598         if (pvfs->ntvfs->ctx->protocol == PROTOCOL_SMB2 &&
     625        if (pvfs->ntvfs->ctx->protocol >= PROTOCOL_SMB2_02 &&
    599626            *access_mask == 0) {
    600627                return NT_STATUS_ACCESS_DENIED;
     
    622649        /* expand the generic access bits to file specific bits */
    623650        *access_mask = pvfs_translate_mask(*access_mask);
    624         if (pvfs->ntvfs->ctx->protocol != PROTOCOL_SMB2) {
     651        if (pvfs->ntvfs->ctx->protocol < PROTOCOL_SMB2_02) {
    625652                *access_mask &= ~SEC_FILE_READ_ATTRIBUTE;
    626653        }
     
    647674        status = se_access_check(sd, token, *access_mask, access_mask);
    648675        talloc_free(acl);
     676
     677        /* if we used a NT acl, then allow access override if the
     678           share allows for posix permission override
     679        */
     680        if (NT_STATUS_IS_OK(status)) {
     681                name->allow_override = (pvfs->flags & PVFS_FLAG_PERM_OVERRIDE) != 0;
     682        }
     683
    649684done:
    650         if (pvfs->ntvfs->ctx->protocol != PROTOCOL_SMB2) {
     685        if (pvfs->ntvfs->ctx->protocol < PROTOCOL_SMB2_02) {
    651686                /* on SMB, this bit is always granted, even if not
    652687                   asked for */
     
    746781        }
    747782
    748         if (pvfs->ntvfs->ctx->protocol != PROTOCOL_SMB2) {
     783        if (pvfs->ntvfs->ctx->protocol < PROTOCOL_SMB2_02) {
    749784                /* on SMB, this bit is always granted, even if not
    750785                   asked for */
     
    775810        }
    776811
    777         return pvfs_access_check_simple(pvfs, req, parent, access_mask);
     812        status = pvfs_access_check_simple(pvfs, req, parent, access_mask);
     813        if (NT_STATUS_IS_OK(status) && parent->allow_override) {
     814                name->allow_override = true;
     815        }
     816        return status;
    778817}
    779818
     
    899938        struct security_descriptor *parent_sd, *sd;
    900939        struct id_map *ids;
    901         struct composite_context *ctx;
    902940        TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
    903941
     
    905943
    906944        acl = talloc(req, struct xattr_NTACL);
    907         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(acl, tmp_ctx);
     945        if (acl == NULL) {
     946                TALLOC_FREE(tmp_ctx);
     947                return NT_STATUS_NO_MEMORY;
     948        }
    908949
    909950        status = pvfs_acl_load(pvfs, parent, -1, acl);
     
    912953                return NT_STATUS_OK;
    913954        }
    914         NT_STATUS_NOT_OK_RETURN_AND_FREE(status, tmp_ctx);
     955        if (!NT_STATUS_IS_OK(status)) {
     956                TALLOC_FREE(tmp_ctx);
     957                return status;
     958        }
    915959
    916960        switch (acl->version) {
     
    933977        /* create the new sd */
    934978        sd = security_descriptor_initialise(req);
    935         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(sd, tmp_ctx);
     979        if (sd == NULL) {
     980                TALLOC_FREE(tmp_ctx);
     981                return NT_STATUS_NO_MEMORY;
     982        }
    936983
    937984        ids = talloc_array(sd, struct id_map, 2);
    938         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(ids, tmp_ctx);
     985        if (ids == NULL) {
     986                TALLOC_FREE(tmp_ctx);
     987                return NT_STATUS_NO_MEMORY;
     988        }
    939989
    940990        ids[0].xid.id = geteuid();
     
    948998        ids[1].status = ID_UNKNOWN;
    949999
    950         ctx = wbc_xids_to_sids_send(pvfs->wbc_ctx, ids, 2, ids);
    951         NT_STATUS_HAVE_NO_MEMORY_AND_FREE(ctx, tmp_ctx);
    952 
    953         status = wbc_xids_to_sids_recv(ctx, &ids);
    954         NT_STATUS_NOT_OK_RETURN_AND_FREE(status, tmp_ctx);
     1000        status = wbc_xids_to_sids(pvfs->ntvfs->ctx->event_ctx, ids, 2);
     1001        if (!NT_STATUS_IS_OK(status)) {
     1002                TALLOC_FREE(tmp_ctx);
     1003                return status;
     1004        }
    9551005
    9561006        sd->owner_sid = talloc_steal(sd, ids[0].sid);
     
    9611011        /* fill in the aces from the parent */
    9621012        status = pvfs_acl_inherit_aces(pvfs, parent_sd, sd, container);
    963         NT_STATUS_NOT_OK_RETURN_AND_FREE(status, tmp_ctx);
     1013        if (!NT_STATUS_IS_OK(status)) {
     1014                TALLOC_FREE(tmp_ctx);
     1015                return status;
     1016        }
    9641017
    9651018        /* if there is nothing to inherit then we fallback to the
  • vendor/current/source4/ntvfs/posix/pvfs_acl_nfs4.c

    r740 r988  
    2727#include "libcli/security/security.h"
    2828
     29NTSTATUS pvfs_acl_nfs4_init(void);
     30
    2931#define ACE4_IDENTIFIER_GROUP 0x40
    3032
     
    4143        int i, num_ids;
    4244        struct id_map *ids;
    43         struct composite_context *ctx;
    4445
    4546        acl = talloc_zero(mem_ctx, struct nfs4acl);
     
    9091        /* Allocate memory for the sids from the security descriptor to be on
    9192         * the safe side. */
    92         ctx = wbc_xids_to_sids_send(pvfs->wbc_ctx, sd, num_ids, ids);
    93         NT_STATUS_HAVE_NO_MEMORY(ctx);
    94         status = wbc_xids_to_sids_recv(ctx, &ids);
     93        status = wbc_xids_to_sids(pvfs->ntvfs->ctx->event_ctx, ids, num_ids);
    9594        NT_STATUS_NOT_OK_RETURN(status);
    9695
     
    123122        TALLOC_CTX *tmp_ctx;
    124123        struct id_map *ids;
    125         struct composite_context *ctx;
    126124
    127125        tmp_ctx = talloc_new(pvfs);
     
    158156        }
    159157
    160         ctx = wbc_sids_to_xids_send(pvfs->wbc_ctx,ids, acl.a_count, ids);
    161         if (ctx == NULL) {
    162                 talloc_free(tmp_ctx);
    163                 return NT_STATUS_NO_MEMORY;
    164         }
    165         status = wbc_sids_to_xids_recv(ctx, &ids);
     158        status = wbc_sids_to_xids(pvfs->ntvfs->ctx->event_ctx, ids,
     159                                  acl.a_count);
    166160        if (!NT_STATUS_IS_OK(status)) {
    167161                talloc_free(tmp_ctx);
  • vendor/current/source4/ntvfs/posix/pvfs_acl_xattr.c

    r740 r988  
    2424#include "../lib/util/unix_privs.h"
    2525#include "librpc/gen_ndr/ndr_xattr.h"
     26
     27NTSTATUS pvfs_acl_xattr_init(void);
    2628
    2729/*
  • vendor/current/source4/ntvfs/posix/pvfs_dirlist.c

    r414 r988  
    200200                (*ofs) = DIR_OFFSET_DOTDOT;
    201201                dir->offset = *ofs;
    202                 if (ms_fnmatch(dir->pattern, ".", protocol) == 0) {
     202                if (ms_fnmatch_protocol(dir->pattern, ".", protocol) == 0) {
    203203                        dcache_add(dir, ".");
    204204                        return ".";
     
    209209                (*ofs) = DIR_OFFSET_BASE;
    210210                dir->offset = *ofs;
    211                 if (ms_fnmatch(dir->pattern, "..", protocol) == 0) {
     211                if (ms_fnmatch_protocol(dir->pattern, "..", protocol) == 0) {
    212212                        dcache_add(dir, "..");
    213213                        return "..";
     
    229229                }
    230230
    231                 if (ms_fnmatch(dir->pattern, dname, protocol) != 0) {
     231                if (ms_fnmatch_protocol(dir->pattern, dname, protocol) != 0) {
    232232                        char *short_name = pvfs_short_name_component(dir->pvfs, dname);
    233233                        if (short_name == NULL ||
    234                             ms_fnmatch(dir->pattern, short_name, protocol) != 0) {
     234                            ms_fnmatch_protocol(dir->pattern, short_name, protocol) != 0) {
    235235                                talloc_free(short_name);
    236236                                continue;
  • vendor/current/source4/ntvfs/posix/pvfs_fileinfo.c

    r740 r988  
    8282        name->dos.alloc_size = pvfs_round_alloc_size(pvfs, name->st.st_size);
    8383        name->dos.nlink = name->st.st_nlink;
    84         name->dos.ea_size = 4;
    85         if (pvfs->ntvfs->ctx->protocol == PROTOCOL_SMB2) {
     84        name->dos.ea_size = 4;  /* TODO: Fill this in without hitting the stream bad in pvfs_doseas_load() */
     85        if (pvfs->ntvfs->ctx->protocol >= PROTOCOL_SMB2_02) {
    8686                /* SMB2 represents a null EA with zero bytes */
    8787                name->dos.ea_size = 0;
  • vendor/current/source4/ntvfs/posix/pvfs_fsinfo.c

    r740 r988  
    202202                return NT_STATUS_OK;
    203203
     204        case RAW_QFS_SECTOR_SIZE_INFORMATION:
     205                fs->sector_size_info.out.logical_bytes_per_sector = block_size;
     206                fs->sector_size_info.out.phys_bytes_per_sector_atomic
     207                                                                = block_size;
     208                fs->sector_size_info.out.phys_bytes_per_sector_perf
     209                                                                = block_size;
     210                fs->sector_size_info.out.fs_effective_phys_bytes_per_sector_atomic
     211                                                                = block_size;
     212                fs->sector_size_info.out.flags
     213                                        = QFS_SSINFO_FLAGS_ALIGNED_DEVICE
     214                                | QFS_SSINFO_FLAGS_PARTITION_ALIGNED_ON_DEVICE;
     215                fs->sector_size_info.out.byte_off_sector_align = 0;
     216                fs->sector_size_info.out.byte_off_partition_align = 0;
     217                return NT_STATUS_OK;
     218
    204219        default:
    205220                break;
  • vendor/current/source4/ntvfs/posix/pvfs_ioctl.c

    r414 r988  
    2222#include "includes.h"
    2323#include "vfs_posix.h"
    24 #include "libcli/raw/ioctl.h"
     24#include "../libcli/smb/smb_constants.h"
    2525
    2626/*
  • vendor/current/source4/ntvfs/posix/pvfs_lock.c

    r740 r988  
    4040        }
    4141
    42         return brl_locktest(pvfs->brl_context,
     42        return brlock_locktest(pvfs->brl_context,
    4343                            f->brl_handle,
    4444                            smbpid,
     
    7171        /* undo the locks we just did */
    7272        for (i--;i>=0;i--) {
    73                 brl_unlock(pvfs->brl_context,
     73                brlock_unlock(pvfs->brl_context,
    7474                           f->brl_handle,
    7575                           locks[i].pid,
     
    117117        /* we don't retry on a cancel */
    118118        if (reason == PVFS_WAIT_CANCEL) {
    119                 if (pvfs->ntvfs->ctx->protocol != PROTOCOL_SMB2) {
     119                if (pvfs->ntvfs->ctx->protocol < PROTOCOL_SMB2_02) {
    120120                        status = NT_STATUS_FILE_LOCK_CONFLICT;
    121121                } else {
     
    128128                 * FILE_LOCK_CONFLICT in the error case
    129129                 */
    130                 status = brl_lock(pvfs->brl_context,
     130                status = brlock_lock(pvfs->brl_context,
    131131                                  f->brl_handle,
    132132                                  locks[pending->pending_lock].pid,
     
    144144        if (NT_STATUS_IS_OK(status) || timed_out) {
    145145                NTSTATUS status2;
    146                 status2 = brl_remove_pending(pvfs->brl_context,
     146                status2 = brlock_remove_pending(pvfs->brl_context,
    147147                                             f->brl_handle, pending);
    148148                if (!NT_STATUS_IS_OK(status2)) {
     
    178178                }
    179179
    180                 status = brl_lock(pvfs->brl_context,
     180                status = brlock_lock(pvfs->brl_context,
    181181                                  f->brl_handle,
    182182                                  locks[i].pid,
     
    226226                DEBUG(5,("pvfs_lock: removing %.0f locks on close\n",
    227227                         (double)f->lock_count));
    228                 brl_close(f->pvfs->brl_context, f->brl_handle);
     228                brlock_close(f->pvfs->brl_context, f->brl_handle);
    229229                f->lock_count = 0;
    230230        }
     
    325325
    326326                pending->end_time =
    327                         timeval_current_ofs(lck->lockx.in.timeout/1000,
    328                                             1000*(lck->lockx.in.timeout%1000));
     327                        timeval_current_ofs_msec(lck->lockx.in.timeout);
    329328        }
    330329
     
    351350
    352351        for (i=0;i<lck->lockx.in.ulock_cnt;i++) {
    353                 status = brl_unlock(pvfs->brl_context,
     352                status = brlock_unlock(pvfs->brl_context,
    354353                                    f->brl_handle,
    355354                                    locks[i].pid,
     
    370369                }
    371370
    372                 status = brl_lock(pvfs->brl_context,
     371                status = brlock_lock(pvfs->brl_context,
    373372                                  f->brl_handle,
    374373                                  locks[i].pid,
     
    395394                        /* undo the locks we just did */
    396395                        for (i--;i>=0;i--) {
    397                                 brl_unlock(pvfs->brl_context,
     396                                brlock_unlock(pvfs->brl_context,
    398397                                           f->brl_handle,
    399398                                           locks[i].pid,
  • vendor/current/source4/ntvfs/posix/pvfs_mkdir.c

    r740 r988  
    5252        mode = pvfs_fileperms(pvfs, FILE_ATTRIBUTE_DIRECTORY);
    5353
    54         if (pvfs_sys_mkdir(pvfs, name->full_name, mode) == -1) {
     54        if (pvfs_sys_mkdir(pvfs, name->full_name, mode, name->allow_override) == -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                 pvfs_sys_rmdir(pvfs, name->full_name);
     72                pvfs_sys_rmdir(pvfs, name->full_name, name->allow_override);
    7373                return status;
    7474        }
     
    7979                                         md->t2mkdir.in.eas);
    8080        if (!NT_STATUS_IS_OK(status)) {
    81                 pvfs_sys_rmdir(pvfs, name->full_name);
     81                pvfs_sys_rmdir(pvfs, name->full_name, name->allow_override);
    8282                return status;
    8383        }
     
    128128        mode = pvfs_fileperms(pvfs, FILE_ATTRIBUTE_DIRECTORY);
    129129
    130         if (pvfs_sys_mkdir(pvfs, name->full_name, mode) == -1) {
     130        if (pvfs_sys_mkdir(pvfs, name->full_name, mode, name->allow_override) == -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                 pvfs_sys_rmdir(pvfs, name->full_name);
     139                pvfs_sys_rmdir(pvfs, name->full_name, name->allow_override);
    140140                return status;
    141141        }
     
    180180        }
    181181
    182         if (pvfs_sys_rmdir(pvfs, name->full_name) == -1) {
     182        if (pvfs_sys_rmdir(pvfs, name->full_name, name->allow_override) == -1) {
    183183                /* some olders systems don't return ENOTEMPTY to rmdir() */
    184184                if (errno == EEXIST) {
  • vendor/current/source4/ntvfs/posix/pvfs_notify.c

    r740 r988  
    110110           would free the request, and the ntvfs modules above us
    111111           could use it, so call it on the next event */
    112         event_add_timed(req->ctx->event_ctx,
     112        tevent_add_timer(req->ctx->event_ctx,
    113113                        req, timeval_zero(), pvfs_notify_send_next, req);
    114114}
     
    279279        pending->info = info;
    280280
    281         DLIST_ADD_END(f->notify_buffer->pending, pending, struct notify_pending *);
     281        DLIST_ADD_END(f->notify_buffer->pending, pending);
    282282
    283283        /* if the buffer is empty then start waiting */
  • vendor/current/source4/ntvfs/posix/pvfs_open.c

    r740 r988  
    7474                                         delete_path, nt_errstr(status)));
    7575                        }
    76                         if (pvfs_sys_rmdir(h->pvfs, delete_path) != 0) {
     76                        if (pvfs_sys_rmdir(h->pvfs, delete_path, h->name->allow_override) != 0) {
    7777                                DEBUG(0,("pvfs_dir_handle_destructor: failed to rmdir '%s' - %s\n",
    7878                                         delete_path, strerror(errno)));
     
    345345                mode_t mode = pvfs_fileperms(pvfs, attrib);
    346346
    347                 if (pvfs_sys_mkdir(pvfs, name->full_name, mode) == -1) {
     347                if (pvfs_sys_mkdir(pvfs, name->full_name, mode, name->allow_override) == -1) {
    348348                        return pvfs_map_errno(pvfs,errno);
    349349                }
     
    433433
    434434cleanup_delete:
    435         pvfs_sys_rmdir(pvfs, name->full_name);
     435        pvfs_sys_rmdir(pvfs, name->full_name, name->allow_override);
    436436        return status;
    437437}
     
    515515                                         delete_path, nt_errstr(status)));
    516516                        }
    517                         if (pvfs_sys_unlink(h->pvfs, delete_path) != 0) {
     517                        if (pvfs_sys_unlink(h->pvfs, delete_path, h->name->allow_override) != 0) {
    518518                                DEBUG(0,("pvfs_close: failed to delete '%s' - %s\n",
    519519                                         delete_path, strerror(errno)));
     
    591591        }
    592592
    593         h = brl_create_handle(mem_ctx, ntvfs, &key);
     593        h = brlock_create_handle(mem_ctx, ntvfs, &key);
    594594        NT_STATUS_HAVE_NO_MEMORY(h);
    595595
     
    678678
    679679        /* create the file */
    680         fd = pvfs_sys_open(pvfs, 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, name->allow_override);
    681681        if (fd == -1) {
    682682                return pvfs_map_errno(pvfs, errno);
     
    718718                status = pvfs_access_maximal_allowed(pvfs, req, name,
    719719                                                     &io->generic.out.maximal_access);
    720                 NT_STATUS_NOT_OK_RETURN(status);
     720                if (!NT_STATUS_IS_OK(status)) {
     721                        goto cleanup_delete;
     722                }
    721723        }
    722724
     
    857859cleanup_delete:
    858860        close(fd);
    859         pvfs_sys_unlink(pvfs, name->full_name);
     861        pvfs_sys_unlink(pvfs, name->full_name, name->allow_override);
    860862        return status;
    861863}
     
    11751177                                             pvfs->oplock_break_timeout,
    11761178                                             0);
    1177                 end_time = timeval_current_ofs(0, (pvfs->sharing_violation_delay*4)/5);
     1179                end_time = timeval_current_ofs_usec((pvfs->sharing_violation_delay*4)/5);
    11781180                end_time = timeval_min(final_timeout, &end_time);
    11791181        } else {
     
    12851287
    12861288        /* what does this bit really mean?? */
    1287         if (req->ctx->protocol == PROTOCOL_SMB2 &&
     1289        if (req->ctx->protocol >= PROTOCOL_SMB2_02 &&
    12881290            access_mask == SEC_STD_SYNCHRONIZE) {
    12891291                return NT_STATUS_ACCESS_DENIED;
     
    15031505         */
    15041506        if (create_options & NTCREATEX_OPTIONS_DELETE_ON_CLOSE &&
    1505             req->ctx->protocol == PROTOCOL_SMB2) {
     1507            req->ctx->protocol >= PROTOCOL_SMB2_02) {
    15061508                del_on_close = true;
    15071509        } else {
     
    15501552
    15511553        /* do the actual open */
    1552         fd = pvfs_sys_open(pvfs, f->handle->name->full_name, flags | O_NONBLOCK, 0);
     1554        fd = pvfs_sys_open(pvfs, f->handle->name->full_name, flags | O_NONBLOCK, 0, name->allow_override);
    15531555        if (fd == -1) {
    15541556                status = pvfs_map_errno(f->pvfs, errno);
     
    15701572        f->handle->fd = fd;
    15711573
    1572         status = brl_count(f->pvfs->brl_context, f->brl_handle, &count);
     1574        status = brlock_count(f->pvfs->brl_context, f->brl_handle, &count);
    15731575        if (!NT_STATUS_IS_OK(status)) {
    15741576                talloc_free(lck);
     
    16361638                if (f->handle->name->st.st_mode != mode &&
    16371639                    f->handle->name->dos.attrib != attrib &&
    1638                     pvfs_sys_fchmod(pvfs, fd, mode) == -1) {
     1640                    pvfs_sys_fchmod(pvfs, fd, mode, name->allow_override) == -1) {
    16391641                        talloc_free(lck);
    16401642                        return pvfs_map_errno(pvfs, errno);
  • vendor/current/source4/ntvfs/posix/pvfs_oplock.c

    r414 r988  
    3333        struct timeval break_to_level_II;
    3434        struct timeval break_to_none;
    35         struct messaging_context *msg_ctx;
     35        struct imessaging_context *msg_ctx;
    3636};
    3737
     
    159159}
    160160
    161 static void pvfs_oplock_break_dispatch(struct messaging_context *msg,
     161static void pvfs_oplock_break_dispatch(struct imessaging_context *msg,
    162162                                       void *private_data, uint32_t msg_type,
    163163                                       struct server_id src, DATA_BLOB *data)
     
    170170
    171171        /* we need to check that this one is for us. See
    172            messaging_send_ptr() for the other side of this.
     172           imessaging_send_ptr() for the other side of this.
    173173         */
    174174        if (data->length == sizeof(struct opendb_oplock_break)) {
     
    193193static int pvfs_oplock_destructor(struct pvfs_oplock *opl)
    194194{
    195         messaging_deregister(opl->msg_ctx, MSG_NTVFS_OPLOCK_BREAK, opl);
     195        imessaging_deregister(opl->msg_ctx, MSG_NTVFS_OPLOCK_BREAK, opl);
    196196        return 0;
    197197}
     
    229229        opl->msg_ctx    = f->pvfs->ntvfs->ctx->msg_ctx;
    230230
    231         status = messaging_register(opl->msg_ctx,
     231        status = imessaging_register(opl->msg_ctx,
    232232                                    opl,
    233233                                    MSG_NTVFS_OPLOCK_BREAK,
  • vendor/current/source4/ntvfs/posix/pvfs_qfileinfo.c

    r740 r988  
    103103                        if (strcasecmp_m(eas->eas[i].name.s,
    104104                                       ealist->eas[j].name) == 0) {
     105                                if (ealist->eas[j].value.length == 0) {
     106                                        continue;
     107                                }
    105108                                eas->eas[i].value = ealist->eas[j].value;
    106109                                break;
     
    135138                eas->eas[eas->num_eas].flags = 0;
    136139                eas->eas[eas->num_eas].name.s = ealist->eas[i].name;
     140                if (ealist->eas[i].value.length == 0) {
     141                        continue;
     142                }
    137143                eas->eas[eas->num_eas].value = ealist->eas[i].value;
    138144                eas->num_eas++;
     
    150156{
    151157        switch (info->generic.level) {
    152         case RAW_FILEINFO_GENERIC:
    153                 return NT_STATUS_INVALID_LEVEL;
    154 
    155158        case RAW_FILEINFO_GETATTR:
    156159                info->getattr.out.attrib     = name->dos.attrib;
     
    226229        case RAW_FILEINFO_NAME_INFO:
    227230        case RAW_FILEINFO_NAME_INFORMATION:
    228                 if (req->ctx->protocol == PROTOCOL_SMB2) {
     231                if (req->ctx->protocol >= PROTOCOL_SMB2_02) {
    229232                        /* strange that SMB2 doesn't have this */
    230233                        return NT_STATUS_NOT_SUPPORTED;
     
    334337                NT_STATUS_HAVE_NO_MEMORY(info->all_info2.out.fname.s);
    335338                return NT_STATUS_OK;
     339
     340        case RAW_FILEINFO_GENERIC:
     341        case RAW_FILEINFO_UNIX_BASIC:
     342        case RAW_FILEINFO_UNIX_INFO2:
     343        case RAW_FILEINFO_UNIX_LINK:
     344                return NT_STATUS_INVALID_LEVEL;
    336345        }
    337346
  • vendor/current/source4/ntvfs/posix/pvfs_read.c

    r740 r988  
    6060
    6161        maxcnt = rd->readx.in.maxcnt;
    62         if (maxcnt > 2*UINT16_MAX && req->ctx->protocol < PROTOCOL_SMB2) {
     62        if (maxcnt > 2*UINT16_MAX && req->ctx->protocol < PROTOCOL_SMB2_02) {
    6363                DEBUG(3,(__location__ ": Invalid SMB maxcnt 0x%x\n", maxcnt));
    6464                return NT_STATUS_INVALID_PARAMETER;
     
    9797
    9898        /* only SMB2 honors mincnt */
    99         if (req->ctx->protocol == PROTOCOL_SMB2) {
     99        if (req->ctx->protocol >= PROTOCOL_SMB2_02) {
    100100                if (rd->readx.in.mincnt > ret ||
    101101                    (ret == 0 && maxcnt > 0)) {
  • vendor/current/source4/ntvfs/posix/pvfs_rename.c

    r740 r988  
    3838        NTSTATUS status;
    3939
    40         if (pvfs_sys_rename(pvfs, name1->full_name, name2) == -1) {
     40        if (pvfs_sys_rename(pvfs, name1->full_name, name2,
     41                            name1->allow_override) == -1) {
    4142                return pvfs_map_errno(pvfs, errno);
    4243        }
     
    625626                status = pvfs_access_check_parent(pvfs, req, name2, SEC_DIR_ADD_FILE);
    626627                NT_STATUS_NOT_OK_RETURN(status);
    627                 return pvfs_copy_file(pvfs, name1, name2);
     628                return pvfs_copy_file(pvfs, name1, name2, name1->allow_override && name2->allow_override);
    628629
    629630        case RENAME_FLAG_MOVE_CLUSTER_INFORMATION:
  • vendor/current/source4/ntvfs/posix/pvfs_resolve.c

    r740 r988  
    519519        (*name)->exists = false;
    520520        (*name)->stream_exists = false;
     521        (*name)->allow_override = false;
    521522
    522523        if (!(pvfs->fs_attribs & FS_ATTR_NAMED_STREAMS)) {
     
    525526
    526527        /* SMB2 doesn't allow a leading slash */
    527         if (req->ctx->protocol == PROTOCOL_SMB2 &&
     528        if (req->ctx->protocol >= PROTOCOL_SMB2_02 &&
    528529            *cifs_name == '\\') {
    529530                return NT_STATUS_INVALID_PARAMETER;
     
    631632        (*name)->stream_name = NULL;
    632633        (*name)->stream_id = 0;
     634        (*name)->allow_override = false;
    633635
    634636        status = pvfs_fill_dos_info(pvfs, *name, flags, -1);
     
    693695        if (h->have_opendb_entry) {
    694696                struct odb_lock *lck;
    695                 char *name = NULL;
     697                const char *name = NULL;
    696698
    697699                lck = odb_lock(h, h->pvfs->odb_context, &h->odb_locking_key);
     
    704706                }
    705707
    706                 status = odb_get_path(lck, (const char **) &name);
     708                status = odb_get_path(lck, &name);
    707709                if (NT_STATUS_IS_OK(status)) {
    708710                        /*
     
    718720                                char *new_orig;
    719721                                char *delim;
     722                                char *full_name = discard_const_p(char, name);
    720723
    721724                                delim = strrchr(name, '/');
     
    746749                                talloc_free(h->name->original_name);
    747750                                talloc_free(h->name->full_name);
    748                                 h->name->full_name = talloc_steal(h->name, name);
     751                                h->name->full_name = talloc_steal(h->name, full_name);
    749752                                h->name->original_name = new_orig;
    750753                        }
     
    816819        (*name)->stream_name = NULL;
    817820        (*name)->stream_id = 0;
     821        (*name)->allow_override = false;
    818822
    819823        status = pvfs_fill_dos_info(pvfs, *name, PVFS_RESOLVE_NO_OPENDB, -1);
  • vendor/current/source4/ntvfs/posix/pvfs_search.c

    r740 r988  
    6262        if (search->handle == INVALID_SEARCH_HANDLE) return;
    6363        talloc_free(search->te);
    64         search->te = event_add_timed(ev, search,
     64        search->te = tevent_add_timer(ev, search,
    6565                                     timeval_current_ofs(search->pvfs->search.inactivity_time, 0),
    6666                                     pvfs_search_timer, search);
     
    222222
    223223        case RAW_SEARCH_DATA_GENERIC:
    224                 break;
     224        case RAW_SEARCH_DATA_UNIX_INFO:
     225        case RAW_SEARCH_DATA_UNIX_INFO2:
     226                return NT_STATUS_INVALID_LEVEL;
    225227        }
    226228
  • vendor/current/source4/ntvfs/posix/pvfs_setfileinfo.c

    r740 r988  
    131131        /* renames are only allowed within a directory */
    132132        if (strchr_m(info->rename_information.in.new_name, '\\') &&
    133             (req->ctx->protocol != PROTOCOL_SMB2)) {
     133            (req->ctx->protocol < PROTOCOL_SMB2_02)) {
    134134                return NT_STATUS_NOT_SUPPORTED;
    135135        }
     
    144144           but I suspect it is just uninitialised memory */
    145145        if (info->rename_information.in.root_fid != 0 &&
    146             (req->ctx->protocol != PROTOCOL_SMB2)) {
     146            (req->ctx->protocol < PROTOCOL_SMB2_02)) {
    147147                return NT_STATUS_INVALID_PARAMETER;
    148148        }
    149149
    150150        /* construct the fully qualified windows name for the new file name */
    151         if (req->ctx->protocol == PROTOCOL_SMB2) {
     151        if (req->ctx->protocol >= PROTOCOL_SMB2_02) {
    152152                /* SMB2 sends the full path of the new name */
    153153                new_name = talloc_asprintf(req, "\\%s", info->rename_information.in.new_name);
     
    368368
    369369        case RAW_SFILEINFO_EA_SET:
    370                 return pvfs_setfileinfo_ea_set(pvfs, h->name, h->fd, 
     370                return pvfs_setfileinfo_ea_set(pvfs, h->name, h->fd,
    371371                                               info->ea_set.in.num_eas,
    372372                                               info->ea_set.in.eas);
     
    420420                h->position = info->position_information.in.position;
    421421                break;
     422
     423        case RAW_SFILEINFO_FULL_EA_INFORMATION:
     424                return pvfs_setfileinfo_ea_set(pvfs, h->name, h->fd,
     425                                info->full_ea_information.in.eas.num_eas,
     426                                info->full_ea_information.in.eas.eas);
    422427
    423428        case RAW_SFILEINFO_MODE_INFORMATION:
     
    535540                mode = pvfs_fileperms(pvfs, newstats.dos.attrib);
    536541                if (!(h->name->dos.attrib & FILE_ATTRIBUTE_DIRECTORY)) {
    537                         if (pvfs_sys_fchmod(pvfs, h->fd, mode) == -1) {
     542                        if (pvfs_sys_fchmod(pvfs, h->fd, mode, h->name->allow_override) == -1) {
    538543                                return pvfs_map_errno(pvfs, errno);
    539544                        }
     
    860865        if (newstats.dos.attrib != name->dos.attrib) {
    861866                mode_t mode = pvfs_fileperms(pvfs, newstats.dos.attrib);
    862                 if (pvfs_sys_chmod(pvfs, name->full_name, mode) == -1) {
     867                if (pvfs_sys_chmod(pvfs, name->full_name, mode, name->allow_override) == -1) {
    863868                        return pvfs_map_errno(pvfs, errno);
    864869                }
  • vendor/current/source4/ntvfs/posix/pvfs_sys.c

    r740 r988  
    197197                return NULL;
    198198        }
     199
    199200        ctx->old_wd = talloc_strdup(ctx, cwd);
     201        free(cwd);
     202
    200203        if (ctx->old_wd == NULL) {
    201                 free(cwd);
    202204                talloc_free(ctx);
    203205                return NULL;
     
    257259  wrap open for system override
    258260*/
    259 int pvfs_sys_open(struct pvfs_state *pvfs, const char *filename, int flags, mode_t mode)
     261int pvfs_sys_open(struct pvfs_state *pvfs, const char *filename, int flags, mode_t mode, bool allow_override)
    260262{
    261263        int fd, ret;
     
    268270        fd = open(filename, flags, mode);
    269271        if (fd != -1 ||
    270             !(pvfs->flags & PVFS_FLAG_PERM_OVERRIDE) ||
     272            !allow_override ||
    271273            errno != EACCES) {
    272274                return fd;
     
    367369  wrap unlink for system override
    368370*/
    369 int pvfs_sys_unlink(struct pvfs_state *pvfs, const char *filename)
     371int pvfs_sys_unlink(struct pvfs_state *pvfs, const char *filename, bool allow_override)
    370372{
    371373        int ret;
     
    377379        ret = unlink(filename);
    378380        if (ret != -1 ||
    379             !(pvfs->flags & PVFS_FLAG_PERM_OVERRIDE) ||
     381            !allow_override ||
    380382            errno != EACCES) {
    381383                return ret;
     
    406408{
    407409        int fd = open(path, PVFS_NOFOLLOW | O_RDONLY);
     410        int posix_errno = errno;
    408411        if (fd != -1) {
    409412                close(fd);
    410413                return false;
    411414        }
    412         return (errno == ELOOP);
     415
     416#if defined(ENOTSUP) && defined(OSF1)
     417        /* handle special Tru64 errno */
     418        if (errno == ENOTSUP) {
     419                posix_errno = ELOOP;
     420        }
     421#endif /* ENOTSUP */
     422
     423#ifdef EFTYPE
     424        /* fix broken NetBSD errno */
     425        if (errno == EFTYPE) {
     426                posix_errno = ELOOP;
     427        }
     428#endif /* EFTYPE */
     429
     430        /* fix broken FreeBSD errno */
     431        if (errno == EMLINK) {
     432                posix_errno = ELOOP;
     433        }
     434
     435        return (posix_errno == ELOOP);
    413436}
    414437
     
    416439  wrap rename for system override
    417440*/
    418 int pvfs_sys_rename(struct pvfs_state *pvfs, const char *name1, const char *name2)
     441int pvfs_sys_rename(struct pvfs_state *pvfs, const char *name1, const char *name2, bool allow_override)
    419442{
    420443        int ret;
     
    426449        ret = rename(name1, name2);
    427450        if (ret != -1 ||
    428             !(pvfs->flags & PVFS_FLAG_PERM_OVERRIDE) ||
     451            !allow_override ||
    429452            errno != EACCES) {
    430453                return ret;
     
    481504  wrap mkdir for system override
    482505*/
    483 int pvfs_sys_mkdir(struct pvfs_state *pvfs, const char *dirname, mode_t mode)
     506int pvfs_sys_mkdir(struct pvfs_state *pvfs, const char *dirname, mode_t mode, bool allow_override)
    484507{
    485508        int ret;
     
    491514        ret = mkdir(dirname, mode);
    492515        if (ret != -1 ||
    493             !(pvfs->flags & PVFS_FLAG_PERM_OVERRIDE) ||
     516            !allow_override ||
    494517            errno != EACCES) {
    495518                return ret;
     
    513536        if (ret == -1) {
    514537                rmdir(dirname);
    515                 talloc_free(ctx);
    516                 errno = saved_errno;
    517                 return -1;
    518         }
    519 
    520         talloc_free(ctx);
    521         return ret;
    522 }
    523 
    524 
    525 /*
    526   wrap rmdir for system override
    527 */
    528 int pvfs_sys_rmdir(struct pvfs_state *pvfs, const char *dirname)
    529 {
    530         int ret;
    531         struct pvfs_sys_ctx *ctx;
    532         int saved_errno, orig_errno;
    533 
    534         orig_errno = errno;
    535 
    536         ret = rmdir(dirname);
    537         if (ret != -1 ||
    538             !(pvfs->flags & PVFS_FLAG_PERM_OVERRIDE) ||
    539             errno != EACCES) {
    540                 return ret;
    541         }
    542 
    543         saved_errno = errno;
    544 
    545         ctx = pvfs_sys_pushdir(pvfs, &dirname);
    546         if (ctx == NULL) {
    547                 errno = saved_errno;
    548                 return -1;
    549         }
    550 
    551         ret = rmdir(dirname);
    552         if (ret == -1) {
    553538                talloc_free(ctx);
    554539                errno = saved_errno;
     
    561546}
    562547
    563 /*
    564   wrap fchmod for system override
    565 */
    566 int pvfs_sys_fchmod(struct pvfs_state *pvfs, int fd, mode_t mode)
     548
     549/*
     550  wrap rmdir for system override
     551*/
     552int pvfs_sys_rmdir(struct pvfs_state *pvfs, const char *dirname, bool allow_override)
    567553{
    568554        int ret;
     
    572558        orig_errno = errno;
    573559
    574         ret = fchmod(fd, mode);
     560        ret = rmdir(dirname);
    575561        if (ret != -1 ||
    576             !(pvfs->flags & PVFS_FLAG_PERM_OVERRIDE) ||
     562            !allow_override ||
    577563            errno != EACCES) {
    578564                return ret;
     
    581567        saved_errno = errno;
    582568
    583         ctx = pvfs_sys_pushdir(pvfs, NULL);
    584         if (ctx == NULL) {
    585                 errno = saved_errno;
    586                 return -1;
    587         }
    588 
    589         ret = fchmod(fd, mode);
     569        ctx = pvfs_sys_pushdir(pvfs, &dirname);
     570        if (ctx == NULL) {
     571                errno = saved_errno;
     572                return -1;
     573        }
     574
     575        ret = rmdir(dirname);
    590576        if (ret == -1) {
    591577                talloc_free(ctx);
     
    599585}
    600586
    601 
    602 /*
    603   wrap chmod for system override
    604 */
    605 int pvfs_sys_chmod(struct pvfs_state *pvfs, const char *filename, mode_t mode)
     587/*
     588  wrap fchmod for system override
     589*/
     590int pvfs_sys_fchmod(struct pvfs_state *pvfs, int fd, mode_t mode, bool allow_override)
    606591{
    607592        int ret;
     
    611596        orig_errno = errno;
    612597
    613         ret = chmod(filename, mode);
     598        ret = fchmod(fd, mode);
    614599        if (ret != -1 ||
    615             !(pvfs->flags & PVFS_FLAG_PERM_OVERRIDE) ||
     600            !allow_override ||
    616601            errno != EACCES) {
    617602                return ret;
     
    620605        saved_errno = errno;
    621606
    622         ctx = pvfs_sys_pushdir(pvfs, &filename);
    623         if (ctx == NULL) {
    624                 errno = saved_errno;
    625                 return -1;
    626         }
    627 
    628         ret = chmod(filename, mode);
     607        ctx = pvfs_sys_pushdir(pvfs, NULL);
     608        if (ctx == NULL) {
     609                errno = saved_errno;
     610                return -1;
     611        }
     612
     613        ret = fchmod(fd, mode);
    629614        if (ret == -1) {
    630615                talloc_free(ctx);
     
    637622        return ret;
    638623}
     624
     625
     626/*
     627  wrap chmod for system override
     628*/
     629int pvfs_sys_chmod(struct pvfs_state *pvfs, const char *filename, mode_t mode, bool allow_override)
     630{
     631        int ret;
     632        struct pvfs_sys_ctx *ctx;
     633        int saved_errno, orig_errno;
     634
     635        orig_errno = errno;
     636
     637        ret = chmod(filename, mode);
     638        if (ret != -1 ||
     639            !allow_override ||
     640            errno != EACCES) {
     641                return ret;
     642        }
     643
     644        saved_errno = errno;
     645
     646        ctx = pvfs_sys_pushdir(pvfs, &filename);
     647        if (ctx == NULL) {
     648                errno = saved_errno;
     649                return -1;
     650        }
     651
     652        ret = chmod(filename, mode);
     653        if (ret == -1) {
     654                talloc_free(ctx);
     655                errno = saved_errno;
     656                return -1;
     657        }
     658
     659        talloc_free(ctx);
     660        errno = orig_errno;
     661        return ret;
     662}
  • vendor/current/source4/ntvfs/posix/pvfs_unlink.c

    r740 r988  
    124124
    125125        /* finally try the actual unlink */
    126         if (pvfs_sys_unlink(pvfs, name->full_name) == -1) {
     126        if (pvfs_sys_unlink(pvfs, name->full_name, name->allow_override) == -1) {
    127127                status = pvfs_map_errno(pvfs, errno);
    128128        }
  • vendor/current/source4/ntvfs/posix/pvfs_util.c

    r740 r988  
    4141{
    4242        NTSTATUS status;
    43         status = map_nt_error_from_unix(unix_errno);
     43        status = map_nt_error_from_unix_common(unix_errno);
    4444        DEBUG(10,(__location__ " mapped unix errno %d -> %s\n", unix_errno, nt_errstr(status)));
    4545        return status;
     
    9191NTSTATUS pvfs_copy_file(struct pvfs_state *pvfs,
    9292                        struct pvfs_filename *name1,
    93                         struct pvfs_filename *name2)
     93                        struct pvfs_filename *name2,
     94                        bool allow_override)
    9495{
    9596        int fd1, fd2;
     
    103104        }
    104105
    105         fd1 = pvfs_sys_open(pvfs, name1->full_name, O_RDONLY, 0);
     106        fd1 = pvfs_sys_open(pvfs, name1->full_name, O_RDONLY, 0, allow_override);
    106107        if (fd1 == -1) {
    107108                talloc_free(buf);
     
    109110        }
    110111
    111         fd2 = pvfs_sys_open(pvfs, name2->full_name, O_CREAT|O_EXCL|O_WRONLY, 0);
     112        fd2 = pvfs_sys_open(pvfs, name2->full_name, O_CREAT|O_EXCL|O_WRONLY, 0, allow_override);
    112113        if (fd2 == -1) {
    113114                close(fd1);
     
    134135                        close(fd2);
    135136                        talloc_free(buf);
    136                         pvfs_sys_unlink(pvfs, name2->full_name);
     137                        pvfs_sys_unlink(pvfs, name2->full_name, allow_override);
    137138                        if (ret2 == -1) {
    138139                                return pvfs_map_errno(pvfs, errno);
     
    146147
    147148        mode = pvfs_fileperms(pvfs, name1->dos.attrib);
    148         if (pvfs_sys_fchmod(pvfs, fd2, mode) == -1) {
     149        if (pvfs_sys_fchmod(pvfs, fd2, mode, allow_override) == -1) {
    149150                status = pvfs_map_errno(pvfs, errno);
    150151                close(fd2);
    151                 pvfs_sys_unlink(pvfs, name2->full_name);
     152                pvfs_sys_unlink(pvfs, name2->full_name, allow_override);
    152153                return status;
    153154        }
     
    159160        if (!NT_STATUS_IS_OK(status)) {
    160161                close(fd2);
    161                 pvfs_sys_unlink(pvfs, name2->full_name);
     162                pvfs_sys_unlink(pvfs, name2->full_name, allow_override);
    162163                return status;
    163164        }
  • vendor/current/source4/ntvfs/posix/pvfs_wait.c

    r740 r988  
    3434        void *private_data;
    3535        int msg_type;
    36         struct messaging_context *msg_ctx;
     36        struct imessaging_context *msg_ctx;
    3737        struct tevent_context *ev;
    3838        struct ntvfs_request *req;
     
    5757  receive a completion message for a wait
    5858*/
    59 static void pvfs_wait_dispatch(struct messaging_context *msg,
     59static void pvfs_wait_dispatch(struct imessaging_context *msg,
    6060                               void *private_data, uint32_t msg_type,
    6161                               struct server_id src, DATA_BLOB *data)
     
    6767
    6868        /* we need to check that this one is for us. See
    69            messaging_send_ptr() for the other side of this.
     69           imessaging_send_ptr() for the other side of this.
    7070         */
    7171        if (data->length == sizeof(void *)) {
     
    117117{
    118118        if (pwait->msg_type != -1) {
    119                 messaging_deregister(pwait->msg_ctx, pwait->msg_type, pwait);
     119                imessaging_deregister(pwait->msg_ctx, pwait->msg_type, pwait);
    120120        }
    121121        DLIST_REMOVE(pwait->pvfs->wait_list, pwait);
     
    157157        if (!timeval_is_zero(&end_time)) {
    158158                /* setup a timer */
    159                 event_add_timed(pwait->ev, pwait, end_time, pvfs_wait_timeout, pwait);
     159                tevent_add_timer(pwait->ev, pwait, end_time, pvfs_wait_timeout, pwait);
    160160        }
    161161
     
    163163           type */
    164164        if (msg_type != -1) {
    165                 messaging_register(pwait->msg_ctx,
     165                imessaging_register(pwait->msg_ctx,
    166166                                   pwait,
    167167                                   msg_type,
  • vendor/current/source4/ntvfs/posix/pvfs_write.c

    r414 r988  
    6565        }
    6666
    67         tv = timeval_current_ofs(0, pvfs->writetime_delay);
     67        tv = timeval_current_ofs_usec(pvfs->writetime_delay);
    6868
    6969        h->write_time.update_triggered = true;
    7070        h->write_time.update_on_close = true;
    71         h->write_time.update_event = event_add_timed(pvfs->ntvfs->ctx->event_ctx,
     71        h->write_time.update_event = tevent_add_timer(pvfs->ntvfs->ctx->event_ctx,
    7272                                                     h, tv,
    7373                                                     pvfs_write_time_update_handler,
    7474                                                     h);
    7575        if (!h->write_time.update_event) {
    76                 DEBUG(0,("Failed event_add_timed\n"));
     76                DEBUG(0,("Failed tevent_add_timer\n"));
    7777        }
    7878}
  • vendor/current/source4/ntvfs/posix/pvfs_xattr.c

    r740 r988  
    2525#include "librpc/gen_ndr/ndr_xattr.h"
    2626#include "param/param.h"
     27#include "ntvfs/posix/posix_eadb_proto.h"
    2728
    2829/*
     
    8283{
    8384        if (pvfs->ea_db) {
    84                 return delete_xattr_tdb(pvfs, attr_name, fname, fd);
     85                return delete_posix_eadb(pvfs, attr_name, fname, fd);
    8586        }
    8687        return delete_xattr_system(pvfs, attr_name, fname, fd);
     
    9394{
    9495        if (pvfs->ea_db) {
    95                 return unlink_xattr_tdb(pvfs, fname);
     96                return unlink_posix_eadb(pvfs, fname);
    9697        }
    9798        return unlink_xattr_system(pvfs, fname);
     
    284285        NTSTATUS status;
    285286        ZERO_STRUCTP(eas);
     287
     288        if (name->stream_name) {
     289                /* We don't support EAs on streams */
     290                return NT_STATUS_INVALID_PARAMETER;
     291        }
     292
    286293        if (!(pvfs->flags & PVFS_FLAG_XATTR_ENABLE)) {
    287294                return NT_STATUS_OK;
  • vendor/current/source4/ntvfs/posix/python/pyxattr_native.c

    r740 r988  
    2222#include "includes.h"
    2323#include "librpc/ndr/libndr.h"
    24 #include "lib/util/wrap_xattr.h"
     24#include "system/filesys.h"
     25
     26void initxattr_native(void);
    2527
    2628static PyObject *py_is_xattr_supported(PyObject *self)
     
    3739        char *filename, *attribute;
    3840        int ret = 0;
    39         int blobsize;
     41        Py_ssize_t blobsize;
    4042        DATA_BLOB blob;
    4143
     
    4547
    4648        blob.length = blobsize;
    47         ret = wrap_setxattr(filename, attribute, blob.data, blob.length, 0);
     49        ret = setxattr(filename, attribute, blob.data, blob.length, 0);
    4850        if( ret < 0 ) {
    4951                if (errno == ENOTSUP) {
     
    6769                return NULL;
    6870        mem_ctx = talloc_new(NULL);
    69         len = wrap_getxattr(filename,attribute,NULL,0);
     71        len = getxattr(filename,attribute,NULL,0);
    7072        if( len < 0 ) {
    7173                if (errno == ENOTSUP) {
     
    7981        /* check length ... */
    8082        buf = talloc_zero_array(mem_ctx, char, len);
    81         len = wrap_getxattr(filename, attribute, buf, len);
     83        len = getxattr(filename, attribute, buf, len);
    8284        if( len < 0 ) {
    8385                if (errno == ENOTSUP) {
     
    9799        { "wrap_getxattr", (PyCFunction)py_wrap_getxattr, METH_VARARGS,
    98100                "wrap_getxattr(filename,attribute) -> blob\n"
    99                 "Retreive given attribute on the given file." },
     101                "Retrieve given attribute on the given file." },
    100102        { "wrap_setxattr", (PyCFunction)py_wrap_setxattr, METH_VARARGS,
    101103                "wrap_setxattr(filename,attribute,value)\n"
  • vendor/current/source4/ntvfs/posix/python/pyxattr_tdb.c

    r740 r988  
    2121#include <Python.h>
    2222#include "includes.h"
     23#include "system/filesys.h"
    2324#include <tdb.h>
    24 #include "lib/util/tdb_wrap.h"
     25#include "lib/tdb_wrap/tdb_wrap.h"
    2526#include "librpc/ndr/libndr.h"
    26 #include "lib/util/wrap_xattr.h"
    27 #include "ntvfs/posix/vfs_posix.h"
     27#include "ntvfs/posix/posix_eadb.h"
    2828#include "libcli/util/pyerrors.h"
     29#include "param/pyparam.h"
     30#include "lib/dbwrap/dbwrap.h"
     31#include "lib/dbwrap/dbwrap_open.h"
     32#include "lib/dbwrap/dbwrap_tdb.h"
     33#include "source3/lib/xattr_tdb.h"
     34
     35void initxattr_tdb(void);
    2936
    3037static PyObject *py_is_xattr_supported(PyObject *self)
     
    3744        char *filename, *attribute, *tdbname;
    3845        DATA_BLOB blob;
    39         int blobsize;
    40         NTSTATUS status;
     46        Py_ssize_t blobsize;
     47        int ret;
    4148        TALLOC_CTX *mem_ctx;
    42         struct tdb_wrap *eadb;
     49        struct loadparm_context *lp_ctx;
     50        struct db_context *eadb = NULL;
     51        struct file_id id;
     52        struct stat sbuf;
    4353
    4454        if (!PyArg_ParseTuple(args, "ssss#", &tdbname, &filename, &attribute,
     
    4858        blob.length = blobsize;
    4959        mem_ctx = talloc_new(NULL);
    50         eadb = tdb_wrap_open(mem_ctx, tdbname, 50000,
    51                                 TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
     60
     61        lp_ctx = py_default_loadparm_context(mem_ctx);
     62        eadb = db_open_tdb(mem_ctx, tdbname, 50000,
     63                           lpcfg_tdb_flags(lp_ctx, TDB_DEFAULT),
     64                           O_RDWR|O_CREAT, 0600, DBWRAP_LOCK_ORDER_2,
     65                           DBWRAP_FLAG_NONE);
    5266
    5367        if (eadb == NULL) {
     
    5670                return NULL;
    5771        }
    58         status = push_xattr_blob_tdb_raw(eadb, mem_ctx, attribute, filename, -1,
    59                                                                          &blob);
    60         if (!NT_STATUS_IS_OK(status)) {
    61                 PyErr_FromNTSTATUS(status);
     72
     73        ret = stat(filename, &sbuf);
     74        if (ret < 0) {
     75                PyErr_SetFromErrno(PyExc_IOError);
     76                talloc_free(mem_ctx);
     77                return NULL;
     78        }
     79
     80        ZERO_STRUCT(id);
     81        id.devid = sbuf.st_dev;
     82        id.inode = sbuf.st_ino;
     83
     84        ret = xattr_tdb_setattr(eadb, &id, attribute, blob.data, blob.length, 0);
     85        if (ret < 0) {
     86                PyErr_SetFromErrno(PyExc_TypeError);
    6287                talloc_free(mem_ctx);
    6388                return NULL;
     
    7196        char *filename, *attribute, *tdbname;
    7297        TALLOC_CTX *mem_ctx;
     98        struct loadparm_context *lp_ctx;
    7399        DATA_BLOB blob;
    74         PyObject *ret;
    75         NTSTATUS status;
    76         struct tdb_wrap *eadb = NULL;
     100        PyObject *ret_obj;
     101        int ret;
     102        ssize_t xattr_size;
     103        struct db_context *eadb = NULL;
     104        struct file_id id;
     105        struct stat sbuf;
    77106
    78107        if (!PyArg_ParseTuple(args, "sss", &tdbname, &filename, &attribute))
     
    80109
    81110        mem_ctx = talloc_new(NULL);
    82         eadb = tdb_wrap_open(mem_ctx, tdbname, 50000,
    83                                 TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
     111
     112        lp_ctx = py_default_loadparm_context(mem_ctx);
     113        eadb = db_open_tdb(mem_ctx, tdbname, 50000,
     114                           lpcfg_tdb_flags(lp_ctx, TDB_DEFAULT),
     115                           O_RDWR|O_CREAT, 0600, DBWRAP_LOCK_ORDER_2,
     116                           DBWRAP_FLAG_NONE);
     117
    84118        if (eadb == NULL) {
    85119                PyErr_SetFromErrno(PyExc_IOError);
     
    87121                return NULL;
    88122        }
    89         status = pull_xattr_blob_tdb_raw(eadb, mem_ctx, attribute, filename,
    90                                                                          -1, 100, &blob);
    91         if (!NT_STATUS_IS_OK(status) || blob.length < 0) {
    92                 PyErr_FromNTSTATUS(status);
     123
     124        ret = stat(filename, &sbuf);
     125        if (ret < 0) {
     126                PyErr_SetFromErrno(PyExc_IOError);
    93127                talloc_free(mem_ctx);
    94128                return NULL;
    95129        }
    96         ret = PyString_FromStringAndSize((char *)blob.data, blob.length);
     130
     131        ZERO_STRUCT(id);
     132        id.devid = sbuf.st_dev;
     133        id.inode = sbuf.st_ino;
     134
     135        xattr_size = xattr_tdb_getattr(eadb, mem_ctx, &id, attribute, &blob);
     136        if (xattr_size < 0) {
     137                PyErr_SetFromErrno(PyExc_TypeError);
     138                talloc_free(mem_ctx);
     139                return NULL;
     140        }
     141        ret_obj = PyString_FromStringAndSize((char *)blob.data, xattr_size);
    97142        talloc_free(mem_ctx);
    98         return ret;
     143        return ret_obj;
    99144}
    100145
     
    102147        { "wrap_getxattr", (PyCFunction)py_wrap_getxattr, METH_VARARGS,
    103148                "wrap_getxattr(filename,attribute) -> blob\n"
    104                 "Retreive given attribute on the given file." },
     149                "Retrieve given attribute on the given file." },
    105150        { "wrap_setxattr", (PyCFunction)py_wrap_setxattr, METH_VARARGS,
    106151                "wrap_setxattr(filename,attribute,value)\n"
  • vendor/current/source4/ntvfs/posix/vfs_posix.c

    r740 r988  
    2828#include "librpc/gen_ndr/security.h"
    2929#include <tdb.h>
    30 #include "lib/util/tdb_wrap.h"
     30#include "lib/tdb_wrap/tdb_wrap.h"
    3131#include "libcli/security/security.h"
    3232#include "lib/events/events.h"
     
    3939{
    4040        struct share_config *scfg = pvfs->ntvfs->ctx->config;
    41         const char *eadb;
     41        char *eadb;
     42        char *xattr_backend;
    4243        bool def_perm_override = false;
    4344
     
    114115                FS_ATTR_CASE_SENSITIVE_SEARCH |
    115116                FS_ATTR_CASE_PRESERVED_NAMES |
    116                 FS_ATTR_UNICODE_ON_DISK |
    117                 FS_ATTR_SPARSE_FILES;
     117                FS_ATTR_UNICODE_ON_DISK;
    118118
    119119        /* allow xattrs to be stored in a external tdb */
    120         eadb = share_string_option(scfg, PVFS_EADB, NULL);
     120        eadb = share_string_option(pvfs, scfg, PVFS_EADB, NULL);
    121121        if (eadb != NULL) {
    122                 pvfs->ea_db = tdb_wrap_open(pvfs, eadb, 50000, 
    123                                             TDB_DEFAULT, O_RDWR|O_CREAT, 0600);
     122                pvfs->ea_db = tdb_wrap_open(
     123                        pvfs, eadb, 50000,
     124                        lpcfg_tdb_flags(pvfs->ntvfs->ctx->lp_ctx, TDB_DEFAULT),
     125                        O_RDWR|O_CREAT, 0600);
     126                TALLOC_FREE(eadb);
    124127                if (pvfs->ea_db != NULL) {
    125128                        pvfs->flags |= PVFS_FLAG_XATTR_ENABLE;
     
    147150
    148151        /* enable an ACL backend */
    149         pvfs->acl_ops = pvfs_acl_backend_byname(share_string_option(scfg, PVFS_ACL, "xattr"));
     152        xattr_backend = share_string_option(pvfs, scfg, PVFS_ACL, "xattr");
     153        pvfs->acl_ops = pvfs_acl_backend_byname(xattr_backend);
     154        TALLOC_FREE(xattr_backend);
    150155}
    151156
     
    213218         *       but currently we don't have a lp_ctx there
    214219         */
    215         status = pvfs_acl_init(ntvfs->ctx->lp_ctx);
     220        status = pvfs_acl_init();
    216221        NT_STATUS_NOT_OK_RETURN(status);
    217222
     
    220225
    221226        /* for simplicity of path construction, remove any trailing slash now */
    222         base_directory = talloc_strdup(pvfs, share_string_option(ntvfs->ctx->config, SHARE_PATH, ""));
     227        base_directory = share_string_option(pvfs, ntvfs->ctx->config, SHARE_PATH, "");
    223228        NT_STATUS_HAVE_NO_MEMORY(base_directory);
    224229        if (strcmp(base_directory, "/") != 0) {
     
    250255        ntvfs->private_data = pvfs;
    251256
    252         pvfs->brl_context = brl_init(pvfs,
     257        pvfs->brl_context = brlock_init(pvfs,
    253258                                     pvfs->ntvfs->ctx->server_id,
    254259                                     pvfs->ntvfs->ctx->lp_ctx,
     
    271276                                           pvfs->ntvfs->ctx->config);
    272277
    273         pvfs->wbc_ctx = wbc_init(pvfs,
    274                                  pvfs->ntvfs->ctx->msg_ctx,
    275                                  pvfs->ntvfs->ctx->event_ctx);
    276         if (pvfs->wbc_ctx == NULL) {
    277                 return NT_STATUS_INTERNAL_DB_CORRUPTION;
    278         }
    279 
    280278        /* allocate the search handle -> ptr tree */
    281279        pvfs->search.idtree = idr_init(pvfs);
     
    373371       
    374372        /* fill in all the operations */
    375         ops.connect = pvfs_connect;
    376         ops.disconnect = pvfs_disconnect;
    377         ops.unlink = pvfs_unlink;
    378         ops.chkpath = pvfs_chkpath;
    379         ops.qpathinfo = pvfs_qpathinfo;
    380         ops.setpathinfo = pvfs_setpathinfo;
    381         ops.open = pvfs_open;
    382         ops.mkdir = pvfs_mkdir;
    383         ops.rmdir = pvfs_rmdir;
    384         ops.rename = pvfs_rename;
    385         ops.copy = pvfs_copy;
    386         ops.ioctl = pvfs_ioctl;
    387         ops.read = pvfs_read;
    388         ops.write = pvfs_write;
    389         ops.seek = pvfs_seek;
    390         ops.flush = pvfs_flush;
    391         ops.close = pvfs_close;
    392         ops.exit = pvfs_exit;
    393         ops.lock = pvfs_lock;
    394         ops.setfileinfo = pvfs_setfileinfo;
    395         ops.qfileinfo = pvfs_qfileinfo;
    396         ops.fsinfo = pvfs_fsinfo;
    397         ops.lpq = pvfs_lpq;
    398         ops.search_first = pvfs_search_first;
    399         ops.search_next = pvfs_search_next;
    400         ops.search_close = pvfs_search_close;
    401         ops.trans = pvfs_trans;
    402         ops.logoff = pvfs_logoff;
    403         ops.async_setup = pvfs_async_setup;
    404         ops.cancel = pvfs_cancel;
    405         ops.notify = pvfs_notify;
     373        ops.connect_fn = pvfs_connect;
     374        ops.disconnect_fn = pvfs_disconnect;
     375        ops.unlink_fn = pvfs_unlink;
     376        ops.chkpath_fn = pvfs_chkpath;
     377        ops.qpathinfo_fn = pvfs_qpathinfo;
     378        ops.setpathinfo_fn = pvfs_setpathinfo;
     379        ops.open_fn = pvfs_open;
     380        ops.mkdir_fn = pvfs_mkdir;
     381        ops.rmdir_fn = pvfs_rmdir;
     382        ops.rename_fn = pvfs_rename;
     383        ops.copy_fn = pvfs_copy;
     384        ops.ioctl_fn = pvfs_ioctl;
     385        ops.read_fn = pvfs_read;
     386        ops.write_fn = pvfs_write;
     387        ops.seek_fn = pvfs_seek;
     388        ops.flush_fn = pvfs_flush;
     389        ops.close_fn = pvfs_close;
     390        ops.exit_fn = pvfs_exit;
     391        ops.lock_fn = pvfs_lock;
     392        ops.setfileinfo_fn = pvfs_setfileinfo;
     393        ops.qfileinfo_fn = pvfs_qfileinfo;
     394        ops.fsinfo_fn = pvfs_fsinfo;
     395        ops.lpq_fn = pvfs_lpq;
     396        ops.search_first_fn = pvfs_search_first;
     397        ops.search_next_fn = pvfs_search_next;
     398        ops.search_close_fn = pvfs_search_close;
     399        ops.trans_fn = pvfs_trans;
     400        ops.logoff_fn = pvfs_logoff;
     401        ops.async_setup_fn = pvfs_async_setup;
     402        ops.cancel_fn = pvfs_cancel;
     403        ops.notify_fn = pvfs_notify;
    406404
    407405        /* register ourselves with the NTVFS subsystem. We register
  • vendor/current/source4/ntvfs/posix/vfs_posix.h

    r740 r988  
    4848        struct odb_context *odb_context;
    4949        struct notify_context *notify_context;
    50         struct wbc_context *wbc_ctx;
    5150
    5251        /* a list of pending async requests. Needed to support
     
    132131        bool exists;          /* true if the base filename exists */
    133132        bool stream_exists;   /* true if the stream exists */
     133        bool allow_override;
    134134        struct stat st;
    135135        struct pvfs_dos_fileinfo dos;
     
    205205        struct brl_handle *brl_handle;
    206206
    207         /* a count of active locks - used to avoid calling brl_close on
     207        /* a count of active locks - used to avoid calling brlock_close on
    208208           file close */
    209209        uint64_t lock_count;
  • vendor/current/source4/ntvfs/posix/wscript_build

    r740 r988  
    44        source='pvfs_acl.c',
    55        autoproto='vfs_acl_proto.h',
    6         deps='events',
     6        deps='events samba-modules',
    77        )
    88
     
    3232
    3333bld.SAMBA_MODULE('ntvfs_posix',
    34         source='vfs_posix.c pvfs_util.c pvfs_search.c pvfs_dirlist.c pvfs_fileinfo.c pvfs_unlink.c pvfs_mkdir.c pvfs_open.c pvfs_read.c pvfs_flush.c pvfs_write.c pvfs_fsinfo.c pvfs_qfileinfo.c pvfs_setfileinfo.c pvfs_rename.c pvfs_resolve.c pvfs_shortname.c pvfs_lock.c pvfs_oplock.c pvfs_wait.c pvfs_seek.c pvfs_ioctl.c pvfs_xattr.c pvfs_streams.c pvfs_notify.c pvfs_sys.c xattr_system.c xattr_tdb.c',
     34        source='vfs_posix.c pvfs_util.c pvfs_search.c pvfs_dirlist.c pvfs_fileinfo.c pvfs_unlink.c pvfs_mkdir.c pvfs_open.c pvfs_read.c pvfs_flush.c pvfs_write.c pvfs_fsinfo.c pvfs_qfileinfo.c pvfs_setfileinfo.c pvfs_rename.c pvfs_resolve.c pvfs_shortname.c pvfs_lock.c pvfs_oplock.c pvfs_wait.c pvfs_seek.c pvfs_ioctl.c pvfs_xattr.c pvfs_streams.c pvfs_notify.c pvfs_sys.c xattr_system.c',
    3535        autoproto='vfs_posix_proto.h',
    3636        subsystem='ntvfs',
    3737        init_function='ntvfs_posix_init',
    38         deps='NDR_XATTR wrap_xattr ntvfs_common MESSAGING LIBWBCLIENT_OLD pvfs_acl pvfs_aio',
     38        deps='NDR_XATTR attr ntvfs_common MESSAGING LIBWBCLIENT_OLD pvfs_acl pvfs_aio posix_eadb',
    3939        internal_module=True
    4040        )
     
    4343bld.SAMBA_PYTHON('python_xattr_native',
    4444        source='python/pyxattr_native.c',
    45         deps='ndr ldb samdb credentials pyparam_util wrap_xattr attr',
     45        deps='ndr ldb samdb samba-credentials pyparam_util attr',
    4646        realname='samba/xattr_native.so'
    4747        )
    4848
     49bld.SAMBA_LIBRARY('posix_eadb',
     50                  source='posix_eadb.c',
     51                  deps='tdb tdb-wrap samba-util',
     52                  autoproto='posix_eadb_proto.h',
     53                  private_library=True)
     54
     55bld.SAMBA_PYTHON('python_posix_eadb',
     56        source='python/pyposix_eadb.c',
     57        deps='pyparam_util posix_eadb tdb',
     58        realname='samba/posix_eadb.so'
     59        )
    4960
    5061bld.SAMBA_PYTHON('python_xattr_tdb',
    51         source='python/pyxattr_tdb.c xattr_tdb.c',
    52         deps='ndr ldb pyparam_util share attr',
     62        source='python/pyxattr_tdb.c',
     63        deps='pyparam_util xattr_tdb',
    5364        realname='samba/xattr_tdb.so'
    5465        )
  • vendor/current/source4/ntvfs/posix/xattr_system.c

    r414 r988  
    2222#include "includes.h"
    2323#include "vfs_posix.h"
    24 #include "../lib/util/wrap_xattr.h"
    2524
    2625/*
     
    4443again:
    4544        if (fd != -1) {
    46                 ret = wrap_fgetxattr(fd, attr_name, blob->data, estimated_size);
     45                ret = fgetxattr(fd, attr_name, blob->data, estimated_size);
    4746        } else {
    48                 ret = wrap_getxattr(fname, attr_name, blob->data, estimated_size);
     47                ret = getxattr(fname, attr_name, blob->data, estimated_size);
    4948        }
    5049        if (ret == -1 && errno == ERANGE) {
     
    105104
    106105        if (fd != -1) {
    107                 ret = wrap_fsetxattr(fd, attr_name, blob->data, blob->length, 0);
     106                ret = fsetxattr(fd, attr_name, blob->data, blob->length, 0);
    108107        } else {
    109                 ret = wrap_setxattr(fname, attr_name, blob->data, blob->length, 0);
     108                ret = setxattr(fname, attr_name, blob->data, blob->length, 0);
    110109        }
    111110        if (ret == -1) {
     
    126125
    127126        if (fd != -1) {
    128                 ret = wrap_fremovexattr(fd, attr_name);
     127                ret = fremovexattr(fd, attr_name);
    129128        } else {
    130                 ret = wrap_removexattr(fname, attr_name);
     129                ret = removexattr(fname, attr_name);
    131130        }
    132131        if (ret == -1) {
  • vendor/current/source4/ntvfs/print/vfs_print.c

    r740 r988  
    2323
    2424#include "includes.h"
    25 #include "libcli/raw/ioctl.h"
     25#include "../libcli/smb/smb_constants.h"
    2626#include "ntvfs/ntvfs.h"
    2727#include "param/param.h"
     28
     29NTSTATUS ntvfs_print_init(void);
    2830
    2931/*
     
    114116       
    115117        /* fill in all the operations */
    116         ops.connect = print_connect;
    117         ops.disconnect = print_disconnect;
    118         ops.unlink = print_unlink;
    119         ops.ioctl = print_ioctl;
     118        ops.connect_fn = print_connect;
     119        ops.disconnect_fn = print_disconnect;
     120        ops.unlink_fn = print_unlink;
     121        ops.ioctl_fn = print_ioctl;
    120122
    121123        /* register ourselves with the NTVFS subsystem. We register under the name 'default'
  • vendor/current/source4/ntvfs/simple/svfs_util.c

    r740 r988  
    3939        struct svfs_private *p = ntvfs->private_data;
    4040        char *ret;
     41        char *name_lower = strlower_talloc(p, name);
    4142
    4243        if (*name != '\\') {
    43                 ret = talloc_asprintf(req, "%s/%s", p->connectpath, name);
     44                ret = talloc_asprintf(req, "%s/%s", p->connectpath, name_lower);
    4445        } else {
    45                 ret = talloc_asprintf(req, "%s%s", p->connectpath, name);
     46                ret = talloc_asprintf(req, "%s%s", p->connectpath, name_lower);
    4647        }
    4748        all_string_sub(ret, "\\", "/", 0);
    48 
    49         strlower(ret + strlen(p->connectpath));
    50 
     49        talloc_free(name_lower);
    5150        return ret;
    5251}
     
    8382        mask = p+1;
    8483
    85         low_mask = talloc_strdup(mem_ctx, mask);
     84        low_mask = strlower_talloc(mem_ctx, mask);
    8685        if (!low_mask) { return NULL; }
    87         strlower(low_mask);
    8886
    8987        odir = opendir(dir->unix_dir);
     
    10098                }
    10199
    102                 low_name = talloc_strdup(mem_ctx, dent->d_name);
     100                low_name = strlower_talloc(mem_ctx, dent->d_name);
    103101                if (!low_name) { continue; }
    104                 strlower(low_name);
    105102
    106103                /* check it matches the wildcard pattern */
    107                 if (ms_fnmatch(low_mask, low_name, PROTOCOL_NT1) != 0) {
     104                if (ms_fnmatch_protocol(low_mask, low_name, PROTOCOL_NT1) != 0) {
    108105                        continue;
    109106                }
  • vendor/current/source4/ntvfs/simple/vfs_simple.c

    r740 r988  
    8181        p->ntvfs = ntvfs;
    8282        p->next_search_handle = 0;
    83         p->connectpath = talloc_strdup(p, share_string_option(scfg, SHARE_PATH, ""));
     83        p->connectpath = share_string_option(p, scfg, SHARE_PATH, "");
    8484        p->open_files = NULL;
    8585        p->search = NULL;
     
    148148        /* ignoring wildcards ... */
    149149        if (unlink(unix_path) == -1) {
    150                 return map_nt_error_from_unix(errno);
     150                return map_nt_error_from_unix_common(errno);
    151151        }
    152152
     
    177177
    178178        if (stat(unix_path, &st) == -1) {
    179                 return map_nt_error_from_unix(errno);
     179                return map_nt_error_from_unix_common(errno);
    180180        }
    181181
     
    292292        if (stat(unix_path, &st) == -1) {
    293293                DEBUG(19,("svfs_qpathinfo: file %s errno=%d\n", unix_path, errno));
    294                 return map_nt_error_from_unix(errno);
     294                return map_nt_error_from_unix_common(errno);
    295295        }
    296296        DEBUG(19,("svfs_qpathinfo: file %s, stat done\n", unix_path));
     
    318318       
    319319        if (fstat(f->fd, &st) == -1) {
    320                 return map_nt_error_from_unix(errno);
     320                return map_nt_error_from_unix_common(errno);
    321321        }
    322322
     
    387387                        if (mkdir(unix_path, 0755) == -1) {
    388388                                DEBUG(9,("svfs_open: mkdir %s errno=%d\n", unix_path, errno));
    389                                 return map_nt_error_from_unix(errno);
     389                                return map_nt_error_from_unix_common(errno);
    390390                        }
    391391                        break;
     
    393393                        if (mkdir(unix_path, 0755) == -1 && errno != EEXIST) {
    394394                                DEBUG(9,("svfs_open: mkdir %s errno=%d\n", unix_path, errno));
    395                                 return map_nt_error_from_unix(errno);
     395                                return map_nt_error_from_unix_common(errno);
    396396                        }
    397397                        break;
     
    402402        fd = open(unix_path, flags, 0644);
    403403        if (fd == -1) {
    404                 return map_nt_error_from_unix(errno);
     404                return map_nt_error_from_unix_common(errno);
    405405        }
    406406
     
    408408                DEBUG(9,("svfs_open: fstat errno=%d\n", errno));
    409409                close(fd);
    410                 return map_nt_error_from_unix(errno);
     410                return map_nt_error_from_unix_common(errno);
    411411        }
    412412
     
    415415
    416416        f = talloc(handle, struct svfs_file);
    417         NT_STATUS_HAVE_NO_MEMORY(f);
     417        if (f == NULL) {
     418                close(fd);
     419                return NT_STATUS_NO_MEMORY;
     420        }
    418421        f->fd = fd;
    419422        f->name = talloc_strdup(f, unix_path);
     
    457460
    458461        if (mkdir(unix_path, 0777) == -1) {
    459                 return map_nt_error_from_unix(errno);
     462                return map_nt_error_from_unix_common(errno);
    460463        }
    461464
     
    476479
    477480        if (rmdir(unix_path) == -1) {
    478                 return map_nt_error_from_unix(errno);
     481                return map_nt_error_from_unix_common(errno);
    479482        }
    480483
     
    500503
    501504        if (rename(unix_path1, unix_path2) == -1) {
    502                 return map_nt_error_from_unix(errno);
     505                return map_nt_error_from_unix_common(errno);
    503506        }
    504507       
     
    539542                    rd->readx.in.offset);
    540543        if (ret == -1) {
    541                 return map_nt_error_from_unix(errno);
     544                return map_nt_error_from_unix_common(errno);
    542545        }
    543546
     
    575578                     wr->writex.in.offset);
    576579        if (ret == -1) {
    577                 return map_nt_error_from_unix(errno);
     580                return map_nt_error_from_unix_common(errno);
    578581        }
    579582               
     
    646649
    647650        if (close(f->fd) == -1) {
    648                 return map_nt_error_from_unix(errno);
     651                return map_nt_error_from_unix_common(errno);
    649652        }
    650653
     
    736739                if (ftruncate(f->fd,
    737740                              info->end_of_file_info.in.size) == -1) {
    738                         return map_nt_error_from_unix(errno);
     741                        return map_nt_error_from_unix_common(errno);
    739742                }
    740743                break;
     
    782785                        &fs->generic.out.blocks_free,
    783786                        &fs->generic.out.blocks_total) == -1) {
    784                 return map_nt_error_from_unix(errno);
     787                return map_nt_error_from_unix_common(errno);
    785788        }
    786789
     
    822825
    823826        if (stat(p->connectpath, &st) == -1) {
    824                 return map_nt_error_from_unix(errno);
     827                return map_nt_error_from_unix_common(errno);
    825828        }
    826829
     
    10591062
    10601063        /* fill in all the operations */
    1061         ops.connect = svfs_connect;
    1062         ops.disconnect = svfs_disconnect;
    1063         ops.unlink = svfs_unlink;
    1064         ops.chkpath = svfs_chkpath;
    1065         ops.qpathinfo = svfs_qpathinfo;
    1066         ops.setpathinfo = svfs_setpathinfo;
    1067         ops.open = svfs_open;
    1068         ops.mkdir = svfs_mkdir;
    1069         ops.rmdir = svfs_rmdir;
    1070         ops.rename = svfs_rename;
    1071         ops.copy = svfs_copy;
    1072         ops.ioctl = svfs_ioctl;
    1073         ops.read = svfs_read;
    1074         ops.write = svfs_write;
    1075         ops.seek = svfs_seek;
    1076         ops.flush = svfs_flush;
    1077         ops.close = svfs_close;
    1078         ops.exit = svfs_exit;
    1079         ops.lock = svfs_lock;
    1080         ops.setfileinfo = svfs_setfileinfo;
    1081         ops.qfileinfo = svfs_qfileinfo;
    1082         ops.fsinfo = svfs_fsinfo;
    1083         ops.lpq = svfs_lpq;
    1084         ops.search_first = svfs_search_first;
    1085         ops.search_next = svfs_search_next;
    1086         ops.search_close = svfs_search_close;
    1087         ops.trans = svfs_trans;
    1088         ops.logoff = svfs_logoff;
    1089         ops.async_setup = svfs_async_setup;
    1090         ops.cancel = svfs_cancel;
     1064        ops.connect_fn = svfs_connect;
     1065        ops.disconnect_fn = svfs_disconnect;
     1066        ops.unlink_fn = svfs_unlink;
     1067        ops.chkpath_fn = svfs_chkpath;
     1068        ops.qpathinfo_fn = svfs_qpathinfo;
     1069        ops.setpathinfo_fn = svfs_setpathinfo;
     1070        ops.open_fn = svfs_open;
     1071        ops.mkdir_fn = svfs_mkdir;
     1072        ops.rmdir_fn = svfs_rmdir;
     1073        ops.rename_fn = svfs_rename;
     1074        ops.copy_fn = svfs_copy;
     1075        ops.ioctl_fn = svfs_ioctl;
     1076        ops.read_fn = svfs_read;
     1077        ops.write_fn = svfs_write;
     1078        ops.seek_fn = svfs_seek;
     1079        ops.flush_fn = svfs_flush;
     1080        ops.close_fn = svfs_close;
     1081        ops.exit_fn = svfs_exit;
     1082        ops.lock_fn = svfs_lock;
     1083        ops.setfileinfo_fn = svfs_setfileinfo;
     1084        ops.qfileinfo_fn = svfs_qfileinfo;
     1085        ops.fsinfo_fn = svfs_fsinfo;
     1086        ops.lpq_fn = svfs_lpq;
     1087        ops.search_first_fn = svfs_search_first;
     1088        ops.search_next_fn = svfs_search_next;
     1089        ops.search_close_fn = svfs_search_close;
     1090        ops.trans_fn = svfs_trans;
     1091        ops.logoff_fn = svfs_logoff;
     1092        ops.async_setup_fn = svfs_async_setup;
     1093        ops.cancel_fn = svfs_cancel;
    10911094
    10921095        /* register ourselves with the NTVFS subsystem. We register
  • vendor/current/source4/ntvfs/smb2/vfs_smb2.c

    r740 r988  
    4242#include "libcli/smb2/smb2_calls.h"
    4343
     44NTSTATUS ntvfs_smb2_init(void);
     45
    4446struct cvfs_file {
    4547        struct cvfs_file *prev, *next;
     
    99101  along to the client
    100102 */
     103#if 0
    101104static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *p_private)
    102105{
     
    122125        return true;
    123126}
     127#endif
    124128
    125129/*
     
    161165        struct cvfs_private *p;
    162166        const char *host, *user, *pass, *domain, *remote_share, *sharename;
    163         struct composite_context *creq;
    164167        struct share_config *scfg = ntvfs->ctx->config;
    165168        struct smb2_tree *tree;
     
    167170        bool machine_account;
    168171        struct smbcli_options options;
     172        TALLOC_CTX *tmp_ctx;
     173
     174        tmp_ctx = talloc_new(req);
     175        if (tmp_ctx == NULL) {
     176                return NT_STATUS_NO_MEMORY;
     177        }
    169178
    170179        switch (tcon->generic.level) {
     
    179188                break;
    180189        default:
    181                 return NT_STATUS_INVALID_LEVEL;
     190                status = NT_STATUS_INVALID_LEVEL;
     191                goto out;
    182192        }
    183193
     
    191201        /* Here we need to determine which server to connect to.
    192202         * For now we use parametric options, type cifs.
    193          * Later we will use security=server and auth_server.c.
    194203         */
    195         host = share_string_option(scfg, SMB2_SERVER, NULL);
    196         user = share_string_option(scfg, SMB2_USER, NULL);
    197         pass = share_string_option(scfg, SMB2_PASSWORD, NULL);
    198         domain = share_string_option(scfg, SMB2_DOMAIN, NULL);
    199         remote_share = share_string_option(scfg, SMB2_SHARE, NULL);
     204        host = share_string_option(tmp_ctx, scfg, SMB2_SERVER, NULL);
     205        user = share_string_option(tmp_ctx, scfg, SMB2_USER, NULL);
     206        pass = share_string_option(tmp_ctx, scfg, SMB2_PASSWORD, NULL);
     207        domain = share_string_option(tmp_ctx, scfg, SMB2_DOMAIN, NULL);
     208        remote_share = share_string_option(tmp_ctx, scfg, SMB2_SHARE, NULL);
    200209        if (!remote_share) {
    201210                remote_share = sharename;
     
    206215        p = talloc_zero(ntvfs, struct cvfs_private);
    207216        if (!p) {
    208                 return NT_STATUS_NO_MEMORY;
     217                status = NT_STATUS_NO_MEMORY;
     218                goto out;
    209219        }
    210220
     
    213223        if (!host) {
    214224                DEBUG(1,("CIFS backend: You must supply server\n"));
    215                 return NT_STATUS_INVALID_PARAMETER;
     225                status = NT_STATUS_INVALID_PARAMETER;
     226                goto out;
    216227        }
    217228       
     
    220231                credentials = cli_credentials_init(p);
    221232                if (!credentials) {
    222                         return NT_STATUS_NO_MEMORY;
     233                        status = NT_STATUS_NO_MEMORY;
     234                        goto out;
    223235                }
    224236                cli_credentials_set_conf(credentials, ntvfs->ctx->lp_ctx);
     
    237249                status = cli_credentials_set_machine_account(credentials, ntvfs->ctx->lp_ctx);
    238250                if (!NT_STATUS_IS_OK(status)) {
    239                         return status;
     251                        goto out;
    240252                }
    241253        } else if (req->session_info->credentials) {
     
    244256        } else {
    245257                DEBUG(1,("CIFS backend: NO delegated credentials found: You must supply server, user and password or the client must supply delegated credentials\n"));
    246                 return NT_STATUS_INVALID_PARAMETER;
     258                status = NT_STATUS_INVALID_PARAMETER;
     259                goto out;
    247260        }
    248261
    249262        lpcfg_smbcli_options(ntvfs->ctx->lp_ctx, &options);
    250263
    251         creq = smb2_connect_send(p, host,
     264        status = smb2_connect(p, host,
    252265                        lpcfg_parm_string_list(p, ntvfs->ctx->lp_ctx, NULL, "smb2", "ports", NULL),
    253                                 remote_share,
    254                                  lpcfg_resolve_context(ntvfs->ctx->lp_ctx),
    255                                  credentials,
    256                                  ntvfs->ctx->event_ctx, &options,
    257                                  lpcfg_socket_options(ntvfs->ctx->lp_ctx),
    258                                  lpcfg_gensec_settings(p, ntvfs->ctx->lp_ctx)
    259                                  );
    260 
    261         status = smb2_connect_recv(creq, p, &tree);
    262         NT_STATUS_NOT_OK_RETURN(status);
     266                        remote_share,
     267                        lpcfg_resolve_context(ntvfs->ctx->lp_ctx),
     268                        credentials,
     269                        &tree,
     270                        ntvfs->ctx->event_ctx, &options,
     271                        lpcfg_socket_options(ntvfs->ctx->lp_ctx),
     272                        lpcfg_gensec_settings(p, ntvfs->ctx->lp_ctx));
     273        if (!NT_STATUS_IS_OK(status)) {
     274                goto out;
     275        }
    263276
    264277        status = smb2_get_roothandle(tree, &p->roothandle);
    265         NT_STATUS_NOT_OK_RETURN(status);
     278        if (!NT_STATUS_IS_OK(status)) {
     279                goto out;
     280        }
    266281
    267282        p->tree = tree;
     
    270285
    271286        ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS");
    272         NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type);
     287        if (ntvfs->ctx->fs_type == NULL) {
     288                status = NT_STATUS_NO_MEMORY;
     289                goto out;
     290        }
    273291        ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "A:");
    274         NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type);
     292        if (ntvfs->ctx->dev_type == NULL) {
     293                status = NT_STATUS_NO_MEMORY;
     294                goto out;
     295        }
    275296
    276297        if (tcon->generic.level == RAW_TCON_TCONX) {
     
    283304        smbcli_oplock_handler(p->transport, oplock_handler, p);
    284305        */
    285         return NT_STATUS_OK;
     306
     307        status = NT_STATUS_OK;
     308
     309out:
     310        TALLOC_FREE(tmp_ctx);
     311        return status;
    286312}
    287313
     
    835861       
    836862        /* fill in all the operations */
    837         ops.connect = cvfs_connect;
    838         ops.disconnect = cvfs_disconnect;
    839         ops.unlink = cvfs_unlink;
    840         ops.chkpath = cvfs_chkpath;
    841         ops.qpathinfo = cvfs_qpathinfo;
    842         ops.setpathinfo = cvfs_setpathinfo;
    843         ops.open = cvfs_open;
    844         ops.mkdir = cvfs_mkdir;
    845         ops.rmdir = cvfs_rmdir;
    846         ops.rename = cvfs_rename;
    847         ops.copy = cvfs_copy;
    848         ops.ioctl = cvfs_ioctl;
    849         ops.read = cvfs_read;
    850         ops.write = cvfs_write;
    851         ops.seek = cvfs_seek;
    852         ops.flush = cvfs_flush;
    853         ops.close = cvfs_close;
    854         ops.exit = cvfs_exit;
    855         ops.lock = cvfs_lock;
    856         ops.setfileinfo = cvfs_setfileinfo;
    857         ops.qfileinfo = cvfs_qfileinfo;
    858         ops.fsinfo = cvfs_fsinfo;
    859         ops.lpq = cvfs_lpq;
    860         ops.search_first = cvfs_search_first;
    861         ops.search_next = cvfs_search_next;
    862         ops.search_close = cvfs_search_close;
    863         ops.trans = cvfs_trans;
    864         ops.logoff = cvfs_logoff;
    865         ops.async_setup = cvfs_async_setup;
    866         ops.cancel = cvfs_cancel;
    867         ops.notify = cvfs_notify;
     863        ops.connect_fn = cvfs_connect;
     864        ops.disconnect_fn = cvfs_disconnect;
     865        ops.unlink_fn = cvfs_unlink;
     866        ops.chkpath_fn = cvfs_chkpath;
     867        ops.qpathinfo_fn = cvfs_qpathinfo;
     868        ops.setpathinfo_fn = cvfs_setpathinfo;
     869        ops.open_fn = cvfs_open;
     870        ops.mkdir_fn = cvfs_mkdir;
     871        ops.rmdir_fn = cvfs_rmdir;
     872        ops.rename_fn = cvfs_rename;
     873        ops.copy_fn = cvfs_copy;
     874        ops.ioctl_fn = cvfs_ioctl;
     875        ops.read_fn = cvfs_read;
     876        ops.write_fn = cvfs_write;
     877        ops.seek_fn = cvfs_seek;
     878        ops.flush_fn = cvfs_flush;
     879        ops.close_fn = cvfs_close;
     880        ops.exit_fn = cvfs_exit;
     881        ops.lock_fn = cvfs_lock;
     882        ops.setfileinfo_fn = cvfs_setfileinfo;
     883        ops.qfileinfo_fn = cvfs_qfileinfo;
     884        ops.fsinfo_fn = cvfs_fsinfo;
     885        ops.lpq_fn = cvfs_lpq;
     886        ops.search_first_fn = cvfs_search_first;
     887        ops.search_next_fn = cvfs_search_next;
     888        ops.search_close_fn = cvfs_search_close;
     889        ops.trans_fn = cvfs_trans;
     890        ops.logoff_fn = cvfs_logoff;
     891        ops.async_setup_fn = cvfs_async_setup;
     892        ops.cancel_fn = cvfs_cancel;
     893        ops.notify_fn = cvfs_notify;
    868894
    869895        /* register ourselves with the NTVFS subsystem. We register
  • vendor/current/source4/ntvfs/sysdep/inotify.c

    r414 r988  
    3030#include "param/param.h"
    3131
    32 #if HAVE_SYS_INOTIFY_H
    3332#include <sys/inotify.h>
    34 #else
    35 /* for older glibc varients - we can remove this eventually */
    36 #include <linux/inotify.h>
    37 #include <asm/unistd.h>
    38 
    39 #ifndef HAVE_INOTIFY_INIT
    40 /*
    41   glibc doesn't define these functions yet (as of March 2006)
    42 */
    43 static int inotify_init(void)
    44 {
    45         return syscall(__NR_inotify_init);
    46 }
    47 
    48 static int inotify_add_watch(int fd, const char *path, __u32 mask)
    49 {
    50         return syscall(__NR_inotify_add_watch, fd, path, mask);
    51 }
    52 
    53 static int inotify_rm_watch(int fd, int wd)
    54 {
    55         return syscall(__NR_inotify_rm_watch, fd, wd);
    56 }
    57 #endif
    58 #endif
    59 
    60 
    61 /* older glibc headers don't have these defines either */
     33
     34/* glibc < 2.5 headers don't have these defines */
    6235#ifndef IN_ONLYDIR
    6336#define IN_ONLYDIR 0x01000000
     
    172145                next = w->next;
    173146                if (w->wd == e->wd && filter_match(w, e)) {
     147                        ne.dir = w->path;
    174148                        w->callback(in->ctx, w->private_data, &ne);
    175149                }
     
    191165                if (w->wd == e->wd && filter_match(w, e) &&
    192166                    !(w->filter & FILE_NOTIFY_CHANGE_CREATION)) {
     167                        ne.dir = w->path;
    193168                        w->callback(in->ctx, w->private_data, &ne);
    194169                }
     
    259234                DEBUG(0,("Failed to init inotify - %s\n", strerror(errno)));
    260235                talloc_free(in);
    261                 return map_nt_error_from_unix(errno);
     236                return map_nt_error_from_unix_common(errno);
    262237        }
    263238        in->ctx = ctx;
     
    275250                DEBUG(0,("Failed to tevent_add_fd() - %s\n", strerror(errno)));
    276251                talloc_free(in);
    277                 return map_nt_error_from_unix(errno);
     252                return map_nt_error_from_unix_common(errno);
    278253        }
    279254
     
    374349        if (wd == -1) {
    375350                e->filter = filter;
    376                 return map_nt_error_from_unix(errno);
     351                return map_nt_error_from_unix_common(errno);
    377352        }
    378353
     
    416391  initialialise the inotify module
    417392 */
     393NTSTATUS sys_notify_inotify_init(void);
    418394NTSTATUS sys_notify_inotify_init(void)
    419395{
  • vendor/current/source4/ntvfs/sysdep/sys_lease.c

    r740 r988  
    2828#include "../lib/util/dlinklist.h"
    2929#include "param/param.h"
     30#include "lib/util/samba_modules.h"
    3031
    3132/* list of registered backends */
     
    4142                                                            TALLOC_CTX *mem_ctx,
    4243                                                            struct tevent_context *ev,
    43                                                             struct messaging_context *msg,
     44                                                            struct imessaging_context *msg,
    4445                                                            sys_lease_send_break_fn break_send)
    4546{
     
    4849        int i;
    4950        NTSTATUS status;
     51        TALLOC_CTX * tmp_ctx;
    5052
    5153        if (num_backends == 0) {
     
    6264        }
    6365
     66        tmp_ctx = talloc_new(ctx);
     67        if (tmp_ctx == NULL) {
     68                return NULL;
     69        }
     70
    6471        ctx->event_ctx = ev;
    6572        ctx->msg_ctx = msg;
    6673        ctx->break_send = break_send;
    6774
    68         bname = share_string_option(scfg, LEASE_BACKEND, NULL);
     75        bname = share_string_option(tmp_ctx, scfg, LEASE_BACKEND, NULL);
    6976        if (!bname) {
    7077                talloc_free(ctx);
     
    9097        }
    9198
     99        TALLOC_FREE(tmp_ctx);
    92100        return ctx;
    93101}
  • vendor/current/source4/ntvfs/sysdep/sys_lease.h

    r414 r988  
    2222struct sys_lease_context;
    2323struct opendb_entry;
    24 struct messaging_context;
     24struct imessaging_context;
    2525struct tevent_context;
    2626
    27 typedef NTSTATUS (*sys_lease_send_break_fn)(struct messaging_context *,
     27typedef NTSTATUS (*sys_lease_send_break_fn)(struct imessaging_context *,
    2828                                            struct opendb_entry *,
    2929                                            uint8_t level);
     
    4242struct sys_lease_context {
    4343        struct tevent_context *event_ctx;
    44         struct messaging_context *msg_ctx;
     44        struct imessaging_context *msg_ctx;
    4545        sys_lease_send_break_fn break_send;
    4646        void *private_data; /* for use of backend */
     
    5454                                                   TALLOC_CTX *mem_ctx,
    5555                                                   struct tevent_context *ev,
    56                                                    struct messaging_context *msg_ctx,
     56                                                   struct imessaging_context *msg_ctx,
    5757                                                   sys_lease_send_break_fn break_send);
    5858
  • vendor/current/source4/ntvfs/sysdep/sys_lease_linux.c

    r414 r988  
    3030#include "../lib/util/dlinklist.h"
    3131#include "cluster/cluster.h"
     32
     33NTSTATUS sys_lease_linux_init(void);
    3234
    3335#define LINUX_LEASE_RT_SIGNAL (SIGRTMIN+1)
     
    130132        if (ret == -1) {
    131133                talloc_free(p);
    132                 return map_nt_error_from_unix(errno);
     134                return map_nt_error_from_unix_common(errno);
    133135        }
    134136
     
    136138        if (ret == -1) {
    137139                talloc_free(p);
    138                 return map_nt_error_from_unix(errno);
     140                return map_nt_error_from_unix_common(errno);
    139141        }
    140142
  • vendor/current/source4/ntvfs/sysdep/sys_notify.c

    r740 r988  
    2929#include "../lib/util/dlinklist.h"
    3030#include "param/param.h"
     31#include "lib/util/samba_modules.h"
    3132
    3233/* list of registered backends */
     
    6263        ctx->ev = ev;
    6364
    64         bname = share_string_option(scfg, NOTIFY_BACKEND, NULL);
     65        bname = share_string_option(ctx, scfg, NOTIFY_BACKEND, NULL);
    6566        if (!bname) {
    6667                if (num_backends) {
  • vendor/current/source4/ntvfs/sysdep/sys_notify.h

    r740 r988  
    1818*/
    1919
    20 #include "librpc/gen_ndr/s4_notify.h"
     20#include "librpc/gen_ndr/notify.h"
    2121#include "param/share.h"
    2222
  • vendor/current/source4/ntvfs/sysdep/wscript_build

    r740 r988  
    55                 subsystem='sys_notify',
    66                 init_function='sys_notify_inotify_init',
    7                  deps='events',
     7                 deps='events inotify',
    88                 enabled = bld.CONFIG_SET('HAVE_LINUX_INOTIFY')
    99                 )
  • vendor/current/source4/ntvfs/sysdep/wscript_configure

    r740 r988  
    11#!/usr/bin/env python
    22
    3 conf.CHECK_HEADERS('linux/inotify.h asm/unistd.h sys/inotify.h', add_headers=False)
     3import sys
    44
    5 conf.CHECK_FUNCS('inotify_init')
     5# Check for inotify support (Skip if we are SunOS)
     6#NOTE: illumos provides sys/inotify.h but is not an exact match for linux
     7host_os = sys.platform
     8if host_os.rfind('sunos') == -1:
     9    conf.CHECK_HEADERS('sys/inotify.h', add_headers=False)
     10    if (conf.CONFIG_SET('HAVE_SYS_INOTIFY_H')):
     11        conf.DEFINE('HAVE_LINUX_INOTIFY', 1)
    612
    7 conf.CHECK_VARIABLE('__NR_inotify_init')
    813conf.CHECK_DECLS('F_SETLEASE', headers='linux/fcntl.h', reverse=True)
    914conf.CHECK_DECLS('SA_SIGINFO', headers='signal.h', reverse=True)
    10 
    11 conf.CHECK_DECLS('__NR_inotify_init', reverse=True, headers='asm/unistd.h')
    12 
    13 if (conf.CONFIG_SET('HAVE___NR_INOTIFY_INIT') and
    14     (conf.CONFIG_SET('HAVE_LINUX_INOTIFY_H') or
    15      conf.CONFIG_SET('HAVE_SYS_INOTIFY_H'))):
    16     conf.DEFINE('HAVE_LINUX_INOTIFY', 1)
  • vendor/current/source4/ntvfs/unixuid/vfs_unixuid.c

    r740 r988  
    2929#define TEVENT_DEPRECATED
    3030#include <tevent.h>
    31 
    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 
     31#include "../lib/util/setid.h"
     32
     33NTSTATUS ntvfs_unixuid_init(void);
    4134
    4235struct unixuid_private {
    43         struct wbc_context *wbc_ctx;
    44         struct unix_sec_ctx *last_sec_ctx;
     36        struct security_unix_token *last_sec_ctx;
    4537        struct security_token *last_token;
    4638};
    4739
    4840
    49 
    50 struct unix_sec_ctx {
    51         uid_t uid;
    52         gid_t gid;
    53         unsigned int ngroups;
    54         gid_t *groups;
    55 };
    56 
    57 /*
    58   pull the current security context into a unix_sec_ctx
    59 */
    60 static struct unix_sec_ctx *save_unix_security(TALLOC_CTX *mem_ctx)
    61 {
    62         struct unix_sec_ctx *sec = talloc(mem_ctx, struct unix_sec_ctx);
     41/*
     42  pull the current security context into a security_unix_token
     43*/
     44static struct security_unix_token *save_unix_security(TALLOC_CTX *mem_ctx)
     45{
     46        struct security_unix_token *sec = talloc(mem_ctx, struct security_unix_token);
    6347        if (sec == NULL) {
    6448                return NULL;
     
    8670
    8771/*
    88   set the current security context from a unix_sec_ctx
    89 */
    90 static NTSTATUS set_unix_security(struct unix_sec_ctx *sec)
    91 {
    92         seteuid(0);
    93 
    94         if (setgroups(sec->ngroups, sec->groups) != 0) {
     72  set the current security context from a security_unix_token
     73*/
     74static NTSTATUS set_unix_security(struct security_unix_token *sec)
     75{
     76        samba_seteuid(0);
     77
     78        if (samba_setgroups(sec->ngroups, sec->groups) != 0) {
     79                DBG_ERR("*** samba_setgroups failed\n");
    9580                return NT_STATUS_ACCESS_DENIED;
    9681        }
    97         if (setegid(sec->gid) != 0) {
     82        if (samba_setegid(sec->gid) != 0) {
     83                DBG_ERR("*** samba_setegid(%u) failed\n", sec->gid);
    9884                return NT_STATUS_ACCESS_DENIED;
    9985        }
    100         if (seteuid(sec->uid) != 0) {
     86        if (samba_seteuid(sec->uid) != 0) {
     87                DBG_ERR("*** samba_seteuid(%u) failed\n", sec->uid);
    10188                return NT_STATUS_ACCESS_DENIED;
    10289        }
     
    117104                                      const char *location)
    118105{
    119         struct unix_sec_ctx *sec_ctx;
     106        struct security_unix_token *sec_ctx;
    120107
    121108        if (unixuid_nesting_level == 0) {
     
    131118                        return -1;
    132119                }
    133                 *(struct unix_sec_ctx **)stack_ptr = sec_ctx;
    134                 if (seteuid(0) != 0 || setegid(0) != 0) {
     120                *(struct security_unix_token **)stack_ptr = sec_ctx;
     121                if (samba_seteuid(0) != 0 || samba_setegid(0) != 0) {
    135122                        DEBUG(0,("%s: Failed to change to root\n", location));
    136123                        return -1;                     
     
    140127                NTSTATUS status;
    141128
    142                 sec_ctx = *(struct unix_sec_ctx **)stack_ptr;
     129                sec_ctx = *(struct security_unix_token **)stack_ptr;
    143130                if (sec_ctx == NULL) {
    144131                        /* this happens the first time this function
     
    148135                }
    149136
    150                 sec_ctx = talloc_get_type_abort(sec_ctx, struct unix_sec_ctx);
     137                sec_ctx = talloc_get_type_abort(sec_ctx, struct security_unix_token);
    151138                status = set_unix_security(sec_ctx);
    152139                talloc_free(sec_ctx);
     
    163150
    164151/*
    165   form a unix_sec_ctx from the current security_token
     152  form a security_unix_token from the current security_token
    166153*/
    167154static NTSTATUS nt_token_to_unix_security(struct ntvfs_module_context *ntvfs,
    168155                                          struct ntvfs_request *req,
    169156                                          struct security_token *token,
    170                                           struct unix_sec_ctx **sec)
    171 {
    172         struct unixuid_private *priv = ntvfs->private_data;
    173         int i;
    174         NTSTATUS status;
    175         struct id_map *ids;
    176         struct composite_context *ctx;
    177         *sec = talloc(req, struct unix_sec_ctx);
    178 
    179         /* we can't do unix security without a user and group */
    180         if (token->num_sids < 2) {
    181                 return NT_STATUS_ACCESS_DENIED;
    182         }
    183 
    184         ids = talloc_array(req, struct id_map, token->num_sids);
    185         NT_STATUS_HAVE_NO_MEMORY(ids);
    186 
    187         (*sec)->ngroups = token->num_sids - 2;
    188         (*sec)->groups = talloc_array(*sec, gid_t, (*sec)->ngroups);
    189         NT_STATUS_HAVE_NO_MEMORY((*sec)->groups);
    190 
    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;
    195         }
    196 
    197         ctx = wbc_sids_to_xids_send(priv->wbc_ctx, ids, token->num_sids, ids);
    198         NT_STATUS_HAVE_NO_MEMORY(ctx);
    199 
    200         status = wbc_sids_to_xids_recv(ctx, &ids);
    201         NT_STATUS_NOT_OK_RETURN(status);
    202 
    203         if (ids[0].xid.type == ID_TYPE_BOTH ||
    204             ids[0].xid.type == ID_TYPE_UID) {
    205                 (*sec)->uid = ids[0].xid.id;
    206         } else {
    207                 return NT_STATUS_INVALID_SID;
    208         }
    209 
    210         if (ids[1].xid.type == ID_TYPE_BOTH ||
    211             ids[1].xid.type == ID_TYPE_GID) {
    212                 (*sec)->gid = ids[1].xid.id;
    213         } else {
    214                 return NT_STATUS_INVALID_SID;
    215         }
    216 
    217         for (i=0;i<(*sec)->ngroups;i++) {
    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;
    221                 } else {
    222                         return NT_STATUS_INVALID_SID;
    223                 }
    224         }
    225 
    226         return NT_STATUS_OK;
     157                                          struct security_unix_token **sec)
     158{
     159        return security_token_to_unix_token(req,
     160                                            ntvfs->ctx->event_ctx,
     161                                            token, sec);
    227162}
    228163
     
    231166*/
    232167static NTSTATUS unixuid_setup_security(struct ntvfs_module_context *ntvfs,
    233                                        struct ntvfs_request *req, struct unix_sec_ctx **sec)
     168                                       struct ntvfs_request *req, struct security_unix_token **sec)
    234169{
    235170        struct unixuid_private *priv = ntvfs->private_data;
    236171        struct security_token *token;
    237         struct unix_sec_ctx *newsec;
     172        struct security_unix_token *newsec;
    238173        NTSTATUS status;
    239174
     
    282217#define PASS_THRU_REQ(ntvfs, req, op, args) do { \
    283218        NTSTATUS status2; \
    284         struct unix_sec_ctx *sec; \
     219        struct security_unix_token *sec; \
    285220        status = unixuid_setup_security(ntvfs, req, &sec); \
    286221        NT_STATUS_NOT_OK_RETURN(status); \
     
    309244        }
    310245
    311         priv->wbc_ctx = wbc_init(priv, ntvfs->ctx->msg_ctx,
    312                                     ntvfs->ctx->event_ctx);
    313         if (priv->wbc_ctx == NULL) {
    314                 talloc_free(priv);
    315                 return NT_STATUS_INTERNAL_ERROR;
    316         }
    317 
    318246        priv->last_sec_ctx = NULL;
    319247        priv->last_token = NULL;
     
    747675
    748676        /* fill in all the operations */
    749         ops.connect = unixuid_connect;
    750         ops.disconnect = unixuid_disconnect;
    751         ops.unlink = unixuid_unlink;
    752         ops.chkpath = unixuid_chkpath;
    753         ops.qpathinfo = unixuid_qpathinfo;
    754         ops.setpathinfo = unixuid_setpathinfo;
    755         ops.open = unixuid_open;
    756         ops.mkdir = unixuid_mkdir;
    757         ops.rmdir = unixuid_rmdir;
    758         ops.rename = unixuid_rename;
    759         ops.copy = unixuid_copy;
    760         ops.ioctl = unixuid_ioctl;
    761         ops.read = unixuid_read;
    762         ops.write = unixuid_write;
    763         ops.seek = unixuid_seek;
    764         ops.flush = unixuid_flush;     
    765         ops.close = unixuid_close;
    766         ops.exit = unixuid_exit;
    767         ops.lock = unixuid_lock;
    768         ops.setfileinfo = unixuid_setfileinfo;
    769         ops.qfileinfo = unixuid_qfileinfo;
    770         ops.fsinfo = unixuid_fsinfo;
    771         ops.lpq = unixuid_lpq;
    772         ops.search_first = unixuid_search_first;
    773         ops.search_next = unixuid_search_next;
    774         ops.search_close = unixuid_search_close;
    775         ops.trans = unixuid_trans;
    776         ops.logoff = unixuid_logoff;
    777         ops.async_setup = unixuid_async_setup;
    778         ops.cancel = unixuid_cancel;
    779         ops.notify = unixuid_notify;
     677        ops.connect_fn = unixuid_connect;
     678        ops.disconnect_fn = unixuid_disconnect;
     679        ops.unlink_fn = unixuid_unlink;
     680        ops.chkpath_fn = unixuid_chkpath;
     681        ops.qpathinfo_fn = unixuid_qpathinfo;
     682        ops.setpathinfo_fn = unixuid_setpathinfo;
     683        ops.open_fn = unixuid_open;
     684        ops.mkdir_fn = unixuid_mkdir;
     685        ops.rmdir_fn = unixuid_rmdir;
     686        ops.rename_fn = unixuid_rename;
     687        ops.copy_fn = unixuid_copy;
     688        ops.ioctl_fn = unixuid_ioctl;
     689        ops.read_fn = unixuid_read;
     690        ops.write_fn = unixuid_write;
     691        ops.seek_fn = unixuid_seek;
     692        ops.flush_fn = unixuid_flush;
     693        ops.close_fn = unixuid_close;
     694        ops.exit_fn = unixuid_exit;
     695        ops.lock_fn = unixuid_lock;
     696        ops.setfileinfo_fn = unixuid_setfileinfo;
     697        ops.qfileinfo_fn = unixuid_qfileinfo;
     698        ops.fsinfo_fn = unixuid_fsinfo;
     699        ops.lpq_fn = unixuid_lpq;
     700        ops.search_first_fn = unixuid_search_first;
     701        ops.search_next_fn = unixuid_search_next;
     702        ops.search_close_fn = unixuid_search_close;
     703        ops.trans_fn = unixuid_trans;
     704        ops.logoff_fn = unixuid_logoff;
     705        ops.async_setup_fn = unixuid_async_setup;
     706        ops.cancel_fn = unixuid_cancel;
     707        ops.notify_fn = unixuid_notify;
    780708
    781709        ops.name = "unixuid";
  • vendor/current/source4/ntvfs/unixuid/wscript_build

    r740 r988  
    55        subsystem='ntvfs',
    66        init_function='ntvfs_unixuid_init',
    7         deps='samdb'
     7        deps='auth_unix_token talloc'
    88        )
    99
  • vendor/current/source4/ntvfs/wscript_build

    r740 r988  
    11#!/usr/bin/env python
    22
    3 bld.RECURSE('posix')
    4 bld.RECURSE('common')
    5 bld.RECURSE('unixuid')
    6 bld.RECURSE('sysdep')
     3bld.SAMBA_LIBRARY('ntvfs',
     4                  source='ntvfs_base.c ntvfs_generic.c ntvfs_interface.c ntvfs_util.c',
     5                  autoproto='ntvfs_proto.h',
     6                  deps='tevent samba-modules',
     7                  private_library=True,
     8                  enabled=bld.AD_DC_BUILD_IS_ENABLED()
     9                  )
     10
     11if bld.AD_DC_BUILD_IS_ENABLED():
     12    bld.RECURSE('posix')
     13    bld.RECURSE('common')
     14    bld.RECURSE('unixuid')
     15    bld.RECURSE('sysdep')
    716
    817bld.SAMBA_MODULE('ntvfs_cifs',
     
    1019        subsystem='ntvfs',
    1120        init_function='ntvfs_cifs_init',
    12         deps='LIBCLI_SMB LIBCLI_RAW'
     21        deps='LIBCLI_SMB smbclient-raw param_options'
    1322        )
    1423
     
    1827        subsystem='ntvfs',
    1928        init_function='ntvfs_smb2_init',
    20         deps='LIBCLI_SMB LIBCLI_RAW'
     29        deps='LIBCLI_SMB smbclient-raw param_options'
    2130        )
    2231
     
    5362        subsystem='ntvfs',
    5463        init_function='ntvfs_ipc_init',
    55         deps='NDR_NAMED_PIPE_AUTH NAMED_PIPE_AUTH_TSTREAM gssapi credentials DCERPC_SHARE'
     64        deps='NDR_NAMED_PIPE_AUTH npa_tstream gssapi samba-credentials DCERPC_SHARE'
    5665        )
    5766
     
    6574
    6675
    67 bld.SAMBA_LIBRARY('ntvfs',
    68                   source='ntvfs_base.c ntvfs_generic.c ntvfs_interface.c ntvfs_util.c',
    69                   autoproto='ntvfs_proto.h',
    70                   deps='tevent',
    71                   private_library=True
    72                   )
    73 
Note: See TracChangeset for help on using the changeset viewer.