summaryrefslogtreecommitdiff
path: root/source3/rpcclient
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2003-09-09 04:07:32 +0000
committerGerald Carter <jerry@samba.org>2003-09-09 04:07:32 +0000
commit4093bf7ff8c8861cf7b941945ede53a8ec5bb6c8 (patch)
treedd0a9f32d9933e1f75d919b5083e007d7453f9c4 /source3/rpcclient
parent3d7cb49747a9a7f5cdec0ee05c6270ec3604202f (diff)
downloadsamba-4093bf7ff8c8861cf7b941945ede53a8ec5bb6c8.tar.gz
samba-4093bf7ff8c8861cf7b941945ede53a8ec5bb6c8.tar.bz2
samba-4093bf7ff8c8861cf7b941945ede53a8ec5bb6c8.zip
sync 3.0 into HEAD for the last time
(This used to be commit c17a7dc9a190156a069da3e861c18fd3f81224ad)
Diffstat (limited to 'source3/rpcclient')
-rw-r--r--source3/rpcclient/cmd_ds.c2
-rw-r--r--source3/rpcclient/cmd_netlogon.c86
-rw-r--r--source3/rpcclient/cmd_spoolss.c44
-rw-r--r--source3/rpcclient/rpcclient.c12
4 files changed, 86 insertions, 58 deletions
diff --git a/source3/rpcclient/cmd_ds.c b/source3/rpcclient/cmd_ds.c
index 721bd59ba0..b01236d9a5 100644
--- a/source3/rpcclient/cmd_ds.c
+++ b/source3/rpcclient/cmd_ds.c
@@ -54,7 +54,7 @@ static NTSTATUS cmd_ds_enum_domain_trusts(struct cli_state *cli,
NTSTATUS result;
uint32 flags = 0x1;
DS_DOMAIN_TRUSTS *trusts = NULL;
- int num_domains = 0;
+ unsigned int num_domains = 0;
result = cli_ds_enum_domain_trusts( cli, mem_ctx, cli->desthost, flags,
&trusts, &num_domains );
diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c
index 0ec78a0673..a48b59bf6a 100644
--- a/source3/rpcclient/cmd_netlogon.c
+++ b/source3/rpcclient/cmd_netlogon.c
@@ -146,13 +146,10 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli,
const char **argv)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- unsigned char trust_passwd[16];
uint32 database_id = 0, num_deltas;
SAM_DELTA_HDR *hdr_deltas;
SAM_DELTA_CTR *deltas;
DOM_CRED ret_creds;
- uint32 neg_flags = 0x000001ff;
- uint32 sec_channel_type = 0;
if (argc > 2) {
fprintf(stderr, "Usage: %s [database_id]\n", argv[0]);
@@ -162,26 +159,6 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli,
if (argc == 2)
database_id = atoi(argv[1]);
- if (!secrets_init()) {
- fprintf(stderr, "Unable to initialise secrets database\n");
- return result;
- }
-
- /* Initialise session credentials */
-
- if (!secrets_fetch_trust_account_password(lp_workgroup(), trust_passwd,
- NULL, &sec_channel_type)) {
- fprintf(stderr, "could not fetch trust account password\n");
- goto done;
- }
-
- result = cli_nt_setup_creds(cli, sec_channel_type, trust_passwd, &neg_flags, 2);
-
- if (!NT_STATUS_IS_OK(result)) {
- fprintf(stderr, "Error initialising session creds\n");
- goto done;
- }
-
/* on first call the returnAuthenticator is empty */
memset(&ret_creds, 0, sizeof(ret_creds));
@@ -208,13 +185,10 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli,
const char **argv)
{
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- unsigned char trust_passwd[16];
uint32 database_id, num_deltas, tmp;
SAM_DELTA_HDR *hdr_deltas;
SAM_DELTA_CTR *deltas;
UINT64_S seqnum;
- uint32 neg_flags = 0x000001ff;
- uint32 sec_channel_type = 0;
if (argc != 3) {
fprintf(stderr, "Usage: %s database_id seqnum\n", argv[0]);
@@ -227,28 +201,6 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli,
seqnum.low = tmp & 0xffff;
seqnum.high = 0;
- if (!secrets_init()) {
- fprintf(stderr, "Unable to initialise secrets database\n");
- goto done;
- }
-
- /* Initialise session credentials */
-
- if (!secrets_fetch_trust_account_password(lp_workgroup(), trust_passwd,
- NULL, &sec_channel_type)) {
- fprintf(stderr, "could not fetch trust account password\n");
- goto done;
- }
-
- result = cli_nt_setup_creds(cli, sec_channel_type, trust_passwd, &neg_flags, 2);
-
- if (!NT_STATUS_IS_OK(result)) {
- fprintf(stderr, "Error initialising session creds\n");
- goto done;
- }
-
- /* Synchronise sam database */
-
result = cli_netlogon_sam_deltas(cli, mem_ctx, database_id,
seqnum, &num_deltas,
&hdr_deltas, &deltas);
@@ -308,6 +260,8 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli,
result = cli_netlogon_sam_logon(cli, mem_ctx, &ret_creds, username, password, logon_type);
+ clnt_deal_with_creds(cli->sess_key, &(cli->clnt_cred), &ret_creds);
+
if (!NT_STATUS_IS_OK(result))
goto done;
@@ -315,6 +269,39 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli,
return result;
}
+/* Change the trust account password */
+
+static NTSTATUS cmd_netlogon_change_trust_pw(struct cli_state *cli,
+ TALLOC_CTX *mem_ctx, int argc,
+ const char **argv)
+{
+ NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
+ DOM_CRED ret_creds;
+
+ /* Check arguments */
+
+ if (argc > 1) {
+ fprintf(stderr, "Usage: change_trust_pw");
+ return NT_STATUS_OK;
+ }
+
+ /* Perform the sam logon */
+
+ ZERO_STRUCT(ret_creds);
+
+ result = trust_pw_find_change_and_store_it(cli, mem_ctx,
+ lp_workgroup());
+
+ clnt_deal_with_creds(cli->sess_key, &(cli->clnt_cred), &ret_creds);
+
+ if (!NT_STATUS_IS_OK(result))
+ goto done;
+
+ done:
+ return result;
+}
+
+
/* List of commands exported by this module */
struct cmd_set netlogon_commands[] = {
@@ -325,7 +312,8 @@ struct cmd_set netlogon_commands[] = {
{ "logonctrl", RPC_RTYPE_NTSTATUS, cmd_netlogon_logon_ctrl, NULL, PI_NETLOGON, "Logon Control", "" },
{ "samsync", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_sync, NULL, PI_NETLOGON, "Sam Synchronisation", "" },
{ "samdeltas", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_deltas, NULL, PI_NETLOGON, "Query Sam Deltas", "" },
- { "samlogon", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_logon, NULL, PI_NETLOGON, "Sam Logon", "" },
+ { "samlogon", RPC_RTYPE_NTSTATUS, cmd_netlogon_sam_logon, NULL, PI_NETLOGON, "Sam Logon", "" },
+ { "samlogon", RPC_RTYPE_NTSTATUS, cmd_netlogon_change_trust_pw, NULL, PI_NETLOGON, "Change Trust Account Password", "" },
{ NULL }
};
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index b2fa802e9a..61e100c03b 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -35,6 +35,7 @@ static const struct table_node archi_table[]= {
{"Windows 4.0", "WIN40", 0 },
{"Windows NT x86", "W32X86", 2 },
+ {"Windows NT x86", "W32X86", 3 },
{"Windows NT R4000", "W32MIPS", 2 },
{"Windows NT Alpha_AXP", "W32ALPHA", 2 },
{"Windows NT PowerPC", "W32PPC", 2 },
@@ -395,7 +396,31 @@ static void display_port_info_2(PORT_INFO_2 *i2)
rpcstr_pull(buffer, i2->description.buffer, sizeof(buffer), -1, STR_TERMINATE);
printf("\tDescription:\t[%s]\n", buffer);
- printf("\tPort Type:\t[%d]\n", i2->port_type);
+ printf("\tPort Type:\t" );
+ if ( i2->port_type ) {
+ int comma = 0; /* hack */
+ printf( "[" );
+ if ( i2->port_type & PORT_TYPE_READ ) {
+ printf( "Read" );
+ comma = 1;
+ }
+ if ( i2->port_type & PORT_TYPE_WRITE ) {
+ printf( "%sWrite", comma ? ", " : "" );
+ comma = 1;
+ }
+ /* These two have slightly different interpretations
+ on 95/98/ME but I'm disregarding that for now */
+ if ( i2->port_type & PORT_TYPE_REDIRECTED ) {
+ printf( "%sRedirected", comma ? ", " : "" );
+ comma = 1;
+ }
+ if ( i2->port_type & PORT_TYPE_NET_ATTACHED ) {
+ printf( "%sNet-Attached", comma ? ", " : "" );
+ }
+ printf( "]\n" );
+ } else {
+ printf( "[Unset]\n" );
+ }
printf("\tReserved:\t[%d]\n", i2->reserved);
printf("\n");
}
@@ -912,6 +937,7 @@ static WERROR cmd_spoolss_getdriver(struct cli_state *cli,
servername,
user;
uint32 i;
+ BOOL success = False;
if ((argc == 1) || (argc > 3))
{
@@ -947,15 +973,22 @@ static WERROR cmd_spoolss_getdriver(struct cli_state *cli,
werror = cli_spoolss_getprinterdriver(
cli, mem_ctx, 0, &needed, &pol, info_level,
- archi_table[i].long_archi, &ctr);
+ archi_table[i].long_archi, archi_table[i].version,
+ &ctr);
- if (W_ERROR_V(werror) == ERRinsufficientbuffer)
+ if (W_ERROR_V(werror) == ERRinsufficientbuffer) {
werror = cli_spoolss_getprinterdriver(
cli, mem_ctx, needed, NULL, &pol, info_level,
- archi_table[i].long_archi, &ctr);
+ archi_table[i].long_archi, archi_table[i].version,
+ &ctr);
+ }
if (!W_ERROR_IS_OK(werror))
continue;
+
+ /* need at least one success */
+
+ success = True;
printf ("\n[%s]\n", archi_table[i].long_archi);
@@ -980,6 +1013,9 @@ static WERROR cmd_spoolss_getdriver(struct cli_state *cli,
if (opened_hnd)
cli_spoolss_close_printer (cli, mem_ctx, &pol);
+ if ( success )
+ werror = WERR_OK;
+
return werror;
}
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 831d2beaa4..515489292b 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -40,7 +40,7 @@ static struct cmd_list {
/****************************************************************************
handle completion of commands for readline
****************************************************************************/
-static char **completion_fn(char *text, int start, int end)
+static char **completion_fn(const char *text, int start, int end)
{
#define MAX_COMPLETIONS 100
char **matches;
@@ -361,7 +361,7 @@ static NTSTATUS cmd_schannel(struct cli_state *cli, TALLOC_CTX *mem_ctx,
static uchar zeros[16];
if (argc == 2) {
- strhex_to_str(cli->auth_info.sess_key,
+ strhex_to_str((char *)cli->auth_info.sess_key,
strlen(argv[1]),
argv[1]);
memcpy(cli->sess_key, cli->auth_info.sess_key, sizeof(cli->sess_key));
@@ -522,6 +522,8 @@ static NTSTATUS do_cmd(struct cli_state *cli,
/* some of the DsXXX commands use the netlogon pipe */
if (lp_client_schannel() && (cmd_entry->pipe_idx == PI_NETLOGON) && !(cli->pipe_auth_flags & AUTH_PIPE_NETSEC)) {
+ /* The 7 here seems to be required to get Win2k not to downgrade us
+ to NT4. Actually, anything other than 1ff would seem to do... */
uint32 neg_flags = 0x000001ff;
uint32 sec_channel_type;
@@ -725,8 +727,10 @@ out_free:
nt_status = cli_full_connection(&cli, global_myname(), server,
opt_ipaddr ? &server_ip : NULL, 0,
"IPC$", "IPC",
- cmdline_auth_info.username, lp_workgroup(),
- cmdline_auth_info.password, 0,
+ cmdline_auth_info.username,
+ lp_workgroup(),
+ cmdline_auth_info.password,
+ cmdline_auth_info.use_kerberos ? CLI_FULL_CONNECTION_USE_KERBEROS : 0,
cmdline_auth_info.signing_state,NULL);
if (!NT_STATUS_IS_OK(nt_status)) {