1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

s3:libsmb: move cli->pid to cli->smb1.pid and hide it behind cli_[g|s]etpid()

metze
This commit is contained in:
Stefan Metzmacher 2011-07-19 12:56:51 +02:00
parent 9fb7e228f5
commit 1e3822115c
5 changed files with 18 additions and 12 deletions

View File

@ -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;

View File

@ -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.
****************************************************************************/

View File

@ -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);

View File

@ -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,

View File

@ -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",