The branch, master has been updated
       via  7c10b5e s3:winbindd_cm: make use of cli->src_ss instead of calling 
getsockname()
       via  cf4832d s3:winbindd_cm: make use of cli->dest_ss instead calling 
getpeername()
       via  7a795ff s3:winbindd_cm: make use of cli_state_disconnect()
       via  0791a4d s3:winbindd_cm: make use of cli_state_is_connected()
       via  1f50d04 s3:auth_server: use cli_echo() to check if the server is 
alive
       via  8c29afe s3:auth_server: make use of cli_state_is_connected()
       via  6ec26f0 s3:client: simplify readline_callback() to only use 
cli_echo()
       via  a2e248f s3:libsmbclient: use cli_state_is_connected() in 
SMBC_check_server()
       via  e7c9319 s3:libsmbclient: don't log the lowlevel fd in 
smbc_free_context()
       via  7bba81f s3:libsmb: add cli_state_disconnect()
       via  fa60a29 s3:libsmb: make use of cli_state_is_connected()
       via  2b70c0f s3:libsmb: remove unused cli_set_port()
       via  893d137 s3:libsmb: also remember the local socket address after 
connect
       via  a230009 s3:smb2cli_base: add my copyright
       via  50e2785 s3-torture: run_locktest2(): replace check_error() with 
check_both_error()
       via  e14e674 s3-torture: run_locktest2(): replace cli_lock() with 
cli_lock32()
       via  c9f60454 s3-torture: run_locktest1(): replace cli_lock() with 
cli_lock32()
       via  23b417b s3-torture: locktest2: replace cli_lock() with cli_lock32()
       via  b6e9866 s3-torture: let wait_lock() use cli_lock32() instead of 
cli_lock()
      from  f2c5a0a s3-libsmb: let cli_lock64 return NTSTATUS instead of bool

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 7c10b5e03379782841d0e58910c579647b75e39c
Author: Stefan Metzmacher <me...@samba.org>
Date:   Mon Jul 11 15:12:40 2011 +0200

    s3:winbindd_cm: make use of cli->src_ss instead of calling getsockname()
    
    metze
    
    Autobuild-User: Stefan Metzmacher <me...@samba.org>
    Autobuild-Date: Mon Jul 11 19:31:14 CEST 2011 on sn-devel-104

commit cf4832d01069c7c91744ace97b6566c24b5ab7bc
Author: Stefan Metzmacher <me...@samba.org>
Date:   Mon Jul 11 14:58:41 2011 +0200

    s3:winbindd_cm: make use of cli->dest_ss instead calling getpeername()
    
    metze

commit 7a795ffeb42253b46a05771188d1b5f2961b990f
Author: Stefan Metzmacher <me...@samba.org>
Date:   Mon Jul 11 14:38:52 2011 +0200

    s3:winbindd_cm: make use of cli_state_disconnect()
    
    metze

commit 0791a4d5beb7565c0ac476f8117b36b57fa5f938
Author: Stefan Metzmacher <me...@samba.org>
Date:   Mon Jul 11 14:19:55 2011 +0200

    s3:winbindd_cm: make use of cli_state_is_connected()
    
    metze

commit 1f50d04a5cf3ec8909ebf5b7547adef2b16af0cb
Author: Stefan Metzmacher <me...@samba.org>
Date:   Mon Jul 11 13:56:10 2011 +0200

    s3:auth_server: use cli_echo() to check if the server is alive
    
    This works over port 139 and also 445. send_keepalive() would
    only work on port 139.
    
    metze

commit 8c29afe14ecc474d94314c55d730760754f2f067
Author: Stefan Metzmacher <me...@samba.org>
Date:   Mon Jul 11 13:55:18 2011 +0200

    s3:auth_server: make use of cli_state_is_connected()
    
    metze

