summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-03-09 23:48:58 +0000
committerJeremy Allison <jra@samba.org>2001-03-09 23:48:58 +0000
commit00ab9021b0cc5fe2667d383eb9cc2973072cdaaa (patch)
treed6444c6041525e86a61c0aa70247dc332aeb1a80 /source3
parent0bfc10011bd5cacecda8b59c36e80f676e5c7fa3 (diff)
downloadsamba-00ab9021b0cc5fe2667d383eb9cc2973072cdaaa.tar.gz
samba-00ab9021b0cc5fe2667d383eb9cc2973072cdaaa.tar.bz2
samba-00ab9021b0cc5fe2667d383eb9cc2973072cdaaa.zip
Serious (and I *mean* serious) attempt to fix little/bigendian RPC issues.
We were reading the endainness in the RPC header and then never propagating it to the internal parse_structs used to parse the data. Also removed the "align" argument to prs_init as it was *always* set to 4, and if needed can be set differently on a case by case basis. Now ready for AS/U testing when Herb gets it set up :-). Jeremy. (This used to be commit 0cd37c831d79a12a10e479bf4fa89ffe64c1292a)
Diffstat (limited to 'source3')
-rw-r--r--source3/client/smbmount.c301
-rw-r--r--source3/include/ntdomain.h11
-rw-r--r--source3/include/proto.h4
-rw-r--r--source3/lib/msrpc-client.c2
-rw-r--r--source3/libsmb/cli_lsarpc.c24
-rw-r--r--source3/libsmb/clisecdesc.c4
-rw-r--r--source3/printing/nt_printing.c2
-rw-r--r--source3/rpc_client/cli_lsarpc.c28
-rw-r--r--source3/rpc_client/cli_netlogon.c24
-rw-r--r--source3/rpc_client/cli_pipe.c44
-rw-r--r--source3/rpc_client/cli_reg.c64
-rw-r--r--source3/rpc_client/cli_samr.c44
-rw-r--r--source3/rpc_client/cli_spoolss.c52
-rw-r--r--source3/rpc_client/cli_spoolss_notify.c12
-rw-r--r--source3/rpc_client/cli_srvsvc.c20
-rw-r--r--source3/rpc_client/cli_wkssvc.c4
-rw-r--r--source3/rpc_client/msrpc_spoolss.c2
-rw-r--r--source3/rpc_parse/parse_creds.c4
-rw-r--r--source3/rpc_parse/parse_prs.c14
-rw-r--r--source3/rpc_parse/parse_rpc.c4
-rw-r--r--source3/rpc_parse/parse_spoolss.c14
-rw-r--r--source3/rpc_server/srv_pipe.c12
-rw-r--r--source3/rpc_server/srv_pipe_hnd.c62
-rw-r--r--source3/smbd/nttrans.c4
24 files changed, 514 insertions, 242 deletions
diff --git a/source3/client/smbmount.c b/source3/client/smbmount.c
index ec3f32bd36..3c0b132937 100644
--- a/source3/client/smbmount.c
+++ b/source3/client/smbmount.c
@@ -27,25 +27,22 @@
#include <asm/types.h>
#include <linux/smb_fs.h>
-/* Uncomment this to allow debug the mount.smb daemon */
-/* WARNING! This option is incompatible with autofs/automount because
- it does not close the stdout pipe back to the automount
- process, which automount depends on. This will cause automount
- to hang! Use with caution! */
-/* #define SMBFS_DEBUG 1 */
-
extern struct in_addr ipzero;
extern int DEBUGLEVEL;
extern BOOL in_client;
extern pstring user_socket_options;
+extern BOOL append_log;
+extern fstring remote_machine;
+static pstring credentials;
static pstring my_netbios_name;
static pstring password;
static pstring username;
static pstring workgroup;
static pstring mpoint;
static pstring service;
+static pstring options;
static struct in_addr dest_ip;
static BOOL have_ip;
@@ -73,7 +70,7 @@ static void daemonize(void)
signal( SIGTERM, exit_parent );
if ((child_pid = sys_fork()) < 0) {
- fprintf(stderr,"could not fork\n");
+ DEBUG(0,("could not fork\n"));
}
if (child_pid > 0) {
@@ -138,8 +135,6 @@ static struct cli_state *do_connection(char *service)
share++;
server_n = server;
-
- ip = ipzero;
make_nmb_name(&calling, my_netbios_name, 0x0);
make_nmb_name(&called , server, 0x20);
@@ -151,13 +146,24 @@ static struct cli_state *do_connection(char *service)
/* have to open a new connection */
if (!(c=cli_initialise(NULL)) || (cli_set_port(c, smb_port) == 0) ||
!cli_connect(c, server_n, &ip)) {
- fprintf(stderr,"Connection to %s failed\n", server_n);
+ DEBUG(0,("%d: Connection to %s failed\n", getpid(), server_n));
+ if (c) {
+ cli_shutdown(c);
+ free(c);
+ }
return NULL;
}
if (!cli_session_request(c, &calling, &called)) {
- fprintf(stderr, "session request to %s failed\n", called.name);
+ char *p;
+ DEBUG(0,("%d: session request to %s failed (%s)\n",
+ getpid(), called.name, cli_errstr(c)));
cli_shutdown(c);
+ free(c);
+ if ((p=strchr(called.name, '.'))) {
+ *p = 0;
+ goto again;
+ }
if (strcmp(called.name, "*SMBSERVER")) {
make_nmb_name(&called , "*SMBSERVER", 0x20);
goto again;
@@ -165,11 +171,12 @@ static struct cli_state *do_connection(char *service)
return NULL;
}
- DEBUG(4,(" session request ok\n"));
+ DEBUG(4,("%d: session request ok\n", getpid()));
if (!cli_negprot(c)) {
- fprintf(stderr, "protocol negotiation failed\n");
+ DEBUG(0,("%d: protocol negotiation failed\n", getpid()));
cli_shutdown(c);
+ free(c);
return NULL;
}
@@ -184,20 +191,25 @@ static struct cli_state *do_connection(char *service)
password, strlen(password),
password, strlen(password),
workgroup)) {
- fprintf(stderr, "session setup failed: %s\n", cli_errstr(c));
+ DEBUG(0,("%d: session setup failed: %s\n",
+ getpid(), cli_errstr(c)));
+ cli_shutdown(c);
+ free(c);
return NULL;
}
- DEBUG(4,(" session setup ok\n"));
+ DEBUG(4,("%d: session setup ok\n", getpid()));
if (!cli_send_tconX(c, share, "?????",
password, strlen(password)+1)) {
- fprintf(stderr,"tree connect failed: %s\n", cli_errstr(c));
+ DEBUG(0,("%d: tree connect failed: %s\n",
+ getpid(), cli_errstr(c)));
cli_shutdown(c);
+ free(c);
return NULL;
}
- DEBUG(4,(" tconx ok\n"));
+ DEBUG(4,("%d: tconx ok\n", getpid()));
got_pass = True;
@@ -226,29 +238,29 @@ static void smb_umount(char *mount_point)
the lights to exit anyways...
*/
if (umount(mount_point) != 0) {
- fprintf(stderr, "Could not umount %s: %s\n",
- mount_point, strerror(errno));
+ DEBUG(0,("%d: Could not umount %s: %s\n",
+ getpid(), mount_point, strerror(errno)));
return;
}
if ((fd = open(MOUNTED"~", O_RDWR|O_CREAT|O_EXCL, 0600)) == -1) {
- fprintf(stderr, "Can't get "MOUNTED"~ lock file");
+ DEBUG(0,("%d: Can't get "MOUNTED"~ lock file", getpid()));
return;
}
close(fd);
if ((mtab = setmntent(MOUNTED, "r")) == NULL) {
- fprintf(stderr, "Can't open " MOUNTED ": %s\n",
- strerror(errno));
+ DEBUG(0,("%d: Can't open " MOUNTED ": %s\n",
+ getpid(), strerror(errno)));
return;
}
#define MOUNTED_TMP MOUNTED".tmp"
if ((new_mtab = setmntent(MOUNTED_TMP, "w")) == NULL) {
- fprintf(stderr, "Can't open " MOUNTED_TMP ": %s\n",
- strerror(errno));
+ DEBUG(0,("%d: Can't open " MOUNTED_TMP ": %s\n",
+ getpid(), strerror(errno)));
endmntent(mtab);
return;
}
@@ -262,21 +274,21 @@ static void smb_umount(char *mount_point)
endmntent(mtab);
if (fchmod (fileno (new_mtab), S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0) {
- fprintf(stderr, "Error changing mode of %s: %s\n",
- MOUNTED_TMP, strerror(errno));
+ DEBUG(0,("%d: Error changing mode of %s: %s\n",
+ getpid(), MOUNTED_TMP, strerror(errno)));
return;
}
endmntent(new_mtab);
if (rename(MOUNTED_TMP, MOUNTED) < 0) {
- fprintf(stderr, "Cannot rename %s to %s: %s\n",
- MOUNTED, MOUNTED_TMP, strerror(errno));
+ DEBUG(0,("%d: Cannot rename %s to %s: %s\n",
+ getpid(), MOUNTED, MOUNTED_TMP, strerror(errno)));
return;
}
if (unlink(MOUNTED"~") == -1) {
- fprintf(stderr, "Can't remove "MOUNTED"~");
+ DEBUG(0,("%d: Can't remove "MOUNTED"~", getpid()));
return;
}
}
@@ -298,9 +310,10 @@ static void send_fs_socket(char *service, char *mount_point, struct cli_state *c
while (1) {
if ((fd = open(mount_point, O_RDONLY)) < 0) {
- fprintf(stderr, "mount.smbfs: can't open %s\n", mount_point);
+ DEBUG(0,("mount.smbfs[%d]: can't open %s\n",
+ getpid(), mount_point));
break;
- }
+ }
conn_options.fd = c->fd;
conn_options.protocol = c->protocol;
@@ -317,7 +330,9 @@ static void send_fs_socket(char *service, char *mount_point, struct cli_state *c
res = ioctl(fd, SMB_IOC_NEWCONN, &conn_options);
if (res != 0) {
- fprintf(stderr, "mount.smbfs: ioctl failed, res=%d\n", res);
+ DEBUG(0,("mount.smbfs[%d]: ioctl failed, res=%d\n",
+ getpid(), res));
+ close(fd);
break;
}
@@ -332,27 +347,50 @@ static void send_fs_socket(char *service, char *mount_point, struct cli_state *c
close(fd);
-#ifndef SMBFS_DEBUG
- /* Close all open files if we haven't done so yet. */
+ /* This looks wierd but we are only closing the userspace
+ side, the connection has already been passed to smbfs and
+ it has increased the usage count on the socket.
+
+ If we don't do this we will "leak" sockets and memory on
+ each reconnection we have to make. */
+ cli_shutdown(c);
+ free(c);
+ c = NULL;
+
if (!closed) {
- extern FILE *dbf;
+ /* redirect stdout & stderr since we can't know that
+ the library functions we use are using DEBUG. */
+ if ( (fd = open("/dev/null", O_WRONLY)) < 0)
+ DEBUG(2,("mount.smbfs: can't open /dev/null\n"));
+ close_our_files(fd);
+ if (fd >= 0) {
+ dup2(fd, STDOUT_FILENO);
+ dup2(fd, STDERR_FILENO);
+ close(fd);
+ }
+
+ /* here we are no longer interactive */
+ pstrcpy(remote_machine, "smbmount"); /* sneaky ... */
+ setup_logging("mount.smbfs", False);
+ append_log = True;
+ reopen_logs();
+ DEBUG(0, ("mount.smbfs: entering daemon mode for service %s, pid=%d\n", service, getpid()));
+
closed = 1;
- dbf = NULL;
- close_our_files(c?c->fd:-1);
}
-#endif
- /* Wait for a signal from smbfs ... */
- CatchSignal(SIGUSR1, &usr1_handler);
- pause();
-#ifdef SMBFS_DEBUG
- DEBUG(2,("mount.smbfs: got signal, getting new socket\n"));
-#endif
- c = do_connection(service);
+ /* Wait for a signal from smbfs ... but don't continue
+ until we actually get a new connection. */
+ while (!c) {
+ CatchSignal(SIGUSR1, &usr1_handler);
+ pause();
+ DEBUG(2,("mount.smbfs[%d]: got signal, getting new socket\n", getpid()));
+ c = do_connection(service);
+ }
}
smb_umount(mount_point);
- DEBUG(2,("mount.smbfs: exit\n"));
+ DEBUG(2,("mount.smbfs[%d]: exit\n", getpid()));
exit(1);
}
@@ -436,6 +474,10 @@ static void init_mount(void)
args[i++] = "-d";
args[i++] = xstrdup(tmp);
}
+ if (options) {
+ args[i++] = "-o";
+ args[i++] = options;
+ }
if (sys_fork() == 0) {
if (file_exist(BINDIR "/smbmnt", NULL)) {
@@ -452,10 +494,12 @@ static void init_mount(void)
fprintf(stderr,"waitpid failed: Error was %s", strerror(errno) );
/* FIXME: do some proper error handling */
exit(1);
- }
+ }
if (WIFEXITED(status) && WEXITSTATUS(status) != 0) {
fprintf(stderr,"smbmnt failed: %d\n", WEXITSTATUS(status));
+ /* FIXME: do some proper error handling */
+ exit(1);
}
/* Ok... This is the rubicon for that mount point... At any point
@@ -468,6 +512,123 @@ static void init_mount(void)
/****************************************************************************
+get a password from a a file or file descriptor
+exit on failure (from smbclient, move to libsmb or shared .c file?)
+****************************************************************************/
+static void get_password_file(void)
+{
+ int fd = -1;
+ char *p;
+ BOOL close_it = False;
+ pstring spec;
+ char pass[128];
+
+ if ((p = getenv("PASSWD_FD")) != NULL) {
+ pstrcpy(spec, "descriptor ");
+ pstrcat(spec, p);
+ sscanf(p, "%d", &fd);
+ close_it = False;
+ } else if ((p = getenv("PASSWD_FILE")) != NULL) {
+ fd = sys_open(p, O_RDONLY, 0);
+ pstrcpy(spec, p);
+ if (fd < 0) {
+ fprintf(stderr, "Error opening PASSWD_FILE %s: %s\n",
+ spec, strerror(errno));
+ exit(1);
+ }
+ close_it = True;
+ }
+
+ for(p = pass, *p = '\0'; /* ensure that pass is null-terminated */
+ p && p - pass < sizeof(pass);) {
+ switch (read(fd, p, 1)) {
+ case 1:
+ if (*p != '\n' && *p != '\0') {
+ *++p = '\0'; /* advance p, and null-terminate pass */
+ break;
+ }
+ case 0:
+ if (p - pass) {
+ *p = '\0'; /* null-terminate it, just in case... */
+ p = NULL; /* then force the loop condition to become false */
+ break;
+ } else {
+ fprintf(stderr, "Error reading password from file %s: %s\n",
+ spec, "empty password\n");
+ exit(1);
+ }
+
+ default:
+ fprintf(stderr, "Error reading password from file %s: %s\n",
+ spec, strerror(errno));
+ exit(1);
+ }
+ }
+ pstrcpy(password, pass);
+ if (close_it)
+ close(fd);
+}
+
+/****************************************************************************
+get username and password from a credentials file
+exit on failure (from smbclient, move to libsmb or shared .c file?)
+****************************************************************************/
+static void read_credentials_file(char *filename)
+{
+ FILE *auth;
+ fstring buf;
+ uint16 len = 0;
+ char *ptr, *val, *param;
+
+ if ((auth=sys_fopen(filename, "r")) == NULL)
+ {
+ /* fail if we can't open the credentials file */
+ DEBUG(0,("ERROR: Unable to open credentials file!\n"));
+ exit (-1);
+ }
+
+ while (!feof(auth))
+ {
+ /* get a line from the file */
+ if (!fgets (buf, sizeof(buf), auth))
+ continue;
+ len = strlen(buf);
+
+ if ((len) && (buf[len-1]=='\n'))
+ {
+ buf[len-1] = '\0';
+ len--;
+ }
+ if (len == 0)
+ continue;
+
+ /* break up the line into parameter & value.
+ will need to eat a little whitespace possibly */
+ param = buf;
+ if (!(ptr = strchr (buf, '=')))
+ continue;
+ val = ptr+1;
+ *ptr = '\0';
+
+ /* eat leading white space */
+ while ((*val!='\0') && ((*val==' ') || (*val=='\t')))
+ val++;
+
+ if (strwicmp("password", param) == 0)
+ {
+ pstrcpy(password, val);
+ got_pass = True;
+ }
+ else if (strwicmp("username", param) == 0)
+ pstrcpy(username, val);
+
+ memset(buf, 0, sizeof(buf));
+ }
+ fclose(auth);
+}
+
+
+/****************************************************************************
usage on the program
****************************************************************************/
static void usage(void)
@@ -491,6 +652,7 @@ static void usage(void)
workgroup=<arg> workgroup on destination
sockopt=<arg> TCP socket options
scope=<arg> NetBIOS scope
+ credentials=<filename> file with username/password
guest don't prompt for a password
ro mount read-only
rw mount read-write
@@ -517,6 +679,7 @@ static void parse_mount_smb(int argc, char **argv)
extern char *optarg;
int val;
extern pstring global_scope;
+ char *p;
if (argc < 2 || argv[1][0] == '-') {
usage();
@@ -537,6 +700,9 @@ static void parse_mount_smb(int argc, char **argv)
return;
}
+ options[0] = 0;
+ p = options;
+
/*
* option parsing from nfsmount.c (util-linux-2.9u)
*/
@@ -565,6 +731,8 @@ static void parse_mount_smb(int argc, char **argv)
pstrcpy(password,opteq+1);
got_pass = True;
memset(opteq+1,'X',strlen(password));
+ } else if(!strcmp(opts, "credentials")) {
+ pstrcpy(credentials,opteq+1);
} else if(!strcmp(opts, "netbiosname")) {
pstrcpy(my_netbios_name,opteq+1);
} else if(!strcmp(opts, "uid")) {
@@ -593,8 +761,8 @@ static void parse_mount_smb(int argc, char **argv)
} else if(!strcmp(opts, "scope")) {
pstrcpy(global_scope,opteq+1);
} else {
- usage();
- exit(1);
+ slprintf(p, sizeof(pstring) - (p - options) - 1, "%s=%s,", opts, opteq+1);
+ p += strlen(p);
}
} else {
val = 1;
@@ -607,6 +775,11 @@ static void parse_mount_smb(int argc, char **argv)
mount_ro = 0;
} else if(!strcmp(opts, "ro")) {
mount_ro = 1;
+ } else {
+ strncpy(p, opts, sizeof(pstring) - (p - options) - 1);
+ p += strlen(opts);
+ *p++ = ',';
+ *p = 0;
}
}
}
@@ -615,6 +788,11 @@ static void parse_mount_smb(int argc, char **argv)
usage();
exit(1);
}
+
+ if (p != options) {
+ *(p-1) = 0; /* remove trailing , */
+ DEBUG(3,("passthrough options '%s'\n", options));
+ }
}
/****************************************************************************
@@ -628,7 +806,8 @@ static void parse_mount_smb(int argc, char **argv)
char *p;
DEBUGLEVEL = 1;
-
+
+ /* here we are interactive, even if run from autofs */
setup_logging("mount.smbfs",True);
TimeInit();
@@ -643,26 +822,38 @@ static void parse_mount_smb(int argc, char **argv)
*p = 0;
pstrcpy(password,p+1);
got_pass = True;
+ memset(strchr(getenv("USER"),'%')+1,'X',strlen(password));
}
+ strupper(username);
}
if (getenv("PASSWD")) {
pstrcpy(password,getenv("PASSWD"));
+ got_pass = True;
+ }
+
+ if (getenv("PASSWD_FD") || getenv("PASSWD_FILE")) {
+ get_password_file();
+ got_pass = True;
}
if (*username == 0 && getenv("LOGNAME")) {
pstrcpy(username,getenv("LOGNAME"));
}
- parse_mount_smb(argc, argv);
-
- DEBUG(3,("mount.smbfs started (version %s)\n", VERSION));
-
if (!lp_load(servicesf,True,False,False)) {
fprintf(stderr, "Can't load %s - run testparm to debug it\n",
servicesf);
}
+ parse_mount_smb(argc, argv);
+
+ if (*credentials != 0) {
+ read_credentials_file(credentials);
+ }
+
+ DEBUG(3,("mount.smbfs started (version %s)\n", VERSION));
+
codepage_initialise(lp_client_code_page());
if (*workgroup == 0) {
diff --git a/source3/include/ntdomain.h b/source3/include/ntdomain.h
index 7a47f6150e..0ae48169fb 100644
--- a/source3/include/ntdomain.h
+++ b/source3/include/ntdomain.h
@@ -79,6 +79,11 @@ typedef struct _prs_struct
#define MARSHALLING(ps) (!(ps)->io)
#define UNMARSHALLING(ps) ((ps)->io)
+#define RPC_BIG_ENDIAN 1
+#define RPC_LITTLE_ENDIAN 0
+
+#define RPC_PARSE_ALIGN 4
+
typedef struct _output_data {
/*
* Raw RPC output data. This does not include RPC headers or footers.
@@ -196,6 +201,12 @@ typedef struct pipes_struct
BOOL fault_state;
/*
+ * Set to RPC_BIG_ENDIAN when dealing with big-endian PDU's
+ */
+
+ BOOL endian;
+
+ /*
* Struct to deal with multiple pdu inputs.
*/
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 442354abed..a532830ce1 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2529,7 +2529,7 @@ BOOL net_io_r_sam_logoff(char *desc, NET_R_SAM_LOGOFF *r_l, prs_struct *ps, int
void prs_dump(char *name, int v, prs_struct *ps);
void prs_debug(prs_struct *ps, int depth, char *desc, char *fn_name);
-BOOL prs_init(prs_struct *ps, uint32 size, uint8 align, TALLOC_CTX *ctx, BOOL io);
+BOOL prs_init(prs_struct *ps, uint32 size, TALLOC_CTX *ctx, BOOL io);
BOOL prs_read(prs_struct *ps, int fd, size_t len, int timeout);
void prs_mem_free(prs_struct *ps);
char *prs_alloc_mem(prs_struct *ps, size_t size);
@@ -2546,7 +2546,7 @@ BOOL prs_set_offset(prs_struct *ps, uint32 offset);
BOOL prs_append_prs_data(prs_struct *dst, prs_struct *src);
BOOL prs_append_some_prs_data(prs_struct *dst, prs_struct *src, int32 start, uint32 len);
BOOL prs_append_data(prs_struct *dst, char *src, uint32 len);
-void prs_set_bigendian_data(prs_struct *ps);
+void prs_set_endian_data(prs_struct *ps, BOOL endian);
BOOL prs_align(prs_struct *ps);
BOOL prs_align_needed(prs_struct *ps, uint32 needed);
char *prs_mem_get(prs_struct *ps, uint32 extra_size);
diff --git a/source3/lib/msrpc-client.c b/source3/lib/msrpc-client.c
index 867094a2c6..7051db563b 100644
--- a/source3/lib/msrpc-client.c
+++ b/source3/lib/msrpc-client.c
@@ -36,7 +36,7 @@ BOOL receive_msrpc(int fd, prs_struct *data, unsigned int timeout)
size_t len;
RPC_HDR hdr;
- prs_init(data, 0, 4, NULL, True);
+ prs_init(data, 0, NULL, True);
ok = prs_read(data, fd, 16, timeout);
diff --git a/source3/libsmb/cli_lsarpc.c b/source3/libsmb/cli_lsarpc.c
index e4da7a7cc7..7f5431e4b3 100644
--- a/source3/libsmb/cli_lsarpc.c
+++ b/source3/libsmb/cli_lsarpc.c
@@ -98,8 +98,8 @@ uint32 cli_lsa_open_policy(struct cli_state *cli, BOOL sec_qos,
/* Initialise parse structures */
- prs_init(&qbuf, MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, False);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, True);
+ prs_init(&qbuf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* Initialise input parameters */
@@ -152,8 +152,8 @@ uint32 cli_lsa_close(struct cli_state *cli, POLICY_HND *pol)
/* Initialise parse structures */
- prs_init(&qbuf, MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, False);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, True);
+ prs_init(&qbuf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* Marshall data and send request */
@@ -204,8 +204,8 @@ uint32 cli_lsa_lookup_sids(struct cli_state *cli, POLICY_HND *pol,
/* Initialise parse structures */
- prs_init(&qbuf, MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, False);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, True);
+ prs_init(&qbuf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* Marshall data and send request */
@@ -310,8 +310,8 @@ uint32 cli_lsa_lookup_names(struct cli_state *cli, POLICY_HND *pol,
/* Initialise parse structures */
- prs_init(&qbuf, MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, False);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, True);
+ prs_init(&qbuf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* Marshall data and send request */
@@ -409,8 +409,8 @@ uint32 cli_lsa_query_info_policy(struct cli_state *cli, POLICY_HND *pol,
/* Initialise parse structures */
- prs_init(&qbuf, MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, False);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, True);
+ prs_init(&qbuf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* Marshall data and send request */
@@ -494,8 +494,8 @@ uint32 cli_lsa_enum_trust_dom(struct cli_state *cli, POLICY_HND *pol,
/* Initialise parse structures */
- prs_init(&qbuf, MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, False);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, True);
+ prs_init(&qbuf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* Marshall data and send request */
diff --git a/source3/libsmb/clisecdesc.c b/source3/libsmb/clisecdesc.c
index 59d8bdcc71..d34a23537a 100644
--- a/source3/libsmb/clisecdesc.c
+++ b/source3/libsmb/clisecdesc.c
@@ -63,7 +63,7 @@ SEC_DESC *cli_query_secdesc(struct cli_state *cli,int fd)
goto cleanup;
}
- prs_init(&pd, rdata_count, 4, mem_ctx, UNMARSHALL);
+ prs_init(&pd, rdata_count, mem_ctx, UNMARSHALL);
prs_append_data(&pd, rdata, rdata_count);
pd.data_offset = 0;
@@ -104,7 +104,7 @@ BOOL cli_set_secdesc(struct cli_state *cli,int fd, SEC_DESC *sd)
goto cleanup;
}
- prs_init(&pd, 0, 4, mem_ctx, MARSHALL);
+ prs_init(&pd, 0, mem_ctx, MARSHALL);
prs_give_memory(&pd, NULL, 0, True);
if (!sec_io_desc("sd data", &sd, &pd, 1)) {
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index a2337c25f3..e491d9a6b9 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -2756,7 +2756,7 @@ uint32 nt_printing_setsec(char *printername, SEC_DESC_BUF *secdesc_ctr)
/* Store the security descriptor in a tdb */
prs_init(&ps, (uint32)sec_desc_size(new_secdesc_ctr->sec) +
- sizeof(SEC_DESC_BUF), 4, mem_ctx, MARSHALL);
+ sizeof(SEC_DESC_BUF), mem_ctx, MARSHALL);
if (!sec_io_desc_buf("nt_printing_setsec", &new_secdesc_ctr,
&ps, 1)) {
diff --git a/source3/rpc_client/cli_lsarpc.c b/source3/rpc_client/cli_lsarpc.c
index 9ba13552bc..649be20a52 100644
--- a/source3/rpc_client/cli_lsarpc.c
+++ b/source3/rpc_client/cli_lsarpc.c
@@ -43,8 +43,8 @@ BOOL do_lsa_open_policy(struct cli_state *cli,
if (hnd == NULL)
return False;
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, UNMARSHALL );
+ prs_init(&buf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL );
/* create and send a MSRPC command with api LSA_OPENPOLICY */
@@ -114,8 +114,8 @@ BOOL do_lsa_query_info_pol(struct cli_state *cli,
if (hnd == NULL || domain_name == NULL || domain_sid == NULL)
return False;
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, UNMARSHALL );
+ prs_init(&buf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL );
/* create and send a MSRPC command with api LSA_QUERYINFOPOLICY */
@@ -213,8 +213,8 @@ BOOL do_lsa_close(struct cli_state *cli, POLICY_HND *hnd)
/* create and send a MSRPC command with api LSA_OPENPOLICY */
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, UNMARSHALL );
+ prs_init(&buf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL );
DEBUG(4,("LSA Close\n"));
@@ -305,8 +305,8 @@ uint32 lsa_open_policy(const char *system_name, POLICY_HND *hnd,
if (hnd == NULL) return NT_STATUS_UNSUCCESSFUL;
- prs_init(&buf, MAX_PDU_FRAG_LEN, 4, NULL, False);
- prs_init(&rbuf, 0, 4, NULL, True);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, NULL, MARSHALL);
+ prs_init(&rbuf, 0, NULL, UNMARSHALL);
/* create and send a MSRPC command with api LSA_OPENPOLICY */
@@ -371,8 +371,8 @@ uint32 lsa_close(POLICY_HND *hnd)
/* Create and send a MSRPC command with api LSA_OPENPOLICY */
- prs_init(&buf, MAX_PDU_FRAG_LEN, 4, NULL, False);
- prs_init(&rbuf, 0, 4, NULL, True);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, NULL, MARSHALL);
+ prs_init(&rbuf, 0, NULL, UNMARSHALL);
DEBUG(4, ("LSA Close\n"));
@@ -437,8 +437,8 @@ uint32 lsa_lookup_sids(POLICY_HND *hnd, int num_sids, DOM_SID *sids,
*names = NULL;
}
- prs_init(&buf, MAX_PDU_FRAG_LEN, 4, ctx, False);
- prs_init(&rbuf, 0, 4, ctx, True);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, ctx, MARSHALL);
+ prs_init(&rbuf, 0, ctx, UNMARSHALL);
/* Create and send a MSRPC command with api LSA_LOOKUP_SIDS */
@@ -580,8 +580,8 @@ uint32 lsa_lookup_names(POLICY_HND *hnd, int num_names, char **names,
if (hnd == NULL || num_sids == 0 || sids == NULL) return False;
- prs_init(&buf, MAX_PDU_FRAG_LEN, 4, ctx, False);
- prs_init(&rbuf, 0, 4, ctx, True);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, ctx, MARSHALL);
+ prs_init(&rbuf, 0, ctx, UNMARSHALL);
/* create and send a MSRPC command with api LSA_LOOKUP_NAMES */
diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c
index 1ed1db4d0a..493e5ac152 100644
--- a/source3/rpc_client/cli_netlogon.c
+++ b/source3/rpc_client/cli_netlogon.c
@@ -64,8 +64,8 @@ BOOL cli_net_logon_ctrl2(struct cli_state *cli, uint32 status_level)
NET_Q_LOGON_CTRL2 q_l;
BOOL ok = False;
- prs_init(&buf , 1024, 4, cli->mem_ctx, False);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, True );
+ prs_init(&buf , 1024, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api NET_LOGON_CTRL2 */
@@ -126,8 +126,8 @@ BOOL cli_net_auth2(struct cli_state *cli, uint16 sec_chan,
NET_Q_AUTH_2 q_a;
BOOL ok = False;
- prs_init(&buf , 1024, 4, cli->mem_ctx, False);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, True );
+ prs_init(&buf , 1024, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api NET_AUTH2 */
@@ -216,8 +216,8 @@ BOOL cli_net_req_chal(struct cli_state *cli, DOM_CHAL *clnt_chal, DOM_CHAL *srv_
NET_Q_REQ_CHAL q_c;
BOOL valid_chal = False;
- prs_init(&buf , 1024, 4, cli->mem_ctx, False);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, True );
+ prs_init(&buf , 1024, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api NET_REQCHAL */
@@ -281,8 +281,8 @@ BOOL cli_net_srv_pwset(struct cli_state *cli, uint8 hashed_mach_pwd[16])
gen_next_creds( cli, &new_clnt_cred);
- prs_init(&buf , 1024, 4, cli->mem_ctx, False);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, True );
+ prs_init(&buf , 1024, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api NET_SRV_PWSET */
@@ -354,8 +354,8 @@ static uint32 cli_net_sam_logon_internal(struct cli_state *cli, NET_ID_INFO_CTR
gen_next_creds( cli, &new_clnt_cred);
- prs_init(&buf , 1024, 4, cli->mem_ctx, False);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, True );
+ prs_init(&buf , 1024, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api NET_SAMLOGON */
@@ -498,8 +498,8 @@ BOOL cli_net_sam_logoff(struct cli_state *cli, NET_ID_INFO_CTR *ctr)
gen_next_creds( cli, &new_clnt_cred);
- prs_init(&buf , 1024, 4, cli->mem_ctx, False);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, True );
+ prs_init(&buf , 1024, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api NET_SAMLOGOFF */
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index 67cf65a4ff..b4ca34ea7d 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -106,7 +106,7 @@ static BOOL rpc_read(struct cli_state *cli, prs_struct *rdata, uint32 data_to_re
}
/****************************************************************************
- Checks the header.
+ Checks the header. This will set the endian bit in the rdata prs_struct. JRA.
****************************************************************************/
static BOOL rpc_check_hdr(prs_struct *rdata, RPC_HDR *rhdr,
@@ -114,6 +114,8 @@ static BOOL rpc_check_hdr(prs_struct *rdata, RPC_HDR *rhdr,
{
DEBUG(5,("rpc_check_hdr: rdata->data_size = %u\n", (uint32)prs_data_size(rdata) ));
+ /* Next call sets endian bit. */
+
if(!smb_io_rpc_hdr("rpc_hdr ", rhdr, rdata, 0)) {
DEBUG(0,("rpc_check_hdr: Failed to unmarshall RPC_HDR.\n"));
return False;
@@ -223,7 +225,12 @@ static BOOL rpc_auth_pipe(struct cli_state *cli, prs_struct *rdata, int len, int
memcpy(data, dp, sizeof(data));
- prs_init(&auth_req , 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&auth_req , 0, cli->mem_ctx, UNMARSHALL);
+
+ /* The endianness must be preserved... JRA. */
+
+ prs_set_endian_data(&auth_req, rdata->bigendian_data);
+
prs_give_memory(&auth_req, data, RPC_HDR_AUTH_LEN, False);
/*
@@ -267,7 +274,11 @@ static BOOL rpc_auth_pipe(struct cli_state *cli, prs_struct *rdata, int len, int
memcpy(data, dp, RPC_AUTH_NTLMSSP_CHK_LEN);
dump_data(100, data, auth_len);
- prs_init(&auth_verf, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&auth_verf, 0, cli->mem_ctx, UNMARSHALL);
+
+ /* The endinness must be preserved. JRA. */
+ prs_set_endian_data( &auth_verf, rdata->bigendian_data);
+
prs_give_memory(&auth_verf, data, RPC_AUTH_NTLMSSP_CHK_LEN, False);
if(!smb_io_rpc_auth_ntlmssp_chk("auth_sign", &chk, &auth_verf, 0)) {
@@ -369,6 +380,8 @@ static BOOL rpc_api_pipe(struct cli_state *cli, uint16 cmd, prs_struct *data, pr
prs_give_memory(rdata, prdata, rdata_len, True);
current_offset = rdata_len;
+ /* This next call sets the endian bit correctly in rdata. */
+
if (!rpc_check_hdr(rdata, &rhdr, &first, &last, &len)) {
prs_mem_free(rdata);
return False;
@@ -446,7 +459,7 @@ static BOOL rpc_api_pipe(struct cli_state *cli, uint16 cmd, prs_struct *data, pr
* First read the header of the next PDU.
*/
- prs_init(&hps, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&hps, 0, cli->mem_ctx, UNMARSHALL);
prs_give_memory(&hps, hdr_data, sizeof(hdr_data), False);
num_read = cli_read(cli, cli->nt_pipe_fnum, hdr_data, 0, RPC_HEADER_LEN+RPC_HDR_RESP_LEN);
@@ -463,9 +476,20 @@ static BOOL rpc_api_pipe(struct cli_state *cli, uint16 cmd, prs_struct *data, pr
return False;
}
+ /* This call sets the endianness in hps. */
+
if (!rpc_check_hdr(&hps, &rhdr, &first, &last, &len))
return False;
+ /* Ensure the endianness in rdata is set correctly - must be same as hps. */
+
+ if (hps.bigendian_data != rdata->bigendian_data) {
+ DEBUG(0,("rpc_api_pipe: Error : Endianness changed from %s to %s\n",
+ rdata->bigendian_data ? "big" : "little",
+ hps.bigendian_data ? "big" : "little" ));
+ return False;
+ }
+
if(!smb_io_rpc_hdr_resp("rpc_hdr_resp", &rhdr_resp, &hps, 0)) {
DEBUG(0,("rpc_api_pipe: Error in unmarshalling RPC_HDR_RESP.\n"));
return False;
@@ -522,7 +546,7 @@ static BOOL create_rpc_bind_req(prs_struct *rpc_out, BOOL do_auth, uint32 rpc_ca
prs_struct auth_info;
int auth_len = 0;
- prs_init(&auth_info, 0, 4, prs_get_mem_context(rpc_out), MARSHALL);
+ prs_init(&auth_info, 0, prs_get_mem_context(rpc_out), MARSHALL);
if (do_auth) {
RPC_HDR_AUTH hdr_auth;
@@ -626,7 +650,7 @@ static BOOL create_rpc_bind_resp(struct pwd_info *pwd,
* Marshall the variable length data into a temporary parse
* struct, pointing into a 4k local buffer.
*/
- prs_init(&auth_info, 0, 4, prs_get_mem_context(rpc_out), MARSHALL);
+ prs_init(&auth_info, 0, prs_get_mem_context(rpc_out), MARSHALL);
/*
* Use the 4k buffer to store the auth info.
@@ -784,7 +808,7 @@ BOOL rpc_api_pipe_req(struct cli_state *cli, uint8 op_num,
* Malloc a parse struct to hold it (and enough for alignments).
*/
- if(!prs_init(&outgoing_packet, data_len + 8, 4, cli->mem_ctx, MARSHALL)) {
+ if(!prs_init(&outgoing_packet, data_len + 8, cli->mem_ctx, MARSHALL)) {
DEBUG(0,("rpc_api_pipe_req: Failed to malloc %u bytes.\n", (unsigned int)data_len ));
return False;
}
@@ -1022,7 +1046,7 @@ static BOOL rpc_send_auth_reply(struct cli_state *cli, prs_struct *rdata, uint32
pwd_make_lm_nt_owf(&cli->pwd, rhdr_chal.challenge);
- prs_init(&rpc_out, 0, 4, cli->mem_ctx, MARSHALL);
+ prs_init(&rpc_out, 0, cli->mem_ctx, MARSHALL);
prs_give_memory( &rpc_out, buffer, sizeof(buffer), False);
@@ -1094,7 +1118,7 @@ BOOL rpc_pipe_bind(struct cli_state *cli, char *pipe_name, char *my_name)
if (!valid_pipe_name(pipe_name, &abstract, &transfer))
return False;
- prs_init(&rpc_out, 0, 4, cli->mem_ctx, MARSHALL);
+ prs_init(&rpc_out, 0, cli->mem_ctx, MARSHALL);
/*
* Use the MAX_PDU_FRAG_LEN buffer to store the bind request.
@@ -1110,7 +1134,7 @@ BOOL rpc_pipe_bind(struct cli_state *cli, char *pipe_name, char *my_name)
global_myname, cli->domain, cli->ntlmssp_cli_flgs);
/* Initialize the incoming data struct. */
- prs_init(&rdata, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&rdata, 0, cli->mem_ctx, UNMARSHALL);
/* send data on \PIPE\. receive a response */
if (rpc_api_pipe(cli, 0x0026, &rpc_out, &rdata)) {
diff --git a/source3/rpc_client/cli_reg.c b/source3/rpc_client/cli_reg.c
index 32439e9b5d..dc547801df 100644
--- a/source3/rpc_client/cli_reg.c
+++ b/source3/rpc_client/cli_reg.c
@@ -86,8 +86,8 @@ BOOL do_reg_open_hklm(struct cli_state *cli, uint16 unknown_0, uint32 level,
if (hnd == NULL)
return False;
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api REG_OPEN_HKLM */
@@ -147,8 +147,8 @@ BOOL do_reg_open_hku(struct cli_state *cli, uint16 unknown_0, uint32 level,
if (hnd == NULL)
return False;
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api REG_OPEN_HKU */
@@ -209,8 +209,8 @@ BOOL do_reg_flush_key(struct cli_state *cli, POLICY_HND *hnd)
if (hnd == NULL)
return False;
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api REG_FLUSH_KEY */
@@ -271,8 +271,8 @@ BOOL do_reg_query_key(struct cli_state *cli, POLICY_HND *hnd,
if (hnd == NULL)
return False;
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api REG_QUERY_KEY */
@@ -339,8 +339,8 @@ BOOL do_reg_unknown_1a(struct cli_state *cli, POLICY_HND *hnd, uint32 *unk)
if (hnd == NULL)
return False;
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api REG_UNKNOWN_1A */
@@ -399,8 +399,8 @@ BOOL do_reg_query_info(struct cli_state *cli, POLICY_HND *hnd,
if (hnd == NULL)
return False;
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api REG_INFO */
@@ -459,8 +459,8 @@ BOOL do_reg_set_key_sec(struct cli_state *cli, POLICY_HND *hnd, SEC_DESC_BUF *se
if (hnd == NULL)
return False;
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api REG_SET_KEY_SEC */
@@ -515,8 +515,8 @@ BOOL do_reg_get_key_sec(struct cli_state *cli, POLICY_HND *hnd, uint32 *sec_buf_
if (hnd == NULL)
return False;
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api REG_GET_KEY_SEC */
@@ -581,8 +581,8 @@ BOOL do_reg_delete_val(struct cli_state *cli, POLICY_HND *hnd, char *val_name)
if (hnd == NULL)
return False;
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api REG_DELETE_VALUE */
@@ -638,8 +638,8 @@ BOOL do_reg_delete_key(struct cli_state *cli, POLICY_HND *hnd, char *key_name)
if (hnd == NULL)
return False;
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api REG_DELETE_KEY */
@@ -720,8 +720,8 @@ BOOL do_reg_create_key(struct cli_state *cli, POLICY_HND *hnd,
return False;
}
- prs_init(&buf, MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
init_reg_q_create_key(&q_o, hnd, key_name, key_class, sam_access, sec_buf);
@@ -778,8 +778,8 @@ BOOL do_reg_enum_key(struct cli_state *cli, POLICY_HND *hnd,
if (hnd == NULL)
return False;
- prs_init(&buf, MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api REG_ENUM_KEY */
@@ -841,8 +841,8 @@ BOOL do_reg_create_val(struct cli_state *cli, POLICY_HND *hnd,
if (hnd == NULL)
return False;
- prs_init(&buf, MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api REG_CREATE_VALUE */
@@ -901,8 +901,8 @@ BOOL do_reg_enum_val(struct cli_state *cli, POLICY_HND *hnd,
if (hnd == NULL)
return False;
- prs_init(&buf, MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api REG_ENUM_VALUE */
@@ -964,8 +964,8 @@ BOOL do_reg_open_entry(struct cli_state *cli, POLICY_HND *hnd,
if (hnd == NULL)
return False;
- prs_init(&buf, MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api REG_OPEN_ENTRY */
@@ -1025,8 +1025,8 @@ BOOL do_reg_close(struct cli_state *cli, POLICY_HND *hnd)
/* create and send a MSRPC command with api REG_CLOSE */
- prs_init(&buf, MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL);
DEBUG(4,("REG Close\n"));
diff --git a/source3/rpc_client/cli_samr.c b/source3/rpc_client/cli_samr.c
index f8c10abae1..eb9032f7ce 100644
--- a/source3/rpc_client/cli_samr.c
+++ b/source3/rpc_client/cli_samr.c
@@ -113,8 +113,8 @@ BOOL do_samr_chgpasswd_user(struct cli_state *cli,
/* create and send a MSRPC command with api SAMR_CHGPASSWD_USER */
- prs_init(&data , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rdata, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&data, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rdata, 0, cli->mem_ctx, UNMARSHALL);
DEBUG(4,("SAMR Change User Password. server:%s username:%s\n",
srv_name, user_name));
@@ -169,8 +169,8 @@ BOOL do_samr_unknown_38(struct cli_state *cli, char *srv_name)
/* create and send a MSRPC command with api SAMR_ENUM_DOM_USERS */
- prs_init(&data , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rdata, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&data, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rdata, 0, cli->mem_ctx, UNMARSHALL);
DEBUG(4,("SAMR Unknown 38 server:%s\n", srv_name));
@@ -225,8 +225,8 @@ BOOL do_samr_query_dom_info(struct cli_state *cli,
/* create and send a MSRPC command with api SAMR_ENUM_DOM_USERS */
- prs_init(&data , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rdata, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&data, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rdata, 0, cli->mem_ctx, UNMARSHALL);
DEBUG(4,("SAMR Unknown 8 switch:%d\n", switch_value));
@@ -287,8 +287,8 @@ BOOL do_samr_enum_dom_users(struct cli_state *cli,
/* create and send a MSRPC command with api SAMR_ENUM_DOM_USERS */
- prs_init(&data , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rdata, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&data, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rdata, 0, cli->mem_ctx, UNMARSHALL);
DEBUG(4,("SAMR Enum SAM DB max size:%x\n", size));
@@ -374,8 +374,8 @@ BOOL do_samr_connect(struct cli_state *cli,
/* create and send a MSRPC command with api SAMR_CONNECT */
- prs_init(&data , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rdata, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&data, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rdata, 0, cli->mem_ctx, UNMARSHALL);
DEBUG(4,("SAMR Open Policy server:%s undoc value:%x\n",
srv_name, unknown_0));
@@ -435,8 +435,8 @@ BOOL do_samr_open_user(struct cli_state *cli,
/* create and send a MSRPC command with api SAMR_OPEN_USER */
- prs_init(&data , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rdata, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&data, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rdata, 0, cli->mem_ctx, UNMARSHALL);
DEBUG(4,("SAMR Open User. unk_0: %08x RID:%x\n",
unk_0, rid));
@@ -497,8 +497,8 @@ BOOL do_samr_open_domain(struct cli_state *cli,
/* create and send a MSRPC command with api SAMR_OPEN_DOMAIN */
- prs_init(&data , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rdata, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&data, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rdata, 0, cli->mem_ctx, UNMARSHALL);
sid_to_string(sid_str, sid);
DEBUG(4,("SAMR Open Domain. SID:%s RID:%x\n", sid_str, rid));
@@ -561,8 +561,8 @@ BOOL do_samr_query_unknown_12(struct cli_state *cli,
/* create and send a MSRPC command with api SAMR_UNKNOWN_12 */
- prs_init(&data , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rdata, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&data, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rdata, 0, cli->mem_ctx, UNMARSHALL);
DEBUG(4,("SAMR Query Unknown 12.\n"));
@@ -638,8 +638,8 @@ BOOL do_samr_query_usergroups(struct cli_state *cli,
/* create and send a MSRPC command with api SAMR_QUERY_USERGROUPS */
- prs_init(&data , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rdata, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&data, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rdata, 0, cli->mem_ctx, UNMARSHALL);
DEBUG(4,("SAMR Query User Groups.\n"));
@@ -700,8 +700,8 @@ BOOL do_samr_query_userinfo(struct cli_state *cli,
/* create and send a MSRPC command with api SAMR_QUERY_USERINFO */
- prs_init(&data , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rdata, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&data, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rdata, 0, cli->mem_ctx, UNMARSHALL);
DEBUG(4,("SAMR Query User Info. level: %d\n", switch_value));
@@ -769,8 +769,8 @@ BOOL do_samr_close(struct cli_state *cli, POLICY_HND *hnd)
if (hnd == NULL)
return False;
- prs_init(&data , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rdata, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&data, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rdata, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api SAMR_CLOSE_HND */
diff --git a/source3/rpc_client/cli_spoolss.c b/source3/rpc_client/cli_spoolss.c
index 75e5e66d90..7588ba152f 100644
--- a/source3/rpc_client/cli_spoolss.c
+++ b/source3/rpc_client/cli_spoolss.c
@@ -47,8 +47,8 @@ uint32 spoolss_enum_printerdrivers(const char *srv_name, const char *environment
if (!cli_connection_init(srv_name, PIPE_SPOOLSS, &con))
return False;
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, ctx, MARSHALL);
+ prs_init(&rbuf, 0, ctx, UNMARSHALL);
/* create and send a MSRPC command with api SPOOLSS_ENUM_PRINTERS */
@@ -106,8 +106,8 @@ uint32 spoolss_enum_printers(uint32 flags, fstring srv_name, uint32 level,
if (!cli_connection_init(srv_name, PIPE_SPOOLSS, &con))
return False;
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, ctx, MARSHALL);
+ prs_init(&rbuf, 0, ctx, UNMARSHALL);
/* create and send a MSRPC command with api SPOOLSS_ENUM_PRINTERS */
@@ -165,8 +165,8 @@ uint32 spoolss_enum_ports(fstring srv_name, uint32 level,
if (!cli_connection_init(srv_name, PIPE_SPOOLSS, &con))
return False;
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, ctx, MARSHALL);
+ prs_init(&rbuf, 0, ctx, UNMARSHALL);
/* create and send a MSRPC command with api SPOOLSS_ENUMPORTS */
@@ -221,8 +221,8 @@ uint32 spoolss_enum_jobs(const POLICY_HND *hnd, uint32 firstjob, uint32 numofjob
if (hnd == NULL)
return NT_STATUS_INVALID_PARAMETER;
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, ctx, MARSHALL);
+ prs_init(&rbuf, 0, ctx, UNMARSHALL);
/* create and send a MSRPC command with api SPOOLSS_ENUMJOBS */
@@ -278,8 +278,8 @@ uint32 spoolss_enum_printerdata(const POLICY_HND *hnd, uint32 idx,
DEBUG(0,("msrpc_spoolss_enum_jobs: talloc_init failed!\n"));
return False;
}
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api SPOOLSS_ENUMPRINTERDATA*/
@@ -337,8 +337,8 @@ uint32 spoolss_getprinter(const POLICY_HND *hnd, uint32 level,
if (hnd == NULL)
return NT_STATUS_INVALID_PARAMETER;
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, ctx, MARSHALL);
+ prs_init(&rbuf, 0, ctx, UNMARSHALL);
/* create and send a MSRPC command with api SPOOLSS_ENUMJOBS */
@@ -390,8 +390,8 @@ uint32 spoolss_getprinterdriver(const POLICY_HND *hnd,
if (hnd == NULL)
return NT_STATUS_INVALID_PARAMETER;
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, ctx, MARSHALL);
+ prs_init(&rbuf, 0, ctx, UNMARSHALL);
/* create and send a MSRPC command with api SPOOLSS_ENUMJOBS */
@@ -464,8 +464,8 @@ BOOL spoolss_open_printer_ex( const char *printername,
DEBUG(0,("msrpc_spoolss_enum_jobs: talloc_init failed!\n"));
return False;
}
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api SPOOLSS_OPENPRINTEREX */
@@ -538,8 +538,8 @@ BOOL spoolss_addprinterex(POLICY_HND *hnd, const char* srv_name, PRINTER_INFO_2
DEBUG(0,("spoolss_addprinterex: talloc_init() failed!\n"));
return NT_STATUS_ACCESS_DENIED;
}
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api SPOOLSS_ENUMPORTS */
DEBUG(5,("SPOOLSS Add Printer Ex (Server: %s)\n", srv_name));
@@ -611,8 +611,8 @@ BOOL spoolss_closeprinter(POLICY_HND *hnd)
DEBUG(0,("msrpc_spoolss_enum_jobs: talloc_init failed!\n"));
return False;
}
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
DEBUG(4,("SPOOL Close Printer\n"));
@@ -671,8 +671,8 @@ uint32 spoolss_getprinterdata(const POLICY_HND *hnd, const UNISTR2 *valuename,
DEBUG(0,("msrpc_spoolss_enum_jobs: talloc_init failed!\n"));
return False;
}
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api SPOOLSS_GETPRINTERDATA */
@@ -726,8 +726,8 @@ uint32 spoolss_getprinterdriverdir(fstring srv_name, fstring env_name, uint32 le
if (!cli_connection_init(srv_name, PIPE_SPOOLSS, &con))
return False;
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, ctx, MARSHALL);
+ prs_init(&rbuf, 0, ctx, UNMARSHALL);
/* create and send a MSRPC command with api SPOOLSS_ENUM_PRINTERS */
@@ -787,8 +787,8 @@ uint32 spoolss_addprinterdriver(const char *srv_name, uint32 level, PRINTER_DRIV
DEBUG(0,("msrpc_spoolss_enum_jobs: talloc_init failed!\n"));
return False;
}
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, mem_ctx, UNMARSHALL);
+ prs_init(&buf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
/* make the ADDPRINTERDRIVER PDU */
make_spoolss_q_addprinterdriver(mem_ctx, &q_o, srv_name, level, info);
diff --git a/source3/rpc_client/cli_spoolss_notify.c b/source3/rpc_client/cli_spoolss_notify.c
index acd53ced4c..879a4f129f 100644
--- a/source3/rpc_client/cli_spoolss_notify.c
+++ b/source3/rpc_client/cli_spoolss_notify.c
@@ -141,8 +141,8 @@ BOOL cli_spoolss_reply_open_printer(struct cli_state *cli, char *printer, uint32
SPOOL_Q_REPLYOPENPRINTER q_s;
SPOOL_R_REPLYOPENPRINTER r_s;
- prs_init(&buf , 1024, 4, cli->mem_ctx, False);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, True );
+ prs_init(&buf, 1024, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL );
/* create and send a MSRPC command with api SPOOLSS_REPLYOPENPRINTER */
/*
@@ -197,8 +197,8 @@ BOOL cli_spoolss_reply_rrpcn(struct cli_state *cli, POLICY_HND *handle,
SPOOL_Q_REPLY_RRPCN q_s;
SPOOL_R_REPLY_RRPCN r_s;
- prs_init(&buf , 1024, 4, cli->mem_ctx, False);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, True );
+ prs_init(&buf, 1024, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL );
/* create and send a MSRPC command with api */
/*
@@ -251,8 +251,8 @@ BOOL cli_spoolss_reply_close_printer(struct cli_state *cli, POLICY_HND *handle,
SPOOL_Q_REPLYCLOSEPRINTER q_s;
SPOOL_R_REPLYCLOSEPRINTER r_s;
- prs_init(&buf , 1024, 4, cli->mem_ctx, False);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, True );
+ prs_init(&buf, 1024, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL );
/* create and send a MSRPC command with api */
/*
diff --git a/source3/rpc_client/cli_srvsvc.c b/source3/rpc_client/cli_srvsvc.c
index 4a3aed6d15..d4522714f2 100644
--- a/source3/rpc_client/cli_srvsvc.c
+++ b/source3/rpc_client/cli_srvsvc.c
@@ -49,8 +49,8 @@ BOOL do_srv_net_srv_conn_enum(struct cli_state *cli,
if (server_name == NULL || ctr == NULL || preferred_len == 0)
return False;
- prs_init(&data , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rdata, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&data, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rdata, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api SRV_NETCONNENUM */
@@ -129,8 +129,8 @@ BOOL do_srv_net_srv_sess_enum(struct cli_state *cli,
if (server_name == NULL || ctr == NULL || preferred_len == 0)
return False;
- prs_init(&data , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rdata, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&data, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rdata, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api SRV_NETSESSENUM */
@@ -206,8 +206,8 @@ BOOL do_srv_net_srv_share_enum(struct cli_state *cli,
if (server_name == NULL || preferred_len == 0)
return False;
- prs_init(&data , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rdata, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&data, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rdata, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api SRV_NETSHAREENUM */
@@ -277,8 +277,8 @@ BOOL do_srv_net_srv_file_enum(struct cli_state *cli,
if (server_name == NULL || ctr == NULL || preferred_len == 0)
return False;
- prs_init(&data , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rdata, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&data, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rdata, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api SRV_NETFILEENUM */
@@ -355,8 +355,8 @@ BOOL do_srv_net_srv_get_info(struct cli_state *cli,
if (server_name == NULL || switch_value == 0 || ctr == NULL)
return False;
- prs_init(&data , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rdata, 0, 4, cli->mem_ctx, UNMARSHALL);
+ prs_init(&data, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rdata, 0, cli->mem_ctx, UNMARSHALL);
/* create and send a MSRPC command with api SRV_NET_SRV_GET_INFO */
diff --git a/source3/rpc_client/cli_wkssvc.c b/source3/rpc_client/cli_wkssvc.c
index 16968b39e4..5d4ad80707 100644
--- a/source3/rpc_client/cli_wkssvc.c
+++ b/source3/rpc_client/cli_wkssvc.c
@@ -47,8 +47,8 @@ BOOL do_wks_query_info(struct cli_state *cli,
if (server_name == 0 || wks100 == NULL)
return False;
- prs_init(&buf , MAX_PDU_FRAG_LEN, 4, cli->mem_ctx, MARSHALL);
- prs_init(&rbuf, 0, 4, cli->mem_ctx, UNMARSHALL );
+ prs_init(&buf, MAX_PDU_FRAG_LEN, cli->mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, cli->mem_ctx, UNMARSHALL );
/* create and send a MSRPC command with api WKS_QUERY_INFO */
diff --git a/source3/rpc_client/msrpc_spoolss.c b/source3/rpc_client/msrpc_spoolss.c
index a7a25caaea..bee30de854 100644
--- a/source3/rpc_client/msrpc_spoolss.c
+++ b/source3/rpc_client/msrpc_spoolss.c
@@ -43,7 +43,7 @@ void init_buffer(NEW_BUFFER *buffer, uint32 size, TALLOC_CTX *ctx)
buffer->ptr = (size!=0)? 1:0;
buffer->size=size;
buffer->string_at_end=size;
- prs_init(&buffer->prs, size, 4, ctx, MARSHALL);
+ prs_init(&buffer->prs, size, ctx, MARSHALL);
buffer->struct_start = prs_offset(&buffer->prs);
}
diff --git a/source3/rpc_parse/parse_creds.c b/source3/rpc_parse/parse_creds.c
index 05b33d4da7..7bdbe65880 100644
--- a/source3/rpc_parse/parse_creds.c
+++ b/source3/rpc_parse/parse_creds.c
@@ -597,7 +597,7 @@ BOOL create_ntuser_creds( prs_struct *ps,
usr.ptr_ntc = 0;
}
- prs_init(ps, 1024, 4, NULL, False);
+ prs_init(ps, 1024, NULL, MARSHALL);
ps->data_offset = 4;
return creds_io_cmd("creds", &cmd, ps, 0);
@@ -623,7 +623,7 @@ BOOL create_user_creds( prs_struct *ps,
cmd.ptr_creds = usr != NULL ? 1 : 0;
cmd.cred = usr;
- prs_init(ps, 1024, 4, NULL, False);
+ prs_init(ps, 1024, NULL, MARSHALL);
ps->data_offset = 4;
return creds_io_cmd("creds", &cmd, ps, 0);
diff --git a/source3/rpc_parse/parse_prs.c b/source3/rpc_parse/parse_prs.c
index 1ec3f72d4c..84ccbd5db6 100644
--- a/source3/rpc_parse/parse_prs.c
+++ b/source3/rpc_parse/parse_prs.c
@@ -67,12 +67,12 @@ void prs_debug(prs_struct *ps, int depth, char *desc, char *fn_name)
/*******************************************************************
Initialise a parse structure - malloc the data if requested.
********************************************************************/
-BOOL prs_init(prs_struct *ps, uint32 size, uint8 align, TALLOC_CTX *ctx, BOOL io)
+BOOL prs_init(prs_struct *ps, uint32 size, TALLOC_CTX *ctx, BOOL io)
{
ZERO_STRUCTP(ps);
ps->io = io;
- ps->bigendian_data = False;
- ps->align = align;
+ ps->bigendian_data = RPC_LITTLE_ENDIAN;
+ ps->align = RPC_PARSE_ALIGN;
ps->is_dynamic = False;
ps->data_offset = 0;
ps->buffer_size = 0;
@@ -387,12 +387,12 @@ BOOL prs_append_data(prs_struct *dst, char *src, uint32 len)
}
/*******************************************************************
- Set the data as big-endian (external interface).
+ Set the data as X-endian (external interface).
********************************************************************/
-void prs_set_bigendian_data(prs_struct *ps)
+void prs_set_endian_data(prs_struct *ps, BOOL endian)
{
- ps->bigendian_data = True;
+ ps->bigendian_data = endian;
}
/*******************************************************************
@@ -1010,7 +1010,7 @@ int tdb_prs_fetch(TDB_CONTEXT *tdb, char *keystr, prs_struct *ps, TALLOC_CTX *me
if (!dbuf.dptr) return -1;
ZERO_STRUCTP(ps);
- prs_init(ps, 0, 4, mem_ctx, UNMARSHALL);
+ prs_init(ps, 0, mem_ctx, UNMARSHALL);
prs_give_memory(ps, dbuf.dptr, dbuf.dsize, True);
return 0;
diff --git a/source3/rpc_parse/parse_rpc.c b/source3/rpc_parse/parse_rpc.c
index c40de10445..9fe893d4be 100644
--- a/source3/rpc_parse/parse_rpc.c
+++ b/source3/rpc_parse/parse_rpc.c
@@ -203,7 +203,7 @@ BOOL smb_io_rpc_hdr(char *desc, RPC_HDR *rpc, prs_struct *ps, int depth)
if (ps->io && rpc->pack_type[0] == 0) {
DEBUG(10,("smb_io_rpc_hdr: PDU data format is big-endian. Setting flag.\n"));
- prs_set_bigendian_data(ps);
+ prs_set_endian_data(ps, RPC_BIG_ENDIAN);
}
if(!prs_uint16("frag_len ", ps, depth, &rpc->frag_len))
@@ -239,7 +239,7 @@ static BOOL smb_io_rpc_iface(char *desc, RPC_IFACE *ifc, prs_struct *ps, int dep
if(!prs_uint8s (False, "data ", ps, depth, ifc->uuid.remaining, sizeof(ifc->uuid.remaining)))
return False;
- if(!prs_uint32 ( "version", ps, depth, &(ifc->version)))
+ if(!prs_uint32 ( "version", ps, depth, &ifc->version))
return False;
return True;
diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c
index 3774a91100..0073f22cab 100644
--- a/source3/rpc_parse/parse_spoolss.c
+++ b/source3/rpc_parse/parse_spoolss.c
@@ -2515,7 +2515,12 @@ static BOOL new_spoolss_io_buffer(char *desc, prs_struct *ps, int depth, NEW_BUF
buffer->string_at_end=0;
if (buffer->ptr==0) {
- if (!prs_init(&buffer->prs, 0, 4, prs_get_mem_context(ps), UNMARSHALL))
+ /*
+ * JRA. I'm not sure if the data in here is in big-endian format if
+ * the client is big-endian. Leave as default (little endian) for now.
+ */
+
+ if (!prs_init(&buffer->prs, 0, prs_get_mem_context(ps), UNMARSHALL))
return False;
return True;
}
@@ -2523,7 +2528,12 @@ static BOOL new_spoolss_io_buffer(char *desc, prs_struct *ps, int depth, NEW_BUF
if (!prs_uint32("size", ps, depth, &buffer->size))
return False;
- if (!prs_init(&buffer->prs, buffer->size, 4, prs_get_mem_context(ps), UNMARSHALL))
+ /*
+ * JRA. I'm not sure if the data in here is in big-endian format if
+ * the client is big-endian. Leave as default (little endian) for now.
+ */
+
+ if (!prs_init(&buffer->prs, buffer->size, prs_get_mem_context(ps), UNMARSHALL))
return False;
if (!prs_append_some_prs_data(&buffer->prs, ps, prs_offset(ps), buffer->size))
diff --git a/source3/rpc_server/srv_pipe.c b/source3/rpc_server/srv_pipe.c
index c0174280ab..dcefeed8b9 100644
--- a/source3/rpc_server/srv_pipe.c
+++ b/source3/rpc_server/srv_pipe.c
@@ -167,7 +167,7 @@ BOOL create_next_pdu(pipes_struct *p)
* data.
*/
- prs_init( &outgoing_pdu, 0, 4, p->mem_ctx, MARSHALL);
+ prs_init( &outgoing_pdu, 0, p->mem_ctx, MARSHALL);
prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False);
/* Store the header in the data stream. */
@@ -586,7 +586,7 @@ static BOOL setup_bind_nak(pipes_struct *p)
* header and are never sending more than one PDU here.
*/
- prs_init( &outgoing_rpc, 0, 4, p->mem_ctx, MARSHALL);
+ prs_init( &outgoing_rpc, 0, p->mem_ctx, MARSHALL);
prs_give_memory( &outgoing_rpc, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False);
@@ -645,7 +645,7 @@ BOOL setup_fault_pdu(pipes_struct *p)
* header and are never sending more than one PDU here.
*/
- prs_init( &outgoing_pdu, 0, 4, p->mem_ctx, MARSHALL);
+ prs_init( &outgoing_pdu, 0, p->mem_ctx, MARSHALL);
prs_give_memory( &outgoing_pdu, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False);
/*
@@ -862,7 +862,7 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p)
* header and are never sending more than one PDU here.
*/
- prs_init( &outgoing_rpc, 0, 4, p->mem_ctx, MARSHALL);
+ prs_init( &outgoing_rpc, 0, p->mem_ctx, MARSHALL);
prs_give_memory( &outgoing_rpc, (char *)p->out_data.current_pdu, sizeof(p->out_data.current_pdu), False);
/*
@@ -870,13 +870,13 @@ BOOL api_pipe_bind_req(pipes_struct *p, prs_struct *rpc_in_p)
* auth footers.
*/
- if(!prs_init(&out_hdr_ba, 1024, 4, p->mem_ctx, MARSHALL)) {
+ if(!prs_init(&out_hdr_ba, 1024, p->mem_ctx, MARSHALL)) {
DEBUG(0,("api_pipe_bind_req: malloc out_hdr_ba failed.\n"));
prs_mem_free(&outgoing_rpc);
return False;
}
- if(!prs_init(&out_auth, 1024, 4, p->mem_ctx, MARSHALL)) {
+ if(!prs_init(&out_auth, 1024, p->mem_ctx, MARSHALL)) {
DEBUG(0,("pi_pipe_bind_req: malloc out_auth failed.\n"));
prs_mem_free(&outgoing_rpc);
prs_mem_free(&out_hdr_ba);
diff --git a/source3/rpc_server/srv_pipe_hnd.c b/source3/rpc_server/srv_pipe_hnd.c
index eb369f22b4..5545071913 100644
--- a/source3/rpc_server/srv_pipe_hnd.c
+++ b/source3/rpc_server/srv_pipe_hnd.c
@@ -96,7 +96,7 @@ static BOOL pipe_init_outgoing_data(pipes_struct *p)
* Initialize the outgoing RPC data buffer.
* we will use this as the raw data area for replying to rpc requests.
*/
- if(!prs_init(&o_data->rdata, MAX_PDU_FRAG_LEN, 4, p->mem_ctx, MARSHALL)) {
+ if(!prs_init(&o_data->rdata, MAX_PDU_FRAG_LEN, p->mem_ctx, MARSHALL)) {
DEBUG(0,("pipe_init_outgoing_data: malloc fail.\n"));
return False;
}
@@ -159,7 +159,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name,
* change the type to UNMARSALLING before processing the stream.
*/
- if(!prs_init(&p->in_data.data, MAX_PDU_FRAG_LEN, 4, p->mem_ctx, MARSHALL)) {
+ if(!prs_init(&p->in_data.data, MAX_PDU_FRAG_LEN, p->mem_ctx, MARSHALL)) {
DEBUG(0,("open_rpc_pipe_p: malloc fail for in_data struct.\n"));
return NULL;
}
@@ -185,6 +185,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name,
p->pipe_bound = False;
p->fault_state = False;
+ p->endian = RPC_LITTLE_ENDIAN;
/*
* Initialize the incoming RPC struct.
@@ -204,7 +205,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name,
/*
* Initialize the outgoing RPC data buffer with no memory.
*/
- prs_init(&p->out_data.rdata, 0, 4, p->mem_ctx, MARSHALL);
+ prs_init(&p->out_data.rdata, 0, p->mem_ctx, MARSHALL);
ZERO_STRUCT(p->pipe_user);
@@ -275,13 +276,16 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p)
return -1;
}
- prs_init( &rpc_in, 0, 4, p->mem_ctx, UNMARSHALL);
+ prs_init( &rpc_in, 0, p->mem_ctx, UNMARSHALL);
+ prs_set_endian_data( &rpc_in, p->endian);
+
prs_give_memory( &rpc_in, (char *)&p->in_data.current_in_pdu[0],
p->in_data.pdu_received_len, False);
/*
* Unmarshall the header as this will tell us how much
* data we need to read to get the complete pdu.
+ * This also sets the endian flag in rpc_in.
*/
if(!smb_io_rpc_hdr("", &p->hdr, &rpc_in, 0)) {
@@ -303,16 +307,45 @@ static ssize_t unmarshall_rpc_header(pipes_struct *p)
}
/*
- * If there is no data in the incoming buffer and it's a requst pdu then
- * ensure that the FIRST flag is set. If not then we have
- * a stream missmatch.
+ * If there's not data in the incoming buffer and it's a
+ * request PDU this should be the start of a new RPC.
*/
- if((p->hdr.pkt_type == RPC_REQUEST) && (prs_offset(&p->in_data.data) == 0) && !(p->hdr.flags & RPC_FLG_FIRST)) {
- DEBUG(0,("unmarshall_rpc_header: FIRST flag not set in first PDU !\n"));
- set_incoming_fault(p);
- prs_mem_free(&rpc_in);
- return -1;
+ if((p->hdr.pkt_type == RPC_REQUEST) && (prs_offset(&p->in_data.data) == 0)) {
+
+ if (!(p->hdr.flags & RPC_FLG_FIRST)) {
+ /*
+ * Ensure that the FIRST flag is set. If not then we have
+ * a stream missmatch.
+ */
+
+ DEBUG(0,("unmarshall_rpc_header: FIRST flag not set in first PDU !\n"));
+ set_incoming_fault(p);
+ prs_mem_free(&rpc_in);
+ return -1;
+ }
+
+ /*
+ * If this is the first PDU then set the endianness
+ * flag in the pipe. We will need this when parsing all
+ * data in this RPC.
+ */
+
+ p->endian = rpc_in.bigendian_data;
+
+ } else {
+
+ /*
+ * If this is *NOT* the first PDU then check the endianness
+ * flag in the pipe is the same as that in the PDU.
+ */
+
+ if (p->endian != rpc_in.bigendian_data) {
+ DEBUG(0,("unmarshall_rpc_header: FIRST endianness flag different in next PDU !\n"));
+ set_incoming_fault(p);
+ prs_mem_free(&rpc_in);
+ return -1;
+ }
}
/*
@@ -493,7 +526,10 @@ static ssize_t process_complete_pdu(pipes_struct *p)
return (ssize_t)data_len;
}
- prs_init( &rpc_in, 0, 4, p->mem_ctx, UNMARSHALL);
+ prs_init( &rpc_in, 0, p->mem_ctx, UNMARSHALL);
+ /* Ensure we're using the corrent endianness. */
+ prs_set_endian_data( &rpc_in, p->endian);
+
prs_give_memory( &rpc_in, data_p, (uint32)data_len, False);
DEBUG(10,("process_complete_pdu: processing packet type %u\n",
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index c326dd561f..d9a93f8d78 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -1085,7 +1085,7 @@ static BOOL set_sd(files_struct *fsp, char *data, uint32 sd_len, uint security_i
return False;
}
- prs_init(&pd, 0, 4, mem_ctx, UNMARSHALL);
+ prs_init(&pd, 0, mem_ctx, UNMARSHALL);
/*
* Setup the prs_struct to point at the memory we just
@@ -1662,7 +1662,7 @@ static int call_nt_transact_query_security_desc(connection_struct *conn,
return(ERROR(ERRDOS,ERRnomem));
}
- prs_init(&pd, 0, 4, mem_ctx, MARSHALL);
+ prs_init(&pd, 0, mem_ctx, MARSHALL);
/*
* Setup the prs_struct to point at the memory we just