summaryrefslogtreecommitdiff
path: root/source/rpcclient
diff options
context:
space:
mode:
Diffstat (limited to 'source/rpcclient')
-rw-r--r--source/rpcclient/cmd_dfs.c3
-rw-r--r--source/rpcclient/cmd_reg.c3
-rw-r--r--source/rpcclient/cmd_wkssvc.c3
-rw-r--r--source/rpcclient/display.c3
-rw-r--r--source/rpcclient/display_sec.c258
-rw-r--r--source/rpcclient/display_spool.c3
-rw-r--r--source/rpcclient/rpcclient.h3
-rw-r--r--source/rpcclient/samsync.c316
-rw-r--r--source/rpcclient/spoolss_cmds.c3
9 files changed, 222 insertions, 373 deletions
diff --git a/source/rpcclient/cmd_dfs.c b/source/rpcclient/cmd_dfs.c
index 8a3c3e9db33..78f68dcc86b 100644
--- a/source/rpcclient/cmd_dfs.c
+++ b/source/rpcclient/cmd_dfs.c
@@ -1,5 +1,6 @@
/*
- Unix SMB/CIFS implementation.
+ Unix SMB/Netbios implementation.
+ Version 2.2
RPC pipe client
Copyright (C) Tim Potter 2000
diff --git a/source/rpcclient/cmd_reg.c b/source/rpcclient/cmd_reg.c
index c089917f9b6..787cd4f553a 100644
--- a/source/rpcclient/cmd_reg.c
+++ b/source/rpcclient/cmd_reg.c
@@ -1,5 +1,6 @@
/*
- Unix SMB/CIFS implementation.
+ Unix SMB/Netbios implementation.
+ Version 1.9.
NT Domain Authentication SMB / MSRPC client
Copyright (C) Andrew Tridgell 1994-1997
Copyright (C) Luke Kenneth Casson Leighton 1996-1997
diff --git a/source/rpcclient/cmd_wkssvc.c b/source/rpcclient/cmd_wkssvc.c
index 79acf35943c..52c110dbd56 100644
--- a/source/rpcclient/cmd_wkssvc.c
+++ b/source/rpcclient/cmd_wkssvc.c
@@ -1,5 +1,6 @@
/*
- Unix SMB/CIFS implementation.
+ Unix SMB/Netbios implementation.
+ Version 1.9.
NT Domain Authentication SMB / MSRPC client
Copyright (C) Andrew Tridgell 1994-1997
Copyright (C) Luke Kenneth Casson Leighton 1996-1997
diff --git a/source/rpcclient/display.c b/source/rpcclient/display.c
index d03465206e2..345ed7d49af 100644
--- a/source/rpcclient/display.c
+++ b/source/rpcclient/display.c
@@ -1,5 +1,6 @@
/*
- Unix SMB/CIFS implementation.
+ Unix SMB/Netbios implementation.
+ Version 1.9.
Samba utility functions
Copyright (C) Andrew Tridgell 1992-1998
Copyright (C) Luke Kenneth Casson Leighton 1996 - 1998
diff --git a/source/rpcclient/display_sec.c b/source/rpcclient/display_sec.c
index 9d54fe2235a..a428a956863 100644
--- a/source/rpcclient/display_sec.c
+++ b/source/rpcclient/display_sec.c
@@ -1,5 +1,6 @@
/*
- Unix SMB/CIFS implementation.
+ Unix SMB/Netbios implementation.
+ Version 1.9.
Samba utility functions
Copyright (C) Andrew Tridgell 1992-1999
Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
@@ -22,39 +23,67 @@
#include "includes.h"
#include "rpcclient.h"
+
/****************************************************************************
convert a security permissions into a string
****************************************************************************/
-char *get_sec_mask_str(uint32 type)
+static const char *get_sec_mask_str(uint32 type)
{
- static fstring typestr="";
+ static fstring typestr;
+ int i;
+
+ switch (type)
+ {
+ case SEC_RIGHTS_FULL_CONTROL:
+ {
+ fstrcpy(typestr, "Full Control");
+ return typestr;
+ }
+
+ case SEC_RIGHTS_READ:
+ {
+ fstrcpy(typestr, "Read");
+ return typestr;
+ }
+ default:
+ {
+ break;
+ }
+ }
typestr[0] = 0;
+ for (i = 0; i < 32; i++)
+ {
+ if (type & (1 << i))
+ {
+ switch (1 << i)
+ {
+ case SEC_RIGHTS_QUERY_VALUE : fstrcat(typestr, "Query " ); break;
+ case SEC_RIGHTS_SET_VALUE : fstrcat(typestr, "Set " ); break;
+ case SEC_RIGHTS_CREATE_SUBKEY : fstrcat(typestr, "Create "); break;
+ case SEC_RIGHTS_ENUM_SUBKEYS : fstrcat(typestr, "Enum "); break;
+ case SEC_RIGHTS_NOTIFY : fstrcat(typestr, "Notify "); break;
+ case SEC_RIGHTS_CREATE_LINK : fstrcat(typestr, "CreateLink "); break;
+ case DELETE_ACCESS : fstrcat(typestr, "Delete "); break;
+ case READ_CONTROL_ACCESS : fstrcat(typestr, "ReadControl "); break;
+ case WRITE_DAC_ACCESS : fstrcat(typestr, "WriteDAC "); break;
+ case WRITE_OWNER_ACCESS : fstrcat(typestr, "WriteOwner "); break;
+ }
+ type &= ~(1 << i);
+ }
+ }
+
+ /* remaining bits get added on as-is */
+ if (type != 0)
+ {
+ fstring tmp;
+ slprintf(tmp, sizeof(tmp)-1, "[%08x]", type);
+ fstrcat(typestr, tmp);
+ }
- if (type & GENERIC_ALL_ACCESS)
- fstrcat(typestr, "Generic all access ");
- if (type & GENERIC_EXECUTE_ACCESS)
- fstrcat(typestr, "Generic execute access ");
- if (type & GENERIC_WRITE_ACCESS)
- fstrcat(typestr, "Generic write access ");
- if (type & GENERIC_READ_ACCESS)
- fstrcat(typestr, "Generic read access ");
- if (type & MAXIMUM_ALLOWED_ACCESS)
- fstrcat(typestr, "MAXIMUM_ALLOWED_ACCESS ");
- if (type & SYSTEM_SECURITY_ACCESS)
- fstrcat(typestr, "SYSTEM_SECURITY_ACCESS ");
- if (type & SYNCHRONIZE_ACCESS)
- fstrcat(typestr, "SYNCHRONIZE_ACCESS ");
- if (type & WRITE_OWNER_ACCESS)
- fstrcat(typestr, "WRITE_OWNER_ACCESS ");
- if (type & WRITE_DAC_ACCESS)
- fstrcat(typestr, "WRITE_DAC_ACCESS ");
- if (type & READ_CONTROL_ACCESS)
- fstrcat(typestr, "READ_CONTROL_ACCESS ");
- if (type & DELETE_ACCESS)
- fstrcat(typestr, "DELETE_ACCESS ");
-
- printf("\t\tSpecific bits: 0x%lx\n", type&SPECIFIC_RIGHTS_MASK);
+ /* remove last space */
+ i = strlen(typestr)-1;
+ if (typestr[i] == ' ') typestr[i] = 0;
return typestr;
}
@@ -62,83 +91,152 @@ char *get_sec_mask_str(uint32 type)
/****************************************************************************
display sec_access structure
****************************************************************************/
-void display_sec_access(SEC_ACCESS *info)
+static void display_sec_access(FILE *out_hnd, enum action_type action, SEC_ACCESS *const info)
{
- printf("\t\tPermissions: 0x%x: %s\n", info->mask, get_sec_mask_str(info->mask));
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ report(out_hnd, "\t\tPermissions:\t%s\n",
+ get_sec_mask_str(info->mask));
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
}
/****************************************************************************
display sec_ace structure
****************************************************************************/
-void display_sec_ace(SEC_ACE *ace)
+static void display_sec_ace(FILE *out_hnd, enum action_type action, SEC_ACE *const ace)
{
- fstring sid_str;
-
- printf("\tACE\n\t\ttype: ");
- switch (ace->type) {
- case SEC_ACE_TYPE_ACCESS_ALLOWED:
- printf("ACCESS ALLOWED");
- break;
- case SEC_ACE_TYPE_ACCESS_DENIED:
- printf("ACCESS DENIED");
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "\tACE\n");
break;
- case SEC_ACE_TYPE_SYSTEM_AUDIT:
- printf("SYSTEM AUDIT");
- break;
- case SEC_ACE_TYPE_SYSTEM_ALARM:
- printf("SYSTEM ALARM");
- break;
- default:
- printf("????");
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring sid_str;
+
+ report(out_hnd,
+ "\t\tType:%2x Flags:%2x Perms:%04x\n",
+ ace->type, ace->flags,
+ (uint32) ace->info.mask);
+
+ display_sec_access(out_hnd, ACTION_HEADER , &ace->info);
+ display_sec_access(out_hnd, ACTION_ENUMERATE, &ace->info);
+ display_sec_access(out_hnd, ACTION_FOOTER , &ace->info);
+
+ sid_to_string(sid_str, &ace->sid);
+ report(out_hnd, "\t\tSID:\t%s\n", sid_str);
+ }
+ case ACTION_FOOTER:
+ {
break;
+ }
}
- printf(" (%d) flags: %d\n", ace->type, ace->flags);
- display_sec_access(&ace->info);
- sid_to_string(sid_str, &ace->trustee);
- printf("\t\tSID: %s\n\n", sid_str);
}
/****************************************************************************
display sec_acl structure
****************************************************************************/
-void display_sec_acl(SEC_ACL *sec_acl)
+static void display_sec_acl(FILE *out_hnd, enum action_type action, SEC_ACL *const sec_acl)
{
- int i;
-
- printf("\tACL\tNum ACEs:\t%d\trevision:\t%x\n",
- sec_acl->num_aces, sec_acl->revision);
- printf("\t---\n");
+ if (sec_acl == NULL)
+ {
+ return;
+ }
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "\tACL\tNum ACEs:\t%d\trevision:\t%x\n",
+ sec_acl->num_aces, sec_acl->revision);
+ report(out_hnd, "\t---\n");
- if (sec_acl->size != 0 && sec_acl->num_aces != 0)
- for (i = 0; i < sec_acl->num_aces; i++)
- display_sec_ace(&sec_acl->ace[i]);
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ if (sec_acl->size != 0 && sec_acl->num_aces != 0)
+ {
+ int i;
+ for (i = 0; i < sec_acl->num_aces; i++)
+ {
+ display_sec_ace(out_hnd, ACTION_HEADER , &sec_acl->ace[i]);
+ display_sec_ace(out_hnd, ACTION_ENUMERATE, &sec_acl->ace[i]);
+ display_sec_ace(out_hnd, ACTION_FOOTER , &sec_acl->ace[i]);
+ }
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
}
/****************************************************************************
display sec_desc structure
****************************************************************************/
-void display_sec_desc(SEC_DESC *sec)
+void display_sec_desc(FILE *out_hnd, enum action_type action, SEC_DESC *const sec)
{
- fstring sid_str;
-
- if (sec->off_sacl != 0) {
- printf("S-ACL\n");
- display_sec_acl(sec->sacl);
- }
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "\tSecurity Descriptor\trevision:\t%x\ttype:\t%x\n",
+ sec->revision, sec->type);
+ report(out_hnd, "\t-------------------\n");
- if (sec->off_dacl != 0) {
- printf("D-ACL\n");
- display_sec_acl(sec->dacl);
- }
-
- if (sec->off_owner_sid != 0) {
- sid_to_string(sid_str, sec->owner_sid);
- printf("\tOwner SID:\t%s\n", sid_str);
- }
-
- if (sec->off_grp_sid != 0) {
- sid_to_string(sid_str, sec->grp_sid);
- printf("\tParent SID:\t%s\n", sid_str);
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring sid_str;
+
+ if (sec->off_sacl != 0)
+ {
+ display_sec_acl(out_hnd, ACTION_HEADER , sec->sacl);
+ display_sec_acl(out_hnd, ACTION_ENUMERATE, sec->sacl);
+ display_sec_acl(out_hnd, ACTION_FOOTER , sec->sacl);
+ }
+ if (sec->off_dacl != 0)
+ {
+ display_sec_acl(out_hnd, ACTION_HEADER , sec->dacl);
+ display_sec_acl(out_hnd, ACTION_ENUMERATE, sec->dacl);
+ display_sec_acl(out_hnd, ACTION_FOOTER , sec->dacl);
+ }
+ if (sec->off_owner_sid != 0)
+ {
+ sid_to_string(sid_str, sec->owner_sid);
+ report(out_hnd, "\tOwner SID:\t%s\n", sid_str);
+ }
+ if (sec->off_grp_sid != 0)
+ {
+ sid_to_string(sid_str, sec->grp_sid);
+ report(out_hnd, "\tParent SID:\t%s\n", sid_str);
+ }
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
}
}
+
diff --git a/source/rpcclient/display_spool.c b/source/rpcclient/display_spool.c
index b4baf570f17..cdca0c393dd 100644
--- a/source/rpcclient/display_spool.c
+++ b/source/rpcclient/display_spool.c
@@ -1,5 +1,6 @@
/*
- Unix SMB/CIFS implementation.
+ Unix SMB/Netbios implementation.
+ Version 1.9.
Samba utility functions
Copyright (C) Andrew Tridgell 1992-1999
Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
diff --git a/source/rpcclient/rpcclient.h b/source/rpcclient/rpcclient.h
index 72491373d67..588d10b3e6b 100644
--- a/source/rpcclient/rpcclient.h
+++ b/source/rpcclient/rpcclient.h
@@ -1,5 +1,6 @@
/*
- Unix SMB/CIFS implementation.
+ Unix SMB/Netbios implementation.
+ Version 2.2
RPC pipe client
Copyright (C) Tim Potter 2000
diff --git a/source/rpcclient/samsync.c b/source/rpcclient/samsync.c
index 3a0bc2d6f69..15efc1d42bc 100644
--- a/source/rpcclient/samsync.c
+++ b/source/rpcclient/samsync.c
@@ -1,5 +1,6 @@
/*
- Unix SMB/CIFS implementation.
+ Unix SMB/Netbios implementation.
+ Version 2.2
RPC pipe client
Copyright (C) Tim Potter 2001
@@ -21,249 +22,17 @@
#include "includes.h"
-static void decode_domain_info(SAM_DOMAIN_INFO *a)
-{
- fstring temp;
- printf("Domain Information\n");
- printf("------------------\n");
-
- unistr2_to_ascii(temp, &a->uni_dom_name, sizeof(temp)-1);
- printf("\tDomain :%s\n", temp);
- printf("\tMin password len :%d\n", a->min_pwd_len);
- printf("\tpassword history len:%d\n", a->pwd_history_len);
- printf("\tcreation time :%s\n", http_timestring(nt_time_to_unix(&a->creation_time)));
-}
-
-static void decode_sam_group_info(SAM_GROUP_INFO *a)
-{
- fstring temp;
- printf("\nDomain Group Information\n");
- printf("------------------------\n");
-
- unistr2_to_ascii(temp, &a->uni_grp_name, sizeof(temp)-1);
- printf("\tGroup name :%s\n", temp);
- unistr2_to_ascii(temp, &a->uni_grp_desc, sizeof(temp)-1);
- printf("\tGroup description :%s\n", temp);
- printf("\trid :%d\n", a->gid.g_rid);
- printf("\tattribute :%d\n", a->gid.attr);
-}
-
-static void decode_sam_account_info(SAM_ACCOUNT_INFO *a)
-{
- fstring temp;
- printf("\nUser Information\n");
- printf("----------------\n");
-
- unistr2_to_ascii(temp, &a->uni_acct_name, sizeof(temp)-1);
- printf("\tUser name :%s\n", temp);
- printf("\tuser's rid :%d\n", a->user_rid);
- printf("\tuser's primary gid :%d\n", a->group_rid);
- unistr2_to_ascii(temp, &a->uni_full_name, sizeof(temp)-1);
- printf("\tfull name :%s\n", temp);
- unistr2_to_ascii(temp, &a->uni_home_dir, sizeof(temp)-1);
- printf("\thome directory :%s\n", temp);
- unistr2_to_ascii(temp, &a->uni_dir_drive, sizeof(temp)-1);
- printf("\tdrive :%s\n", temp);
- unistr2_to_ascii(temp, &a->uni_logon_script, sizeof(temp)-1);
- printf("\tlogon script :%s\n", temp);
- unistr2_to_ascii(temp, &a->uni_acct_desc, sizeof(temp)-1);
- printf("\tdescription :%s\n", temp);
- unistr2_to_ascii(temp, &a->uni_workstations, sizeof(temp)-1);
- printf("\tworkstations :%s\n", temp);
-}
-
-static void decode_sam_grp_mem_info(SAM_GROUP_MEM_INFO *a)
-{
- int i;
- printf("\nGroup members information\n");
- printf("-------------------------\n");
- printf("\tnum members :%d\n", a->num_members);
-
- for (i=0; i<a->num_members; i++) {
- printf("\trid, attr:%d, %d\n", a->rids[i], a->attribs[i]);
- }
-}
-
-static void decode_sam_alias_info(SAM_ALIAS_INFO *a)
-{
- fstring temp;
- printf("\nAlias Information\n");
- printf("-----------------\n");
-
- unistr2_to_ascii(temp, &a->uni_als_name, sizeof(temp)-1);
- printf("\tname :%s\n", temp);
- unistr2_to_ascii(temp, &a->uni_als_desc, sizeof(temp)-1);
- printf("\tdescription :%s\n", temp);
- printf("\trid :%d\n", a->als_rid);
-}
-
-static void decode_sam_als_mem_info(SAM_ALIAS_MEM_INFO *a)
-{
- int i;
- fstring temp;
- printf("\nAlias members Information\n");
- printf("-------------------------\n");
- printf("\tnum members :%d\n", a->num_members);
- printf("\tnum sids :%d\n", a->num_sids);
- for (i=0; i<a->num_sids; i++) {
- printf("\tsid :%s\n", sid_to_string(temp, &a->sids[i].sid));
- }
-
-
-}
-
-static void decode_sam_dom_info(SAM_DELTA_DOM *a)
-{
- fstring temp;
- printf("\nDomain information\n");
- printf("------------------\n");
-
- unistr2_to_ascii(temp, &a->domain_name, sizeof(temp)-1);
- printf("\tdomain name :%s\n", temp);
- printf("\tsid :%s\n", sid_to_string(temp, &a->domain_sid.sid));
-}
-
-static void decode_sam_unk0e_info(SAM_DELTA_UNK0E *a)
-{
- fstring temp;
- printf("\nTrust information\n");
- printf("-----------------\n");
-
- unistr2_to_ascii(temp, &a->domain, sizeof(temp)-1);
- printf("\tdomain name :%s\n", temp);
- printf("\tsid :%s\n", sid_to_string(temp, &a->sid.sid));
- display_sec_desc(a->sec_desc);
-}
-
-static void decode_sam_privs_info(SAM_DELTA_PRIVS *a)
-{
- int i;
- fstring temp;
- printf("\nSID and privileges information\n");
- printf("------------------------------\n");
- printf("\tsid :%s\n", sid_to_string(temp, &a->sid.sid));
- display_sec_desc(a->sec_desc);
- printf("\tprivileges count :%d\n", a->privlist_count);
- for (i=0; i<a->privlist_count; i++) {
- unistr2_to_ascii(temp, &a->uni_privslist[i], sizeof(temp)-1);
- printf("\tprivilege name :%s\n", temp);
- printf("\tattribute :%d\n", a->attributes[i]);
- }
-}
-
-static void decode_sam_unk12_info(SAM_DELTA_UNK12 *a)
-{
- fstring temp;
- printf("\nTrusted information\n");
- printf("-------------------\n");
-
- unistr2_to_ascii(temp, &a->secret, sizeof(temp)-1);
- printf("\tsecret name :%s\n", temp);
- display_sec_desc(a->sec_desc);
-
- printf("\ttime 1 :%s\n", http_timestring(nt_time_to_unix(&a->time1)));
- printf("\ttime 2 :%s\n", http_timestring(nt_time_to_unix(&a->time2)));
-
- display_sec_desc(a->sec_desc2);
-}
-
-static void decode_sam_stamp(SAM_DELTA_STAMP *a)
-{
- printf("\nStamp information\n");
- printf("-----------------\n");
- printf("\tsequence number :%d\n", a->seqnum);
-}
-
-static void decode_sam_deltas(uint32 num_deltas, SAM_DELTA_HDR *hdr_deltas, SAM_DELTA_CTR *deltas)
-{
- int i;
- for (i = 0; i < num_deltas; i++) {
- switch (hdr_deltas[i].type) {
- case SAM_DELTA_DOMAIN_INFO: {
- SAM_DOMAIN_INFO *a;
- a = &deltas[i].domain_info;
- decode_domain_info(a);
- break;
- }
- case SAM_DELTA_GROUP_INFO: {
- SAM_GROUP_INFO *a;
- a = &deltas[i].group_info;
- decode_sam_group_info(a);
- break;
- }
- case SAM_DELTA_ACCOUNT_INFO: {
- SAM_ACCOUNT_INFO *a;
- a = &deltas[i].account_info;
- decode_sam_account_info(a);
- break;
- }
- case SAM_DELTA_GROUP_MEM: {
- SAM_GROUP_MEM_INFO *a;
- a = &deltas[i].grp_mem_info;
- decode_sam_grp_mem_info(a);
- break;
- }
- case SAM_DELTA_ALIAS_INFO: {
- SAM_ALIAS_INFO *a;
- a = &deltas[i].alias_info;
- decode_sam_alias_info(a);
- break;
- }
- case SAM_DELTA_ALIAS_MEM: {
- SAM_ALIAS_MEM_INFO *a;
- a = &deltas[i].als_mem_info;
- decode_sam_als_mem_info(a);
- break;
- }
- case SAM_DELTA_DOM_INFO: {
- SAM_DELTA_DOM *a;
- a = &deltas[i].dom_info;
- decode_sam_dom_info(a);
- break;
- }
- case SAM_DELTA_UNK0E_INFO: {
- SAM_DELTA_UNK0E *a;
- a = &deltas[i].unk0e_info;
- decode_sam_unk0e_info(a);
- break;
- }
- case SAM_DELTA_PRIVS_INFO: {
- SAM_DELTA_PRIVS *a;
- a = &deltas[i].privs_info;
- decode_sam_privs_info(a);
- break;
- }
- case SAM_DELTA_UNK12_INFO: {
- SAM_DELTA_UNK12 *a;
- a = &deltas[i].unk12_info;
- decode_sam_unk12_info(a);
- break;
- }
- case SAM_DELTA_SAM_STAMP: {
- SAM_DELTA_STAMP *a;
- a = &deltas[i].stamp;
- decode_sam_stamp(a);
- break;
- }
- default:
- DEBUG(0,("unknown delta type: %d\n", hdr_deltas[i].type));
- break;
- }
- }
-}
-
/* Synchronise sam database */
static NTSTATUS sam_sync(struct cli_state *cli, unsigned char trust_passwd[16],
- BOOL do_smbpasswd_output, BOOL verbose)
+ BOOL do_smbpasswd_output)
{
TALLOC_CTX *mem_ctx;
- SAM_DELTA_HDR *hdr_deltas_0, *hdr_deltas_1, *hdr_deltas_2;
- SAM_DELTA_CTR *deltas_0, *deltas_1, *deltas_2;
- uint32 num_deltas_0, num_deltas_1, num_deltas_2;
+ SAM_DELTA_HDR *hdr_deltas;
+ SAM_DELTA_CTR *deltas;
+ uint32 database_id = 0, num_deltas;
NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
- DOM_CRED ret_creds;
/* Initialise */
if (!(mem_ctx = talloc_init())) {
@@ -283,55 +52,31 @@ static NTSTATUS sam_sync(struct cli_state *cli, unsigned char trust_passwd[16],
goto done;
}
- /* on first call the returnAuthenticator is empty */
- memset(&ret_creds, 0, sizeof(ret_creds));
-
- /* Do sam synchronisation on the SAM database*/
+ /* Do sam synchronisation */
- result = cli_netlogon_sam_sync(cli, mem_ctx, &ret_creds, 0, &num_deltas_0, &hdr_deltas_0, &deltas_0);
+ result = cli_netlogon_sam_sync(cli, mem_ctx, database_id,
+ &num_deltas, &hdr_deltas, &deltas);
- if (!NT_STATUS_IS_OK(result))
- goto done;
-
- /* verbose mode */
- if (verbose)
- decode_sam_deltas(num_deltas_0, hdr_deltas_0, deltas_0);
-
-
- /*
- * we can't yet do several sam_sync in a raw, it's a credential problem
- * we must chain the credentials
- */
-
-#if 1
- /* Do sam synchronisation on the LSA database */
-
- result = cli_netlogon_sam_sync(cli, mem_ctx, &ret_creds, 2, &num_deltas_2, &hdr_deltas_2, &deltas_2);
-
- if (!NT_STATUS_IS_OK(result))
+ if (!NT_STATUS_IS_OK(result)) {
goto done;
-
- /* verbose mode */
- if (verbose)
- decode_sam_deltas(num_deltas_2, hdr_deltas_2, deltas_2);
-#endif
+ }
/* Produce smbpasswd output - good for migrating from NT! */
if (do_smbpasswd_output) {
int i;
- for (i = 0; i < num_deltas_0; i++) {
+ for (i = 0; i < num_deltas; i++) {
SAM_ACCOUNT_INFO *a;
fstring acct_name, hex_nt_passwd, hex_lm_passwd;
uchar lm_passwd[16], nt_passwd[16];
/* Skip non-user accounts */
- if (hdr_deltas_0[i].type != SAM_DELTA_ACCOUNT_INFO)
+ if (hdr_deltas[i].type != SAM_DELTA_ACCOUNT_INFO)
continue;
- a = &deltas_0[i].account_info;
+ a = &deltas[i].account_info;
unistr2_to_ascii(acct_name, &a->uni_acct_name,
sizeof(acct_name) - 1);
@@ -354,7 +99,8 @@ static NTSTATUS sam_sync(struct cli_state *cli, unsigned char trust_passwd[16],
printf("%s:%d:%s:%s:%s:LCT-0\n", acct_name,
a->user_rid, hex_lm_passwd, hex_nt_passwd,
- smbpasswd_encode_acb_info(a->acb_info));
+ smbpasswd_encode_acb_info(
+ deltas[i].account_info.acb_info));
}
goto done;
@@ -392,7 +138,6 @@ static void usage(void)
printf("\t-R replicate sam deltas\n");
printf("\t-U username username and password\n");
printf("\t-p produce smbpasswd output\n");
- printf("\t-V verbose output\n");
printf("\n");
}
@@ -449,8 +194,8 @@ static struct cli_state *init_connection(struct cli_state *cli,
return NULL;
}
- if (!lookup_dc_name(global_myname, lp_workgroup(), dest_ip,
- dest_host)) {
+ if (!lookup_pdc_name(global_myname, lp_workgroup(), dest_ip,
+ dest_host)) {
DEBUG(0, ("Could not lookup up PDC name for domain %s\n",
lp_workgroup()));
return NULL;
@@ -477,12 +222,12 @@ static struct cli_state *init_connection(struct cli_state *cli,
int main(int argc, char **argv)
{
BOOL do_sam_sync = False, do_sam_repl = False;
+ pstring servicesf = CONFIGFILE;
struct cli_state cli;
NTSTATUS result;
int opt;
pstring logfile;
BOOL interactive = False, do_smbpasswd_output = False;
- BOOL verbose = False;
uint32 low_serial = 0;
unsigned char trust_passwd[16];
fstring username, domain, password;
@@ -498,10 +243,10 @@ static struct cli_state *init_connection(struct cli_state *cli,
/* Parse command line options */
- while((opt = getopt(argc, argv, "s:d:SR:hiU:W:pV")) != EOF) {
+ while((opt = getopt(argc, argv, "s:d:SR:hiU:W:p")) != EOF) {
switch (opt) {
case 's':
- pstrcpy(dyn_CONFIGFILE, optarg);
+ pstrcpy(servicesf, optarg);
break;
case 'd':
DEBUGLEVEL = atoi(optarg);
@@ -520,10 +265,10 @@ static struct cli_state *init_connection(struct cli_state *cli,
char *lp;
fstrcpy(username,optarg);
- if ((lp=strchr_m(username,'%'))) {
+ if ((lp=strchr(username,'%'))) {
*lp = 0;
fstrcpy(password,lp+1);
- memset(strchr_m(optarg, '%') + 1, 'X',
+ memset(strchr(optarg, '%') + 1, 'X',
strlen(password));
}
break;
@@ -534,10 +279,7 @@ static struct cli_state *init_connection(struct cli_state *cli,
case 'p':
do_smbpasswd_output = True;
break;
- case 'V':
- verbose = True;
- break;
- case 'h':
+ case 'h':
default:
usage();
exit(1);
@@ -553,7 +295,7 @@ static struct cli_state *init_connection(struct cli_state *cli,
/* Initialise samba */
- slprintf(logfile, sizeof(logfile) - 1, "%s/log.%s", dyn_LOGFILEBASE,
+ slprintf(logfile, sizeof(logfile) - 1, "%s/log.%s", LOGFILEBASE,
"samsync");
lp_set_logfile(logfile);
@@ -562,12 +304,14 @@ static struct cli_state *init_connection(struct cli_state *cli,
if (!interactive)
reopen_logs();
- if (!lp_load(dyn_CONFIGFILE, True, False, False)) {
- fprintf(stderr, "Can't load %s\n", dyn_CONFIGFILE);
+ if (!lp_load(servicesf, True, False, False)) {
+ fprintf(stderr, "Can't load %s\n", servicesf);
}
load_interfaces();
+ TimeInit();
+
/* Check arguments make sense */
if (do_sam_sync && do_sam_repl) {
@@ -605,7 +349,7 @@ static struct cli_state *init_connection(struct cli_state *cli,
return 1;
if (do_sam_sync)
- result = sam_sync(&cli, trust_passwd, do_smbpasswd_output, verbose);
+ result = sam_sync(&cli, trust_passwd, do_smbpasswd_output);
if (do_sam_repl)
result = sam_repl(&cli, trust_passwd, low_serial);
diff --git a/source/rpcclient/spoolss_cmds.c b/source/rpcclient/spoolss_cmds.c
index 1c999119008..b010aa4874c 100644
--- a/source/rpcclient/spoolss_cmds.c
+++ b/source/rpcclient/spoolss_cmds.c
@@ -1,5 +1,6 @@
/*
- Unix SMB/CIFS implementation.
+ Unix SMB/Netbios implementation.
+ Version 1.9.
SMB client
Copyright (C) Andrew Tridgell 1994-2000
Copyright (C) Luke Kenneth Casson Leighton 1996-2000