commit 6ec26f0c1a5ac917864078296d6ca89eb65510f9
Author: Stefan Metzmacher <me...@samba.org>
Date:   Mon Jul 11 13:19:47 2011 +0200

    s3:client: simplify readline_callback() to only use cli_echo()
    
    cli_echo() already swallows NBT keepalive messages,
    so there's no need to filter them in the 'smbclient' layer.
    
    metze

commit a2e248f27084fd81631dd3dc6614e078d8f99924
Author: Stefan Metzmacher <me...@samba.org>
Date:   Mon Jul 11 14:15:21 2011 +0200

    s3:libsmbclient: use cli_state_is_connected() in SMBC_check_server()
    
    metze

commit e7c9319cacab287cb5772e38f30e9492afc82e8d
Author: Stefan Metzmacher <me...@samba.org>
Date:   Mon Jul 11 14:29:28 2011 +0200

    s3:libsmbclient: don't log the lowlevel fd in smbc_free_context()
    
    metze

commit 7bba81f69dec444a7adb16bed5bba921e483c7b2
Author: Stefan Metzmacher <me...@samba.org>
Date:   Mon Jul 11 14:33:54 2011 +0200

    s3:libsmb: add cli_state_disconnect()
    
    metze

commit fa60a299f5621ca06b25e64d552a85f846d7f0f2
Author: Stefan Metzmacher <me...@samba.org>
Date:   Mon Jul 11 16:25:18 2011 +0200

    s3:libsmb: make use of cli_state_is_connected()
    
    metze

commit 2b70c0f4f39d2ab7e678e91bc57a2e5980dbc816
Author: Stefan Metzmacher <me...@samba.org>
Date:   Mon Jul 11 16:37:25 2011 +0200

    s3:libsmb: remove unused cli_set_port()
    
    metze

commit 893d137f3f426e7b91542cc50b6c1ef8d69643f0
Author: Stefan Metzmacher <me...@samba.org>
Date:   Mon Jul 11 14:26:23 2011 +0200

    s3:libsmb: also remember the local socket address after connect
    
    metze

commit a2300094db04048766ca3f136eff2090065c6652
Author: Stefan Metzmacher <me...@samba.org>
Date:   Mon Jul 11 15:14:34 2011 +0200

    s3:smb2cli_base: add my copyright
    
    metze

commit 50e2785f5e2c870485f8219c97d447b8ea89a1a7
Author: Björn Baumbach <b...@sernet.de>
Date:   Mon Jul 11 14:23:30 2011 +0200

    s3-torture: run_locktest2(): replace check_error() with check_both_error()
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>

commit e14e6747aed8b5777d4b79ab35fc045f7a0a330f
Author: Björn Baumbach <b...@sernet.de>
Date:   Mon Jul 11 14:20:14 2011 +0200

    s3-torture: run_locktest2(): replace cli_lock() with cli_lock32()
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>

commit c9f604543bd771c94e5f4990a6b5beccd3322d74
Author: Björn Baumbach <b...@sernet.de>
Date:   Mon Jul 11 14:05:14 2011 +0200

    s3-torture: run_locktest1(): replace cli_lock() with cli_lock32()
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>

commit 23b417b4c0e867913f47bc5e65c99eb395f47970
Author: Björn Baumbach <b...@sernet.de>
Date:   Mon Jul 11 13:49:18 2011 +0200

    s3-torture: locktest2: replace cli_lock() with cli_lock32()
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>

commit b6e9866c54bbcc1d9eaf184b387d863c77adb6e2
Author: Björn Baumbach <b...@sernet.de>
Date:   Mon Jul 11 11:50:59 2011 +0200

    s3-torture: let wait_lock() use cli_lock32() instead of cli_lock()
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/auth/auth_server.c      |   21 ++++--
 source3/client/client.c         |   63 +++---------------
 source3/include/client.h        |    2 +-
 source3/libsmb/cliconnect.c     |    9 ++-
 source3/libsmb/clientgen.c      |   10 ---
 source3/libsmb/clierror.c       |   29 +++++----
 source3/libsmb/libsmb_context.c |    4 +-
 source3/libsmb/libsmb_server.c  |    8 +-
 source3/libsmb/proto.h          |    2 +-
 source3/libsmb/smb2cli_base.c   |    1 +
 source3/torture/locktest2.c     |    3 +-
 source3/torture/torture.c       |  137 +++++++++++++++++++++++++--------------
 source3/winbindd/winbindd_cm.c  |   39 +++++++-----
 13 files changed, 167 insertions(+), 161 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/auth/auth_server.c b/source3/auth/auth_server.c
