summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-07-21 09:20:43 +0200
committerStefan Metzmacher <metze@samba.org>2011-07-21 22:08:52 +0200
commit25447a528a1f5c37e0e62bbc990b87c868de784a (patch)
tree1c6dbdf6ce7dd670d621fd92cc2c1ca87d14c230 /source3
parentc70103f3f81c45846acc60fa84027247d72913f5 (diff)
downloadsamba-25447a528a1f5c37e0e62bbc990b87c868de784a.tar.gz
samba-25447a528a1f5c37e0e62bbc990b87c868de784a.tar.bz2
samba-25447a528a1f5c37e0e62bbc990b87c868de784a.zip
s3:libsmb: move cli->vuid to cli->smb1.uid and hide it behind cli_state_[g|s]et_uid()
metze
Diffstat (limited to 'source3')
-rw-r--r--source3/client/client.c7
-rw-r--r--source3/include/client.h2
-rw-r--r--source3/libsmb/cliconnect.c16
-rw-r--r--source3/libsmb/clientgen.c16
-rw-r--r--source3/libsmb/proto.h2
-rw-r--r--source3/torture/torture.c35
6 files changed, 46 insertions, 32 deletions
diff --git a/source3/client/client.c b/source3/client/client.c
index d489ea7eba..1cf44103e9 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -4261,11 +4261,12 @@ static int cmd_vuid(void)
char *buf;
if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) {
- d_printf("Current VUID is %d\n", cli->vuid);
+ d_printf("Current VUID is %d\n",
+ cli_state_get_uid(cli));
return 0;
}
- cli->vuid = atoi(buf);
+ cli_state_set_uid(cli, atoi(buf));
return 0;
}
@@ -4303,7 +4304,7 @@ static int cmd_logon(void)
return -1;
}
- d_printf("Current VUID is %d\n", cli->vuid);
+ d_printf("Current VUID is %d\n", cli_state_get_uid(cli));
return 0;
}
diff --git a/source3/include/client.h b/source3/include/client.h
index 5e4e0a3690..75fca5efa1 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -52,7 +52,6 @@ struct cli_state {
*/
struct cli_state *prev, *next;
int fd;
- uint16 vuid;
int protocol;
int sec_mode;
int rap_error;
@@ -135,6 +134,7 @@ struct cli_state {
uint16_t pid;
uint16_t vc_num;
uint16_t tid;
+ uint16_t uid;
} smb1;
struct {
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 4e3e47f512..9b9d751284 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -274,7 +274,7 @@ static void cli_session_setup_lanman2_done(struct tevent_req *subreq)
inbuf = (char *)in;
p = bytes;
- cli->vuid = SVAL(inbuf, smb_uid);
+ cli_state_set_uid(state->cli, SVAL(inbuf, smb_uid));
cli->is_guestlogin = ((SVAL(vwv+2, 0) & 1) != 0);
status = smb_bytes_talloc_string(cli,
@@ -502,7 +502,7 @@ static void cli_session_setup_guest_done(struct tevent_req *subreq)
inbuf = (char *)in;
p = bytes;
- cli->vuid = SVAL(inbuf, smb_uid);
+ cli_state_set_uid(state->cli, SVAL(inbuf, smb_uid));
cli->is_guestlogin = ((SVAL(vwv+2, 0) & 1) != 0);
status = smb_bytes_talloc_string(cli,
@@ -709,7 +709,7 @@ static void cli_session_setup_plain_done(struct tevent_req *subreq)
inbuf = (char *)in;
p = bytes;
- cli->vuid = SVAL(inbuf, smb_uid);
+ cli_state_set_uid(state->cli, SVAL(inbuf, smb_uid));
cli->is_guestlogin = ((SVAL(vwv+2, 0) & 1) != 0);
status = smb_bytes_talloc_string(cli,
@@ -1066,7 +1066,7 @@ static void cli_session_setup_nt1_done(struct tevent_req *subreq)
inbuf = (char *)in;
p = bytes;
- cli->vuid = SVAL(inbuf, smb_uid);
+ cli_state_set_uid(state->cli, SVAL(inbuf, smb_uid));
cli->is_guestlogin = ((SVAL(vwv+2, 0) & 1) != 0);
status = smb_bytes_talloc_string(cli,
@@ -1305,7 +1305,7 @@ static void cli_sesssetup_blob_done(struct tevent_req *subreq)
TALLOC_FREE(state->buf);
state->inbuf = (char *)inbuf;
- cli->vuid = SVAL(state->inbuf, smb_uid);
+ cli_state_set_uid(state->cli, SVAL(inbuf, smb_uid));
cli->is_guestlogin = ((SVAL(vwv+2, 0) & 1) != 0);
blob_length = SVAL(vwv+3, 0);
@@ -1385,7 +1385,7 @@ static NTSTATUS cli_sesssetup_blob_recv(struct tevent_req *req,
char *inbuf;
if (tevent_req_is_nterror(req, &status)) {
- state->cli->vuid = 0;
+ cli_state_set_uid(state->cli, UID_FIELD_INVALID);
return status;
}
@@ -1743,7 +1743,7 @@ static NTSTATUS cli_session_setup_ntlmssp_recv(struct tevent_req *req)
NTSTATUS status;
if (tevent_req_is_nterror(req, &status)) {
- state->cli->vuid = 0;
+ cli_state_set_uid(state->cli, UID_FIELD_INVALID);
return status;
}
return NT_STATUS_OK;
@@ -2126,7 +2126,7 @@ static void cli_ulogoff_done(struct tevent_req *subreq)
tevent_req_nterror(req, status);
return;
}
- state->cli->vuid = -1;
+ cli_state_set_uid(state->cli, UID_FIELD_INVALID);
tevent_req_done(req);
}
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index ab0079650a..be27f1e093 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -70,7 +70,7 @@ void cli_setup_packet_buf(struct cli_state *cli, char *buf)
SIVAL(buf,smb_rcls,0);
SSVAL(buf,smb_pid,cli->smb1.pid);
memset(buf+smb_pidhigh, 0, 12);
- SSVAL(buf,smb_uid,cli->vuid);
+ SSVAL(buf,smb_uid, cli_state_get_uid(cli));
SSVAL(buf,smb_mid,cli->smb1.mid);
if (cli->protocol <= PROTOCOL_CORE) {
@@ -184,7 +184,6 @@ struct cli_state *cli_initialise_ex(int signing_state)
}
cli->fd = -1;
cli->raw_status = NT_STATUS_INTERNAL_ERROR;
- cli->vuid = UID_FIELD_INVALID;
cli->protocol = PROTOCOL_NT1;
cli->timeout = 20000; /* Timeout is in milliseconds. */
cli->max_xmit = CLI_BUFFER_SIZE+4;
@@ -241,6 +240,7 @@ struct cli_state *cli_initialise_ex(int signing_state)
cli->smb1.pid = (uint16_t)sys_getpid();
cli->smb1.vc_num = cli->smb1.pid;
cli->smb1.tid = UINT16_MAX;
+ cli->smb1.uid = UID_FIELD_INVALID;
return cli;
@@ -391,6 +391,18 @@ uint16_t cli_state_set_tid(struct cli_state *cli, uint16_t tid)
return ret;
}
+uint16_t cli_state_get_uid(struct cli_state *cli)
+{
+ return cli->smb1.uid;
+}
+
+uint16_t cli_state_set_uid(struct cli_state *cli, uint16_t uid)
+{
+ uint16_t ret = cli->smb1.uid;
+ cli->smb1.uid = uid;
+ return ret;
+}
+
/****************************************************************************
Set the case sensitivity flag on the packets. Returns old state.
****************************************************************************/
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index 98aabee0a7..d7a5612733 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -171,6 +171,8 @@ uint16_t cli_getpid(struct cli_state *cli);
bool cli_state_has_tcon(struct cli_state *cli);
uint16_t cli_state_get_tid(struct cli_state *cli);
uint16_t cli_state_set_tid(struct cli_state *cli, uint16_t tid);
+uint16_t cli_state_get_uid(struct cli_state *cli);
+uint16_t cli_state_set_uid(struct cli_state *cli, uint16_t uid);
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 6317d0eae6..fbfe52d83f 100644
--- a/source3/torture/torture.c
+++ b/source3/torture/torture.c
@@ -429,20 +429,20 @@ bool torture_init_connection(struct cli_state **pcli)
bool torture_cli_session_setup2(struct cli_state *cli, uint16 *new_vuid)
{
- uint16 old_vuid = cli->vuid;
+ uint16_t old_vuid = cli_state_get_uid(cli);
fstring old_user_name;
size_t passlen = strlen(password);
NTSTATUS status;
bool ret;
fstrcpy(old_user_name, cli->user_name);
- cli->vuid = 0;
+ cli_state_set_uid(cli, 0);
ret = NT_STATUS_IS_OK(cli_session_setup(cli, username,
password, passlen,
password, passlen,
workgroup));
- *new_vuid = cli->vuid;
- cli->vuid = old_vuid;
+ *new_vuid = cli_state_get_uid(cli);
+ cli_state_set_uid(cli, old_vuid);
status = cli_set_username(cli, old_user_name);
if (!NT_STATUS_IS_OK(status)) {
return false;
@@ -1367,7 +1367,7 @@ static bool run_tcon_test(int dummy)
}
cnum1 = cli_state_get_tid(cli);
- vuid1 = cli->vuid;
+ vuid1 = cli_state_get_uid(cli);
status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
if (!NT_STATUS_IS_OK(status)) {
@@ -1386,7 +1386,7 @@ static bool run_tcon_test(int dummy)
cnum2 = cli_state_get_tid(cli);
cnum3 = MAX(cnum1, cnum2) + 1; /* any invalid number */
- vuid2 = cli->vuid + 1;
+ vuid2 = cli_state_get_uid(cli) + 1;
/* try a write with the wrong tid */
cli_state_set_tid(cli, cnum2);
@@ -1414,7 +1414,7 @@ static bool run_tcon_test(int dummy)
}
/* try a write with an invalid vuid */
- cli->vuid = vuid2;
+ cli_state_set_uid(cli, vuid2);
cli_state_set_tid(cli, cnum1);
status = cli_writeall(cli, fnum1, 0, (uint8_t *)buf, 130, 4, NULL);
@@ -1427,7 +1427,7 @@ static bool run_tcon_test(int dummy)
}
cli_state_set_tid(cli, cnum1);
- cli->vuid = vuid1;
+ cli_state_set_uid(cli, vuid1);
status = cli_close(cli, fnum1);
if (!NT_STATUS_IS_OK(status)) {
@@ -2734,7 +2734,7 @@ static bool run_fdpasstest(int dummy)
return False;
}
- cli2->vuid = cli1->vuid;
+ cli_state_set_uid(cli2, cli_state_get_uid(cli1));
cli_state_set_tid(cli2, cli_state_get_tid(cli1));
cli_setpid(cli2, cli_getpid(cli1));
@@ -2800,8 +2800,8 @@ static bool run_fdsesstest(int dummy)
return False;
}
- saved_vuid = cli->vuid;
- cli->vuid = new_vuid;
+ saved_vuid = cli_state_get_uid(cli);
+ cli_state_set_uid(cli, new_vuid);
if (cli_read_old(cli, fnum1, buf, 0, 13) == 13) {
printf("read succeeded with different vuid! nasty security hole [%s]\n",
@@ -2819,7 +2819,7 @@ static bool run_fdsesstest(int dummy)
ret = False;
}
- cli->vuid = saved_vuid;
+ cli_state_set_uid(cli, saved_vuid);
/* Try with same vuid, different cnum. */
cli_state_set_tid(cli, new_cnum);
@@ -6358,7 +6358,7 @@ static bool run_sesssetup_bench(int dummy)
return false;
}
- d_printf("\r%d ", (int)c->vuid);
+ d_printf("\r%d ", (int)cli_state_get_uid(c));
status = cli_ulogoff(c);
if (!NT_STATUS_IS_OK(status)) {
@@ -6366,7 +6366,6 @@ static bool run_sesssetup_bench(int dummy)
__location__, nt_errstr(status));
return false;
}
- c->vuid = 0;
}
return true;
@@ -7099,7 +7098,7 @@ static bool run_uid_regression_test(int dummy)
cli_sockopt(cli, sockops);
/* Ok - now save then logoff our current user. */
- old_vuid = cli->vuid;
+ old_vuid = cli_state_get_uid(cli);
status = cli_ulogoff(cli);
if (!NT_STATUS_IS_OK(status)) {
@@ -7109,7 +7108,7 @@ static bool run_uid_regression_test(int dummy)
goto out;
}
- cli->vuid = old_vuid;
+ cli_state_set_uid(cli, old_vuid);
/* Try an operation. */
status = cli_mkdir(cli, "\\uid_reg_test");
@@ -7130,7 +7129,7 @@ static bool run_uid_regression_test(int dummy)
old_cnum = cli_state_get_tid(cli);
/* Now try a SMBtdis with the invald vuid set to zero. */
- cli->vuid = 0;
+ cli_state_set_uid(cli, 0);
/* This should succeed. */
status = cli_tdis(cli);
@@ -7143,7 +7142,7 @@ static bool run_uid_regression_test(int dummy)
goto out;
}
- cli->vuid = old_vuid;
+ cli_state_set_uid(cli, old_vuid);
cli_state_set_tid(cli, old_cnum);
/* This should fail. */