summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-07-19 12:56:51 +0200
committerStefan Metzmacher <metze@samba.org>2011-07-20 15:55:08 +0200
commit1e3822115c3b466632044fe64c908b6f2de5803a (patch)
treebd8d064257576166fa50d3f3db324a81f3ac6df1 /source3
parent9fb7e228f5a6e39dd22e1c56733c61178ee0be49 (diff)
downloadsamba-1e3822115c3b466632044fe64c908b6f2de5803a.tar.gz
samba-1e3822115c3b466632044fe64c908b6f2de5803a.tar.bz2
samba-1e3822115c3b466632044fe64c908b6f2de5803a.zip
s3:libsmb: move cli->pid to cli->smb1.pid and hide it behind cli_[g|s]etpid()
metze
Diffstat (limited to 'source3')
-rw-r--r--source3/include/client.h2
-rw-r--r--source3/libsmb/clientgen.c15
-rw-r--r--source3/libsmb/clifile.c10
-rw-r--r--source3/libsmb/proto.h1
-rw-r--r--source3/torture/torture.c2
5 files changed, 18 insertions, 12 deletions
diff --git a/source3/include/client.h b/source3/include/client.h
index 3c99716e62..67c858f76f 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -53,7 +53,6 @@ struct cli_state {
struct cli_state *prev, *next;
int fd;
uint16 cnum;
- uint16 pid;
uint16 vuid;
int protocol;
int sec_mode;
@@ -134,6 +133,7 @@ struct cli_state {
struct {
uint16_t mid;
+ uint16_t pid;
uint16_t vc_num;
} smb1;
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index aac38df360..67e8e06d1a 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -68,7 +68,7 @@ void cli_setup_packet_buf(struct cli_state *cli, char *buf)
uint16 flags2;
cli->rap_error = 0;
SIVAL(buf,smb_rcls,0);
- SSVAL(buf,smb_pid,cli->pid);
+ SSVAL(buf,smb_pid,cli->smb1.pid);
memset(buf+smb_pidhigh, 0, 12);
SSVAL(buf,smb_uid,cli->vuid);
SSVAL(buf,smb_mid,cli->smb1.mid);
@@ -185,7 +185,6 @@ struct cli_state *cli_initialise_ex(int signing_state)
cli->fd = -1;
cli->raw_status = NT_STATUS_INTERNAL_ERROR;
cli->cnum = -1;
- cli->pid = (uint16)sys_getpid();
cli->vuid = UID_FIELD_INVALID;
cli->protocol = PROTOCOL_NT1;
cli->timeout = 20000; /* Timeout is in milliseconds. */
@@ -240,7 +239,8 @@ struct cli_state *cli_initialise_ex(int signing_state)
cli->initialised = 1;
cli->smb1.mid = 1;
- cli->smb1.vc_num = cli->pid;
+ cli->smb1.pid = (uint16_t)sys_getpid();
+ cli->smb1.vc_num = cli->smb1.pid;
return cli;
@@ -354,11 +354,16 @@ uint16_t cli_state_get_vc_num(struct cli_state *cli)
uint16 cli_setpid(struct cli_state *cli, uint16 pid)
{
- uint16 ret = cli->pid;
- cli->pid = pid;
+ uint16_t ret = cli->smb1.pid;
+ cli->smb1.pid = pid;
return ret;
}
+uint16_t cli_getpid(struct cli_state *cli)
+{
+ return cli->smb1.pid;
+}
+
/****************************************************************************
Set the case sensitivity flag on the packets. Returns old state.
****************************************************************************/
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 8cf60ded81..6503e234e5 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -2556,7 +2556,7 @@ NTSTATUS cli_locktype(struct cli_state *cli, uint16_t fnum,
SSVAL(vwv + 6, 0, 0);
SSVAL(vwv + 7, 0, 1);
- SSVAL(bytes, 0, cli->pid);
+ SSVAL(bytes, 0, cli_getpid(cli));
SIVAL(bytes, 2, offset);
SIVAL(bytes, 6, len);
@@ -2626,7 +2626,7 @@ struct tevent_req *cli_unlock_send(TALLOC_CTX *mem_ctx,
SSVAL(state->vwv+6, 0, 1);
SSVAL(state->vwv+7, 0, 0);
- SSVAL(state->data, 0, cli->pid);
+ SSVAL(state->data, 0, cli_getpid(cli));
SIVAL(state->data, 2, offset);
SIVAL(state->data, 6, len);
@@ -2732,7 +2732,7 @@ NTSTATUS cli_lock64(struct cli_state *cli, uint16_t fnum,
SSVAL(vwv + 6, 0, 0);
SSVAL(vwv + 7, 0, 1);
- SIVAL(bytes, 0, cli->pid);
+ SIVAL(bytes, 0, cli_getpid(cli));
SOFF_T_R(bytes, 4, offset);
SOFF_T_R(bytes, 12, len);
@@ -2786,7 +2786,7 @@ struct tevent_req *cli_unlock64_send(TALLOC_CTX *mem_ctx,
SSVAL(state->vwv+6, 0, 1);
SSVAL(state->vwv+7, 0, 0);
- SIVAL(state->data, 0, cli->pid);
+ SIVAL(state->data, 0, cli_getpid(cli));
SOFF_T_R(state->data, 4, offset);
SOFF_T_R(state->data, 12, len);
@@ -2932,7 +2932,7 @@ static struct tevent_req *cli_posix_lock_internal_send(TALLOC_CTX *mem_ctx,
POSIX_LOCK_FLAG_NOWAIT);
}
- SIVAL(&state->data, POSIX_LOCK_PID_OFFSET, cli->pid);
+ SIVAL(&state->data, POSIX_LOCK_PID_OFFSET, cli_getpid(cli));
SOFF_T(&state->data, POSIX_LOCK_START_OFFSET, offset);
SOFF_T(&state->data, POSIX_LOCK_LEN_OFFSET, len);
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index 7ba2aaccad..9775bd775d 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -166,6 +166,7 @@ void cli_shutdown(struct cli_state *cli);
void cli_sockopt(struct cli_state *cli, const char *options);
uint16_t cli_state_get_vc_num(struct cli_state *cli);
uint16 cli_setpid(struct cli_state *cli, uint16 pid);
+uint16_t cli_getpid(struct cli_state *cli);
bool cli_set_case_sensitive(struct cli_state *cli, bool case_sensitive);
struct tevent_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
struct cli_state *cli, uint16_t num_echos,
diff --git a/source3/torture/torture.c b/source3/torture/torture.c
index 39d7ad3005..e0e7275e8b 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -2725,7 +2725,7 @@ static bool run_fdpasstest(int dummy)
cli2->vuid = cli1->vuid;
cli2->cnum = cli1->cnum;
- cli2->pid = cli1->pid;
+ cli_setpid(cli2, cli_getpid(cli1));
if (cli_read(cli2, fnum1, buf, 0, 13) == 13) {
printf("read succeeded! nasty security hole [%s]\n",