Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
1 deleted
17 edited
9 copied

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/torture/cmd_vfs.c

    r414 r745  
    2121
    2222#include "includes.h"
     23#include "smbd/smbd.h"
     24#include "system/passwd.h"
     25#include "system/filesys.h"
    2326#include "vfstest.h"
     27#include "../lib/util/util_pw.h"
    2428
    2529static const char *null_string = "";
     
    11291133static NTSTATUS cmd_realpath(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv)
    11301134{
    1131         char respath[PATH_MAX];
    1132        
    11331135        if (argc != 2) {
    11341136                printf("Usage: realpath <path>\n");
     
    11361138        }
    11371139
    1138         if (SMB_VFS_REALPATH(vfs->conn, argv[1], respath) == NULL) {
     1140        if (SMB_VFS_REALPATH(vfs->conn, argv[1]) == NULL) {
    11391141                printf("realpath: error=%d (%s)\n", errno, strerror(errno));
    11401142                return NT_STATUS_UNSUCCESSFUL;
  • trunk/server/source3/torture/denytest.c

    r414 r745  
    1919
    2020#include "includes.h"
     21#include "system/filesys.h"
     22#include "torture/proto.h"
     23#include "libsmb/libsmb.h"
    2124
    2225extern bool torture_showall;
     
    14201423
    14211424        for (i=0;i<2;i++) {
    1422                 cli_unlink(cli1, fnames[i], aSYSTEM | aHIDDEN);
     1425                cli_unlink(cli1, fnames[i], FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    14231426                cli_open(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE, &fnum1);
    1424                 cli_write(cli1, fnum1, 0, fnames[i], 0, strlen(fnames[i]));
     1427                cli_writeall(cli1, fnum1, 0, (uint8_t *)fnames[i], 0,
     1428                             strlen(fnames[i]), NULL);
    14251429                cli_close(cli1, fnum1);
    14261430        }
     
    14511455                                res += A_R;
    14521456                        }
    1453                         if (cli_write(cli1, fnum2, 0, (char *)&x, 0, 1) == 1) {
     1457                        if (NT_STATUS_IS_OK(cli_writeall(cli1, fnum2, 0,
     1458                                                         (uint8_t *)&x, 0, 1,
     1459                                                         NULL))) {
    14541460                                res += A_W;
    14551461                        }
     
    14801486
    14811487        for (i=0;i<2;i++) {
    1482                 cli_unlink(cli1, fnames[i], aSYSTEM | aHIDDEN);
     1488                cli_unlink(cli1, fnames[i], FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    14831489        }
    14841490               
     
    15111517
    15121518        for (i=0;i<2;i++) {
    1513                 cli_unlink(cli1, fnames[i], aSYSTEM | aHIDDEN);
     1519                cli_unlink(cli1, fnames[i], FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    15141520                cli_open(cli1, fnames[i], O_RDWR|O_CREAT, DENY_NONE, &fnum1);
    1515                 cli_write(cli1, fnum1, 0, fnames[i], 0, strlen(fnames[i]));
     1521                cli_writeall(cli1, fnum1, 0, (uint8_t *)fnames[i], 0,
     1522                             strlen(fnames[i]), NULL);
    15161523                cli_close(cli1, fnum1);
    15171524        }
     
    15401547                                res += A_R;
    15411548                        }
    1542                         if (cli_write(cli2, fnum2, 0, (char *)&x, 0, 1) == 1) {
     1549                        if (NT_STATUS_IS_OK(cli_writeall(cli2, fnum2, 0,
     1550                                                         (uint8_t *)&x, 0, 1,
     1551                                                         NULL))) {
    15431552                                res += A_W;
    15441553                        }
     
    15691578               
    15701579        for (i=0;i<2;i++) {
    1571                 cli_unlink(cli1, fnames[i], aSYSTEM | aHIDDEN);
     1580                cli_unlink(cli1, fnames[i], FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    15721581        }
    15731582
  • trunk/server/source3/torture/locktest.c

    r414 r745  
    1919
    2020#include "includes.h"
     21#include "libsmb/libsmb.h"
     22#include "system/filesys.h"
     23#include "locking/proto.h"
     24#include "libsmb/nmblib.h"
    2125
    2226static fstring password[2];
     
    234238        }
    235239
    236         if (!NT_STATUS_IS_OK(cli_session_setup(c, username[snum],
    237                                                password[snum],
    238                                                strlen(password[snum]),
    239                                                password[snum],
    240                                                strlen(password[snum]),
    241                                                lp_workgroup()))) {
    242                 DEBUG(0,("session setup failed: %s\n", cli_errstr(c)));
     240        status = cli_session_setup(c, username[snum],
     241                                   password[snum], strlen(password[snum]),
     242                                   password[snum], strlen(password[snum]),
     243                                   lp_workgroup());
     244        if (!NT_STATUS_IS_OK(status)) {
     245                DEBUG(0,("session setup failed: %s\n", nt_errstr(status)));
    243246                return NULL;
    244247        }
     
    399402        }
    400403        for (server=0;server<NSERVERS;server++) {
    401                 cli_unlink(cli[server][0], FILENAME, aSYSTEM | aHIDDEN);
     404                cli_unlink(cli[server][0], FILENAME, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    402405        }
    403406}
     
    605608        load_case_tables();
    606609
    607         dbf = x_stderr;
    608 
    609610        if (argc < 3 || argv[1][0] == '-') {
    610611                usage();
     
    612613        }
    613614
    614         setup_logging(argv[0],True);
     615        setup_logging(argv[0], DEBUG_STDOUT);
    615616
    616617        for (server=0;server<NSERVERS;server++) {
  • trunk/server/source3/torture/locktest2.c

    r414 r745  
    1919
    2020#include "includes.h"
     21#include "libsmb/libsmb.h"
     22#include "system/filesys.h"
     23#include "locking/proto.h"
    2124
    2225static fstring password;
     
    191194        nt_status = cli_full_connection(&c, myname, server_n, NULL, 0, share, "?????",
    192195                                        username, lp_workgroup(), password, 0,
    193                                         Undefined, NULL);
     196                                        Undefined);
    194197
    195198        if (!NT_STATUS_IS_OK(nt_status)) {
     
    324327        }
    325328        for (server=0;server<NSERVERS;server++) {
    326                 cli_unlink(cli[server][0], FILENAME, aSYSTEM | aHIDDEN);
     329                cli_unlink(cli[server][0], FILENAME, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    327330        }
    328331}
     
    492495        setlinebuf(stdout);
    493496
    494         dbf = x_stderr;
    495 
    496497        if (argc < 5 || argv[1][0] == '-') {
    497498                usage();
    498499                exit(1);
    499500        }
     501
     502        setup_logging(argv[0], DEBUG_STDOUT);
    500503
    501504        share1 = argv[1];
     
    506509        all_string_sub(share1,"/","\\",0);
    507510        all_string_sub(share2,"/","\\",0);
    508 
    509         setup_logging(argv[0],True);
    510511
    511512        argc -= 4;
  • trunk/server/source3/torture/mangle_test.c

    r414 r745  
    1919
    2020#include "includes.h"
     21#include "system/filesys.h"
     22#include "torture/proto.h"
     23#include "libsmb/libsmb.h"
     24#include "libsmb/clirap.h"
     25#include "util_tdb.h"
    2126
    2227extern int torture_numops;
     
    5661
    5762        fstr_sprintf(name2, "\\mangle_test\\%s", shortname);
    58         if (!NT_STATUS_IS_OK(cli_unlink(cli, name2, aSYSTEM | aHIDDEN))) {
     63        if (!NT_STATUS_IS_OK(cli_unlink(cli, name2, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) {
    5964                printf("unlink of %s  (%s) failed (%s)\n",
    6065                       name2, name, cli_errstr(cli));
     
    7378
    7479        /* and unlink by long name */
    75         if (!NT_STATUS_IS_OK(cli_unlink(cli, name, aSYSTEM | aHIDDEN))) {
     80        if (!NT_STATUS_IS_OK(cli_unlink(cli, name, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) {
    7681                printf("unlink2 of %s  (%s) failed (%s)\n",
    7782                       name, name2, cli_errstr(cli));
    7883                failures++;
    79                 cli_unlink(cli, name2, aSYSTEM | aHIDDEN);
     84                cli_unlink(cli, name2, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    8085                return True;
    8186        }
     
    176181        }
    177182
    178         cli_unlink(cli, "\\mangle_test\\*", aSYSTEM | aHIDDEN);
     183        cli_unlink(cli, "\\mangle_test\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    179184        cli_rmdir(cli, "\\mangle_test");
    180185
     
    200205        }
    201206
    202         cli_unlink(cli, "\\mangle_test\\*", aSYSTEM | aHIDDEN);
     207        cli_unlink(cli, "\\mangle_test\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    203208        if (!NT_STATUS_IS_OK(cli_rmdir(cli, "\\mangle_test"))) {
    204209                printf("ERROR: Failed to remove directory\n");
  • trunk/server/source3/torture/masktest.c

    r414 r745  
    1919
    2020#include "includes.h"
     21#include "system/filesys.h"
     22#include "trans2.h"
     23#include "libsmb/libsmb.h"
     24#include "libsmb/nmblib.h"
    2125
    2226static fstring password;
     
    3539extern char *optarg;
    3640extern int optind;
    37 extern bool AllowDebugChange;
    3841
    3942/* a test fn for LANMAN mask support */
     
    228231        }
    229232
    230         if (!NT_STATUS_IS_OK(cli_session_setup(c, username,
    231                                                password, strlen(password),
    232                                                password, strlen(password),
    233                                                lp_workgroup()))) {
    234                 DEBUG(0,("session setup failed: %s\n", cli_errstr(c)));
     233        status = cli_session_setup(c, username,
     234                                   password, strlen(password),
     235                                   password, strlen(password),
     236                                   lp_workgroup());
     237        if (!NT_STATUS_IS_OK(status)) {
     238                DEBUG(0, ("session setup failed: %s\n", nt_errstr(status)));
    235239                return NULL;
    236240        }
     
    264268
    265269static char *resultp;
    266 static file_info *f_info;
    267 
    268 static void listfn(const char *mnt, file_info *f, const char *s, void *state)
    269 {
     270
     271struct rn_state {
     272        char **pp_long_name;
     273        char *short_name;
     274};
     275
     276static NTSTATUS listfn(const char *mnt, struct file_info *f, const char *s,
     277                   void *private_data)
     278{
     279        struct rn_state *state = (struct rn_state *)private_data;
    270280        if (strcmp(f->name,".") == 0) {
    271281                resultp[0] = '+';
     
    275285                resultp[2] = '+';
    276286        }
    277         f_info = f;
     287
     288        if (state == NULL) {
     289                return NT_STATUS_INTERNAL_ERROR;
     290        }
     291
     292        if (ISDOT(f->name) || ISDOTDOT(f->name))  {
     293                return NT_STATUS_OK;
     294        }
     295
     296        fstrcpy(state->short_name, f->short_name);
     297        strlower_m(state->short_name);
     298        *state->pp_long_name = SMB_STRDUP(f->name);
     299        if (!*state->pp_long_name) {
     300                return NT_STATUS_NO_MEMORY;
     301        }
     302        strlower_m(*state->pp_long_name);
     303        return NT_STATUS_OK;
    278304}
    279305
     
    281307                          char **pp_long_name, fstring short_name)
    282308{
     309        struct rn_state state;
     310
     311        state.pp_long_name = pp_long_name;
     312        state.short_name = short_name;
     313
    283314        *pp_long_name = NULL;
    284315        /* nasty hack to force level 260 listings - tridge */
    285         cli->capabilities |= CAP_NT_SMBS;
    286316        if (max_protocol <= PROTOCOL_LANMAN1) {
    287                 cli_list_new(cli, "\\masktest\\*.*", aHIDDEN | aDIR, listfn, NULL);
     317                cli_list_trans(cli, "\\masktest\\*.*", FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY,
     318                               SMB_FIND_FILE_BOTH_DIRECTORY_INFO, listfn,
     319                               &state);
    288320        } else {
    289                 cli_list_new(cli, "\\masktest\\*", aHIDDEN | aDIR, listfn, NULL);
    290         }
    291         if (f_info) {
    292                 fstrcpy(short_name, f_info->short_name);
    293                 strlower_m(short_name);
    294                 *pp_long_name = SMB_STRDUP(f_info->name);
    295                 if (!*pp_long_name) {
    296                         return;
    297                 }
    298                 strlower_m(*pp_long_name);
     321                cli_list_trans(cli, "\\masktest\\*", FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY,
     322                               SMB_FIND_FILE_BOTH_DIRECTORY_INFO,
     323                               listfn, &state);
    299324        }
    300325
     
    331356        resultp = res1;
    332357        fstrcpy(short_name, "");
    333         f_info = NULL;
    334358        get_real_name(cli, &long_name, short_name);
    335359        if (!long_name) {
    336360                return;
    337361        }
    338         f_info = NULL;
    339362        fstrcpy(res1, "---");
    340         cli_list(cli, mask, aHIDDEN | aDIR, listfn, NULL);
     363        cli_list(cli, mask, FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY, listfn, NULL);
    341364
    342365        res2 = reg_test(cli, mask, long_name, short_name);
     
    350373        }
    351374
    352         cli_unlink(cli, file, aSYSTEM | aHIDDEN);
     375        cli_unlink(cli, file, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    353376
    354377        if (count % 100 == 0) DEBUG(0,("%d\n", count));
     
    367390        cli_mkdir(cli, "\\masktest");
    368391
    369         cli_unlink(cli, "\\masktest\\*", aSYSTEM | aHIDDEN);
     392        cli_unlink(cli, "\\masktest\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    370393
    371394        if (argc >= 2) {
     
    466489        setlinebuf(stdout);
    467490
    468         dbf = x_stderr;
    469 
    470         DEBUGLEVEL = 0;
    471         AllowDebugChange = False;
     491        lp_set_cmdline("log level", "0");
    472492
    473493        if (argc < 2 || argv[1][0] == '-') {
     
    480500        all_string_sub(share,"/","\\",0);
    481501
    482         setup_logging(argv[0],True);
     502        setup_logging(argv[0], DEBUG_STDERR);
    483503
    484504        argc -= 1;
    485505        argv += 1;
    486506
     507        load_case_tables();
    487508        lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
    488509        load_interfaces();
     
    500521                        break;
    501522                case 'd':
    502                         DEBUGLEVEL = atoi(optarg);
     523                        lp_set_cmdline("log level", optarg);
    503524                        break;
    504525                case 'E':
  • trunk/server/source3/torture/msgtest.c

    r414 r745  
    22   Unix SMB/CIFS implementation.
    33   Copyright (C) Andrew Tridgell 2000
    4    
     4
    55   This program is free software; you can redistribute it and/or modify
    66   it under the terms of the GNU General Public License as published by
    77   the Free Software Foundation; either version 3 of the License, or
    88   (at your option) any later version.
    9    
     9
    1010   This program is distributed in the hope that it will be useful,
    1111   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1212   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1313   GNU General Public License for more details.
    14    
     14
    1515   You should have received a copy of the GNU General Public License
    1616   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    2222
    2323#include "includes.h"
     24#include "messages.h"
    2425
    2526static int pong_count;
     
    4950        load_case_tables();
    5051
    51         setup_logging(argv[0],True);
    52        
     52        setup_logging(argv[0], DEBUG_STDOUT);
     53
    5354        lp_load(get_dyn_CONFIGFILE(),False,False,False,True);
    5455
    5556        if (!(evt_ctx = tevent_context_init(NULL)) ||
    56             !(msg_ctx = messaging_init(NULL, server_id_self(), evt_ctx))) {
     57            !(msg_ctx = messaging_init(NULL, procid_self(), evt_ctx))) {
    5758                fprintf(stderr, "could not init messaging context\n");
    5859                exit(1);
    5960        }
    60        
     61
    6162        if (argc != 3) {
    6263                fprintf(stderr, "%s: Usage - %s pid count\n", argv[0],
     
    8889
    8990        for (i=0;i<n;i++) {
    90                 messaging_send(msg_ctx, pid_to_procid(getpid()), MSG_PING,
     91                messaging_send(msg_ctx, messaging_server_id(msg_ctx), MSG_PING,
    9192                               &data_blob_null);
    92                 messaging_send_buf(msg_ctx, pid_to_procid(getpid()), MSG_PING,
    93                                    (uint8 *)buf, 11);
     93                messaging_send_buf(msg_ctx, messaging_server_id(msg_ctx),
     94                                   MSG_PING,(uint8 *)buf, 11);
    9495        }
    9596
     
    133134                        }
    134135                }
    135                
     136
    136137                printf("waiting for %d remaining replies (done %d)\n",
    137138                       (int)(ping_count - pong_count), pong_count);
     
    142143                        }
    143144                }
    144                
     145
    145146                if (ping_count != pong_count) {
    146147                        fprintf(stderr, "ping test failed! received %d, sent "
    147148                                "%d\n", pong_count, (int)ping_count);
    148149                }
    149                
     150
    150151                printf("ping rate of %.0f messages/sec\n",
    151152                       (ping_count+pong_count)/timeval_elapsed(&tv));
  • trunk/server/source3/torture/nbio.c

    r414 r745  
    2121
    2222#include "includes.h"
     23#include "torture/proto.h"
     24#include "../libcli/security/security.h"
     25#include "libsmb/libsmb.h"
     26#include "libsmb/clirap.h"
    2327
    2428#define MAX_FILES 1000
     
    2832extern int nbio_id;
    2933static int nprocs;
     34static struct timeval nb_start;
    3035
    3136static struct {
     
    6166        }
    6267
    63         printf("%4d  %8d  %.2f MB/sec\r", num_clients, lines/nprocs, 1.0e-6 * nbio_total() / end_timer());
     68        printf("%4d  %8d  %.2f MB/sec\r",
     69               num_clients, lines/nprocs,
     70               1.0e-6 * nbio_total() / timeval_elapsed(&nb_start));
    6471
    6572        signal(SIGALRM, nb_alarm);
     
    122129        signal(SIGSEGV, sigsegv);
    123130        c = cli;
    124         start_timer();
     131        nb_start = timeval_current();
    125132        children[nbio_id].done = 0;
    126133}
     
    129136void nb_unlink(const char *fname)
    130137{
    131         if (!NT_STATUS_IS_OK(cli_unlink(c, fname, aSYSTEM | aHIDDEN))) {
     138        if (!NT_STATUS_IS_OK(cli_unlink(c, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) {
    132139#if NBDEBUG
    133140                printf("(%d) unlink %s failed (%s)\n",
     
    184191{
    185192        int i;
     193        NTSTATUS status;
    186194
    187195        if (buf[0] == 0) memset(buf, 1, sizeof(buf));
    188196
    189197        i = find_handle(handle);
    190         if (cli_write(c, ftable[i].fd, 0, buf, offset, size) != ret_size) {
    191                 printf("(%d) ERROR: write failed on handle %d, fd %d \
    192 errno %d (%s)\n", line_count, handle, ftable[i].fd, errno, strerror(errno));
     198        status = cli_writeall(c, ftable[i].fd, 0, (uint8_t *)buf, offset, size,
     199                              NULL);
     200        if (!NT_STATUS_IS_OK(status)) {
     201                printf("(%d) ERROR: write failed on handle %d, fd %d "
     202                       "error %s\n", line_count, handle, ftable[i].fd,
     203                       nt_errstr(status));
    193204                exit(1);
    194205        }
     
    242253void nb_qpathinfo(const char *fname)
    243254{
    244         cli_qpathinfo(c, fname, NULL, NULL, NULL, NULL, NULL);
     255        cli_qpathinfo1(c, fname, NULL, NULL, NULL, NULL, NULL);
    245256}
    246257
     
    249260        int i;
    250261        i = find_handle(fnum);
    251         cli_qfileinfo(c, ftable[i].fd, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
     262        cli_qfileinfo_basic(c, ftable[i].fd, NULL, NULL, NULL, NULL, NULL,
     263                            NULL, NULL);
    252264}
    253265
     
    259271}
    260272
    261 static void find_fn(const char *mnt, file_info *finfo, const char *name, void *state)
     273static NTSTATUS find_fn(const char *mnt, struct file_info *finfo, const char *name,
     274                    void *state)
    262275{
    263276        /* noop */
     277        return NT_STATUS_OK;
    264278}
    265279
     
    278292static int total_deleted;
    279293
    280 static void delete_fn(const char *mnt, file_info *finfo, const char *name, void *state)
    281 {
     294static NTSTATUS delete_fn(const char *mnt, struct file_info *finfo,
     295                      const char *name, void *state)
     296{
     297        NTSTATUS status;
    282298        char *s, *n;
    283         if (finfo->name[0] == '.') return;
     299        if (finfo->name[0] == '.') {
     300                return NT_STATUS_OK;
     301        }
    284302
    285303        n = SMB_STRDUP(name);
     
    287305        if (asprintf(&s, "%s%s", n, finfo->name) == -1) {
    288306                printf("asprintf failed\n");
    289                 return;
    290         }
    291         if (finfo->mode & aDIR) {
     307                return NT_STATUS_NO_MEMORY;
     308        }
     309        if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
    292310                char *s2;
    293311                if (asprintf(&s2, "%s\\*", s) == -1) {
    294312                        printf("asprintf failed\n");
    295                         return;
     313                        return NT_STATUS_NO_MEMORY;
    296314                }
    297                 cli_list(c, s2, aDIR, delete_fn, NULL);
     315                status = cli_list(c, s2, FILE_ATTRIBUTE_DIRECTORY, delete_fn, NULL);
     316                if (!NT_STATUS_IS_OK(status)) {
     317                        free(n);
     318                        free(s2);
     319                        return status;
     320                }
    298321                nb_rmdir(s);
    299322        } else {
     
    303326        free(s);
    304327        free(n);
     328        return NT_STATUS_OK;
    305329}
    306330
     
    314338
    315339        total_deleted = 0;
    316         cli_list(c, mask, aDIR, delete_fn, NULL);
     340        cli_list(c, mask, FILE_ATTRIBUTE_DIRECTORY, delete_fn, NULL);
    317341        free(mask);
    318342        cli_rmdir(c, dname);
  • trunk/server/source3/torture/pdbtest.c

    r596 r745  
    2222
    2323#include "includes.h"
     24#include "popt_common.h"
     25#include "passdb.h"
    2426
    2527static bool samu_correct(struct samu *s1, struct samu *s2)
     
    248250        load_case_tables();
    249251
    250         pc = poptGetContext("vfstest", argc, (const char **) argv,
     252        pc = poptGetContext("pdbtest", argc, (const char **) argv,
    251253                            long_options, 0);
    252254
     
    259261        /* Load configuration */
    260262        lp_load(get_dyn_CONFIGFILE(), False, False, True, True);
    261         setup_logging("pdbtest", True);
     263        setup_logging("pdbtest", DEBUG_STDOUT);
    262264
    263265        if (backend == NULL) {
  • trunk/server/source3/torture/rpc_open_tcp.c

    r414 r745  
    2020
    2121#include "includes.h"
    22 
     22#include "rpc_client/cli_pipe.h"
    2323#include "librpc/gen_ndr/ndr_dfs.h"
    2424#include "librpc/gen_ndr/ndr_drsuapi.h"
  • trunk/server/source3/torture/scanner.c

    r414 r745  
    33   SMB torture tester - scanning functions
    44   Copyright (C) Andrew Tridgell 2001
    5    
     5
    66   This program is free software; you can redistribute it and/or modify
    77   it under the terms of the GNU General Public License as published by
    88   the Free Software Foundation; either version 3 of the License, or
    99   (at your option) any later version.
    10    
     10
    1111   This program is distributed in the hope that it will be useful,
    1212   but WITHOUT ANY WARRANTY; without even the implied warranty of
    1313   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1414   GNU General Public License for more details.
    15    
     15
    1616   You should have received a copy of the GNU General Public License
    1717   along with this program.  If not, see <http://www.gnu.org/licenses/>.
     
    1919
    2020#include "includes.h"
     21#include "system/filesys.h"
     22#include "torture/proto.h"
     23#include "libsmb/libsmb.h"
    2124
    2225#define VERBOSE 0
     
    5053static NTSTATUS try_trans2(struct cli_state *cli,
    5154                         int op,
    52                          char *param, char *data,
    53                          int param_len, int data_len,
    54                          unsigned int *rparam_len, unsigned int *rdata_len)
    55 {
    56         uint16 setup = op;
    57         char *rparam=NULL, *rdata=NULL;
    58 
    59         if (!cli_send_trans(cli, SMBtrans2,
    60                             NULL,                           /* name */
    61                             -1, 0,                          /* fid, flags */
    62                             &setup, 1, 0,                   /* setup, length, max */
    63                             param, param_len, 2,            /* param, length, max */
    64                             data, data_len, cli->max_xmit   /* data, length, max */
    65                            )) {
    66                 return cli_nt_error(cli);
    67         }
    68 
    69         cli_receive_trans(cli, SMBtrans2,
    70                            &rparam, rparam_len,
    71                            &rdata, rdata_len);
    72 
    73         SAFE_FREE(rdata);
    74         SAFE_FREE(rparam);
    75 
    76         return cli_nt_error(cli);
     55                         uint8_t *param, uint8_t *data,
     56                         uint32_t param_len, uint32_t data_len,
     57                         uint32_t *rparam_len, uint32_t *rdata_len)
     58{
     59        uint16_t setup[1];
     60        uint8_t *rparam=NULL, *rdata=NULL;
     61        NTSTATUS status;
     62
     63        SSVAL(setup+0, 0, op);
     64
     65        status = cli_trans(talloc_tos(), cli, SMBtrans2,
     66                           NULL, -1, /* name, fid */
     67                           op, 0,
     68                           NULL, 0, 0, /* setup */
     69                           param, param_len, 2,
     70                           data, data_len, cli->max_xmit,
     71                           NULL,                /* recv_flags2 */
     72                           NULL, 0, NULL,       /* rsetup */
     73                           &rparam, 0, rparam_len,
     74                           &rdata, 0, rdata_len);
     75
     76        TALLOC_FREE(rdata);
     77        TALLOC_FREE(rparam);
     78
     79        return status;
    7780}
    7881
     
    8184                             const char *format,
    8285                             int op, int level,
    83                              char *param, char *data,
    84                              int param_len, int *data_len,
    85                              unsigned int *rparam_len, unsigned int *rdata_len)
     86                             uint8_t *param, uint8_t *data,
     87                             uint32_t param_len, uint32_t *data_len,
     88                             uint32_t *rparam_len, uint32_t *rdata_len)
    8689{
    8790        NTSTATUS ret=NT_STATUS_OK;
     
    116119                        int fnum, int dnum, const char *fname)
    117120{
    118         int data_len = 0;
    119         int param_len = 0;
    120         unsigned int rparam_len, rdata_len;
    121         char param[PARAM_SIZE], data[DATA_SIZE];
     121        uint32_t data_len = 0;
     122        uint32_t param_len = 0;
     123        uint32_t rparam_len, rdata_len;
     124        uint8_t param[PARAM_SIZE], data[DATA_SIZE];
    122125        NTSTATUS status;
    123126
     
    171174        status = try_trans2_len(cli, "newfile", op, level, param, data, param_len, &data_len,
    172175                                &rparam_len, &rdata_len);
    173         cli_unlink(cli, "\\newfile.dat", aSYSTEM | aHIDDEN);
     176        cli_unlink(cli, "\\newfile.dat", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    174177        cli_rmdir(cli, "\\newfile.dat");
    175178        if (NT_STATUS_IS_OK(status)) return True;
     
    259262****************************************************************************/
    260263static NTSTATUS try_nttrans(struct cli_state *cli,
    261                          int op,
    262                          char *param, char *data,
    263                          int param_len, int data_len,
    264                          unsigned int *rparam_len, unsigned int *rdata_len)
    265 {
    266         char *rparam=NULL, *rdata=NULL;
    267 
    268         if (!cli_send_nt_trans(cli, op,
    269                                0,   
    270                                NULL, 0, 0,
    271                                param, param_len, 2,            /* param, length, max */
    272                                data, data_len, cli->max_xmit   /* data, length, max */
    273                            )) {
    274                 return cli_nt_error(cli);
    275         }
    276 
    277         cli_receive_nt_trans(cli,
    278                              &rparam, rparam_len,
    279                              &rdata, rdata_len);
    280 
     264                            int op,
     265                            uint8_t *param, uint8_t *data,
     266                            int32_t param_len, uint32_t data_len,
     267                            uint32_t *rparam_len,
     268                            uint32_t *rdata_len)
     269{
     270        uint8_t *rparam=NULL, *rdata=NULL;
     271        NTSTATUS status;
     272
     273        status = cli_trans(talloc_tos(), cli, SMBnttrans,
     274                           NULL, -1, /* name, fid */
     275                           op, 0,
     276                           NULL, 0, 0, /* setup */
     277                           param, param_len, 2,
     278                           data, data_len, cli->max_xmit,
     279                           NULL,                /* recv_flags2 */
     280                           NULL, 0, NULL,       /* rsetup */
     281                           &rparam, 0, rparam_len,
     282                           &rdata, 0, rdata_len);
    281283        SAFE_FREE(rdata);
    282284        SAFE_FREE(rparam);
    283285
    284         return cli_nt_error(cli);
     286        return status;
    285287}
    286288
     
    289291                             const char *format,
    290292                             int op, int level,
    291                              char *param, char *data,
    292                              int param_len, int *data_len,
    293                              unsigned int *rparam_len, unsigned int *rdata_len)
     293                             uint8_t *param, uint8_t *data,
     294                             int param_len, uint32_t *data_len,
     295                             uint32_t *rparam_len, uint32_t *rdata_len)
    294296{
    295297        NTSTATUS ret=NT_STATUS_OK;
     
    324326                        int fnum, int dnum, const char *fname)
    325327{
    326         int data_len = 0;
    327         int param_len = 0;
    328         unsigned int rparam_len, rdata_len;
    329         char param[PARAM_SIZE], data[DATA_SIZE];
     328        uint32_t data_len = 0;
     329        uint32_t param_len = 0;
     330        uint32_t rparam_len, rdata_len;
     331        uint8_t param[PARAM_SIZE], data[DATA_SIZE];
    330332        NTSTATUS status;
    331333
     
    379381        status = try_nttrans_len(cli, "newfile", op, level, param, data, param_len, &data_len,
    380382                                &rparam_len, &rdata_len);
    381         cli_unlink(cli, "\\newfile.dat", aSYSTEM | aHIDDEN);
     383        cli_unlink(cli, "\\newfile.dat", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    382384        cli_rmdir(cli, "\\newfile.dat");
    383385        if (NT_STATUS_IS_OK(status)) return True;
  • trunk/server/source3/torture/smbiconv.c

    r414 r745  
    2222
    2323#include "includes.h"
     24#include "system/filesys.h"
     25#include "popt_common.h"
    2426#undef realloc
    2527
     
    201203        /* the following functions are part of the Samba debugging
    202204           facilities.  See lib/debug.c */
    203         setup_logging("smbiconv", True);
     205        setup_logging("smbiconv", DEBUG_STDOUT);
    204206
    205207        if (preload_modules[0]) smb_load_modules(preload_modules);
  • trunk/server/source3/torture/t_stringoverflow.c

    r414 r745  
    33 int main(void)
    44{
    5         fstring dest;
     5        char dest[100];
    66        char *ptr = dest;
    77
     
    1818#endif /* 0 */
    1919
    20         pstrcpy(ptr, "hello!");
     20        fstrcpy(ptr, "hello!");
    2121
    2222        return 0;
  • trunk/server/source3/torture/torture.c

    r454 r745  
    2020
    2121#include "includes.h"
    22 #include "nsswitch/libwbclient/wbc_async.h"
     22#include "system/shmem.h"
     23#include "wbc_async.h"
     24#include "torture/proto.h"
     25#include "libcli/security/security.h"
     26#include "tldap.h"
     27#include "tldap_util.h"
     28#include "../librpc/gen_ndr/svcctl.h"
     29#include "memcache.h"
     30#include "nsswitch/winbind_client.h"
     31#include "dbwrap.h"
     32#include "talloc_dict.h"
     33#include "async_smb.h"
     34#include "libsmb/libsmb.h"
     35#include "libsmb/clirap.h"
     36#include "trans2.h"
     37#include "libsmb/nmblib.h"
     38#include "../lib/util/tevent_ntstatus.h"
     39#include "util_tdb.h"
    2340
    2441extern char *optarg;
     
    4360static bool do_encrypt;
    4461static const char *local_path = NULL;
     62static int signing_state = Undefined;
    4563
    4664bool torture_showall = False;
    4765
    4866static double create_procs(bool (*fn)(int), bool *result);
    49 
    50 
    51 static struct timeval tp1,tp2;
    52 
    53 
    54 void start_timer(void)
    55 {
    56         GetTimeOfDay(&tp1);
    57 }
    58 
    59 double end_timer(void)
    60 {
    61         GetTimeOfDay(&tp2);
    62         return((tp2.tv_sec - tp1.tv_sec) +
    63                (tp2.tv_usec - tp1.tv_usec)*1.0e-6);
    64 }
    6567
    6668
     
    185187        zero_sockaddr(&ss);
    186188
    187         if (!(c = cli_initialise())) {
     189        if (!(c = cli_initialise_ex(signing_state))) {
    188190                printf("Failed initialize cli_struct to connect with %s\n", host);
    189191                return NULL;
     
    228230}
    229231
     232/****************************************************************************
     233 Send a corrupt session request. See rfc1002.txt 4.3 and 4.3.2.
     234****************************************************************************/
     235
     236static bool cli_bad_session_request(struct cli_state *cli,
     237                         struct nmb_name *calling, struct nmb_name *called)
     238{
     239        char *p;
     240        int len = 4;
     241        int namelen = 0;
     242        char *tmp;
     243
     244        memcpy(&(cli->calling), calling, sizeof(*calling));
     245        memcpy(&(cli->called ), called , sizeof(*called ));
     246
     247        /* put in the destination name */
     248
     249        tmp = name_mangle(talloc_tos(), cli->called.name,
     250                          cli->called.name_type);
     251        if (tmp == NULL) {
     252                return false;
     253        }
     254
     255        p = cli->outbuf+len;
     256        namelen = name_len((unsigned char *)tmp, talloc_get_size(tmp));
     257        if (namelen > 0) {
     258                memcpy(p, tmp, namelen);
     259                len += namelen;
     260        }
     261        TALLOC_FREE(tmp);
     262
     263        /* Deliberately corrupt the name len (first byte) */
     264        *p = 100;
     265
     266        /* and my name */
     267
     268        tmp = name_mangle(talloc_tos(), cli->calling.name,
     269                          cli->calling.name_type);
     270        if (tmp == NULL) {
     271                return false;
     272        }
     273
     274        p = cli->outbuf+len;
     275        namelen = name_len((unsigned char *)tmp, talloc_get_size(tmp));
     276        if (namelen > 0) {
     277                memcpy(p, tmp, namelen);
     278                len += namelen;
     279        }
     280        TALLOC_FREE(tmp);
     281        /* Deliberately corrupt the name len (first byte) */
     282        *p = 100;
     283
     284        /* send a session request (RFC 1002) */
     285        /* setup the packet length
     286         * Remove four bytes from the length count, since the length
     287         * field in the NBT Session Service header counts the number
     288         * of bytes which follow.  The cli_send_smb() function knows
     289         * about this and accounts for those four bytes.
     290         * CRH.
     291         */
     292        len -= 4;
     293        _smb_setlen(cli->outbuf,len);
     294        SCVAL(cli->outbuf,0,0x81);
     295
     296        cli_send_smb(cli);
     297        DEBUG(5,("Sent session request\n"));
     298
     299        if (!cli_receive_smb(cli))
     300                return False;
     301
     302        if (CVAL(cli->inbuf,0) != 0x82) {
     303                /* This is the wrong place to put the error... JRA. */
     304                cli->rap_error = CVAL(cli->inbuf,4);
     305                return False;
     306        }
     307        return(True);
     308}
     309
     310static struct cli_state *open_bad_nbt_connection(void)
     311{
     312        struct nmb_name called, calling;
     313        struct sockaddr_storage ss;
     314        struct cli_state *c;
     315        NTSTATUS status;
     316
     317        make_nmb_name(&calling, myname, 0x0);
     318        make_nmb_name(&called , host, 0x20);
     319
     320        zero_sockaddr(&ss);
     321
     322        if (!(c = cli_initialise_ex(signing_state))) {
     323                printf("Failed initialize cli_struct to connect with %s\n", host);
     324                return NULL;
     325        }
     326
     327        c->port = 139;
     328
     329        status = cli_connect(c, host, &ss);
     330        if (!NT_STATUS_IS_OK(status)) {
     331                printf("Failed to connect with %s. Error %s\n", host, nt_errstr(status) );
     332                return NULL;
     333        }
     334
     335        c->timeout = 4000; /* set a short timeout (4 seconds) */
     336
     337        if (!cli_bad_session_request(c, &calling, &called)) {
     338                printf("Failed to connect with %s. Error %s\n", host, nt_errstr(status) );
     339                return NULL;
     340        }
     341
     342        return c;
     343}
     344
     345
    230346/* Insert a NULL at the first separator of the given path and return a pointer
    231347 * to the remainder of the string.
     
    290406                                   const char *sharename)
    291407{
    292         bool retry;
    293408        int flags = 0;
    294409        NTSTATUS status;
     
    305420                                     sharename, "?????",
    306421                                     username, workgroup,
    307                                      password, flags, Undefined, &retry);
     422                                     password, flags, signing_state);
    308423        if (!NT_STATUS_IS_OK(status)) {
    309424                printf("failed to open share connection: //%s/%s port:%d - %s\n",
     
    380495{
    381496        bool ret = True;
    382         if (!cli_tdis(c)) {
    383                 printf("tdis failed (%s)\n", cli_errstr(c));
     497        NTSTATUS status;
     498
     499        status = cli_tdis(c);
     500        if (!NT_STATUS_IS_OK(status)) {
     501                printf("tdis failed (%s)\n", nt_errstr(status));
    384502                ret = False;
    385503        }
     
    464582        for (i=0;i<torture_numops;i++) {
    465583                unsigned n = (unsigned)sys_random()%10;
     584
    466585                if (i % 10 == 0) {
    467586                        printf("%d\r", i); fflush(stdout);
     
    479598                }
    480599
    481                 if (cli_write(c, fnum, 0, (char *)&pid, 0, sizeof(pid)) != sizeof(pid)) {
    482                         printf("write failed (%s)\n", cli_errstr(c));
     600                status = cli_writeall(c, fnum, 0, (uint8_t *)&pid, 0,
     601                                      sizeof(pid), NULL);
     602                if (!NT_STATUS_IS_OK(status)) {
     603                        printf("write failed (%s)\n", nt_errstr(status));
    483604                        correct = False;
    484605                }
    485606
    486607                for (j=0;j<50;j++) {
    487                         if (cli_write(c, fnum, 0, (char *)buf,
    488                                       sizeof(pid)+(j*sizeof(buf)),
    489                                       sizeof(buf)) != sizeof(buf)) {
    490                                 printf("write failed (%s)\n", cli_errstr(c));
     608                        status = cli_writeall(c, fnum, 0, (uint8_t *)buf,
     609                                              sizeof(pid)+(j*sizeof(buf)),
     610                                              sizeof(buf), NULL);
     611                        if (!NT_STATUS_IS_OK(status)) {
     612                                printf("write failed (%s)\n",
     613                                       nt_errstr(status));
    491614                                correct = False;
    492615                        }
     
    510633                }
    511634
    512                 if (!NT_STATUS_IS_OK(cli_unlink(c, fname, aSYSTEM | aHIDDEN))) {
     635                if (!NT_STATUS_IS_OK(cli_unlink(c, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) {
    513636                        printf("unlink failed (%s)\n", cli_errstr(c));
    514637                        correct = False;
     
    522645
    523646        cli_close(c, fnum2);
    524         cli_unlink(c, lockfname, aSYSTEM | aHIDDEN);
     647        cli_unlink(c, lockfname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    525648
    526649        printf("%d\n", i);
     
    557680        ssize_t sent = 0;
    558681        bool correct = True;
    559         NTSTATUS status;
     682        NTSTATUS status = NT_STATUS_OK;
    560683
    561684        srandom(1);
     
    567690        if (procnum == 0)
    568691        {
     692                if (!NT_STATUS_IS_OK(cli_unlink(c, lockfname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) {
     693                        printf("unlink failed (%s) (normal, this file should not exist)\n", cli_errstr(c));
     694                }
     695
    569696                if (!NT_STATUS_IS_OK(cli_open(c, lockfname, O_RDWR | O_CREAT | O_EXCL,
    570697                                 DENY_NONE, &fnum))) {
     
    610737                        }
    611738
    612                         if (cli_write(c, fnum, 0, buf+count, count, (size_t)sent) != sent) {
    613                                 printf("write failed (%s)\n", cli_errstr(c));
     739                        status = cli_writeall(c, fnum, 0, (uint8_t *)buf+count,
     740                                              count, (size_t)sent, NULL);
     741                        if (!NT_STATUS_IS_OK(status)) {
     742                                printf("write failed (%s)\n",
     743                                       nt_errstr(status));
    614744                                correct = False;
    615745                        }
     
    660790        ssize_t bytes_read;
    661791
    662         if (!NT_STATUS_IS_OK(cli_unlink(c1, lockfname, aSYSTEM | aHIDDEN))) {
     792        if (!NT_STATUS_IS_OK(cli_unlink(c1, lockfname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) {
    663793                printf("unlink failed (%s) (normal, this file should not exist)\n", cli_errstr(c1));
    664794        }
     
    680810        for (i=0;i<torture_numops;i++)
    681811        {
     812                NTSTATUS status;
    682813                size_t buf_size = ((unsigned)sys_random()%(sizeof(buf)-1))+ 1;
    683814                if (i % 10 == 0) {
     
    687818                generate_random_buffer((unsigned char *)buf, buf_size);
    688819
    689                 if (cli_write(c1, fnum1, 0, buf, 0, buf_size) != buf_size) {
    690                         printf("write failed (%s)\n", cli_errstr(c1));
     820                status = cli_writeall(c1, fnum1, 0, (uint8_t *)buf, 0,
     821                                      buf_size, NULL);
     822                if (!NT_STATUS_IS_OK(status)) {
     823                        printf("write failed (%s)\n", nt_errstr(status));
    691824                        correct = False;
    692825                        break;
     
    718851        }
    719852
    720         if (!NT_STATUS_IS_OK(cli_unlink(c1, lockfname, aSYSTEM | aHIDDEN))) {
     853        if (!NT_STATUS_IS_OK(cli_unlink(c1, lockfname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) {
    721854                printf("unlink failed (%s)\n", cli_errstr(c1));
    722855                correct = False;
     
    777910}
    778911
    779 static bool run_readwritelarge(int dummy)
     912static bool run_readwritelarge_internal(int max_xmit_k)
    780913{
    781914        static struct cli_state *cli1;
     
    792925        memset(buf,'\0',sizeof(buf));
    793926
    794         cli1->max_xmit = 128*1024;
    795 
    796         printf("starting readwritelarge\n");
    797 
    798         cli_unlink(cli1, lockfname, aSYSTEM | aHIDDEN);
     927        cli1->max_xmit = max_xmit_k*1024;
     928
     929        if (signing_state == Required) {
     930                /* Horrible cheat to force
     931                   multiple signed outstanding
     932                   packets against a Samba server.
     933                */
     934                cli1->is_samba = false;
     935        }
     936
     937        printf("starting readwritelarge_internal\n");
     938
     939        cli_unlink(cli1, lockfname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    799940
    800941        if (!NT_STATUS_IS_OK(cli_open(cli1, lockfname, O_RDWR | O_CREAT | O_EXCL, DENY_NONE, &fnum1))) {
     
    803944        }
    804945
    805         cli_write(cli1, fnum1, 0, buf, 0, sizeof(buf));
    806 
    807         if (!cli_qfileinfo(cli1, fnum1, NULL, &fsize, NULL, NULL, NULL, NULL, NULL)) {
     946        cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 0, sizeof(buf), NULL);
     947
     948        if (!NT_STATUS_IS_OK(cli_qfileinfo_basic(
     949                                     cli1, fnum1, NULL, &fsize, NULL, NULL,
     950                                     NULL, NULL, NULL))) {
    808951                printf("qfileinfo failed (%s)\n", cli_errstr(cli1));
    809952                correct = False;
     
    811954
    812955        if (fsize == sizeof(buf))
    813                 printf("readwritelarge test 1 succeeded (size = %lx)\n",
     956                printf("readwritelarge_internal test 1 succeeded (size = %lx)\n",
    814957                       (unsigned long)fsize);
    815958        else {
    816                 printf("readwritelarge test 1 failed (size = %lx)\n",
     959                printf("readwritelarge_internal test 1 failed (size = %lx)\n",
    817960                       (unsigned long)fsize);
    818961                correct = False;
     
    824967        }
    825968
    826         if (!NT_STATUS_IS_OK(cli_unlink(cli1, lockfname, aSYSTEM | aHIDDEN))) {
     969        if (!NT_STATUS_IS_OK(cli_unlink(cli1, lockfname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) {
    827970                printf("unlink failed (%s)\n", cli_errstr(cli1));
    828971                correct = False;
     
    836979        cli1->max_xmit = 4*1024;
    837980
    838         cli_smbwrite(cli1, fnum1, buf, 0, sizeof(buf));
    839 
    840         if (!cli_qfileinfo(cli1, fnum1, NULL, &fsize, NULL, NULL, NULL, NULL, NULL)) {
     981        cli_smbwrite(cli1, fnum1, buf, 0, sizeof(buf), NULL);
     982
     983        if (!NT_STATUS_IS_OK(cli_qfileinfo_basic(
     984                                     cli1, fnum1, NULL, &fsize, NULL, NULL,
     985                                     NULL, NULL, NULL))) {
    841986                printf("qfileinfo failed (%s)\n", cli_errstr(cli1));
    842987                correct = False;
     
    844989
    845990        if (fsize == sizeof(buf))
    846                 printf("readwritelarge test 2 succeeded (size = %lx)\n",
     991                printf("readwritelarge_internal test 2 succeeded (size = %lx)\n",
    847992                       (unsigned long)fsize);
    848993        else {
    849                 printf("readwritelarge test 2 failed (size = %lx)\n",
     994                printf("readwritelarge_internal test 2 failed (size = %lx)\n",
    850995                       (unsigned long)fsize);
    851996                correct = False;
     
    8581003                return False;
    8591004        }
    860         if (!cli_qfileinfo(cli1, fnum1, NULL, &fsize, NULL, NULL, NULL, NULL, NULL)) {
     1005        if (!cli_qfileinfo_basic(cli1, fnum1, NULL, &fsize, NULL, NULL, NULL,
     1006                                 NULL, NULL)) {
    8611007                printf("qfileinfo failed (%s)\n", cli_errstr(cli1));
    8621008                correct = False;
     
    8751021        }
    8761022        return correct;
     1023}
     1024
     1025static bool run_readwritelarge(int dummy)
     1026{
     1027        return run_readwritelarge_internal(128);
     1028}
     1029
     1030static bool run_readwritelarge_signtest(int dummy)
     1031{
     1032        bool ret;
     1033        signing_state = Required;
     1034        ret = run_readwritelarge_internal(2);
     1035        signing_state = Undefined;
     1036        return ret;
    8771037}
    8781038
     
    10241184        printf("starting locktest1\n");
    10251185
    1026         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     1186        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    10271187
    10281188        if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) {
     
    10961256        }
    10971257
    1098         if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, aSYSTEM | aHIDDEN))) {
     1258        if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) {
    10991259                printf("unlink failed (%s)\n", cli_errstr(cli1));
    11001260                return False;
     
    11381298        printf("starting tcontest\n");
    11391299
    1140         cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
     1300        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    11411301
    11421302        if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) {
     
    11481308        vuid1 = cli->vuid;
    11491309
    1150         if (cli_write(cli, fnum1, 0, buf, 130, 4) != 4) {
    1151                 printf("initial write failed (%s)", cli_errstr(cli));
     1310        status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
     1311        if (!NT_STATUS_IS_OK(status)) {
     1312                printf("initial write failed (%s)", nt_errstr(status));
    11521313                return False;
    11531314        }
     
    11691330        cli->cnum = cnum2;
    11701331
    1171         if (cli_write(cli, fnum1, 0, buf, 130, 4) == 4) {
     1332        status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
     1333        if (NT_STATUS_IS_OK(status)) {
    11721334                printf("* server allows write with wrong TID\n");
    11731335                ret = False;
    11741336        } else {
    1175                 printf("server fails write with wrong TID : %s\n", cli_errstr(cli));
     1337                printf("server fails write with wrong TID : %s\n",
     1338                       nt_errstr(status));
    11761339        }
    11771340
     
    11801343        cli->cnum = cnum3;
    11811344
    1182         if (cli_write(cli, fnum1, 0, buf, 130, 4) == 4) {
     1345        status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
     1346        if (NT_STATUS_IS_OK(status)) {
    11831347                printf("* server allows write with invalid TID\n");
    11841348                ret = False;
    11851349        } else {
    1186                 printf("server fails write with invalid TID : %s\n", cli_errstr(cli));
     1350                printf("server fails write with invalid TID : %s\n",
     1351                       nt_errstr(status));
    11871352        }
    11881353
     
    11911356        cli->cnum = cnum1;
    11921357
    1193         if (cli_write(cli, fnum1, 0, buf, 130, 4) == 4) {
     1358        status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
     1359        if (NT_STATUS_IS_OK(status)) {
    11941360                printf("* server allows write with invalid VUID\n");
    11951361                ret = False;
    11961362        } else {
    1197                 printf("server fails write with invalid VUID : %s\n", cli_errstr(cli));
     1363                printf("server fails write with invalid VUID : %s\n",
     1364                       nt_errstr(status));
    11981365        }
    11991366
     
    12081375        cli->cnum = cnum2;
    12091376
    1210         if (!cli_tdis(cli)) {
    1211                 printf("secondary tdis failed (%s)\n", cli_errstr(cli));
     1377        status = cli_tdis(cli);
     1378        if (!NT_STATUS_IS_OK(status)) {
     1379                printf("secondary tdis failed (%s)\n", nt_errstr(status));
    12121380                return False;
    12131381        }
     
    12461414        status = cli_raw_tcon(cli, service, password, "?????", &max_xmit, &cnum);
    12471415
     1416        SAFE_FREE(service);
     1417
    12481418        if (!NT_STATUS_IS_OK(status)) {
    1249                 printf("tcon2 failed : %s\n", cli_errstr(cli));
     1419                printf("tcon2 failed : %s\n", nt_errstr(status));
    12501420        } else {
    1251                 printf("tcon OK : max_xmit=%d cnum=%d tid=%d\n",
    1252                        (int)max_xmit, (int)cnum, SVAL(cli->inbuf, smb_tid));
     1421                printf("tcon OK : max_xmit=%d cnum=%d\n",
     1422                       (int)max_xmit, (int)cnum);
    12531423        }
    12541424
     
    13151485{
    13161486        static struct cli_state *cli1 = NULL;
    1317         bool retry;
    13181487        int flags = 0;
    13191488        NTSTATUS status;
     
    13241493                                     NULL, NULL,
    13251494                                     username, workgroup,
    1326                                      password, flags, Undefined, &retry);
     1495                                     password, flags, signing_state);
    13271496
    13281497        if (!NT_STATUS_IS_OK(status)) {
     
    13961565        printf("starting locktest2\n");
    13971566
    1398         cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
     1567        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    13991568
    14001569        cli_setpid(cli, 1);
     
    15331702        printf("starting locktest3\n");
    15341703
    1535         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     1704        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    15361705
    15371706        if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) {
     
    16131782        }
    16141783
    1615         if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, aSYSTEM | aHIDDEN))) {
     1784        if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) {
    16161785                printf("unlink failed (%s)\n", cli_errstr(cli1));
    16171786                return False;
     
    16461815        char buf[1000];
    16471816        bool correct = True;
     1817        NTSTATUS status;
    16481818
    16491819        if (!torture_open_connection(&cli1, 0) || !torture_open_connection(&cli2, 1)) {
     
    16561826        printf("starting locktest4\n");
    16571827
    1658         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     1828        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    16591829
    16601830        cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
     
    16631833        memset(buf, 0, sizeof(buf));
    16641834
    1665         if (cli_write(cli1, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) {
    1666                 printf("Failed to create file\n");
     1835        status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 0, sizeof(buf),
     1836                              NULL);
     1837        if (!NT_STATUS_IS_OK(status)) {
     1838                printf("Failed to create file: %s\n", nt_errstr(status));
    16671839                correct = False;
    16681840                goto fail;
     
    17361908        printf("this server %s strict write locking\n", ret?"doesn't do":"does");
    17371909
    1738         ret = cli_lock(cli1, fnum1, 130, 4, 0, READ_LOCK) &&
    1739               (cli_write(cli2, fnum2, 0, buf, 130, 4) == 4);
     1910        ret = cli_lock(cli1, fnum1, 130, 4, 0, READ_LOCK);
     1911        if (ret) {
     1912                status = cli_writeall(cli2, fnum2, 0, (uint8_t *)buf, 130, 4,
     1913                                      NULL);
     1914                ret = NT_STATUS_IS_OK(status);
     1915        }
    17401916        EXPECTED(ret, False);
    17411917        printf("this server %s strict read locking\n", ret?"doesn't do":"does");
     
    17541930              NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 150, 4)) &&
    17551931              (cli_read(cli2, fnum2, buf, 150, 4) == 4) &&
    1756               !(cli_write(cli2, fnum2, 0, buf, 150, 4) == 4) &&
     1932              !(NT_STATUS_IS_OK(cli_writeall(cli2, fnum2, 0, (uint8_t *)buf,
     1933                                             150, 4, NULL))) &&
    17571934              NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 150, 4));
    17581935        EXPECTED(ret, True);
     
    17611938        ret = cli_lock(cli1, fnum1, 160, 4, 0, READ_LOCK) &&
    17621939              NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 160, 4)) &&
    1763               (cli_write(cli2, fnum2, 0, buf, 160, 4) == 4) &&         
     1940              NT_STATUS_IS_OK(cli_writeall(cli2, fnum2, 0, (uint8_t *)buf,
     1941                                           160, 4, NULL)) &&
    17641942              (cli_read(cli2, fnum2, buf, 160, 4) == 4);               
    17651943        EXPECTED(ret, True);
     
    17681946        ret = cli_lock(cli1, fnum1, 170, 4, 0, WRITE_LOCK) &&
    17691947              NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 170, 4)) &&
    1770               (cli_write(cli2, fnum2, 0, buf, 170, 4) == 4) &&         
     1948              NT_STATUS_IS_OK(cli_writeall(cli2, fnum2, 0, (uint8_t *)buf,
     1949                                           170, 4, NULL)) &&
    17711950              (cli_read(cli2, fnum2, buf, 170, 4) == 4);               
    17721951        EXPECTED(ret, True);
     
    17761955              cli_lock(cli1, fnum1, 190, 4, 0, READ_LOCK) &&
    17771956              NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 190, 4)) &&
    1778               !(cli_write(cli2, fnum2, 0, buf, 190, 4) == 4) &&         
     1957              !NT_STATUS_IS_OK(cli_writeall(cli2, fnum2, 0, (uint8_t *)buf,
     1958                                            190, 4, NULL)) &&
    17791959              (cli_read(cli2, fnum2, buf, 190, 4) == 4);               
    17801960        EXPECTED(ret, True);
     
    17981978        cli_close(cli1, fnum1);
    17991979        cli_close(cli2, fnum2);
    1800         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     1980        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    18011981        torture_close_connection(cli1);
    18021982        torture_close_connection(cli2);
     
    18171997        char buf[1000];
    18181998        bool correct = True;
     1999        NTSTATUS status;
    18192000
    18202001        if (!torture_open_connection(&cli1, 0) || !torture_open_connection(&cli2, 1)) {
     
    18272008        printf("starting locktest5\n");
    18282009
    1829         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     2010        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    18302011
    18312012        cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
     
    18352016        memset(buf, 0, sizeof(buf));
    18362017
    1837         if (cli_write(cli1, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) {
    1838                 printf("Failed to create file\n");
     2018        status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 0, sizeof(buf),
     2019                              NULL);
     2020        if (!NT_STATUS_IS_OK(status)) {
     2021                printf("Failed to create file: %s\n", nt_errstr(status));
    18392022                correct = False;
    18402023                goto fail;
     
    19172100        cli_close(cli1, fnum1);
    19182101        cli_close(cli2, fnum2);
    1919         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     2102        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    19202103        if (!torture_close_connection(cli1)) {
    19212104                correct = False;
     
    19522135                printf("Testing %s\n", fname[i]);
    19532136
    1954                 cli_unlink(cli, fname[i], aSYSTEM | aHIDDEN);
     2137                cli_unlink(cli, fname[i], FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    19552138
    19562139                cli_open(cli, fname[i], O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum);
     
    19642147                printf("CANCEL_LOCK gave %s\n", nt_errstr(status));
    19652148
    1966                 cli_unlink(cli, fname[i], aSYSTEM | aHIDDEN);
     2149                cli_unlink(cli, fname[i], FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    19672150        }
    19682151
     
    19802163        char buf[200];
    19812164        bool correct = False;
     2165        NTSTATUS status;
    19822166
    19832167        if (!torture_open_connection(&cli1, 0)) {
     
    19892173        printf("starting locktest7\n");
    19902174
    1991         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     2175        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    19922176
    19932177        cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1);
     
    19952179        memset(buf, 0, sizeof(buf));
    19962180
    1997         if (cli_write(cli1, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) {
    1998                 printf("Failed to create file\n");
     2181        status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 0, sizeof(buf),
     2182                              NULL);
     2183        if (!NT_STATUS_IS_OK(status)) {
     2184                printf("Failed to create file: %s\n", nt_errstr(status));
    19992185                goto fail;
    20002186        }
     
    20162202        }
    20172203
    2018         if (cli_write(cli1, fnum1, 0, buf, 130, 4) != 4) {
    2019                 printf("pid1 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1));
    2020                 if (NT_STATUS_V(cli_nt_error(cli1)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
     2204        status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
     2205        if (!NT_STATUS_IS_OK(status)) {
     2206                printf("pid1 unable to write to the range 130:4, error was "
     2207                       "%s\n", nt_errstr(status));
     2208                if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_LOCK_CONFLICT)) {
    20212209                        printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)\n");
    20222210                        goto fail;
     
    20352223        }
    20362224
    2037         if (cli_write(cli1, fnum1, 0, buf, 130, 4) != 4) {
    2038                 printf("pid2 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1));
    2039                 if (NT_STATUS_V(cli_nt_error(cli1)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
     2225        status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
     2226        if (!NT_STATUS_IS_OK(status)) {
     2227                printf("pid2 unable to write to the range 130:4, error was "
     2228                       "%s\n", nt_errstr(status));
     2229                if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_LOCK_CONFLICT)) {
    20402230                        printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)\n");
    20412231                        goto fail;
     
    20632253        }
    20642254
    2065         if (cli_write(cli1, fnum1, 0, buf, 130, 4) != 4) {
    2066                 printf("pid1 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1));
     2255        status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
     2256        if (!NT_STATUS_IS_OK(status)) {
     2257                printf("pid1 unable to write to the range 130:4, error was "
     2258                       "%s\n", nt_errstr(status));
    20672259                goto fail;
    20682260        } else {
     
    20832275        }
    20842276
    2085         if (cli_write(cli1, fnum1, 0, buf, 130, 4) != 4) {
    2086                 printf("pid2 unable to write to the range 130:4, error was %s\n", cli_errstr(cli1));
    2087                 if (NT_STATUS_V(cli_nt_error(cli1)) != NT_STATUS_V(NT_STATUS_FILE_LOCK_CONFLICT)) {
     2277        status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
     2278        if (!NT_STATUS_IS_OK(status)) {
     2279                printf("pid2 unable to write to the range 130:4, error was "
     2280                       "%s\n", nt_errstr(status));
     2281                if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_LOCK_CONFLICT)) {
    20882282                        printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)\n");
    20892283                        goto fail;
     
    20992293fail:
    21002294        cli_close(cli1, fnum1);
    2101         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     2295        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    21022296        torture_close_connection(cli1);
    21032297
     
    21312325        printf("starting locktest8\n");
    21322326
    2133         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     2327        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    21342328
    21352329        status = cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_WRITE,
     
    21732367        cli_close(cli1, fnum1);
    21742368        cli_close(cli1, fnum2);
    2175         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     2369        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    21762370        torture_close_connection(cli1);
    21772371
     
    22782472        char c = '\0';
    22792473        int ret;
     2474        struct timeval start;
    22802475        double seconds;
    22812476        NTSTATUS status;
     
    23502545        alarm(20);
    23512546
    2352         start_timer();
     2547        start = timeval_current();
    23532548
    23542549        if (!cli_lock(cli1, fnum, 0, 4, -1, WRITE_LOCK)) {
     
    23592554        alarm(0);
    23602555
    2361         seconds = end_timer();
     2556        seconds = timeval_elapsed(&start);
    23622557
    23632558        printf("Parent got the lock after %.2f seconds.\n",
     
    23922587        uint16_t fnum1;
    23932588        char buf[1024];
     2589        NTSTATUS status;
    23942590
    23952591        if (!torture_open_connection(&cli1, 0) || !torture_open_connection(&cli2, 1)) {
     
    24012597        printf("starting fdpasstest\n");
    24022598
    2403         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     2599        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    24042600
    24052601        if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) {
     
    24082604        }
    24092605
    2410         if (cli_write(cli1, fnum1, 0, "hello world\n", 0, 13) != 13) {
    2411                 printf("write failed (%s)\n", cli_errstr(cli1));
     2606        status = cli_writeall(cli1, fnum1, 0, (uint8_t *)"hello world\n", 0,
     2607                              13, NULL);
     2608        if (!NT_STATUS_IS_OK(status)) {
     2609                printf("write failed (%s)\n", nt_errstr(status));
    24122610                return False;
    24132611        }
     
    24242622
    24252623        cli_close(cli1, fnum1);
    2426         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     2624        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    24272625
    24282626        torture_close_connection(cli1);
     
    24462644        char buf[1024];
    24472645        bool ret = True;
     2646        NTSTATUS status;
    24482647
    24492648        if (!torture_open_connection(&cli, 0))
     
    24622661        printf("starting fdsesstest\n");
    24632662
    2464         cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
    2465         cli_unlink(cli, fname1, aSYSTEM | aHIDDEN);
     2663        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
     2664        cli_unlink(cli, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    24662665
    24672666        if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) {
     
    24702669        }
    24712670
    2472         if (cli_write(cli, fnum1, 0, "hello world\n", 0, 13) != 13) {
    2473                 printf("write failed (%s)\n", cli_errstr(cli));
     2671        status = cli_writeall(cli, fnum1, 0, (uint8_t *)"hello world\n", 0, 13,
     2672                              NULL);
     2673        if (!NT_STATUS_IS_OK(status)) {
     2674                printf("write failed (%s)\n", nt_errstr(status));
    24742675                return False;
    24752676        }
     
    24872688                printf("create with different vuid, same cnum succeeded.\n");
    24882689                cli_close(cli, fnum2);
    2489                 cli_unlink(cli, fname1, aSYSTEM | aHIDDEN);
     2690                cli_unlink(cli, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    24902691        } else {
    24912692                printf("create with different vuid, same cnum failed.\n");
     
    25072708        cli->cnum = saved_cnum;
    25082709        cli_close(cli, fnum1);
    2509         cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
     2710        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    25102711
    25112712        torture_close_connection(cli);
     
    25352736        printf("starting unlink test\n");
    25362737
    2537         cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
     2738        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    25382739
    25392740        cli_setpid(cli, 1);
     
    25442745        }
    25452746
    2546         if (NT_STATUS_IS_OK(cli_unlink(cli, fname, aSYSTEM | aHIDDEN))) {
     2747        if (NT_STATUS_IS_OK(cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) {
    25472748                printf("error: server allowed unlink on an open file\n");
    25482749                correct = False;
     
    25532754
    25542755        cli_close(cli, fnum);
    2555         cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
     2756        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    25562757
    25572758        if (!torture_close_connection(cli)) {
     
    26052806                slprintf(fname,sizeof(fname)-1,ftemplate, i,(int)getpid());
    26062807                cli_close(cli, fnums[i]);
    2607                 if (!NT_STATUS_IS_OK(cli_unlink(cli, fname, aSYSTEM | aHIDDEN))) {
     2808                if (!NT_STATUS_IS_OK(cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) {
    26082809                        printf("unlink of %s failed (%s)\n",
    26092810                               fname, cli_errstr(cli));
     
    26332834static bool run_negprot_nowait(int dummy)
    26342835{
     2836        struct tevent_context *ev;
    26352837        int i;
     2838        struct cli_state *cli;
     2839        bool correct = True;
     2840
     2841        printf("starting negprot nowait test\n");
     2842
     2843        ev = tevent_context_init(talloc_tos());
     2844        if (ev == NULL) {
     2845                return false;
     2846        }
     2847
     2848        if (!(cli = open_nbt_connection())) {
     2849                TALLOC_FREE(ev);
     2850                return False;
     2851        }
     2852
     2853        for (i=0;i<50000;i++) {
     2854                struct tevent_req *req;
     2855
     2856                req = cli_negprot_send(ev, ev, cli);
     2857                if (req == NULL) {
     2858                        TALLOC_FREE(ev);
     2859                        return false;
     2860                }
     2861                if (!tevent_req_poll(req, ev)) {
     2862                        d_fprintf(stderr, "tevent_req_poll failed: %s\n",
     2863                                  strerror(errno));
     2864                        TALLOC_FREE(ev);
     2865                        return false;
     2866                }
     2867                TALLOC_FREE(req);
     2868        }
     2869
     2870        if (torture_close_connection(cli)) {
     2871                correct = False;
     2872        }
     2873
     2874        printf("finished negprot nowait test\n");
     2875
     2876        return correct;
     2877}
     2878
     2879/* send smb negprot commands, not reading the response */
     2880static bool run_bad_nbt_session(int dummy)
     2881{
    26362882        static struct cli_state *cli;
    2637         bool correct = True;
    2638 
    2639         printf("starting negprot nowait test\n");
    2640 
    2641         if (!(cli = open_nbt_connection())) {
    2642                 return False;
    2643         }
    2644 
    2645         for (i=0;i<50000;i++) {
    2646                 cli_negprot_sendsync(cli);
    2647         }
    2648 
    2649         if (!torture_close_connection(cli)) {
    2650                 correct = False;
    2651         }
    2652 
    2653         printf("finished negprot nowait test\n");
    2654 
    2655         return correct;
    2656 }
    2657 
     2883
     2884        printf("starting bad nbt session test\n");
     2885
     2886        if (!(cli = open_bad_nbt_connection())) {
     2887                return False;
     2888        }
     2889
     2890        cli_shutdown(cli);
     2891        printf("finished bad nbt session test\n");
     2892        return true;
     2893}
    26582894
    26592895/* send random IPC commands */
     
    27663002        }
    27673003
    2768         cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
     3004        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    27693005        cli_open(cli, fname,
    27703006                        O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum);
     
    28013037        }
    28023038
    2803         cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
     3039        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    28043040
    28053041        if (!torture_close_connection(cli)) {
     
    28283064        char pname[1024];
    28293065        bool correct = True;
     3066        NTSTATUS status;
     3067        uint32_t fs_attr;
    28303068
    28313069        printf("starting trans2 test\n");
     
    28353073        }
    28363074
    2837         cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
     3075        status = cli_get_fs_attr_info(cli, &fs_attr);
     3076        if (!NT_STATUS_IS_OK(status)) {
     3077                printf("ERROR: cli_get_fs_attr_info returned %s\n",
     3078                       nt_errstr(status));
     3079                correct = false;
     3080        }
     3081
     3082        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    28383083        cli_open(cli, fname,
    28393084                        O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum);
    2840         if (!cli_qfileinfo(cli, fnum, NULL, &size, &c_time_ts, &a_time_ts, &w_time_ts,
    2841                            &m_time_ts, NULL)) {
     3085        if (!NT_STATUS_IS_OK(cli_qfileinfo_basic(
     3086                                     cli, fnum, NULL, &size, &c_time_ts,
     3087                                     &a_time_ts, &w_time_ts,
     3088                                     &m_time_ts, NULL))) {
    28423089                printf("ERROR: qfileinfo failed (%s)\n", cli_errstr(cli));
    28433090                correct = False;
    28443091        }
    28453092
    2846         if (!cli_qfilename(cli, fnum, pname, sizeof(pname))) {
     3093        if (!NT_STATUS_IS_OK(cli_qfilename(cli, fnum, pname, sizeof(pname)))) {
    28473094                printf("ERROR: qfilename failed (%s)\n", cli_errstr(cli));
    28483095                correct = False;
     
    28593106        sleep(2);
    28603107
    2861         cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
     3108        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    28623109        if (!NT_STATUS_IS_OK(cli_open(cli, fname,
    28633110                        O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum))) {
     
    28673114        cli_close(cli, fnum);
    28683115
    2869         if (!cli_qpathinfo(cli, fname, &c_time, &a_time, &m_time, &size, NULL)) {
    2870                 printf("ERROR: qpathinfo failed (%s)\n", cli_errstr(cli));
     3116        status = cli_qpathinfo1(cli, fname, &c_time, &a_time, &m_time, &size,
     3117                                NULL);
     3118        if (!NT_STATUS_IS_OK(status)) {
     3119                printf("ERROR: qpathinfo failed (%s)\n", nt_errstr(status));
    28713120                correct = False;
    28723121        } else {
     
    28893138
    28903139
    2891         cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
     3140        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    28923141        cli_open(cli, fname,
    28933142                        O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum);
    28943143        cli_close(cli, fnum);
    2895         if (!cli_qpathinfo2(cli, fname, &c_time_ts, &a_time_ts, &w_time_ts,
    2896                             &m_time_ts, &size, NULL, NULL)) {
    2897                 printf("ERROR: qpathinfo2 failed (%s)\n", cli_errstr(cli));
     3144        status = cli_qpathinfo2(cli, fname, &c_time_ts, &a_time_ts, &w_time_ts,
     3145                                &m_time_ts, &size, NULL, NULL);
     3146        if (!NT_STATUS_IS_OK(status)) {
     3147                printf("ERROR: qpathinfo2 failed (%s)\n", nt_errstr(status));
    28983148                correct = False;
    28993149        } else {
     
    29053155        }
    29063156
    2907         cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
     3157        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    29083158
    29093159
     
    29153165        }
    29163166        sleep(3);
    2917         if (!cli_qpathinfo2(cli, "\\trans2\\", &c_time_ts, &a_time_ts, &w_time_ts,
    2918                             &m_time_ts, &size, NULL, NULL)) {
    2919                 printf("ERROR: qpathinfo2 failed (%s)\n", cli_errstr(cli));
     3167        status = cli_qpathinfo2(cli, "\\trans2\\", &c_time_ts, &a_time_ts,
     3168                                &w_time_ts, &m_time_ts, &size, NULL, NULL);
     3169        if (!NT_STATUS_IS_OK(status)) {
     3170                printf("ERROR: qpathinfo2 failed (%s)\n", nt_errstr(status));
    29203171                correct = False;
    29213172        }
     
    29233174        cli_open(cli, fname2,
    29243175                        O_RDWR | O_CREAT | O_TRUNC, DENY_NONE, &fnum);
    2925         cli_write(cli, fnum,  0, (char *)&fnum, 0, sizeof(fnum));
     3176        cli_writeall(cli, fnum,  0, (uint8_t *)&fnum, 0, sizeof(fnum), NULL);
    29263177        cli_close(cli, fnum);
    2927         if (!cli_qpathinfo2(cli, "\\trans2\\", &c_time_ts, &a_time_ts, &w_time_ts,
    2928                             &m_time2_ts, &size, NULL, NULL)) {
    2929                 printf("ERROR: qpathinfo2 failed (%s)\n", cli_errstr(cli));
     3178        status = cli_qpathinfo2(cli, "\\trans2\\", &c_time_ts, &a_time_ts,
     3179                                &w_time_ts, &m_time2_ts, &size, NULL, NULL);
     3180        if (!NT_STATUS_IS_OK(status)) {
     3181                printf("ERROR: qpathinfo2 failed (%s)\n", nt_errstr(status));
    29303182                correct = False;
    29313183        } else {
     
    29363188                }
    29373189        }
    2938         cli_unlink(cli, fname2, aSYSTEM | aHIDDEN);
     3190        cli_unlink(cli, fname2, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    29393191        cli_rmdir(cli, dname);
    29403192
     
    29523204*/
    29533205
    2954 static bool new_trans(struct cli_state *pcli, int fnum, int level)
    2955 {
    2956         char *buf = NULL;
     3206static NTSTATUS new_trans(struct cli_state *pcli, int fnum, int level)
     3207{
     3208        uint8_t *buf = NULL;
    29573209        uint32 len;
    2958         bool correct = True;
    2959 
    2960         if (!cli_qfileinfo_test(pcli, fnum, level, &buf, &len)) {
    2961                 printf("ERROR: qfileinfo (%d) failed (%s)\n", level, cli_errstr(pcli));
    2962                 correct = False;
     3210        NTSTATUS status;
     3211
     3212        status = cli_qfileinfo(talloc_tos(), pcli, fnum, level, 0,
     3213                               pcli->max_xmit, &buf, &len);
     3214        if (!NT_STATUS_IS_OK(status)) {
     3215                printf("ERROR: qfileinfo (%d) failed (%s)\n", level,
     3216                       nt_errstr(status));
    29633217        } else {
    29643218                printf("qfileinfo: level %d, len = %u\n", level, len);
     
    29663220                printf("\n");
    29673221        }
    2968         SAFE_FREE(buf);
    2969         return correct;
     3222        TALLOC_FREE(buf);
     3223        return status;
    29703224}
    29713225
     
    30193273        }
    30203274
    3021         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     3275        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    30223276
    30233277        cli_sockopt(cli1, sockops);
     
    30323286        cli1->use_oplocks = False;
    30333287
    3034         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
    3035         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     3288        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
     3289        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    30363290
    30373291        if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
     
    30403294        }
    30413295
    3042         if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, aSYSTEM | aHIDDEN))) {
     3296        if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) {
    30433297                printf("unlink failed (%s)\n", cli_errstr(cli1));
    30443298                return False;
     
    30903344        cli2->use_level_II_oplocks = True;
    30913345
    3092         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     3346        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    30933347
    30943348        cli_sockopt(cli1, sockops);
     
    31553409        cli_read(cli1, fnum1, buf, 0, 4);
    31563410
    3157 #if 0
    3158         if (cli_write(cli1, fnum1, 0, buf, 0, 4) != 4) {
    3159                 printf("write on fnum1 failed (%s)\n", cli_errstr(cli1));
    3160                 correct = False;
    3161         }
    3162 #endif
    3163 
    31643411        if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
    31653412                printf("close1 failed (%s)\n", cli_errstr(cli1));
     
    31693416        sleep(4);
    31703417
    3171         if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, aSYSTEM | aHIDDEN))) {
     3418        if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) {
    31723419                printf("unlink failed (%s)\n", cli_errstr(cli1));
    31733420                correct = False;
     
    32203467                /* try to trigger a oplock break in parent */
    32213468                cli_open(cli, fname, O_RDWR, DENY_NONE, &fnum);
    3222                 cli_write(cli, fnum, 0, buf, 0, 4);
     3469                cli_writeall(cli, fnum, 0, (uint8_t *)buf, 0, 4, NULL);
    32233470                exit(0);
    32243471        }
     
    32323479        cli_oplock_handler(cli, oplock3_handler);
    32333480        cli_open(cli, fname, O_RDWR|O_CREAT, DENY_NONE, &fnum);
    3234         cli_write(cli, fnum, 0, buf, 0, 4);
     3481        cli_writeall(cli, fnum, 0, (uint8_t *)buf, 0, 4, NULL);
    32353482        cli_close(cli, fnum);
    32363483        cli_open(cli, fname, O_RDWR, DENY_NONE, &fnum);
     
    32443491}
    32453492
     3493/* handler for oplock 4 tests */
     3494bool *oplock4_shared_correct;
     3495
     3496static NTSTATUS oplock4_handler(struct cli_state *cli, uint16_t fnum, unsigned char level)
     3497{
     3498        printf("got oplock break fnum=%d level=%d\n",
     3499               fnum, level);
     3500        *oplock4_shared_correct = true;
     3501        cli_oplock_ack(cli, fnum, level);
     3502        return NT_STATUS_UNSUCCESSFUL; /* Cause cli_receive_smb to return. */
     3503}
     3504
     3505static bool run_oplock4(int dummy)
     3506{
     3507        struct cli_state *cli1, *cli2;
     3508        const char *fname = "\\lockt4.lck";
     3509        const char *fname_ln = "\\lockt4_ln.lck";
     3510        uint16_t fnum1, fnum2;
     3511        int saved_use_oplocks = use_oplocks;
     3512        NTSTATUS status;
     3513        bool correct = true;
     3514
     3515        oplock4_shared_correct = (bool *)shm_setup(sizeof(bool));
     3516        *oplock4_shared_correct = false;
     3517
     3518        printf("starting oplock test 4\n");
     3519
     3520        if (!torture_open_connection(&cli1, 0)) {
     3521                use_level_II_oplocks = false;
     3522                use_oplocks = saved_use_oplocks;
     3523                return false;
     3524        }
     3525
     3526        if (!torture_open_connection(&cli2, 1)) {
     3527                use_level_II_oplocks = false;
     3528                use_oplocks = saved_use_oplocks;
     3529                return false;
     3530        }
     3531
     3532        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
     3533        cli_unlink(cli1, fname_ln, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
     3534
     3535        cli_sockopt(cli1, sockops);
     3536        cli_sockopt(cli2, sockops);
     3537
     3538        /* Create the file. */
     3539        if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum1))) {
     3540                printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
     3541                return false;
     3542        }
     3543
     3544        if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
     3545                printf("close1 failed (%s)\n", cli_errstr(cli1));
     3546                return false;
     3547        }
     3548
     3549        /* Now create a hardlink. */
     3550        if (!NT_STATUS_IS_OK(cli_nt_hardlink(cli1, fname, fname_ln))) {
     3551                printf("nt hardlink failed (%s)\n", cli_errstr(cli1));
     3552                return false;
     3553        }
     3554
     3555        /* Prove that opening hardlinks cause deny modes to conflict. */
     3556        if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR, DENY_ALL, &fnum1))) {
     3557                printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
     3558                return false;
     3559        }
     3560
     3561        status = cli_open(cli1, fname_ln, O_RDWR, DENY_NONE, &fnum2);
     3562        if (NT_STATUS_IS_OK(status)) {
     3563                printf("open of %s succeeded - should fail with sharing violation.\n",
     3564                        fname_ln);
     3565                return false;
     3566        }
     3567
     3568        if (!NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) {
     3569                printf("open of %s should fail with sharing violation. Got %s\n",
     3570                        fname_ln, nt_errstr(status));
     3571                return false;
     3572        }
     3573
     3574        if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
     3575                printf("close1 failed (%s)\n", cli_errstr(cli1));
     3576                return false;
     3577        }
     3578
     3579        cli1->use_oplocks = true;
     3580        cli1->use_level_II_oplocks = true;
     3581
     3582        cli2->use_oplocks = true;
     3583        cli2->use_level_II_oplocks = true;
     3584
     3585        cli_oplock_handler(cli1, oplock4_handler);
     3586        if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR, DENY_NONE, &fnum1))) {
     3587                printf("open of %s failed (%s)\n", fname, cli_errstr(cli1));
     3588                return false;
     3589        }
     3590
     3591        if (fork() == 0) {
     3592                /* Child code */
     3593                if (!NT_STATUS_IS_OK(cli_open(cli2, fname_ln, O_RDWR, DENY_NONE, &fnum2))) {
     3594                        printf("open of %s failed (%s)\n", fname_ln, cli_errstr(cli1));
     3595                        *oplock4_shared_correct = false;
     3596                        exit(0);
     3597                }
     3598
     3599                if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) {
     3600                        printf("close2 failed (%s)\n", cli_errstr(cli1));
     3601                        *oplock4_shared_correct = false;
     3602                }
     3603
     3604                exit(0);
     3605        }
     3606
     3607        sleep(2);
     3608
     3609        /* Process the oplock break. */
     3610        cli_receive_smb(cli1);
     3611
     3612        if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
     3613                printf("close1 failed (%s)\n", cli_errstr(cli1));
     3614                correct = false;
     3615        }
     3616
     3617        if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) {
     3618                printf("unlink failed (%s)\n", cli_errstr(cli1));
     3619                correct = false;
     3620        }
     3621        if (!NT_STATUS_IS_OK(cli_unlink(cli1, fname_ln, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) {
     3622                printf("unlink failed (%s)\n", cli_errstr(cli1));
     3623                correct = false;
     3624        }
     3625
     3626        if (!torture_close_connection(cli1)) {
     3627                correct = false;
     3628        }
     3629
     3630        if (!*oplock4_shared_correct) {
     3631                correct = false;
     3632        }
     3633
     3634        printf("finished oplock test 4\n");
     3635
     3636        return correct;
     3637}
    32463638
    32473639
     
    32693661
    32703662        cli_setatr(cli1, fname, 0, 0);
    3271         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     3663        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    32723664
    32733665        if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, GENERIC_ALL_ACCESS|DELETE_ACCESS, FILE_ATTRIBUTE_NORMAL,
     
    32793671        }
    32803672
    3281 #if 0 /* JRATEST */
    3282         {
    3283                 uint32 *accinfo = NULL;
    3284                 uint32 len;
    3285                 cli_qfileinfo_test(cli1, fnum1, SMB_FILE_ACCESS_INFORMATION, (char **)&accinfo, &len);
    3286                 if (accinfo)
    3287                         printf("access mode = 0x%lx\n", *accinfo);
    3288                 SAFE_FREE(accinfo);
    3289         }
    3290 #endif
    3291 
    32923673        if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
    32933674                printf("[1] close failed (%s)\n", cli_errstr(cli1));
     
    33073688
    33083689        cli_setatr(cli1, fname, 0, 0);
    3309         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     3690        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    33103691
    33113692        if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, GENERIC_ALL_ACCESS,
     
    33363717                        goto fail;
    33373718                }
    3338                 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     3719                cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    33393720        } else
    33403721                printf("second delete on close test succeeded.\n");
     
    33423723        /* Test 3 - ... */
    33433724        cli_setatr(cli1, fname, 0, 0);
    3344         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     3725        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    33453726
    33463727        if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, GENERIC_ALL_ACCESS, FILE_ATTRIBUTE_NORMAL,
     
    33953776                        printf("[3] close failed (%s)\n", cli_errstr(cli1));
    33963777                }
    3397                 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     3778                cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    33983779                correct = False;
    33993780                goto fail;
     
    34033784        /* Test 4 ... */
    34043785        cli_setatr(cli1, fname, 0, 0);
    3405         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     3786        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    34063787
    34073788        if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS,
     
    34503831        /* Test 5 ... */
    34513832        cli_setatr(cli1, fname, 0, 0);
    3452         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     3833        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    34533834
    34543835        if (!NT_STATUS_IS_OK(cli_open(cli1, fname, O_RDWR|O_CREAT, DENY_NONE, &fnum1))) {
     
    34763857        /* Test 6 ... */
    34773858        cli_setatr(cli1, fname, 0, 0);
    3478         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     3859        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    34793860
    34803861        if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_DATA|FILE_WRITE_DATA,
     
    35043885        /* Test 7 ... */
    35053886        cli_setatr(cli1, fname, 0, 0);
    3506         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     3887        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    35073888
    35083889        if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_DATA|FILE_WRITE_DATA|DELETE_ACCESS,
     
    35493930        /* Test 7 ... */
    35503931        cli_setatr(cli1, fname, 0, 0);
    3551         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     3932        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    35523933
    35533934        if (!torture_open_connection(&cli2, 1)) {
     
    36344015
    36354016        cli_setatr(cli1, fname, 0, 0);
    3636         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     4017        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    36374018
    36384019        /* What error do we get when attempting to open a read-only file with
     
    36824063        if (fnum2 != (uint16_t)-1) cli_close(cli1, fnum2);
    36834064        cli_setatr(cli1, fname, 0, 0);
    3684         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     4065        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    36854066
    36864067        if (cli1 && !torture_close_connection(cli1)) {
     
    36934074}
    36944075
     4076static bool run_deletetest_ln(int dummy)
     4077{
     4078        struct cli_state *cli;
     4079        const char *fname = "\\delete1";
     4080        const char *fname_ln = "\\delete1_ln";
     4081        uint16_t fnum;
     4082        uint16_t fnum1;
     4083        NTSTATUS status;
     4084        bool correct = true;
     4085        time_t t;
     4086
     4087        printf("starting deletetest-ln\n");
     4088
     4089        if (!torture_open_connection(&cli, 0)) {
     4090                return false;
     4091        }
     4092
     4093        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
     4094        cli_unlink(cli, fname_ln, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
     4095
     4096        cli_sockopt(cli, sockops);
     4097
     4098        /* Create the file. */
     4099        if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum))) {
     4100                printf("open of %s failed (%s)\n", fname, cli_errstr(cli));
     4101                return false;
     4102        }
     4103
     4104        if (!NT_STATUS_IS_OK(cli_close(cli, fnum))) {
     4105                printf("close1 failed (%s)\n", cli_errstr(cli));
     4106                return false;
     4107        }
     4108
     4109        /* Now create a hardlink. */
     4110        if (!NT_STATUS_IS_OK(cli_nt_hardlink(cli, fname, fname_ln))) {
     4111                printf("nt hardlink failed (%s)\n", cli_errstr(cli));
     4112                return false;
     4113        }
     4114
     4115        /* Open the original file. */
     4116        status = cli_ntcreate(cli, fname, 0, FILE_READ_DATA,
     4117                        FILE_ATTRIBUTE_NORMAL,
     4118                        FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
     4119                        FILE_OPEN_IF, 0, 0, &fnum);
     4120        if (!NT_STATUS_IS_OK(status)) {
     4121                printf("ntcreate of %s failed (%s)\n", fname, nt_errstr(status));
     4122                return false;
     4123        }
     4124
     4125        /* Unlink the hard link path. */
     4126        status = cli_ntcreate(cli, fname_ln, 0, DELETE_ACCESS,
     4127                        FILE_ATTRIBUTE_NORMAL,
     4128                        FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
     4129                        FILE_OPEN_IF, 0, 0, &fnum1);
     4130        if (!NT_STATUS_IS_OK(status)) {
     4131                printf("ntcreate of %s failed (%s)\n", fname_ln, nt_errstr(status));
     4132                return false;
     4133        }
     4134        status = cli_nt_delete_on_close(cli, fnum1, true);
     4135        if (!NT_STATUS_IS_OK(status)) {
     4136                d_printf("(%s) failed to set delete_on_close %s: %s\n",
     4137                        __location__, fname_ln, nt_errstr(status));
     4138                return false;
     4139        }
     4140
     4141        status = cli_close(cli, fnum1);
     4142        if (!NT_STATUS_IS_OK(status)) {
     4143                printf("close %s failed (%s)\n",
     4144                        fname_ln, nt_errstr(status));
     4145                return false;
     4146        }
     4147
     4148        status = cli_close(cli, fnum);
     4149        if (!NT_STATUS_IS_OK(status)) {
     4150                printf("close %s failed (%s)\n",
     4151                        fname, nt_errstr(status));
     4152                return false;
     4153        }
     4154
     4155        /* Ensure the original file is still there. */
     4156        status = cli_getatr(cli, fname, NULL, NULL, &t);
     4157        if (!NT_STATUS_IS_OK(status)) {
     4158                printf("%s getatr on file %s failed (%s)\n",
     4159                        __location__,
     4160                        fname,
     4161                        nt_errstr(status));
     4162                correct = False;
     4163        }
     4164
     4165        /* Ensure the link path is gone. */
     4166        status = cli_getatr(cli, fname_ln, NULL, NULL, &t);
     4167        if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) {
     4168                printf("%s, getatr for file %s returned wrong error code %s "
     4169                        "- should have been deleted\n",
     4170                        __location__,
     4171                        fname_ln, nt_errstr(status));
     4172                correct = False;
     4173        }
     4174
     4175        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
     4176        cli_unlink(cli, fname_ln, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
     4177
     4178        if (!torture_close_connection(cli)) {
     4179                correct = false;
     4180        }
     4181
     4182        printf("finished deletetest-ln\n");
     4183
     4184        return correct;
     4185}
    36954186
    36964187/*
     
    37914282        bool correct = True;
    37924283        uint16_t fnum1;
     4284        uint16_t attr;
    37934285        NTSTATUS status;
    37944286
     
    37994291        }
    38004292
    3801         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
    3802         cli_unlink(cli1, fname1, aSYSTEM | aHIDDEN);
     4293        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
     4294        cli_unlink(cli1, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    38034295        if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS, FILE_ATTRIBUTE_NORMAL,
    38044296                                   FILE_SHARE_READ, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
     
    38194311        }
    38204312
    3821         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
    3822         cli_unlink(cli1, fname1, aSYSTEM | aHIDDEN);
     4313        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
     4314        cli_unlink(cli1, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    38234315        status = cli_ntcreate(cli1, fname, 0, GENERIC_READ_ACCESS, FILE_ATTRIBUTE_NORMAL,
    38244316#if 0
     
    38454337        }
    38464338
    3847         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
    3848         cli_unlink(cli1, fname1, aSYSTEM | aHIDDEN);
     4339        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
     4340        cli_unlink(cli1, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    38494341
    38504342        if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, READ_CONTROL_ACCESS, FILE_ATTRIBUTE_NORMAL,
     
    38884380        }
    38894381
    3890         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
    3891         cli_unlink(cli1, fname1, aSYSTEM | aHIDDEN);
     4382        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
     4383        cli_unlink(cli1, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    38924384
    38934385        /*----*/
     
    39114403        }
    39124404
    3913         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
    3914         cli_unlink(cli1, fname1, aSYSTEM | aHIDDEN);
     4405        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
     4406        cli_unlink(cli1, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    39154407
    39164408        /*--*/
     
    39454437
    39464438        /*--*/
    3947 
    3948 
    39494439        if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
    39504440                printf("close - 5 failed (%s)\n", cli_errstr(cli1));
     
    39524442        }
    39534443
    3954         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
    3955         cli_unlink(cli1, fname1, aSYSTEM | aHIDDEN);
     4444        /* Check that the renamed file has FILE_ATTRIBUTE_ARCHIVE. */
     4445        if (!NT_STATUS_IS_OK(cli_getatr(cli1, fname1, &attr, NULL, NULL))) {
     4446                printf("getatr on file %s failed - %s ! \n",
     4447                        fname1,
     4448                        cli_errstr(cli1));
     4449                correct = False;
     4450        } else {
     4451                if (attr != FILE_ATTRIBUTE_ARCHIVE) {
     4452                        printf("Renamed file %s has wrong attr 0x%x "
     4453                                "(should be 0x%x)\n",
     4454                                fname1,
     4455                                attr,
     4456                                (unsigned int)FILE_ATTRIBUTE_ARCHIVE);
     4457                        correct = False;
     4458                } else {
     4459                        printf("Renamed file %s has archive bit set\n", fname1);
     4460                }
     4461        }
     4462
     4463        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
     4464        cli_unlink(cli1, fname1, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    39564465
    39574466        if (!torture_close_connection(cli1)) {
     
    40034512        bool correct = True;
    40044513        char *tmp_path;
     4514        NTSTATUS status;
    40054515
    40064516        printf("starting open test\n");
     
    40114521
    40124522        cli_setatr(cli1, fname, 0, 0);
    4013         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     4523        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    40144524
    40154525        cli_sockopt(cli1, sockops);
     
    40254535        }
    40264536
    4027         if (!NT_STATUS_IS_OK(cli_setatr(cli1, fname, aRONLY, 0))) {
     4537        if (!NT_STATUS_IS_OK(cli_setatr(cli1, fname, FILE_ATTRIBUTE_READONLY, 0))) {
    40284538                printf("cli_setatr failed (%s)\n", cli_errstr(cli1));
    40294539                return False;
     
    40694579        }
    40704580
    4071         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     4581        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    40724582
    40734583        printf("finished open test 2\n");
     
    40844594        memset(buf, '\0', 20);
    40854595
    4086         if (cli_write(cli1, fnum1, 0, buf, 0, 20) != 20) {
    4087                 printf("write failed (%s)\n", cli_errstr(cli1));
     4596        status = cli_writeall(cli1, fnum1, 0, (uint8_t *)buf, 0, 20, NULL);
     4597        if (!NT_STATUS_IS_OK(status)) {
     4598                printf("write failed (%s)\n", nt_errstr(status));
    40884599                correct = False;
    40894600        }
     
    41294640        printf("finished open test 3\n");
    41304641
    4131         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
    4132 
    4133 
    4134         printf("testing ctemp\n");
     4642        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
     4643
     4644        printf("Do ctemp tests\n");
    41354645        if (!NT_STATUS_IS_OK(cli_ctemp(cli1, talloc_tos(), "\\", &fnum1, &tmp_path))) {
    41364646                printf("ctemp failed (%s)\n", cli_errstr(cli1));
     
    41414651                printf("close of temp failed (%s)\n", cli_errstr(cli1));
    41424652        }
    4143         if (!NT_STATUS_IS_OK(cli_unlink(cli1, tmp_path, aSYSTEM | aHIDDEN))) {
     4653        if (!NT_STATUS_IS_OK(cli_unlink(cli1, tmp_path, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) {
    41444654                printf("unlink of temp failed (%s)\n", cli_errstr(cli1));
    41454655        }
     
    41524662
    41534663        cli_setatr(cli2, fname, 0, 0);
    4154         cli_unlink(cli2, fname, aSYSTEM | aHIDDEN);
     4664        cli_unlink(cli2, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    41554665
    41564666        cli_sockopt(cli2, sockops);
     
    41604670        if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
    41614671                                   FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
    4162                 printf("test 1 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
     4672                printf("TEST #1 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
    41634673                return False;
    41644674        }
     
    41664676        if (!NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
    41674677                                   FILE_SHARE_NONE, FILE_OPEN_IF, 0, 0, &fnum2))) {
    4168                 printf("test 1 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
     4678                printf("TEST #1 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
    41694679                return False;
    41704680        }
    41714681
    41724682        if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
    4173                 printf("test 1 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
     4683                printf("TEST #1 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
    41744684                return False;
    41754685        }
    41764686        if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) {
    4177                 printf("test 1 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
     4687                printf("TEST #1 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
    41784688                return False;
    41794689        }
     
    41814691        printf("non-io open test #1 passed.\n");
    41824692
    4183         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     4693        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    41844694
    41854695        printf("TEST #2 testing 2 non-io opens (first with delete)\n");
     
    41874697        if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, DELETE_ACCESS|FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
    41884698                                   FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
    4189                 printf("test 2 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
     4699                printf("TEST #2 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
    41904700                return False;
    41914701        }
     
    41934703        if (!NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
    41944704                                   FILE_SHARE_NONE, FILE_OPEN_IF, 0, 0, &fnum2))) {
    4195                 printf("test 2 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
     4705                printf("TEST #2 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
    41964706                return False;
    41974707        }
    41984708
    41994709        if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
    4200                 printf("test 1 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
     4710                printf("TEST #2 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
    42014711                return False;
    42024712        }
    42034713        if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) {
    4204                 printf("test 1 close 2 of %s failed (%s)\n", fname, cli_errstr(cli1));
     4714                printf("TEST #2 close 2 of %s failed (%s)\n", fname, cli_errstr(cli1));
    42054715                return False;
    42064716        }
     
    42084718        printf("non-io open test #2 passed.\n");
    42094719
    4210         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     4720        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    42114721
    42124722        printf("TEST #3 testing 2 non-io opens (second with delete)\n");
     
    42144724        if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
    42154725                                   FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
    4216                 printf("test 3 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
     4726                printf("TEST #3 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
    42174727                return False;
    42184728        }
     
    42204730        if (!NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, DELETE_ACCESS|FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
    42214731                                   FILE_SHARE_NONE, FILE_OPEN_IF, 0, 0, &fnum2))) {
    4222                 printf("test 3 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
     4732                printf("TEST #3 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
    42234733                return False;
    42244734        }
    42254735
    42264736        if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
    4227                 printf("test 3 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
     4737                printf("TEST #3 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
    42284738                return False;
    42294739        }
    42304740        if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) {
    4231                 printf("test 3 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
     4741                printf("TEST #3 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
    42324742                return False;
    42334743        }
     
    42354745        printf("non-io open test #3 passed.\n");
    42364746
    4237         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     4747        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    42384748
    42394749        printf("TEST #4 testing 2 non-io opens (both with delete)\n");
     
    42414751        if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, DELETE_ACCESS|FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
    42424752                                   FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
    4243                 printf("test 4 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
     4753                printf("TEST #4 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
    42444754                return False;
    42454755        }
     
    42474757        if (NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, DELETE_ACCESS|FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
    42484758                                   FILE_SHARE_NONE, FILE_OPEN_IF, 0, 0, &fnum2))) {
    4249                 printf("test 4 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, cli_errstr(cli2));
    4250                 return False;
    4251         }
    4252 
    4253         printf("test 3 open 2 of %s gave %s (correct error should be %s)\n", fname, cli_errstr(cli2), "sharing violation");
     4759                printf("TEST #4 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, cli_errstr(cli2));
     4760                return False;
     4761        }
     4762
     4763        printf("TEST #4 open 2 of %s gave %s (correct error should be %s)\n", fname, cli_errstr(cli2), "sharing violation");
    42544764
    42554765        if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
    4256                 printf("test 4 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
     4766                printf("TEST #4 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
    42574767                return False;
    42584768        }
     
    42604770        printf("non-io open test #4 passed.\n");
    42614771
    4262         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     4772        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    42634773
    42644774        printf("TEST #5 testing 2 non-io opens (both with delete - both with file share delete)\n");
     
    42664776        if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, DELETE_ACCESS|FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
    42674777                                   FILE_SHARE_DELETE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
    4268                 printf("test 5 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
     4778                printf("TEST #5 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
    42694779                return False;
    42704780        }
     
    42724782        if (!NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, DELETE_ACCESS|FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
    42734783                                   FILE_SHARE_DELETE, FILE_OPEN_IF, 0, 0, &fnum2))) {
    4274                 printf("test 5 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
     4784                printf("TEST #5 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
    42754785                return False;
    42764786        }
    42774787
    42784788        if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
    4279                 printf("test 5 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
     4789                printf("TEST #5 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
    42804790                return False;
    42814791        }
    42824792
    42834793        if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) {
    4284                 printf("test 5 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
     4794                printf("TEST #5 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
    42854795                return False;
    42864796        }
     
    42904800        printf("TEST #6 testing 1 non-io open, one io open\n");
    42914801
    4292         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     4802        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    42934803
    42944804        if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL,
    42954805                                   FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
    4296                 printf("test 6 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
     4806                printf("TEST #6 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
    42974807                return False;
    42984808        }
     
    43004810        if (!NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
    43014811                                   FILE_SHARE_READ, FILE_OPEN_IF, 0, 0, &fnum2))) {
    4302                 printf("test 6 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
     4812                printf("TEST #6 open 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
    43034813                return False;
    43044814        }
    43054815
    43064816        if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
    4307                 printf("test 6 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
     4817                printf("TEST #6 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
    43084818                return False;
    43094819        }
    43104820
    43114821        if (!NT_STATUS_IS_OK(cli_close(cli2, fnum2))) {
    4312                 printf("test 6 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
     4822                printf("TEST #6 close 2 of %s failed (%s)\n", fname, cli_errstr(cli2));
    43134823                return False;
    43144824        }
     
    43184828        printf("TEST #7 testing 1 non-io open, one io open with delete\n");
    43194829
    4320         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     4830        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    43214831
    43224832        if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL,
    43234833                                   FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
    4324                 printf("test 7 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
     4834                printf("TEST #7 open 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
    43254835                return False;
    43264836        }
     
    43284838        if (NT_STATUS_IS_OK(cli_ntcreate(cli2, fname, 0, DELETE_ACCESS|FILE_READ_ATTRIBUTES, FILE_ATTRIBUTE_NORMAL,
    43294839                                   FILE_SHARE_READ|FILE_SHARE_DELETE, FILE_OPEN_IF, 0, 0, &fnum2))) {
    4330                 printf("test 7 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, cli_errstr(cli2));
    4331                 return False;
    4332         }
    4333 
    4334         printf("test 7 open 2 of %s gave %s (correct error should be %s)\n", fname, cli_errstr(cli2), "sharing violation");
     4840                printf("TEST #7 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, cli_errstr(cli2));
     4841                return False;
     4842        }
     4843
     4844        printf("TEST #7 open 2 of %s gave %s (correct error should be %s)\n", fname, cli_errstr(cli2), "sharing violation");
    43354845
    43364846        if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
    4337                 printf("test 7 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
     4847                printf("TEST #7 close 1 of %s failed (%s)\n", fname, cli_errstr(cli1));
    43384848                return False;
    43394849        }
     
    43414851        printf("non-io open test #7 passed.\n");
    43424852
    4343         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     4853        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
     4854
     4855        printf("TEST #8 testing open without WRITE_ATTRIBUTES, updating close write time.\n");
     4856        status = cli_ntcreate(cli1, fname, 0, FILE_WRITE_DATA, FILE_ATTRIBUTE_NORMAL,
     4857                                FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
     4858                                FILE_OVERWRITE_IF, 0, 0, &fnum1);
     4859        if (!NT_STATUS_IS_OK(status)) {
     4860                printf("TEST #8 open of %s failed (%s)\n", fname, nt_errstr(status));
     4861                correct = false;
     4862                goto out;
     4863        }
     4864
     4865        /* Write to ensure we have to update the file time. */
     4866        status = cli_writeall(cli1, fnum1, 0, (uint8_t *)"TEST DATA\n", 0, 10,
     4867                              NULL);
     4868        if (!NT_STATUS_IS_OK(status)) {
     4869                printf("TEST #8 cli_write failed: %s\n", nt_errstr(status));
     4870                correct = false;
     4871                goto out;
     4872        }
     4873
     4874        status = cli_close(cli1, fnum1);
     4875        if (!NT_STATUS_IS_OK(status)) {
     4876                printf("TEST #8 close of %s failed (%s)\n", fname, nt_errstr(status));
     4877                correct = false;
     4878        }
     4879
     4880  out:
    43444881
    43454882        if (!torture_close_connection(cli1)) {
     
    43514888
    43524889        return correct;
     4890}
     4891
     4892NTSTATUS torture_setup_unix_extensions(struct cli_state *cli)
     4893{
     4894        uint16 major, minor;
     4895        uint32 caplow, caphigh;
     4896        NTSTATUS status;
     4897
     4898        if (!SERVER_HAS_UNIX_CIFS(cli)) {
     4899                printf("Server doesn't support UNIX CIFS extensions.\n");
     4900                return NT_STATUS_NOT_SUPPORTED;
     4901        }
     4902
     4903        status = cli_unix_extensions_version(cli, &major, &minor, &caplow,
     4904                                             &caphigh);
     4905        if (!NT_STATUS_IS_OK(status)) {
     4906                printf("Server didn't return UNIX CIFS extensions: %s\n",
     4907                       nt_errstr(status));
     4908                return status;
     4909        }
     4910
     4911        status = cli_set_unix_extensions_capabilities(cli, major, minor,
     4912                                                      caplow, caphigh);
     4913        if (!NT_STATUS_IS_OK(status)) {
     4914                printf("Server doesn't support setting UNIX CIFS extensions: "
     4915                       "%s.\n", nt_errstr(status));
     4916                return status;
     4917        }
     4918
     4919        return NT_STATUS_OK;
    43534920}
    43544921
     
    43654932        char buf[10];
    43664933        char namebuf[11];
    4367         uint16 major, minor;
    4368         uint32 caplow, caphigh;
    43694934        uint16_t fnum1 = (uint16_t)-1;
    43704935        SMB_STRUCT_STAT sbuf;
     
    43804945        cli_sockopt(cli1, sockops);
    43814946
    4382         if (!SERVER_HAS_UNIX_CIFS(cli1)) {
    4383                 printf("Server doesn't support UNIX CIFS extensions.\n");
     4947        status = torture_setup_unix_extensions(cli1);
     4948        if (!NT_STATUS_IS_OK(status)) {
    43844949                return false;
    43854950        }
    4386 
    4387         status = cli_unix_extensions_version(cli1, &major, &minor, &caplow,
    4388                                              &caphigh);
    4389         if (!NT_STATUS_IS_OK(status)) {
    4390                 printf("Server didn't return UNIX CIFS extensions: %s\n",
    4391                        nt_errstr(status));
    4392                 return false;
    4393         }
    4394 
    4395         if (!cli_set_unix_extensions_capabilities(cli1,
    4396                         major, minor, caplow, caphigh)) {
    4397                 printf("Server doesn't support setting UNIX CIFS extensions.\n");
    4398                 return false;
    4399         }
    44004951
    44014952        cli_setatr(cli1, fname, 0, 0);
     
    44705021        }
    44715022
    4472         /* What happens when we try and POSIX open a directory ? */
    4473         if (NT_STATUS_IS_OK(cli_posix_open(cli1, dname, O_RDONLY, 0, &fnum1))) {
     5023        /* Create again to test open with O_TRUNC. */
     5024        if (!NT_STATUS_IS_OK(cli_posix_open(cli1, fname, O_RDWR|O_CREAT|O_EXCL, 0600, &fnum1))) {
     5025                printf("POSIX create of %s failed (%s)\n", fname, cli_errstr(cli1));
     5026                goto out;
     5027        }
     5028
     5029        /* Test ftruncate - set file size. */
     5030        if (!NT_STATUS_IS_OK(cli_ftruncate(cli1, fnum1, 1000))) {
     5031                printf("ftruncate failed (%s)\n", cli_errstr(cli1));
     5032                goto out;
     5033        }
     5034
     5035        /* Ensure st_size == 1000 */
     5036        if (!NT_STATUS_IS_OK(cli_posix_stat(cli1, fname, &sbuf))) {
     5037                printf("stat failed (%s)\n", cli_errstr(cli1));
     5038                goto out;
     5039        }
     5040
     5041        if (sbuf.st_ex_size != 1000) {
     5042                printf("ftruncate - stat size (%u) != 1000\n", (unsigned int)sbuf.st_ex_size);
     5043                goto out;
     5044        }
     5045
     5046        if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
     5047                printf("close(2) failed (%s)\n", cli_errstr(cli1));
     5048                goto out;
     5049        }
     5050
     5051        /* Re-open with O_TRUNC. */
     5052        if (!NT_STATUS_IS_OK(cli_posix_open(cli1, fname, O_WRONLY|O_TRUNC, 0600, &fnum1))) {
     5053                printf("POSIX create of %s failed (%s)\n", fname, cli_errstr(cli1));
     5054                goto out;
     5055        }
     5056
     5057        /* Ensure st_size == 0 */
     5058        if (!NT_STATUS_IS_OK(cli_posix_stat(cli1, fname, &sbuf))) {
     5059                printf("stat failed (%s)\n", cli_errstr(cli1));
     5060                goto out;
     5061        }
     5062
     5063        if (sbuf.st_ex_size != 0) {
     5064                printf("O_TRUNC - stat size (%u) != 0\n", (unsigned int)sbuf.st_ex_size);
     5065                goto out;
     5066        }
     5067
     5068        if (!NT_STATUS_IS_OK(cli_close(cli1, fnum1))) {
     5069                printf("close failed (%s)\n", cli_errstr(cli1));
     5070                goto out;
     5071        }
     5072
     5073        if (!NT_STATUS_IS_OK(cli_posix_unlink(cli1, fname))) {
     5074                printf("POSIX unlink of %s failed (%s)\n", fname, cli_errstr(cli1));
     5075                goto out;
     5076        }
     5077
     5078        if (!NT_STATUS_IS_OK(cli_posix_open(cli1, dname, O_RDONLY, 0, &fnum1))) {
     5079                printf("POSIX open directory O_RDONLY of %s failed (%s)\n",
     5080                        dname, cli_errstr(cli1));
     5081                goto out;
     5082        }
     5083
     5084        cli_close(cli1, fnum1);
     5085
     5086        /* What happens when we try and POSIX open a directory for write ? */
     5087        if (NT_STATUS_IS_OK(cli_posix_open(cli1, dname, O_RDWR, 0, &fnum1))) {
    44745088                printf("POSIX open of directory %s succeeded, should have failed.\n", fname);
    44755089                goto out;
     
    44885102
    44895103        /* Write some data into it. */
    4490         if (cli_write(cli1, fnum1, 0, "TEST DATA\n", 0, 10) != 10) {
    4491                 printf("cli_write failed: %s\n", cli_errstr(cli1));
     5104        status = cli_writeall(cli1, fnum1, 0, (uint8_t *)"TEST DATA\n", 0, 10,
     5105                              NULL);
     5106        if (!NT_STATUS_IS_OK(status)) {
     5107                printf("cli_write failed: %s\n", nt_errstr(status));
    44925108                goto out;
    44935109        }
     
    46715287        for (k = 0, i = 0; i < sizeof(open_attrs_table)/sizeof(uint32); i++) {
    46725288                cli_setatr(cli1, fname, 0, 0);
    4673                 cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     5289                cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    46745290                if (!NT_STATUS_IS_OK(cli_ntcreate(cli1, fname, 0, FILE_WRITE_DATA, open_attrs_table[i],
    46755291                                   FILE_SHARE_NONE, FILE_OVERWRITE_IF, 0, 0, &fnum1))) {
     
    47435359
    47445360        cli_setatr(cli1, fname, 0, 0);
    4745         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     5361        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    47465362
    47475363        printf("open attr test %s.\n", correct ? "passed" : "failed");
     
    47535369}
    47545370
    4755 static void list_fn(const char *mnt, file_info *finfo, const char *name, void *state)
    4756 {
    4757 
     5371static NTSTATUS list_fn(const char *mnt, struct file_info *finfo,
     5372                    const char *name, void *state)
     5373{
     5374        int *matched = (int *)state;
     5375        if (matched != NULL) {
     5376                *matched += 1;
     5377        }
     5378        return NT_STATUS_OK;
    47585379}
    47595380
     
    47665387        static struct cli_state *cli;
    47675388        uint16_t fnum;
    4768         double t1;
     5389        struct timeval core_start;
    47695390        bool correct = True;
     5391        int matched;
    47705392
    47715393        printf("starting directory test\n");
     
    47885410        }
    47895411
    4790         t1 = end_timer();
    4791 
    4792         printf("Matched %d\n", cli_list(cli, "a*.*", 0, list_fn, NULL));
    4793         printf("Matched %d\n", cli_list(cli, "b*.*", 0, list_fn, NULL));
    4794         printf("Matched %d\n", cli_list(cli, "xyzabc", 0, list_fn, NULL));
    4795 
    4796         printf("dirtest core %g seconds\n", end_timer() - t1);
     5412        core_start = timeval_current();
     5413
     5414        matched = 0;
     5415        cli_list(cli, "a*.*", 0, list_fn, &matched);
     5416        printf("Matched %d\n", matched);
     5417
     5418        matched = 0;
     5419        cli_list(cli, "b*.*", 0, list_fn, &matched);
     5420        printf("Matched %d\n", matched);
     5421
     5422        matched = 0;
     5423        cli_list(cli, "xyzabc", 0, list_fn, &matched);
     5424        printf("Matched %d\n", matched);
     5425
     5426        printf("dirtest core %g seconds\n", timeval_elapsed(&core_start));
    47975427
    47985428        srandom(0);
     
    48005430                fstring fname;
    48015431                slprintf(fname, sizeof(fname), "\\%x", (int)random());
    4802                 cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
     5432                cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    48035433        }
    48045434
     
    48125442}
    48135443
    4814 static void del_fn(const char *mnt, file_info *finfo, const char *mask, void *state)
     5444static NTSTATUS del_fn(const char *mnt, struct file_info *finfo, const char *mask,
     5445                   void *state)
    48155446{
    48165447        struct cli_state *pcli = (struct cli_state *)state;
     
    48195450
    48205451        if (strcmp(finfo->name, ".") == 0 || strcmp(finfo->name, "..") == 0)
    4821                 return;
    4822 
    4823         if (finfo->mode & aDIR) {
     5452                return NT_STATUS_OK;
     5453
     5454        if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
    48245455                if (!NT_STATUS_IS_OK(cli_rmdir(pcli, fname)))
    48255456                        printf("del_fn: failed to rmdir %s\n,", fname );
    48265457        } else {
    4827                 if (!NT_STATUS_IS_OK(cli_unlink(pcli, fname, aSYSTEM | aHIDDEN)))
     5458                if (!NT_STATUS_IS_OK(cli_unlink(pcli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN)))
    48285459                        printf("del_fn: failed to unlink %s\n,", fname );
    48295460        }
     5461        return NT_STATUS_OK;
    48305462}
    48315463
     
    48495481        printf("starting ioctl test\n");
    48505482
    4851         cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
     5483        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    48525484
    48535485        if (!NT_STATUS_IS_OK(cli_open(cli, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE, &fnum))) {
     
    48575489
    48585490        status = cli_raw_ioctl(cli, fnum, 0x2d0000 | (0x0420<<2), &blob);
    4859         printf("ioctl device info: %s\n", cli_errstr(cli));
     5491        printf("ioctl device info: %s\n", nt_errstr(status));
    48605492
    48615493        status = cli_raw_ioctl(cli, fnum, IOCTL_QUERY_JOB_INFO, &blob);
    4862         printf("ioctl job info: %s\n", cli_errstr(cli));
     5494        printf("ioctl job info: %s\n", nt_errstr(status));
    48635495
    48645496        for (device=0;device<0x100;device++) {
    4865                 printf("testing device=0x%x\n", device);
     5497                printf("ioctl test with device = 0x%x\n", device);
    48665498                for (function=0;function<0x100;function++) {
    48675499                        uint32 code = (device<<16) | function;
     
    49025534        /* cleanup from an old run */
    49035535        cli_rmdir(cli, "\\chkpath.dir\\dir2");
    4904         cli_unlink(cli, "\\chkpath.dir\\*", aSYSTEM | aHIDDEN);
     5536        cli_unlink(cli, "\\chkpath.dir\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    49055537        cli_rmdir(cli, "\\chkpath.dir");
    49065538
     
    49565588
    49575589        cli_rmdir(cli, "\\chkpath.dir\\dir2");
    4958         cli_unlink(cli, "\\chkpath.dir\\*", aSYSTEM | aHIDDEN);
     5590        cli_unlink(cli, "\\chkpath.dir\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    49595591        cli_rmdir(cli, "\\chkpath.dir");
    49605592
     
    49765608        struct ea_struct *ea_list = NULL;
    49775609        TALLOC_CTX *mem_ctx = talloc_init("eatest");
     5610        NTSTATUS status;
    49785611
    49795612        printf("starting eatest\n");
     
    49845617        }
    49855618
    4986         cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
     5619        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    49875620        if (!NT_STATUS_IS_OK(cli_ntcreate(cli, fname, 0,
    49885621                                   FIRST_DESIRED_ACCESS, FILE_ATTRIBUTE_ARCHIVE,
     
    49995632                slprintf(ea_name, sizeof(ea_name), "EA_%d", i);
    50005633                memset(ea_val, (char)i+1, i+1);
    5001                 if (!cli_set_ea_fnum(cli, fnum, ea_name, ea_val, i+1)) {
    5002                         printf("ea_set of name %s failed - %s\n", ea_name, cli_errstr(cli));
     5634                status = cli_set_ea_fnum(cli, fnum, ea_name, ea_val, i+1);
     5635                if (!NT_STATUS_IS_OK(status)) {
     5636                        printf("ea_set of name %s failed - %s\n", ea_name,
     5637                               nt_errstr(status));
    50035638                        talloc_destroy(mem_ctx);
    50045639                        return False;
     
    50125647                slprintf(ea_name, sizeof(ea_name), "EA_%d", i+10);
    50135648                memset(ea_val, (char)i+1, i+1);
    5014                 if (!cli_set_ea_path(cli, fname, ea_name, ea_val, i+1)) {
    5015                         printf("ea_set of name %s failed - %s\n", ea_name, cli_errstr(cli));
     5649                status = cli_set_ea_path(cli, fname, ea_name, ea_val, i+1);
     5650                if (!NT_STATUS_IS_OK(status)) {
     5651                        printf("ea_set of name %s failed - %s\n", ea_name,
     5652                               nt_errstr(status));
    50165653                        talloc_destroy(mem_ctx);
    50175654                        return False;
     
    50195656        }
    50205657
    5021         if (!cli_get_ea_list_path(cli, fname, mem_ctx, &num_eas, &ea_list)) {
    5022                 printf("ea_get list failed - %s\n", cli_errstr(cli));
     5658        status = cli_get_ea_list_path(cli, fname, mem_ctx, &num_eas, &ea_list);
     5659        if (!NT_STATUS_IS_OK(status)) {
     5660                printf("ea_get list failed - %s\n", nt_errstr(status));
    50235661                correct = False;
    50245662        }
     
    50505688                fstring ea_name;
    50515689                slprintf(ea_name, sizeof(ea_name), "ea_%d", i);
    5052                 if (!cli_set_ea_path(cli, fname, ea_name, "", 0)) {
    5053                         printf("ea_set of name %s failed - %s\n", ea_name, cli_errstr(cli));
     5690                status = cli_set_ea_path(cli, fname, ea_name, "", 0);
     5691                if (!NT_STATUS_IS_OK(status)) {
     5692                        printf("ea_set of name %s failed - %s\n", ea_name,
     5693                               nt_errstr(status));
    50545694                        talloc_destroy(mem_ctx);
    50555695                        return False;
     
    50585698#endif
    50595699
    5060         if (!cli_get_ea_list_path(cli, fname, mem_ctx, &num_eas, &ea_list)) {
    5061                 printf("ea_get list failed - %s\n", cli_errstr(cli));
     5700        status = cli_get_ea_list_path(cli, fname, mem_ctx, &num_eas, &ea_list);
     5701        if (!NT_STATUS_IS_OK(status)) {
     5702                printf("ea_get list failed - %s\n", nt_errstr(status));
    50625703                correct = False;
    50635704        }
     
    50765717
    50775718        /* Try and delete a non existant EA. */
    5078         if (!cli_set_ea_path(cli, fname, "foo", "", 0)) {
    5079                 printf("deleting non-existant EA 'foo' should succeed. %s\n", cli_errstr(cli));
     5719        status = cli_set_ea_path(cli, fname, "foo", "", 0);
     5720        if (!NT_STATUS_IS_OK(status)) {
     5721                printf("deleting non-existant EA 'foo' should succeed. %s\n",
     5722                       nt_errstr(status));
    50805723                correct = False;
    50815724        }
     
    51065749
    51075750        cli_list(cli, "\\LISTDIR\\*", 0, del_fn, cli);
    5108         cli_list(cli, "\\LISTDIR\\*", aDIR, del_fn, cli);
     5751        cli_list(cli, "\\LISTDIR\\*", FILE_ATTRIBUTE_DIRECTORY, del_fn, cli);
    51095752        cli_rmdir(cli, "\\LISTDIR");
    51105753        cli_mkdir(cli, "\\LISTDIR");
     
    51315774
    51325775        /* Now ensure that doing an old list sees both files and directories. */
    5133         num_seen = cli_list_old(cli, "\\LISTDIR\\*", aDIR, list_fn, NULL);
     5776        num_seen = 0;
     5777        cli_list_old(cli, "\\LISTDIR\\*", FILE_ATTRIBUTE_DIRECTORY, list_fn, &num_seen);
    51345778        printf("num_seen = %d\n", num_seen );
    51355779        /* We should see 100 files + 1000 directories + . and .. */
     
    51405784         * relevent entries.
    51415785         */
    5142         num_seen = cli_list_old(cli, "\\LISTDIR\\*", (aDIR<<8)|aDIR, list_fn, NULL);
     5786        num_seen = 0;
     5787        cli_list_old(cli, "\\LISTDIR\\*", (FILE_ATTRIBUTE_DIRECTORY<<8)|FILE_ATTRIBUTE_DIRECTORY, list_fn, &num_seen);
    51435788        printf("num_seen = %d\n", num_seen );
    51445789        if (num_seen != 1002)
    51455790                correct = False;
    51465791
    5147         num_seen = cli_list_old(cli, "\\LISTDIR\\*", (aARCH<<8)|aDIR, list_fn, NULL);
     5792        num_seen = 0;
     5793        cli_list_old(cli, "\\LISTDIR\\*", (FILE_ATTRIBUTE_ARCHIVE<<8)|FILE_ATTRIBUTE_DIRECTORY, list_fn, &num_seen);
    51485794        printf("num_seen = %d\n", num_seen );
    51495795        if (num_seen != 1000)
     
    51525798        /* Delete everything. */
    51535799        cli_list(cli, "\\LISTDIR\\*", 0, del_fn, cli);
    5154         cli_list(cli, "\\LISTDIR\\*", aDIR, del_fn, cli);
     5800        cli_list(cli, "\\LISTDIR\\*", FILE_ATTRIBUTE_DIRECTORY, del_fn, cli);
    51555801        cli_rmdir(cli, "\\LISTDIR");
    51565802
     
    53175963                d_printf("\r%d   ", (int)c->vuid);
    53185964
    5319                 if (!cli_ulogoff(c)) {
     5965                status = cli_ulogoff(c);
     5966                if (!NT_STATUS_IS_OK(status)) {
    53205967                        d_printf("(%s) cli_ulogoff failed: %s\n",
    5321                                  __location__, cli_errstr(c));
     5968                                 __location__, nt_errstr(status));
    53225969                        return false;
    53235970                }
     
    54556102        printf("starting chain2 test\n");
    54566103        status = cli_start_connection(&cli1, global_myname(), host, NULL,
    5457                                       port_to_use, Undefined, 0, NULL);
     6104                                      port_to_use, Undefined, 0);
    54586105        if (!NT_STATUS_IS_OK(status)) {
    54596106                return False;
     
    57926439        NTSTATUS status;
    57936440        uint16_t dnum;
    5794         struct tevent_req *req1, *req2;
     6441        struct tevent_req *req1;
     6442        struct tevent_req *req2 = NULL;
    57956443        int i, num_unc_names;
    57966444        int num_finished = 0;
     
    59286576        cli_close(cli, fnum);
    59296577
    5930         if (!cli_qpathinfo(cli, alt_name, &change_time, &access_time,
    5931                            &write_time, &size, &mode)) {
    5932                 d_printf("cli_qpathinfo(%s) failed: %s\n", alt_name,
    5933                          cli_errstr(cli));
     6578        status = cli_qpathinfo1(cli, alt_name, &change_time, &access_time,
     6579                                &write_time, &size, &mode);
     6580        if (!NT_STATUS_IS_OK(status)) {
     6581                d_printf("cli_qpathinfo1(%s) failed: %s\n", alt_name,
     6582                         nt_errstr(status));
    59346583                return false;
    59356584        }
     
    59606609        bool ret = false;
    59616610        const char *fname = "\\writetest.txt";
     6611        struct timeval start_time;
    59626612        double seconds;
    59636613        double kbytes;
     
    59756625        cli_sockopt(cli1, sockops);
    59766626
    5977         start_timer();
     6627        start_time = timeval_current();
    59786628
    59796629        for (i=0; i<torture_numops; i++) {
    5980                 char c = 0;
     6630                uint8_t c = 0;
    59816631                off_t start = i * torture_blocksize;
    59826632                NTSTATUS status;
    59836633                size_t to_pull = torture_blocksize - 1;
    59846634
    5985                 if (cli_write(cli1, fnum, 0, &c,
    5986                               start + torture_blocksize - 1, 1) != 1) {
    5987                         printf("cli_write failed: %s\n", cli_errstr(cli1));
     6635                status = cli_writeall(cli1, fnum, 0, &c,
     6636                                      start + torture_blocksize - 1, 1, NULL);
     6637                if (!NT_STATUS_IS_OK(status)) {
     6638                        printf("cli_write failed: %s\n", nt_errstr(status));
    59886639                        goto fail;
    59896640                }
     
    59976648        }
    59986649
    5999         seconds = end_timer();
     6650        seconds = timeval_elapsed(&start_time);
    60006651        kbytes = (double)torture_blocksize * torture_numops;
    60016652        kbytes /= 1024;
     
    60076658 fail:
    60086659        cli_close(cli1, fnum);
    6009         cli_unlink(cli1, fname, aSYSTEM | aHIDDEN);
     6660        cli_unlink(cli1, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    60106661        torture_close_connection(cli1);
    60116662        return ret;
     
    60376688        int16_t old_cnum;
    60386689        bool correct = True;
     6690        NTSTATUS status;
    60396691
    60406692        printf("starting uid regression test\n");
     
    60496701        old_vuid = cli->vuid;
    60506702
    6051         if (!cli_ulogoff(cli)) {
     6703        status = cli_ulogoff(cli);
     6704        if (!NT_STATUS_IS_OK(status)) {
    60526705                d_printf("(%s) cli_ulogoff failed: %s\n",
    6053                         __location__, cli_errstr(cli));
     6706                         __location__, nt_errstr(status));
    60546707                correct = false;
    60556708                goto out;
     
    60596712
    60606713        /* Try an operation. */
    6061         if (!NT_STATUS_IS_OK(cli_mkdir(cli, "\\uid_reg_test"))) {
    6062                 /* We expect bad uid. */
     6714        status = cli_mkdir(cli, "\\uid_reg_test");
     6715        if (NT_STATUS_IS_OK(status)) {
     6716                d_printf("(%s) cli_mkdir succeeded\n",
     6717                         __location__);
     6718                correct = false;
     6719                goto out;
     6720        } else {
     6721                /* Should be bad uid. */
    60636722                if (!check_error(__LINE__, cli, ERRSRV, ERRbaduid,
    6064                                 NT_STATUS_NO_SUCH_USER)) {
    6065                         return False;
     6723                                NT_STATUS_USER_SESSION_DELETED)) {
     6724                        correct = false;
     6725                        goto out;
    60666726                }
    60676727        }
     
    60736733
    60746734        /* This should succeed. */
    6075         if (cli_tdis(cli)) {
    6076                 printf("First tdis with invalid vuid should succeed.\n");
     6735        status = cli_tdis(cli);
     6736
     6737        if (NT_STATUS_IS_OK(status)) {
     6738                d_printf("First tdis with invalid vuid should succeed.\n");
    60776739        } else {
    6078                 printf("First tdis failed (%s)\n", cli_errstr(cli));
     6740                d_printf("First tdis failed (%s)\n", nt_errstr(status));
     6741                correct = false;
     6742                goto out;
    60796743        }
    60806744
     
    60836747
    60846748        /* This should fail. */
    6085         if (cli_tdis(cli)) {
    6086                 printf("Second tdis with invalid vuid should fail - succeeded instead !.\n");
     6749        status = cli_tdis(cli);
     6750        if (NT_STATUS_IS_OK(status)) {
     6751                d_printf("Second tdis with invalid vuid should fail - succeeded instead !.\n");
     6752                correct = false;
     6753                goto out;
    60876754        } else {
    60886755                /* Should be bad tid. */
    60896756                if (!check_error(__LINE__, cli, ERRSRV, ERRinvnid,
    60906757                                NT_STATUS_NETWORK_NAME_DELETED)) {
    6091                         return False;
     6758                        correct = false;
     6759                        goto out;
    60926760                }
    60936761        }
     
    61056773static char force_shortname_chars[] = " +,.[];=\177";
    61066774
    6107 static void shortname_del_fn(const char *mnt, file_info *finfo, const char *mask, void *state)
     6775static NTSTATUS shortname_del_fn(const char *mnt, struct file_info *finfo,
     6776                             const char *mask, void *state)
    61086777{
    61096778        struct cli_state *pcli = (struct cli_state *)state;
    61106779        fstring fname;
     6780        NTSTATUS status = NT_STATUS_OK;
     6781
    61116782        slprintf(fname, sizeof(fname), "\\shortname\\%s", finfo->name);
    61126783
    61136784        if (strcmp(finfo->name, ".") == 0 || strcmp(finfo->name, "..") == 0)
    6114                 return;
    6115 
    6116         if (finfo->mode & aDIR) {
    6117                 if (!NT_STATUS_IS_OK(cli_rmdir(pcli, fname)))
     6785                return NT_STATUS_OK;
     6786
     6787        if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) {
     6788                status = cli_rmdir(pcli, fname);
     6789                if (!NT_STATUS_IS_OK(status)) {
    61186790                        printf("del_fn: failed to rmdir %s\n,", fname );
     6791                }
    61196792        } else {
    6120                 if (!NT_STATUS_IS_OK(cli_unlink(pcli, fname, aSYSTEM | aHIDDEN)))
     6793                status = cli_unlink(pcli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
     6794                if (!NT_STATUS_IS_OK(status)) {
    61216795                        printf("del_fn: failed to unlink %s\n,", fname );
    6122         }
     6796                }
     6797        }
     6798        return status;
    61236799}
    61246800
    61256801struct sn_state {
     6802        int matched;
    61266803        int i;
    61276804        bool val;
    61286805};
    61296806
    6130 static void shortname_list_fn(const char *mnt, file_info *finfo, const char *name, void *state)
     6807static NTSTATUS shortname_list_fn(const char *mnt, struct file_info *finfo,
     6808                              const char *name, void *state)
    61316809{
    61326810        struct sn_state *s = (struct sn_state  *)state;
     
    61516829                s->val = true;
    61526830        }
     6831        s->matched += 1;
     6832        return NT_STATUS_OK;
    61536833}
    61546834
     
    61706850
    61716851        cli_list(cli, "\\shortname\\*", 0, shortname_del_fn, cli);
    6172         cli_list(cli, "\\shortname\\*", aDIR, shortname_del_fn, cli);
     6852        cli_list(cli, "\\shortname\\*", FILE_ATTRIBUTE_DIRECTORY, shortname_del_fn, cli);
    61736853        cli_rmdir(cli, "\\shortname");
    61746854
     
    62056885                }
    62066886                cli_close(cli, fnum);
    6207                 if (cli_list(cli, "\\shortname\\test*.*", 0, shortname_list_fn, &s) != 1) {
     6887
     6888                s.matched = 0;
     6889                cli_list(cli, "\\shortname\\test*.*", 0, shortname_list_fn,
     6890                         &s);
     6891                if (s.matched != 1) {
    62086892                        d_printf("(%s) failed to list %s: %s\n",
    62096893                                __location__, fname, cli_errstr(cli));
     
    62116895                        goto out;
    62126896                }
    6213                 if (!NT_STATUS_IS_OK(cli_unlink(cli, fname, aSYSTEM | aHIDDEN))) {
     6897                if (!NT_STATUS_IS_OK(cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN))) {
    62146898                        d_printf("(%s) failed to delete %s: %s\n",
    62156899                                __location__, fname, cli_errstr(cli));
     
    62276911
    62286912        cli_list(cli, "\\shortname\\*", 0, shortname_del_fn, cli);
    6229         cli_list(cli, "\\shortname\\*", aDIR, shortname_del_fn, cli);
     6913        cli_list(cli, "\\shortname\\*", FILE_ATTRIBUTE_DIRECTORY, shortname_del_fn, cli);
    62306914        cli_rmdir(cli, "\\shortname");
    62316915        torture_close_connection(cli);
     
    62666950        struct tevent_req *req;
    62676951        char *basedn;
     6952        const char *filter;
    62686953
    62696954        if (!resolve_name(host, &addr, 0, false)) {
     
    63197004        TALLOC_FREE(req);
    63207005
     7006        /* test search filters against rootDSE */
     7007        filter = "(&(|(name=samba)(nextRid<=10000000)(usnChanged>=10)(samba~=ambas)(!(name=s*m*a)))"
     7008                   "(|(name:=samba)(name:dn:2.5.13.5:=samba)(:dn:2.5.13.5:=samba)(!(name=*samba))))";
     7009
     7010        rc = tldap_search(ld, "", TLDAP_SCOPE_BASE, filter,
     7011                          NULL, 0, 0, NULL, 0, NULL, 0, 0, 0, 0,
     7012                          talloc_tos(), NULL, NULL);
     7013        if (rc != TLDAP_SUCCESS) {
     7014                d_printf("tldap_search with complex filter failed: %s\n",
     7015                         tldap_errstr(talloc_tos(), ld, rc));
     7016                return false;
     7017        }
     7018
    63217019        TALLOC_FREE(ld);
    63227020        return true;
    63237021}
     7022
     7023/* Torture test to ensure no regression of :
     7024https://bugzilla.samba.org/show_bug.cgi?id=7084
     7025*/
     7026
     7027static bool run_dir_createtime(int dummy)
     7028{
     7029        struct cli_state *cli;
     7030        const char *dname = "\\testdir";
     7031        const char *fname = "\\testdir\\testfile";
     7032        NTSTATUS status;
     7033        struct timespec create_time;
     7034        struct timespec create_time1;
     7035        uint16_t fnum;
     7036        bool ret = false;
     7037
     7038        if (!torture_open_connection(&cli, 0)) {
     7039                return false;
     7040        }
     7041
     7042        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
     7043        cli_rmdir(cli, dname);
     7044
     7045        status = cli_mkdir(cli, dname);
     7046        if (!NT_STATUS_IS_OK(status)) {
     7047                printf("mkdir failed: %s\n", nt_errstr(status));
     7048                goto out;
     7049        }
     7050
     7051        status = cli_qpathinfo2(cli, dname, &create_time, NULL, NULL, NULL,
     7052                                NULL, NULL, NULL);
     7053        if (!NT_STATUS_IS_OK(status)) {
     7054                printf("cli_qpathinfo2 returned %s\n",
     7055                       nt_errstr(status));
     7056                goto out;
     7057        }
     7058
     7059        /* Sleep 3 seconds, then create a file. */
     7060        sleep(3);
     7061
     7062        status = cli_open(cli, fname, O_RDWR | O_CREAT | O_EXCL,
     7063                         DENY_NONE, &fnum);
     7064        if (!NT_STATUS_IS_OK(status)) {
     7065                printf("cli_open failed: %s\n", nt_errstr(status));
     7066                goto out;
     7067        }
     7068
     7069        status = cli_qpathinfo2(cli, dname, &create_time1, NULL, NULL, NULL,
     7070                                NULL, NULL, NULL);
     7071        if (!NT_STATUS_IS_OK(status)) {
     7072                printf("cli_qpathinfo2 (2) returned %s\n",
     7073                       nt_errstr(status));
     7074                goto out;
     7075        }
     7076
     7077        if (timespec_compare(&create_time1, &create_time)) {
     7078                printf("run_dir_createtime: create time was updated (error)\n");
     7079        } else {
     7080                printf("run_dir_createtime: create time was not updated (correct)\n");
     7081                ret = true;
     7082        }
     7083
     7084  out:
     7085
     7086        cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
     7087        cli_rmdir(cli, dname);
     7088        if (!torture_close_connection(cli)) {
     7089                ret = false;
     7090        }
     7091        return ret;
     7092}
     7093
    63247094
    63257095static bool run_streamerror(int dummy)
     
    63397109        }
    63407110
     7111        cli_unlink(cli, "\\testdir\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    63417112        cli_rmdir(cli, dname);
    63427113
     
    63477118        }
    63487119
    6349         cli_qpathinfo(cli, streamname, &change_time, &access_time, &write_time,
     7120        cli_qpathinfo1(cli, streamname, &change_time, &access_time, &write_time,
    63507121                      &size, &mode);
    63517122        status = cli_nt_error(cli);
     
    66517422        TALLOC_FREE(dict);
    66527423
     7424        return true;
     7425}
     7426
     7427static bool run_local_string_to_sid(int dummy) {
     7428        struct dom_sid sid;
     7429
     7430        if (string_to_sid(&sid, "S--1-5-32-545")) {
     7431                printf("allowing S--1-5-32-545\n");
     7432                return false;
     7433        }
     7434        if (string_to_sid(&sid, "S-1-5-32-+545")) {
     7435                printf("allowing S-1-5-32-+545\n");
     7436                return false;
     7437        }
     7438        if (string_to_sid(&sid, "S-1-2-3-4-5-6-7-8-9-0-1-2-3-4-5-6-7-8-9-0")) {
     7439                printf("allowing S-1-2-3-4-5-6-7-8-9-0-1-2-3-4-5-6-7-8-9-0\n");
     7440                return false;
     7441        }
     7442        if (string_to_sid(&sid, "S-1-5-32-545-abc")) {
     7443                printf("allowing S-1-5-32-545-abc\n");
     7444                return false;
     7445        }
     7446        if (!string_to_sid(&sid, "S-1-5-32-545")) {
     7447                printf("could not parse S-1-5-32-545\n");
     7448                return false;
     7449        }
     7450        if (!dom_sid_equal(&sid, &global_sid_Builtin_Users)) {
     7451                printf("mis-parsed S-1-5-32-545 as %s\n",
     7452                       sid_string_tos(&sid));
     7453                return false;
     7454        }
     7455        return true;
     7456}
     7457
     7458static bool run_local_binary_to_sid(int dummy) {
     7459        struct dom_sid *sid = talloc(NULL, struct dom_sid);
     7460        static const char good_binary_sid[] = {
     7461                0x1, /* revision number */
     7462                15, /* num auths */
     7463                0x1, 0x1, 0x1, 0x1, 0x1, 0x1, /* id_auth */
     7464                0x1, 0x1, 0x1, 0x1, /* auth[0] */
     7465                0x1, 0x1, 0x1, 0x1, /* auth[1] */
     7466                0x1, 0x1, 0x1, 0x1, /* auth[2] */
     7467                0x1, 0x1, 0x1, 0x1, /* auth[3] */
     7468                0x1, 0x1, 0x1, 0x1, /* auth[4] */
     7469                0x1, 0x1, 0x1, 0x1, /* auth[5] */
     7470                0x1, 0x1, 0x1, 0x1, /* auth[6] */
     7471                0x1, 0x1, 0x1, 0x1, /* auth[7] */
     7472                0x1, 0x1, 0x1, 0x1, /* auth[8] */
     7473                0x1, 0x1, 0x1, 0x1, /* auth[9] */
     7474                0x1, 0x1, 0x1, 0x1, /* auth[10] */
     7475                0x1, 0x1, 0x1, 0x1, /* auth[11] */
     7476                0x1, 0x1, 0x1, 0x1, /* auth[12] */
     7477                0x1, 0x1, 0x1, 0x1, /* auth[13] */
     7478                0x1, 0x1, 0x1, 0x1, /* auth[14] */
     7479        };
     7480
     7481        static const char long_binary_sid[] = {
     7482                0x1, /* revision number */
     7483                15, /* num auths */
     7484                0x1, 0x1, 0x1, 0x1, 0x1, 0x1, /* id_auth */
     7485                0x1, 0x1, 0x1, 0x1, /* auth[0] */
     7486                0x1, 0x1, 0x1, 0x1, /* auth[1] */
     7487                0x1, 0x1, 0x1, 0x1, /* auth[2] */
     7488                0x1, 0x1, 0x1, 0x1, /* auth[3] */
     7489                0x1, 0x1, 0x1, 0x1, /* auth[4] */
     7490                0x1, 0x1, 0x1, 0x1, /* auth[5] */
     7491                0x1, 0x1, 0x1, 0x1, /* auth[6] */
     7492                0x1, 0x1, 0x1, 0x1, /* auth[7] */
     7493                0x1, 0x1, 0x1, 0x1, /* auth[8] */
     7494                0x1, 0x1, 0x1, 0x1, /* auth[9] */
     7495                0x1, 0x1, 0x1, 0x1, /* auth[10] */
     7496                0x1, 0x1, 0x1, 0x1, /* auth[11] */
     7497                0x1, 0x1, 0x1, 0x1, /* auth[12] */
     7498                0x1, 0x1, 0x1, 0x1, /* auth[13] */
     7499                0x1, 0x1, 0x1, 0x1, /* auth[14] */
     7500                0x1, 0x1, 0x1, 0x1, /* auth[15] */
     7501                0x1, 0x1, 0x1, 0x1, /* auth[16] */
     7502                0x1, 0x1, 0x1, 0x1, /* auth[17] */
     7503        };
     7504
     7505        static const char long_binary_sid2[] = {
     7506                0x1, /* revision number */
     7507                32, /* num auths */
     7508                0x1, 0x1, 0x1, 0x1, 0x1, 0x1, /* id_auth */
     7509                0x1, 0x1, 0x1, 0x1, /* auth[0] */
     7510                0x1, 0x1, 0x1, 0x1, /* auth[1] */
     7511                0x1, 0x1, 0x1, 0x1, /* auth[2] */
     7512                0x1, 0x1, 0x1, 0x1, /* auth[3] */
     7513                0x1, 0x1, 0x1, 0x1, /* auth[4] */
     7514                0x1, 0x1, 0x1, 0x1, /* auth[5] */
     7515                0x1, 0x1, 0x1, 0x1, /* auth[6] */
     7516                0x1, 0x1, 0x1, 0x1, /* auth[7] */
     7517                0x1, 0x1, 0x1, 0x1, /* auth[8] */
     7518                0x1, 0x1, 0x1, 0x1, /* auth[9] */
     7519                0x1, 0x1, 0x1, 0x1, /* auth[10] */
     7520                0x1, 0x1, 0x1, 0x1, /* auth[11] */
     7521                0x1, 0x1, 0x1, 0x1, /* auth[12] */
     7522                0x1, 0x1, 0x1, 0x1, /* auth[13] */
     7523                0x1, 0x1, 0x1, 0x1, /* auth[14] */
     7524                0x1, 0x1, 0x1, 0x1, /* auth[15] */
     7525                0x1, 0x1, 0x1, 0x1, /* auth[16] */
     7526                0x1, 0x1, 0x1, 0x1, /* auth[17] */
     7527                0x1, 0x1, 0x1, 0x1, /* auth[18] */
     7528                0x1, 0x1, 0x1, 0x1, /* auth[19] */
     7529                0x1, 0x1, 0x1, 0x1, /* auth[20] */
     7530                0x1, 0x1, 0x1, 0x1, /* auth[21] */
     7531                0x1, 0x1, 0x1, 0x1, /* auth[22] */
     7532                0x1, 0x1, 0x1, 0x1, /* auth[23] */
     7533                0x1, 0x1, 0x1, 0x1, /* auth[24] */
     7534                0x1, 0x1, 0x1, 0x1, /* auth[25] */
     7535                0x1, 0x1, 0x1, 0x1, /* auth[26] */
     7536                0x1, 0x1, 0x1, 0x1, /* auth[27] */
     7537                0x1, 0x1, 0x1, 0x1, /* auth[28] */
     7538                0x1, 0x1, 0x1, 0x1, /* auth[29] */
     7539                0x1, 0x1, 0x1, 0x1, /* auth[30] */
     7540                0x1, 0x1, 0x1, 0x1, /* auth[31] */
     7541        };
     7542
     7543        if (!sid_parse(good_binary_sid, sizeof(good_binary_sid), sid)) {
     7544                return false;
     7545        }
     7546        if (sid_parse(long_binary_sid2, sizeof(long_binary_sid2), sid)) {
     7547                return false;
     7548        }
     7549        if (sid_parse(long_binary_sid, sizeof(long_binary_sid), sid)) {
     7550                return false;
     7551        }
    66537552        return true;
    66547553}
     
    67767675
    67777676 error:
    6778         d_fprintf(stderr, "test_stream(%s, %s, %s, %s)\n",
     7677        d_fprintf(stderr, "Do test_stream(%s, %s, %s, %s)\n",
    67797678                  fname, expected_base ? expected_base : "<NULL>",
    67807679                  expected_stream ? expected_stream : "<NULL>",
     
    71668065}
    71678066
     8067/*
     8068 * Just a dummy test to be run under a debugger. There's no real way
     8069 * to inspect the tevent_select specific function from outside of
     8070 * tevent_select.c.
     8071 */
     8072
     8073static bool run_local_tevent_select(int dummy)
     8074{
     8075        struct tevent_context *ev;
     8076        struct tevent_fd *fd1, *fd2;
     8077        bool result = false;
     8078
     8079        ev = tevent_context_init_byname(NULL, "select");
     8080        if (ev == NULL) {
     8081                d_fprintf(stderr, "tevent_context_init_byname failed\n");
     8082                goto fail;
     8083        }
     8084
     8085        fd1 = tevent_add_fd(ev, ev, 2, 0, NULL, NULL);
     8086        if (fd1 == NULL) {
     8087                d_fprintf(stderr, "tevent_add_fd failed\n");
     8088                goto fail;
     8089        }
     8090        fd2 = tevent_add_fd(ev, ev, 3, 0, NULL, NULL);
     8091        if (fd2 == NULL) {
     8092                d_fprintf(stderr, "tevent_add_fd failed\n");
     8093                goto fail;
     8094        }
     8095        TALLOC_FREE(fd2);
     8096
     8097        fd2 = tevent_add_fd(ev, ev, 1, 0, NULL, NULL);
     8098        if (fd2 == NULL) {
     8099                d_fprintf(stderr, "tevent_add_fd failed\n");
     8100                goto fail;
     8101        }
     8102
     8103        result = true;
     8104fail:
     8105        TALLOC_FREE(ev);
     8106        return result;
     8107}
     8108
    71688109static double create_procs(bool (*fn)(int), bool *result)
    71698110{
     
    71738114        int synccount;
    71748115        int tries = 8;
     8116        struct timeval start;
    71758117
    71768118        synccount = 0;
     
    71938135        }
    71948136
    7195         start_timer();
     8137        start = timeval_current();
    71968138
    71978139        for (i=0;i<nprocs;i++) {
     
    72148156                        child_status[i] = getpid();
    72158157
    7216                         while (child_status[i] && end_timer() < 5) smb_msleep(2);
     8158                        while (child_status[i] && timeval_elapsed(&start) < 5) smb_msleep(2);
    72178159
    72188160                        child_status_out[i] = fn(i);
     
    72288170                if (synccount == nprocs) break;
    72298171                smb_msleep(10);
    7230         } while (end_timer() < 30);
     8172        } while (timeval_elapsed(&start) < 30);
    72318173
    72328174        if (synccount != nprocs) {
    72338175                printf("FAILED TO START %d CLIENTS (started %d)\n", nprocs, synccount);
    72348176                *result = False;
    7235                 return end_timer();
     8177                return timeval_elapsed(&start);
    72368178        }
    72378179
    72388180        /* start the client load */
    7239         start_timer();
     8181        start = timeval_current();
    72408182
    72418183        for (i=0;i<nprocs;i++) {
     
    72568198                }
    72578199        }
    7258         return end_timer();
     8200        return timeval_elapsed(&start);
    72598201}
    72608202
     
    72858227        {"NEGNOWAIT", run_negprot_nowait, 0},
    72868228        {"NBENCH",  run_nbench, 0},
     8229        {"NBENCH2", run_nbench2, 0},
    72878230        {"OPLOCK1",  run_oplock1, 0},
    72888231        {"OPLOCK2",  run_oplock2, 0},
    72898232        {"OPLOCK3",  run_oplock3, 0},
     8233        {"OPLOCK4",  run_oplock4, 0},
    72908234        {"DIR",  run_dirtest, 0},
    72918235        {"DIR1",  run_dirtest1, 0},
     8236        {"DIR-CREATETIME",  run_dir_createtime, 0},
    72928237        {"DENY1",  torture_denytest1, 0},
    72938238        {"DENY2",  torture_denytest2, 0},
     
    72978242        {"RW2",  run_readwritemulti, FLAG_MULTIPROC},
    72988243        {"RW3",  run_readwritelarge, 0},
     8244        {"RW-SIGNING",  run_readwritelarge_signtest, 0},
    72998245        {"OPEN", run_opentest, 0},
    73008246        {"POSIX", run_simple_posix_open_test, 0},
     8247        {"POSIX-APPEND", run_posix_append, 0},
     8248        {"ASYNC-ECHO", run_async_echo, 0},
    73018249        { "UID-REGRESSION-TEST", run_uid_regression_test, 0},
    73028250        { "SHORTNAME-TEST", run_shortname_test, 0},
     8251        { "ADDRCHANGE", run_addrchange, 0},
    73038252#if 1
    73048253        {"OPENATTR", run_openattrtest, 0},
     
    73078256        {"RENAME", run_rename, 0},
    73088257        {"DELETE", run_deletetest, 0},
     8258        {"DELETE-LN", run_deletetest_ln, 0},
    73098259        {"PROPERTIES", run_properties, 0},
    73108260        {"MANGLE", torture_mangle, 0},
     
    73318281        { "STREAMERROR", run_streamerror },
    73328282        { "NOTIFY-BENCH", run_notify_bench },
     8283        { "BAD-NBT-SESSION", run_bad_nbt_session },
     8284        { "SMB-ANY-CONNECT", run_smb_any_connect },
    73338285        { "LOCAL-SUBSTITUTE", run_local_substitute, 0},
    73348286        { "LOCAL-GENCACHE", run_local_gencache, 0},
     
    73398291        { "LOCAL-STREAM-NAME", run_local_stream_name, 0},
    73408292        { "LOCAL-WBCLIENT", run_local_wbclient, 0},
     8293        { "LOCAL-string_to_sid", run_local_string_to_sid, 0},
     8294        { "LOCAL-binary_to_sid", run_local_binary_to_sid, 0},
    73418295        { "LOCAL-DBTRANS", run_local_dbtrans, 0},
     8296        { "LOCAL-TEVENT-SELECT", run_local_tevent_select, 0},
    73428297        {NULL, NULL, 0}};
    73438298
     
    73758330                                }
    73768331                        } else {
    7377                                 start_timer();
     8332                                struct timeval start;
     8333                                start = timeval_current();
    73788334                                if (!torture_ops[i].fn(0)) {
    73798335                                        ret = False;
    73808336                                        printf("TEST %s FAILED!\n", name);
    73818337                                }
    7382                                 t = end_timer();
     8338                                t = timeval_elapsed(&start);
    73838339                        }
    73848340                        printf("%s took %g secs\n\n", name, t);
     
    74458401        int seed = time(NULL);
    74468402
    7447         dbf = x_stdout;
    7448 
    74498403#ifdef HAVE_SETBUFFER
    74508404        setbuffer(stdout, NULL, 0);
    74518405#endif
    74528406
     8407        setup_logging("smbtorture", DEBUG_STDOUT);
     8408
    74538409        load_case_tables();
    7454 
    7455         setup_logging("smbtorture", true);
    74568410
    74578411        if (is_default_dyn_CONFIGFILE()) {
     
    75198473                        break;
    75208474                case 'd':
    7521                         DEBUGLEVEL = atoi(optarg);
     8475                        lp_set_cmdline("log level", optarg);
    75228476                        break;
    75238477                case 'O':
  • trunk/server/source3/torture/utable.c

    r414 r745  
    1919
    2020#include "includes.h"
     21#include "system/filesys.h"
     22#include "torture/proto.h"
     23#include "../libcli/security/security.h"
     24#include "libsmb/libsmb.h"
     25#include "libsmb/clirap.h"
    2126
    2227bool torture_utable(int dummy)
     
    3944
    4045        cli_mkdir(cli, "\\utable");
    41         cli_unlink(cli, "\\utable\\*", aSYSTEM | aHIDDEN);
     46        cli_unlink(cli, "\\utable\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    4247
    4348        for (c=1; c < 0x10000; c++) {
     
    6974
    7075                cli_close(cli, fnum);
    71                 cli_unlink(cli, fname, aSYSTEM | aHIDDEN);
     76                cli_unlink(cli, fname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    7277
    7378                if (c % 100 == 0) {
     
    132137        memset(equiv, 0, sizeof(equiv));
    133138
    134         cli_unlink(cli, "\\utable\\*", aSYSTEM | aHIDDEN);
     139        cli_unlink(cli, "\\utable\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    135140        cli_rmdir(cli, "\\utable");
    136141        if (!NT_STATUS_IS_OK(cli_mkdir(cli, "\\utable"))) {
     
    158163                size = 0;
    159164
    160                 if (!cli_qfileinfo(cli, fnum, NULL, &size,
    161                                    NULL, NULL, NULL, NULL, NULL)) continue;
     165                if (!NT_STATUS_IS_OK(cli_qfileinfo_basic(
     166                                             cli, fnum, NULL, &size,
     167                                             NULL, NULL, NULL, NULL, NULL))) {
     168                        continue;
     169                }
    162170
    163171                if (size > 0) {
     
    183191                }
    184192
    185                 cli_write(cli, fnum, 0, (char *)&c, size, sizeof(c));
     193                cli_writeall(cli, fnum, 0, (uint8_t *)&c, size, sizeof(c),
     194                             NULL);
    186195                cli_close(cli, fnum);
    187196        }
    188197
    189         cli_unlink(cli, "\\utable\\*", aSYSTEM | aHIDDEN);
     198        cli_unlink(cli, "\\utable\\*", FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN);
    190199        cli_rmdir(cli, "\\utable");
    191200
  • trunk/server/source3/torture/vfstest.c

    r414 r745  
    2525
    2626#include "includes.h"
     27#include "smbd/smbd.h"
     28#include "popt_common.h"
    2729#include "vfstest.h"
     30#include "../libcli/smbreadline/smbreadline.h"
    2831
    2932/* List to hold groups of commands */
     
    3235        struct cmd_set *cmd_set;
    3336} *cmd_list;
    34 
    35 int get_client_fd(void)
    36 {
    37         return -1;
    38 }
    3937
    4038/****************************************************************************
     
    192190
    193191        if (argc == 2) {
    194                 DEBUGLEVEL = atoi(argv[1]);
     192                lp_set_cmdline("log level", argv[1]);
    195193        }
    196194
     
    415413}
    416414
    417 static int server_fd = -1;
    418415int last_message = -1;
    419 
    420 int smbd_server_fd(void)
    421 {
    422                 return server_fd;
    423 }
    424 
    425 void reload_printers(void)
    426 {
    427         return;
    428 }
    429 
    430 /****************************************************************************
    431  Reload the services file.
    432 **************************************************************************/
    433 
    434 bool reload_services(bool test)
    435 {
    436         bool ret;
    437 
    438         if (lp_loaded()) {
    439                 const char *fname = lp_configfile();
    440                 if (file_exist(fname) &&
    441                     !strcsequal(fname, get_dyn_CONFIGFILE())) {
    442                         set_dyn_CONFIGFILE(fname);
    443                         test = False;
    444                 }
    445         }
    446 
    447         reopen_logs();
    448 
    449         if (test && !lp_file_list_changed())
    450                 return(True);
    451 
    452         lp_killunused(conn_snum_used);
    453 
    454         ret = lp_load(get_dyn_CONFIGFILE(), False, False, True, True);
    455 
    456         /* perhaps the config filename is now set */
    457         if (!test)
    458                 reload_services(True);
    459 
    460         reopen_logs();
    461 
    462         load_interfaces();
    463 
    464         {
    465                 if (smbd_server_fd() != -1) {     
    466                         set_socket_options(smbd_server_fd(),"SO_KEEPALIVE");
    467                         set_socket_options(smbd_server_fd(),
    468                                            lp_socket_options());
    469                 }
    470         }
    471 
    472         mangle_reset_cache();
    473         reset_stat_cache();
    474 
    475         /* this forces service parameters to be flushed */
    476         set_current_service(NULL,0,True);
    477 
    478         return (ret);
    479 }
    480416
    481417struct event_context *smbd_event_context(void)
     
    487423        }
    488424        return ctx;
    489 }
    490 
    491 struct messaging_context *smbd_messaging_context(void)
    492 {
    493         static struct messaging_context *ctx;
    494 
    495         if (!ctx && !(ctx = messaging_init(NULL, server_id_self(),
    496                                            smbd_event_context()))) {
    497                 smb_panic("Could not init smbd messaging context\n");
    498         }
    499         return ctx;
    500 }
    501 
    502 struct memcache *smbd_memcache(void)
    503 {
    504         static struct memcache *cache;
    505 
    506         if (!cache
    507             && !(cache = memcache_init(NULL,
    508                                        lp_max_stat_cache_size()*1024))) {
    509 
    510                 smb_panic("Could not init smbd memcache");
    511         }
    512         return cache;
    513425}
    514426
     
    547459        poptFreeContext(pc);
    548460
     461        lp_load_initial_only(get_dyn_CONFIGFILE());
     462
    549463        /* TODO: check output */
    550         reload_services(False);
     464        reload_services(smbd_messaging_context(), -1, False);
    551465
    552466        /* the following functions are part of the Samba debugging
    553467           facilities.  See lib/debug.c */
    554         setup_logging("vfstest", True);
     468        setup_logging("vfstest", DEBUG_STDOUT);
    555469       
    556470        /* Load command lists */
Note: See TracChangeset for help on using the changeset viewer.