diff options
author | Gerald Carter <jerry@samba.org> | 2002-09-25 15:19:00 +0000 |
---|---|---|
committer | Gerald Carter <jerry@samba.org> | 2002-09-25 15:19:00 +0000 |
commit | a834a73e341059be154426390304a42e4a011f72 (patch) | |
tree | 7f53b0f7819238e0ee0396daccf5d924cb9b8d29 /source3/rpcclient | |
parent | 115a39775cb923d026dde58633b6ba6aef3a1943 (diff) | |
download | samba-a834a73e341059be154426390304a42e4a011f72.tar.gz samba-a834a73e341059be154426390304a42e4a011f72.tar.bz2 samba-a834a73e341059be154426390304a42e4a011f72.zip |
sync'ing up for 3.0alpha20 release
(This used to be commit 65e7b5273bb58802bf0c389b77f7fcae0a1f6139)
Diffstat (limited to 'source3/rpcclient')
-rw-r--r-- | source3/rpcclient/cmd_lsarpc.c | 11 | ||||
-rw-r--r-- | source3/rpcclient/cmd_netlogon.c | 39 | ||||
-rw-r--r-- | source3/rpcclient/cmd_spoolss.c | 39 | ||||
-rw-r--r-- | source3/rpcclient/rpcclient.c | 66 | ||||
-rw-r--r-- | source3/rpcclient/samsync.c | 30 |
5 files changed, 83 insertions, 102 deletions
diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c index 194e498122..ed68160658 100644 --- a/source3/rpcclient/cmd_lsarpc.c +++ b/source3/rpcclient/cmd_lsarpc.c @@ -86,15 +86,8 @@ static NTSTATUS cmd_lsa_query_info_policy(struct cli_state *cli, printf("forest name is %s\n", forest_name); if (info_class == 12) { - int i; - uint32 *data1 = (uint32 *) dom_guid.info; - uint16 *data2 = (uint16 *) &dom_guid.info[4]; - uint16 *data3 = (uint16 *) &dom_guid.info[6]; - printf("domain GUID is %08x-%04x-%04x", *data1,*data2,*data3); - printf("-%02x%02x-", dom_guid.info[8], dom_guid.info[9]); - for (i=10;i<GUID_SIZE;i++) - printf("%02x", dom_guid.info[i]); - printf("\n"); + printf("domain GUID is "); + print_guid(&dom_guid); } done: return result; diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c index c3bc9e5e13..98ba92e5a3 100644 --- a/source3/rpcclient/cmd_netlogon.c +++ b/source3/rpcclient/cmd_netlogon.c @@ -125,11 +125,10 @@ static void display_sam_sync(uint32 num_deltas, SAM_DELTA_HDR *hdr_deltas, group->rids[j], group->attribs[j]); break; } - case SAM_DELTA_SAM_STAMP: { - SAM_DELTA_STAMP *stamp = &deltas[i].stamp; + case SAM_DELTA_MODIFIED_COUNT: { + SAM_DELTA_MOD_COUNT *mc = &deltas[i].mod_count; - printf("sam sequence update: 0x%04x\n", - stamp->seqnum); + printf("sam sequence update: 0x%04x\n", mc->seqnum); break; } default: @@ -152,6 +151,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, SAM_DELTA_HDR *hdr_deltas; SAM_DELTA_CTR *deltas; DOM_CRED ret_creds; + uint32 neg_flags = 0x000001ff; if (argc > 2) { fprintf(stderr, "Usage: %s [database_id]\n", argv[0]); @@ -174,8 +174,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, goto done; } - result = cli_nt_setup_creds(cli, (lp_server_role() == ROLE_DOMAIN_MEMBER) ? - SEC_CHAN_WKSTA : SEC_CHAN_BDC, trust_passwd); + result = cli_nt_setup_creds(cli, get_sec_chan(), trust_passwd, &neg_flags, 2); if (!NT_STATUS_IS_OK(result)) { fprintf(stderr, "Error initialising session creds\n"); @@ -188,7 +187,7 @@ static NTSTATUS cmd_netlogon_sam_sync(struct cli_state *cli, /* Synchronise sam database */ result = cli_netlogon_sam_sync(cli, mem_ctx, &ret_creds, database_id, - &num_deltas, &hdr_deltas, &deltas); + 0, &num_deltas, &hdr_deltas, &deltas); if (!NT_STATUS_IS_OK(result)) goto done; @@ -213,6 +212,7 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, SAM_DELTA_HDR *hdr_deltas; SAM_DELTA_CTR *deltas; UINT64_S seqnum; + uint32 neg_flags = 0x000001ff; if (argc != 3) { fprintf(stderr, "Usage: %s database_id seqnum\n", argv[0]); @@ -238,8 +238,7 @@ static NTSTATUS cmd_netlogon_sam_deltas(struct cli_state *cli, goto done; } - result = cli_nt_setup_creds(cli, (lp_server_role() == ROLE_DOMAIN_MEMBER) ? - SEC_CHAN_WKSTA : SEC_CHAN_BDC, trust_passwd); + result = cli_nt_setup_creds(cli, get_sec_chan(), trust_passwd, &neg_flags, 2); if (!NT_STATUS_IS_OK(result)) { fprintf(stderr, "Error initialising session creds\n"); @@ -273,12 +272,15 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, NTSTATUS result = NT_STATUS_UNSUCCESSFUL; int logon_type = NET_LOGON_TYPE; char *username, *password; + uint32 neg_flags = 0x000001ff; + int auth_level = 2; /* Check arguments */ - if (argc < 3 || argc > 4) { + if (argc < 3 || argc > 6) { fprintf(stderr, "Usage: samlogon <username> <password> " - "[logon_type]\n"); + "[logon_type] [neg flags] [auth level (2 or 3)]\n" + "neg flags being 0x000001ff or 0x6007ffff\n"); return NT_STATUS_OK; } @@ -288,6 +290,12 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, if (argc == 4) sscanf(argv[3], "%i", &logon_type); + if (argc == 5) + sscanf(argv[4], "%i", &neg_flags); + + if (argc == 6) + sscanf(argv[5], "%i", &auth_level); + /* Authenticate ourselves with the domain controller */ if (!secrets_init()) { @@ -295,14 +303,12 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, return result; } - if (!secrets_fetch_trust_account_password(lp_workgroup(), trust_passwd, - NULL)) { + if (!secrets_fetch_trust_account_password(lp_workgroup(), trust_passwd, NULL)) { fprintf(stderr, "could not fetch trust account password\n"); goto done; } - result = cli_nt_setup_creds(cli, (lp_server_role() == ROLE_DOMAIN_MEMBER) ? - SEC_CHAN_WKSTA : SEC_CHAN_BDC, trust_passwd); + result = cli_nt_setup_creds(cli, get_sec_chan(), trust_passwd, &neg_flags, auth_level); if (!NT_STATUS_IS_OK(result)) { fprintf(stderr, "Error initialising session creds\n"); @@ -311,8 +317,7 @@ static NTSTATUS cmd_netlogon_sam_logon(struct cli_state *cli, /* Perform the sam logon */ - result = cli_netlogon_sam_logon(cli, mem_ctx, username, password, - logon_type); + result = cli_netlogon_sam_logon(cli, mem_ctx, username, password, logon_type); if (!NT_STATUS_IS_OK(result)) goto done; diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c index 22e2db41f3..15648e4d1b 100644 --- a/source3/rpcclient/cmd_spoolss.c +++ b/source3/rpcclient/cmd_spoolss.c @@ -313,15 +313,22 @@ static NTSTATUS cmd_spoolss_enum_printers(struct cli_state *cli, uint32 info_level = 1; PRINTER_INFO_CTR ctr; uint32 i = 0, num_printers, needed; + fstring name; - if (argc > 2) + if (argc > 3) { - printf("Usage: %s [level]\n", argv[0]); + printf("Usage: %s [level] [name]\n", argv[0]); return NT_STATUS_OK; } - if (argc == 2) { + if (argc == 2) info_level = atoi(argv[1]); + + if (argc == 3) + fstrcpy(name, argv[2]); + else { + slprintf(name, sizeof(name)-1, "\\\\%s", cli->desthost); + strupper(name); } /* Enumerate printers -- Should we enumerate types other @@ -330,12 +337,12 @@ static NTSTATUS cmd_spoolss_enum_printers(struct cli_state *cli, ZERO_STRUCT(ctr); result = cli_spoolss_enum_printers( - cli, mem_ctx, 0, &needed, PRINTER_ENUM_LOCAL, + cli, mem_ctx, 0, &needed, name, PRINTER_ENUM_LOCAL, info_level, &num_printers, &ctr); if (W_ERROR_V(result) == ERRinsufficientbuffer) result = cli_spoolss_enum_printers( - cli, mem_ctx, needed, NULL, PRINTER_ENUM_LOCAL, + cli, mem_ctx, needed, NULL, name, PRINTER_ENUM_LOCAL, info_level, &num_printers, &ctr); if (W_ERROR_IS_OK(result)) { @@ -1613,7 +1620,8 @@ static NTSTATUS cmd_spoolss_setprinterdata(struct cli_state *cli, POLICY_HND pol; BOOL opened_hnd = False; PRINTER_INFO_CTR ctr; - PRINTER_INFO_0 *info = NULL; + PRINTER_INFO_0 info; + REGISTRY_VALUE value; /* parse the command arguements */ if (argc != 4) { @@ -1635,6 +1643,8 @@ static NTSTATUS cmd_spoolss_setprinterdata(struct cli_state *cli, opened_hnd = True; + ctr.printers_0 = &info; + result = cli_spoolss_getprinter(cli, mem_ctx, 0, &needed, &pol, 0, &ctr); @@ -1645,13 +1655,16 @@ static NTSTATUS cmd_spoolss_setprinterdata(struct cli_state *cli, goto done; printf("%s\n", timestring(True)); - printf("\tchange_id (before set)\t:[0x%x]\n", info->change_id); + printf("\tchange_id (before set)\t:[0x%x]\n", info.change_id); /* Set the printer data */ - result = cli_spoolss_setprinterdata( - cli, mem_ctx, &pol, argv[2], REG_SZ, argv[3], - strlen(argv[3]) + 1); + fstrcpy(value.valuename, argv[2]); + value.type = REG_SZ; + value.size = strlen(argv[3]) + 1; + value.data_p = talloc_memdup(mem_ctx, argv[3], value.size); + + result = cli_spoolss_setprinterdata(cli, mem_ctx, &pol, &value); if (!W_ERROR_IS_OK(result)) { printf ("Unable to set [%s=%s]!\n", argv[2], argv[3]); @@ -1668,7 +1681,7 @@ static NTSTATUS cmd_spoolss_setprinterdata(struct cli_state *cli, goto done; printf("%s\n", timestring(True)); - printf("\tchange_id (after set)\t:[0x%x]\n", info->change_id); + printf("\tchange_id (after set)\t:[0x%x]\n", info.change_id); done: /* cleanup */ @@ -1778,10 +1791,10 @@ static NTSTATUS cmd_spoolss_enum_jobs(struct cli_state *cli, for (i = 0; i < num_jobs; i++) { switch(level) { case 1: - display_job_info_1(ctr.job.job_info_1[i]); + display_job_info_1(&ctr.job.job_info_1[i]); break; case 2: - display_job_info_2(ctr.job.job_info_2[i]); + display_job_info_2(&ctr.job.job_info_2[i]); break; default: d_printf("unknown info level %d\n", level); diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index 2d86fb1d3d..880fdc599a 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/rpcclient/rpcclient.c @@ -573,24 +573,6 @@ static NTSTATUS process_cmd(struct cli_state *cli, char *cmd) } -/* Print usage information */ -static void usage(void) -{ - printf("Usage: rpcclient [options] server\n"); - - printf("\t-A or --authfile authfile File containing user credentials\n"); - printf("\t-c or --command \"command string\" Execute semicolon separated cmds\n"); - printf("\t-d or --debug debuglevel Set the debuglevel\n"); - printf("\t-l or --logfile logfile Logfile to use instead of stdout\n"); - printf("\t-h or --help Print this help message.\n"); - printf("\t-N or --nopass Don't ask for a password\n"); - printf("\t-s or --conf configfile Specify an alternative config file\n"); - printf("\t-U or --user username Set the network username\n"); - printf("\t-W or --workgroup domain Set the domain name for user account\n"); - printf("\t-I or --dest-ip ip Specify destination IP address\n"); - printf("\n"); -} - /* Main function */ int main(int argc, char *argv[]) @@ -599,7 +581,6 @@ static void usage(void) static int got_pass = 0; BOOL interactive = True; int opt; - int olddebug; static char *cmdstr = ""; const char *server; struct cli_state *cli; @@ -616,41 +597,36 @@ static void usage(void) struct cmd_set **cmd_set; struct in_addr server_ip; NTSTATUS nt_status; - extern BOOL AllowDebugChange; /* make sure the vars that get altered (4th field) are in a fixed location or certain compilers complain */ poptContext pc; struct poptOption long_options[] = { - {"authfile", 'A', POPT_ARG_STRING, &opt_authfile, 'A'}, - {"conf", 's', POPT_ARG_STRING, &opt_configfile, 's'}, - {"nopass", 'N', POPT_ARG_NONE, &got_pass}, - {"user", 'U', POPT_ARG_STRING, &opt_username, 'U'}, - {"workgroup", 'W', POPT_ARG_STRING, &opt_domain, 'W'}, - {"command", 'c', POPT_ARG_STRING, &cmdstr}, - {"logfile", 'l', POPT_ARG_STRING, &opt_logfile, 'l'}, - {"help", 'h', POPT_ARG_NONE, 0, 'h'}, - {"dest-ip", 'I', POPT_ARG_STRING, &opt_ipaddr, 'I'}, + POPT_AUTOHELP + {"authfile", 'A', POPT_ARG_STRING, &opt_authfile, 'A', "File containing user credentials"}, + {"conf", 's', POPT_ARG_STRING, &opt_configfile, 's', "Specify an alternative config file"}, + {"nopass", 'N', POPT_ARG_NONE, &got_pass, 'N', "Don't ask for a password"}, + {"user", 'U', POPT_ARG_STRING, &opt_username, 'U', "Set the network username"}, + {"workgroup", 'W', POPT_ARG_STRING, &opt_domain, 'W', "Set the domain name for user account"}, + {"command", 'c', POPT_ARG_STRING, &cmdstr, 'c', "Execute semicolon separated cmds"}, + {"logfile", 'l', POPT_ARG_STRING, &opt_logfile, 'l', "Logfile to use instead of stdout"}, + {"dest-ip", 'I', POPT_ARG_STRING, &opt_ipaddr, 'I', "Specify destination IP address"}, { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debug }, { NULL } }; - setlinebuf(stdout); - DEBUGLEVEL = 1; - AllowDebugChange = False; - /* Parse options */ + pc = poptGetContext("rpcclient", argc, (const char **) argv, + long_options, 0); + if (argc == 1) { - usage(); + poptPrintHelp(pc, stderr, 0); return 0; } - pc = poptGetContext("rpcclient", argc, (const char **) argv, - long_options, 0); - while((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { case 'A': @@ -686,7 +662,7 @@ static void usage(void) break; } case 'I': - if (!inet_aton(opt_ipaddr, &server_ip)) { + if ( (server_ip.s_addr=inet_addr(opt_ipaddr)) == INADDR_NONE ) { fprintf(stderr, "%s not a valid IP address\n", opt_ipaddr); return 1; @@ -694,11 +670,6 @@ static void usage(void) case 'W': pstrcpy(domain, opt_domain); break; - - case 'h': - default: - usage(); - exit(1); } } @@ -708,7 +679,7 @@ static void usage(void) server = poptGetArg(pc); if (!server || poptGetArg(pc)) { - usage(); + poptPrintHelp(pc, stderr, 0); return 1; } @@ -721,12 +692,9 @@ static void usage(void) reopen_logs(); /* Load smb.conf file */ - /* FIXME! How to get this DEBUGLEVEL to last over lp_load()? */ - olddebug = DEBUGLEVEL; - if (!lp_load(dyn_CONFIGFILE,True,False,False)) { + + if (!lp_load(dyn_CONFIGFILE,True,False,False)) fprintf(stderr, "Can't load %s\n", dyn_CONFIGFILE); - } - DEBUGLEVEL = olddebug; load_interfaces(); diff --git a/source3/rpcclient/samsync.c b/source3/rpcclient/samsync.c index 3694eb47df..7124f9416a 100644 --- a/source3/rpcclient/samsync.c +++ b/source3/rpcclient/samsync.c @@ -217,8 +217,8 @@ static void decode_sam_deltas(uint32 num_deltas, SAM_DELTA_HDR *hdr_deltas, SAM_ decode_sam_als_mem_info(a); break; } - case SAM_DELTA_DOM_INFO: { - SAM_DELTA_DOM *a; + case SAM_DELTA_POLICY_INFO: { + SAM_DELTA_POLICY *a; a = &deltas[i].dom_info; decode_sam_dom_info(a); break; @@ -324,15 +324,15 @@ static void sam_account_from_delta(SAM_ACCOUNT *account, static void apply_account_info(SAM_ACCOUNT_INFO *sam_acct_delta) { - SAM_ACCOUNT sam_acct; + SAM_ACCOUNT *sam_acct; BOOL result; - ZERO_STRUCT(sam_acct); - - pdb_init_sam(&sam_acct); + if (!NT_STATUS_IS_OK(pdb_init_sam(&sam_acct))) { + return; + } - sam_account_from_delta(&sam_acct, sam_acct_delta); - result = pdb_add_sam_account(&sam_acct); + sam_account_from_delta(sam_acct, sam_acct_delta); + result = pdb_add_sam_account(sam_acct); } /* Apply an array of deltas to the SAM database */ @@ -362,6 +362,7 @@ static NTSTATUS sam_sync(struct cli_state *cli, unsigned char trust_passwd[16], uint32 num_deltas_0, num_deltas_2; NTSTATUS result = NT_STATUS_UNSUCCESSFUL; struct pdb_context *in; + uint32 neg_flags = 0x000001ff; DOM_CRED ret_creds; @@ -384,7 +385,7 @@ static NTSTATUS sam_sync(struct cli_state *cli, unsigned char trust_passwd[16], /* Request a challenge */ - if (!NT_STATUS_IS_OK(cli_nt_setup_creds(cli, SEC_CHAN_BDC, trust_passwd))) { + if (!NT_STATUS_IS_OK(cli_nt_setup_creds(cli, SEC_CHAN_BDC, trust_passwd, &neg_flags, 2))) { DEBUG(0, ("Error initialising session creds\n")); goto done; } @@ -394,13 +395,16 @@ static NTSTATUS sam_sync(struct cli_state *cli, unsigned char trust_passwd[16], /* Do sam synchronisation on the SAM database*/ - result = cli_netlogon_sam_sync(cli, mem_ctx, &ret_creds, 0, + result = cli_netlogon_sam_sync(cli, mem_ctx, &ret_creds, 0, 0, &num_deltas_0, &hdr_deltas_0, &deltas_0); if (!NT_STATUS_IS_OK(result)) goto done; + + /* Update sam */ + apply_deltas(num_deltas_0, hdr_deltas_0, deltas_0); @@ -412,7 +416,7 @@ static NTSTATUS sam_sync(struct cli_state *cli, unsigned char trust_passwd[16], #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); + result = cli_netlogon_sam_sync(cli, mem_ctx, &ret_creds, 2, 0, &num_deltas_2, &hdr_deltas_2, &deltas_2); if (!NT_STATUS_IS_OK(result)) goto done; @@ -466,8 +470,6 @@ static NTSTATUS sam_sync(struct cli_state *cli, unsigned char trust_passwd[16], goto done; } - /* Update sam tdb */ - done: cli_nt_session_close(cli); talloc_destroy(mem_ctx); @@ -543,7 +545,7 @@ static void user_callback(poptContext con, const struct poptOption *opt, const char *arg, const void *data) { - char *p, *ch; + const char *p, *ch; if (!arg) return; |