index d50ed7a..1b7993b 100644
--- a/source3/auth/auth_server.c
+++ b/source3/auth/auth_server.c
@@ -158,20 +158,25 @@ static bool send_server_keepalive(const struct timeval 
*now,
 {
        struct server_security_state *state = talloc_get_type_abort(
                private_data, struct server_security_state);
+       NTSTATUS status;
+       unsigned char garbage[16];
 
-       if (!state->cli || !state->cli->initialised) {
-               return False;
+       if (!cli_state_is_connected(state->cli)) {
+               return false;
        }
 
-       if (send_keepalive(state->cli->fd)) {
-               return True;
+       /* Ping the server to keep the connection alive using SMBecho. */
+       memset(garbage, 0xf0, sizeof(garbage));
+       status = cli_echo(state->cli, 1, data_blob_const(garbage, 
sizeof(garbage)));
+       if (NT_STATUS_IS_OK(status)) {
+               return true;
        }
 
-       DEBUG( 2, ( "send_server_keepalive: password server keepalive "
-                   "failed.\n"));
+       DEBUG(2,("send_server_keepalive: password server SMBecho failed: %s\n",
+                nt_errstr(status)));
        cli_shutdown(state->cli);
        state->cli = NULL;
-       return False;
+       return false;
 }
 
 static int destroy_server_security(struct server_security_state *state)
@@ -285,7 +290,7 @@ static NTSTATUS check_smbserver_security(const struct 
auth_context *auth_context
                locally_made_cli = True;
        }
 
-       if (!cli || !cli->initialised) {
+       if (!cli_state_is_connected(cli)) {
                DEBUG(1,("password server is not connected (cli not 
initialised)\n"));
                return NT_STATUS_LOGON_FAILURE;
        }  
diff --git a/source3/client/client.c b/source3/client/client.c
index 4a5a31a..d489ea7 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -4911,7 +4911,8 @@ static void readline_callback(void)
        static time_t last_t;
        struct timespec now;
        time_t t;
-       int ret, revents;
+       NTSTATUS status;
+       unsigned char garbage[16];
 
        clock_gettime_mono(&now);
        t = now.tv_sec;
@@ -4921,60 +4922,14 @@ static void readline_callback(void)
 
        last_t = t;
 
- again:
-
-       if (cli->fd == -1)
-               return;
-
-       /* We deliberately use receive_smb_raw instead of
-          client_receive_smb as we want to receive
-          session keepalives and then drop them here.
-       */
-
-       ret = poll_intr_one_fd(cli->fd, POLLIN|POLLHUP, 0, &revents);
-
-       if ((ret > 0) && (revents & (POLLIN|POLLHUP|POLLERR))) {
-               char inbuf[CLI_SAMBA_MAX_LARGE_READX_SIZE + 
LARGE_WRITEX_HDR_SIZE];
-               NTSTATUS status;
-               size_t len;
-
-               status = receive_smb_raw(cli->fd, inbuf, sizeof(inbuf), 0, 0, 
&len);
-
-               if (!NT_STATUS_IS_OK(status)) {
-                       if (cli->fd != -1) {
-                               close(cli->fd);
-                               cli->fd = -1;
-                       }
-
-                       DEBUG(0, ("Read from server failed, maybe it closed "
-                                 "the connection: %s\n", nt_errstr(status)));
-
-                       finished = true;
-                       smb_readline_done();
-                       return;
-               }
-               if(CVAL(inbuf,0) != SMBkeepalive) {
-                       DEBUG(0, ("Read from server "
-                               "returned unexpected packet!\n"));
-                       return;
-               }
-
-               goto again;
-       }
-
        /* Ping the server to keep the connection alive using SMBecho. */
-       {
-               NTSTATUS status;
-               unsigned char garbage[16];
-               memset(garbage, 0xf0, sizeof(garbage));
-               status = cli_echo(cli, 1, data_blob_const(garbage, 
sizeof(garbage)));
-
-               if (!NT_STATUS_IS_OK(status)) {
-                       DEBUG(0, ("SMBecho failed. Maybe server has closed "
-                               "the connection\n"));
-                       finished = true;
-                       smb_readline_done();
-               }
+       memset(garbage, 0xf0, sizeof(garbage));
+       status = cli_echo(cli, 1, data_blob_const(garbage, sizeof(garbage)));
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(0, ("SMBecho failed. Maybe server has closed "
+                       "the connection\n"));
+               finished = true;
+               smb_readline_done();
        }
 }
 
diff --git a/source3/include/client.h b/source3/include/client.h
index 4fb785e..eada792 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -51,7 +51,6 @@ struct cli_state {
         * A list of subsidiary connections for DFS.
         */
         struct cli_state *prev, *next;
-       int port;
        int fd;
        uint16 cnum;
        uint16 pid;
@@ -82,6 +81,7 @@ struct cli_state {
        char *share;
        char *dev;
        struct nmb_name called;
+       struct sockaddr_storage src_ss;
        struct nmb_name calling;
        struct sockaddr_storage dest_ss;
 
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index c543297..e5d8700 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -2884,8 +2884,15 @@ NTSTATUS cli_connect_nb(const char *host, struct 
sockaddr_storage *pss,
                goto fail;
        }
        cli->fd = fd;
-       cli->port = port;
 
+       length = sizeof(cli->src_ss);
+       ret = getsockname(fd, (struct sockaddr *)(void *)&cli->src_ss,
+                         &length);
+       if (ret == -1) {
+               status = map_nt_error_from_unix(errno);
+               cli_shutdown(cli);
+               goto fail;
+       }
        length = sizeof(cli->dest_ss);
        ret = getpeername(fd, (struct sockaddr *)(void *)&cli->dest_ss,
                          &length);
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 2380ceb..bcb1215 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -51,15 +51,6 @@ unsigned int cli_set_timeout(struct cli_state *cli, unsigned 
int timeout)
 }
 
 /****************************************************************************
- Change the port number used to call on.
-****************************************************************************/
-
-void cli_set_port(struct cli_state *cli, int port)
-{
-       cli->port = port;
-}
-
-/****************************************************************************
  convenience routine to find if we negotiated ucs2
 ****************************************************************************/
 
@@ -191,7 +182,6 @@ struct cli_state *cli_initialise_ex(int signing_state)
        if (!cli->dfs_mountpoint) {
                goto error;
        }
-       cli->port = 0;
        cli->fd = -1;
        cli->raw_status = NT_STATUS_INTERNAL_ERROR;
        cli->cnum = -1;
diff --git a/source3/libsmb/clierror.c b/source3/libsmb/clierror.c
index 7541a69..92c2cc2 100644
--- a/source3/libsmb/clierror.c
+++ b/source3/libsmb/clierror.c
@@ -45,7 +45,7 @@ const char *cli_errstr(struct cli_state *cli)
                goto done;
        }
 
-       if (cli->fd == -1 && NT_STATUS_IS_OK(cli->raw_status)) {
+       if (!cli_state_is_connected(cli) && NT_STATUS_IS_OK(cli->raw_status)) {
                return nt_errstr(NT_STATUS_CONNECTION_DISCONNECTED);
        }
 
@@ -64,7 +64,7 @@ const char *cli_errstr(struct cli_state *cli)
 NTSTATUS cli_nt_error(struct cli_state *cli)
 {
        /* Deal with socket errors first. */
-       if (cli->fd == -1) {
+       if (!cli_state_is_connected(cli)) {
                return NT_STATUS_CONNECTION_DISCONNECTED;
        }
 
@@ -85,11 +85,7 @@ NTSTATUS cli_nt_error(struct cli_state *cli)
 
 void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *ecode)
 {
-       if(!cli->initialised) {
-               return;
-       }
-
-       if (cli->fd == -1) {
+       if (!cli_state_is_connected(cli)) {
                *eclass = ERRDOS;
                *ecode = ERRnotconnected;
                return;
@@ -144,8 +140,8 @@ int cli_errno(struct cli_state *cli)
 bool cli_is_error(struct cli_state *cli)
 {
        /* A socket error is always an error. */
-       if (cli->fd == -1) {
-               return True;
+       if (!cli_state_is_connected(cli)) {
+               return true;
        }
 
        if (NT_STATUS_IS_DOS(cli->raw_status)) {
@@ -162,8 +158,8 @@ bool cli_is_error(struct cli_state *cli)
 bool cli_is_nt_error(struct cli_state *cli)
 {
        /* A socket error is always an NT error. */
-       if (cli->fd == -1) {
-               return True;
+       if (!cli_state_is_connected(cli)) {
+               return true;
        }
 
        return cli_is_error(cli) && !NT_STATUS_IS_DOS(cli->raw_status);
@@ -174,8 +170,8 @@ bool cli_is_nt_error(struct cli_state *cli)
 bool cli_is_dos_error(struct cli_state *cli)
 {
        /* A socket error is always a DOS error. */
-       if (cli->fd == -1) {
-               return True;
+       if (!cli_state_is_connected(cli)) {
+               return true;
        }
 
        return cli_is_error(cli) && NT_STATUS_IS_DOS(cli->raw_status);
@@ -198,3 +194,10 @@ bool cli_state_is_connected(struct cli_state *cli)
        return true;
 }
 
+void cli_state_disconnect(struct cli_state *cli)
+{
+       if (cli->fd != -1) {
+               close(cli->fd);
+       }
+       cli->fd = -1;
+}
diff --git a/source3/libsmb/libsmb_context.c b/source3/libsmb/libsmb_context.c
index dbf70e0..14f646f 100644
--- a/source3/libsmb/libsmb_context.c
+++ b/source3/libsmb/libsmb_context.c
@@ -261,8 +261,8 @@ smbc_free_context(SMBCCTX *context,
                                   "Nice way shutdown failed.\n"));
                         s = context->internal->servers;
                         while (s) {
-                                DEBUG(1, ("Forced shutdown: %p (fd=%d)\n",
-                                          s, s->cli->fd));
+                                DEBUG(1, ("Forced shutdown: %p (cli=%p)\n",
+                                          s, s->cli));
                                 cli_shutdown(s->cli);
                                 
smbc_getFunctionRemoveCachedServer(context)(context,
                                                                          s);
diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c
index b355137..49018a8 100644
--- a/source3/libsmb/libsmb_server.c
+++ b/source3/libsmb/libsmb_server.c
@@ -44,11 +44,11 @@ int
 SMBC_check_server(SMBCCTX * context,
                   SMBCSRV * server) 
 {
-        socklen_t size;
-        struct sockaddr addr;
+       if (!cli_state_is_connected(server->cli)) {
+               return 1;
+       }
 
-        size = sizeof(addr);
-        return (getpeername(server->cli->fd, &addr, &size) == -1);
+       return 0;
 }
 
 /* 
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index 151df40..66ab6e6 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -154,7 +154,6 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
 
 int cli_set_message(char *buf,int num_words,int num_bytes,bool zero);
 unsigned int cli_set_timeout(struct cli_state *cli, unsigned int timeout);
-void cli_set_port(struct cli_state *cli, int port);
 void cli_setup_packet_buf(struct cli_state *cli, char *buf);
 NTSTATUS cli_set_domain(struct cli_state *cli, const char *domain);
 NTSTATUS cli_set_username(struct cli_state *cli, const char *username);
@@ -192,6 +191,7 @@ bool cli_is_error(struct cli_state *cli);
 bool cli_is_nt_error(struct cli_state *cli);
 bool cli_is_dos_error(struct cli_state *cli);
 bool cli_state_is_connected(struct cli_state *cli);
+void cli_state_disconnect(struct cli_state *cli);
 
 /* The following definitions come from libsmb/clifile.c  */
 
diff --git a/source3/libsmb/smb2cli_base.c b/source3/libsmb/smb2cli_base.c
index 8760c30..da1d598 100644
--- a/source3/libsmb/smb2cli_base.c
+++ b/source3/libsmb/smb2cli_base.c
@@ -2,6 +2,7 @@
    Unix SMB/CIFS implementation.
    smb2 lib
    Copyright (C) Volker Lendecke 2011
+   Copyright (C) Stefan Metzmacher 2011
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
diff --git a/source3/torture/locktest2.c b/source3/torture/locktest2.c
index aba6d2f..5115d13 100644
--- a/source3/torture/locktest2.c
+++ b/source3/torture/locktest2.c
@@ -114,7 +114,8 @@ static bool try_lock(struct cli_state *c, int fstype,
 
        switch (fstype) {
        case FSTYPE_SMB:
-               return cli_lock(c, fd, start, len, LOCK_TIMEOUT, op);
+               return NT_STATUS_IS_OK(cli_lock32(c, fd, start, len,
+                                      LOCK_TIMEOUT, op));
 
        case FSTYPE_NFS:
                lock.l_type = (op==READ_LOCK) ? F_RDLCK:F_WRLCK;
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 52ae4bb..d40d5aa 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -542,10 +542,20 @@ static bool check_error(int line, struct cli_state *c,
 
 static bool wait_lock(struct cli_state *c, int fnum, uint32 offset, uint32 len)
 {
-       while (!cli_lock(c, fnum, offset, len, -1, WRITE_LOCK)) {
-               if (!check_error(__LINE__, c, ERRDOS, ERRlock, 
NT_STATUS_LOCK_NOT_GRANTED)) return False;
+       NTSTATUS status;
+
+       status = cli_lock32(c, fnum, offset, len, -1, WRITE_LOCK);
+
+       while (!NT_STATUS_IS_OK(status)) {
+               if (!check_both_error(__LINE__, status, ERRDOS,
+                                     ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) {
+                       return false;
+               }
+
+               status = cli_lock32(c, fnum, offset, len, -1, WRITE_LOCK);
        }
-       return True;
+
+       return true;
 }
 
 
@@ -1226,30 +1236,35 @@ static bool run_locktest1(int dummy)
                return False;
        }
 
-       if (!cli_lock(cli1, fnum1, 0, 4, 0, WRITE_LOCK)) {
-               printf("lock1 failed (%s)\n", cli_errstr(cli1));
-               return False;
+       status = cli_lock32(cli1, fnum1, 0, 4, 0, WRITE_LOCK);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("lock1 failed (%s)\n", nt_errstr(status));
+               return false;
        }
 
-
-       if (cli_lock(cli2, fnum3, 0, 4, 0, WRITE_LOCK)) {
+       status = cli_lock32(cli2, fnum3, 0, 4, 0, WRITE_LOCK);
+       if (NT_STATUS_IS_OK(status)) {
                printf("lock2 succeeded! This is a locking bug\n");
-               return False;
+               return false;
        } else {
-               if (!check_error(__LINE__, cli2, ERRDOS, ERRlock, 
-                                NT_STATUS_LOCK_NOT_GRANTED)) return False;
+               if (!check_both_error(__LINE__, status, ERRDOS, ERRlock,
+                                     NT_STATUS_LOCK_NOT_GRANTED)) {
+                       return false;
+               }
        }
 
-
        lock_timeout = (1 + (random() % 20));
        printf("Testing lock timeout with timeout=%u\n", lock_timeout);
        t1 = time(NULL);
-       if (cli_lock(cli2, fnum3, 0, 4, lock_timeout * 1000, WRITE_LOCK)) {
+       status = cli_lock32(cli2, fnum3, 0, 4, lock_timeout * 1000, WRITE_LOCK);
+       if (NT_STATUS_IS_OK(status)) {
                printf("lock3 succeeded! This is a locking bug\n");
-               return False;
+               return false;
        } else {
-               if (!check_error(__LINE__, cli2, ERRDOS, ERRlock, 
-                                NT_STATUS_FILE_LOCK_CONFLICT)) return False;
+               if (!check_both_error(__LINE__, status, ERRDOS, ERRlock,
+                                     NT_STATUS_FILE_LOCK_CONFLICT)) {
+                       return false;
+               }
        }
        t2 = time(NULL);
 
@@ -1266,12 +1281,15 @@ static bool run_locktest1(int dummy)
                return False;
        }
 
-       if (cli_lock(cli2, fnum3, 0, 4, 0, WRITE_LOCK)) {
+       status = cli_lock32(cli2, fnum3, 0, 4, 0, WRITE_LOCK);
+       if (NT_STATUS_IS_OK(status)) {
                printf("lock4 succeeded! This is a locking bug\n");
-               return False;
+               return false;
        } else {
-               if (!check_error(__LINE__, cli2, ERRDOS, ERRlock, 
-                                NT_STATUS_FILE_LOCK_CONFLICT)) return False;
+               if (!check_both_error(__LINE__, status, ERRDOS, ERRlock,
+                                     NT_STATUS_FILE_LOCK_CONFLICT)) {
+                       return false;
+               }
        }
 
        status = cli_close(cli1, fnum1);
@@ -1625,37 +1643,48 @@ static bool run_locktest2(int dummy)
 
        cli_setpid(cli, 1);
 
-       if (!cli_lock(cli, fnum1, 0, 4, 0, WRITE_LOCK)) {
-               printf("lock1 failed (%s)\n", cli_errstr(cli));
-               return False;
+       status = cli_lock32(cli, fnum1, 0, 4, 0, WRITE_LOCK);
+       if (!NT_STATUS_IS_OK(status)) {
+               printf("lock1 failed (%s)\n", nt_errstr(status));
+               return false;
        }
 
-       if (cli_lock(cli, fnum1, 0, 4, 0, WRITE_LOCK)) {
+       status = cli_lock32(cli, fnum1, 0, 4, 0, WRITE_LOCK);
+       if (NT_STATUS_IS_OK(status)) {
                printf("WRITE lock1 succeeded! This is a locking bug\n");
-               correct = False;
+               correct = false;
        } else {
-               if (!check_error(__LINE__, cli, ERRDOS, ERRlock, 
-                                NT_STATUS_LOCK_NOT_GRANTED)) return False;
+               if (!check_both_error(__LINE__, status, ERRDOS, ERRlock,
+                                     NT_STATUS_LOCK_NOT_GRANTED)) {
+                       return false;
+               }
        }
 
-       if (cli_lock(cli, fnum2, 0, 4, 0, WRITE_LOCK)) {
+       status = cli_lock32(cli, fnum2, 0, 4, 0, WRITE_LOCK);
+       if (NT_STATUS_IS_OK(status)) {
                printf("WRITE lock2 succeeded! This is a locking bug\n");
-               correct = False;
+               correct = false;
        } else {
-               if (!check_error(__LINE__, cli, ERRDOS, ERRlock, 
-                                NT_STATUS_LOCK_NOT_GRANTED)) return False;
+               if (!check_both_error(__LINE__, status, ERRDOS, ERRlock,
+                                     NT_STATUS_LOCK_NOT_GRANTED)) {
+                       return false;
+               }
        }
 
-       if (cli_lock(cli, fnum2, 0, 4, 0, READ_LOCK)) {
+       status = cli_lock32(cli, fnum2, 0, 4, 0, READ_LOCK);
+       if (NT_STATUS_IS_OK(status)) {


-- 
Samba Shared Repository

Reply via email to