diff options
Diffstat (limited to 'source/utils')
-rw-r--r-- | source/utils/net.c | 46 | ||||
-rw-r--r-- | source/utils/net_groupmap.c | 18 | ||||
-rw-r--r-- | source/utils/net_help.c | 2 | ||||
-rw-r--r-- | source/utils/net_rpc.c | 34 | ||||
-rw-r--r-- | source/utils/net_rpc_printer.c | 23 | ||||
-rw-r--r-- | source/utils/net_rpc_samsync.c | 2 | ||||
-rw-r--r-- | source/utils/pdbedit.c | 4 | ||||
-rw-r--r-- | source/utils/profiles.c | 9 | ||||
-rw-r--r-- | source/utils/status.c | 2 |
9 files changed, 94 insertions, 46 deletions
diff --git a/source/utils/net.c b/source/utils/net.c index cfbc8aca512..9c05828357c 100644 --- a/source/utils/net.c +++ b/source/utils/net.c @@ -552,14 +552,16 @@ static int net_getdomainsid(int argc, const char **argv) #ifdef WITH_FAKE_KASERVER -int net_afskey_usage(int argc, const char **argv) +int net_help_afs(int argc, const char **argv) { - d_printf(" net afskey filename\n" + d_printf(" net afs key filename\n" "\tImports a OpenAFS KeyFile into our secrets.tdb\n\n"); + d_printf(" net afs impersonate <user> <cell>\n" + "\tCreates a token for user@cell\n\n"); return -1; } -static int net_afskey(int argc, const char **argv) +static int net_afs_key(int argc, const char **argv) { int fd; struct afs_keyfile keyfile; @@ -592,6 +594,42 @@ static int net_afskey(int argc, const char **argv) return 0; } +static int net_afs_impersonate(int argc, const char **argv) +{ + char *token; + + if (argc != 2) { + fprintf(stderr, "Usage: net afs impersonate <user> <cell>\n"); + exit(1); + } + + token = afs_createtoken_str(argv[0], argv[1]); + + if (token == NULL) { + fprintf(stderr, "Could not create token\n"); + exit(1); + } + + if (!afs_settoken_str(token)) { + fprintf(stderr, "Could not set token into kernel\n"); + exit(1); + } + + printf("Success: %s@%s\n", argv[0], argv[1]); + return 0; +} + +static int net_afs(int argc, const char **argv) +{ + struct functable func[] = { + {"key", net_afs_key}, + {"impersonate", net_afs_impersonate}, + {"help", net_help_afs}, + {NULL, NULL} + }; + return net_run_function(argc, argv, func, net_help_afs); +} + #endif /* WITH_FAKE_KASERVER */ static uint32 get_maxrid(void) @@ -707,7 +745,7 @@ static struct functable net_func[] = { {"STATUS", net_status}, {"USERSIDLIST", net_usersidlist}, #ifdef WITH_FAKE_KASERVER - {"AFSKEY", net_afskey}, + {"AFS", net_afs}, #endif {"HELP", net_help}, diff --git a/source/utils/net_groupmap.c b/source/utils/net_groupmap.c index c6391a65feb..158c006d1c0 100644 --- a/source/utils/net_groupmap.c +++ b/source/utils/net_groupmap.c @@ -277,8 +277,22 @@ static int net_groupmap_add(int argc, const char **argv) sid_to_string(string_sid, &sid); } - if (!ntcomment[0]) - fstrcpy(ntcomment, "Local Unix group"); + if (!ntcomment[0]) { + switch (sid_type) { + case SID_NAME_WKN_GRP: + fstrcpy(ntcomment, "Wellknown Unix group"); + break; + case SID_NAME_DOM_GRP: + fstrcpy(ntcomment, "Domain Unix group"); + break; + case SID_NAME_ALIAS: + fstrcpy(ntcomment, "Local Unix group"); + break; + default: + fstrcpy(ntcomment, "Unix group"); + break; + } + } if (!ntgroup[0] ) fstrcpy( ntgroup, unixgrp ); diff --git a/source/utils/net_help.c b/source/utils/net_help.c index 60206429b7e..26d59beda2b 100644 --- a/source/utils/net_help.c +++ b/source/utils/net_help.c @@ -269,7 +269,7 @@ int net_help(int argc, const char **argv) {"LOOKUP", net_lookup_usage}, {"USERSIDLIST", net_usersidlist_usage}, #ifdef WITH_FAKE_KASERVER - {"AFSKEY", net_afskey_usage}, + {"AFS", net_help_afs}, #endif {"HELP", help_usage}, diff --git a/source/utils/net_rpc.c b/source/utils/net_rpc.c index 76b53d61136..b18d4b0ba5e 100644 --- a/source/utils/net_rpc.c +++ b/source/utils/net_rpc.c @@ -1005,26 +1005,32 @@ rpc_user_info_internals(const DOM_SID *domain_sid, const char *domain_name, result = cli_samr_query_usergroups(cli, mem_ctx, &user_pol, &num_rids, &user_gids); - /* Look up rids */ + if (!NT_STATUS_IS_OK(result)) goto done; - rids = TALLOC_ARRAY(mem_ctx, uint32, num_rids); + /* Look up rids */ - for (i = 0; i < num_rids; i++) - rids[i] = user_gids[i].g_rid; + if (rids) { + rids = TALLOC_ARRAY(mem_ctx, uint32, num_rids); - result = cli_samr_lookup_rids(cli, mem_ctx, &domain_pol, - flags, num_rids, rids, - &num_names, &names, &name_types); + for (i = 0; i < num_rids; i++) + rids[i] = user_gids[i].g_rid; - if (!NT_STATUS_IS_OK(result)) { - goto done; - } + result = cli_samr_lookup_rids(cli, mem_ctx, &domain_pol, + num_rids, rids, + &num_names, &names, &name_types); - /* Display results */ + if (!NT_STATUS_IS_OK(result)) { + goto done; + } - for (i = 0; i < num_names; i++) - printf("%s\n", names[i]); + /* Display results */ + for (i = 0; i < num_names; i++) + printf("%s\n", names[i]); + } + else { + printf("no groups\n"); + } done: return result; } @@ -2142,7 +2148,7 @@ rpc_list_group_members(struct cli_state *cli, TALLOC_CTX *mem_ctx, if (num_members < this_time) this_time = num_members; - result = cli_samr_lookup_rids(cli, mem_ctx, domain_pol, 1000, + result = cli_samr_lookup_rids(cli, mem_ctx, domain_pol, this_time, group_rids, &num_names, &names, &name_types); diff --git a/source/utils/net_rpc_printer.c b/source/utils/net_rpc_printer.c index 456a29287fd..4b53dec36e9 100644 --- a/source/utils/net_rpc_printer.c +++ b/source/utils/net_rpc_printer.c @@ -234,7 +234,7 @@ static void display_print_driver_3(DRIVER_INFO_3 *i1) } -static void display_reg_value(pstring subkey, REGISTRY_VALUE value) +static void display_reg_value(const char *subkey, REGISTRY_VALUE value) { pstring text; @@ -980,7 +980,7 @@ net_spoolss_enumprinterdataex(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* enumprinterdataex call */ result = cli_spoolss_enumprinterdataex( - cli, mem_ctx, 0, &needed, hnd, keyname, NULL); + cli, mem_ctx, 0, &needed, hnd, keyname, ctr); if (W_ERROR_V(result) == W_ERROR_V(WERR_MORE_DATA)) result = cli_spoolss_enumprinterdataex( @@ -2205,7 +2205,6 @@ NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid, const char *devicename = NULL, *unc_name = NULL, *url = NULL; fstring longname; - const char *keyname = NULL; uint16 *keylist = NULL, *curkey; ZERO_STRUCT(ctr_enum); @@ -2242,7 +2241,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid, const sizeof(printername), -1, STR_TERMINATE); rpcstr_pull(sharename, ctr_enum.printers_2[i].sharename.buffer, sizeof(sharename), -1, STR_TERMINATE); - keyname = ""; + /* we can reset NT_STATUS here because we do not get any real NT_STATUS-codes anymore from now on */ nt_status = NT_STATUS_UNSUCCESSFUL; @@ -2305,14 +2304,6 @@ NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid, const /* do not copy security descriptor (we have another command for that) */ ctr_dst.printers_2->secdesc = NULL; - - /* devmode->devicename is possibly broken at the moment for all - strlen(longprinternames) > MAXDEVICENAME (that is 32 chars) - this fires up thousands of safe_strncpy-debug0-messages - on my test-servers - TODO: tell jerry, jra, etc. again. - */ - #if 0 if (asprintf(&devicename, "\\\\%s\\%s", longname, printername) < 0) { nt_status = NT_STATUS_NO_MEMORY; @@ -2333,7 +2324,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid, const /* please keep in mind that samba parse_spools gives horribly crippled results when used to cli_spoolss_enumprinterdataex - a win2k3-server. + a win2k3-server. (Bugzilla #1851) FIXME: IIRC I've seen it too on a win2k-server */ @@ -2341,7 +2332,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid, const result = cli_spoolss_enumprinterdata(cli, mem_ctx, &hnd_src, p, 0, 0, &val_needed, &data_needed, NULL); - /* loop for all printerdata */ + /* loop for all printerdata of "PrinterDriverData" */ while (W_ERROR_IS_OK(result)) { REGISTRY_VALUE value; @@ -2355,7 +2346,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid, const /* display_value */ if (opt_verbose) - display_reg_value(NULL, value); + display_reg_value(SPOOL_PRINTERDATA_KEY, value); /* set_value */ if (!net_spoolss_setprinterdata(cli_dst, mem_ctx, @@ -2374,7 +2365,7 @@ NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid, const respond to enumprinterkey, win2k does, so continue in case of an error */ - if (!net_spoolss_enumprinterkey(cli, mem_ctx, &hnd_src, keyname, &keylist)) { + if (!net_spoolss_enumprinterkey(cli, mem_ctx, &hnd_src, "", &keylist)) { printf("got no key-data\n"); continue; } diff --git a/source/utils/net_rpc_samsync.c b/source/utils/net_rpc_samsync.c index 320341ec050..49aef2a23cd 100644 --- a/source/utils/net_rpc_samsync.c +++ b/source/utils/net_rpc_samsync.c @@ -523,7 +523,7 @@ static NTSTATUS fetch_account_info(uint32 rid, SAM_ACCOUNT_INFO *delta) all_string_sub(add_script, "%u", account, sizeof(account)); add_ret = smbrun(add_script,NULL); - DEBUG(1,("fetch_account: Running the command `%s' " + DEBUG(add_ret ? 0 : 1,("fetch_account: Running the command `%s' " "gave %d\n", add_script, add_ret)); } else { DEBUG(8,("fetch_account_info: no add user/machine script. Asking winbindd\n")); diff --git a/source/utils/pdbedit.c b/source/utils/pdbedit.c index ea2faebdff4..3584ef0367a 100644 --- a/source/utils/pdbedit.c +++ b/source/utils/pdbedit.c @@ -694,8 +694,8 @@ int main (int argc, char **argv) {"force-initialized-passwords", 0, POPT_ARG_NONE, &force_initialised_password, 0, "Force initialization of corrupt password strings in a passdb backend", NULL}, {"bad-password-count-reset", 'z', POPT_ARG_NONE, &badpw_reset, 0, "reset bad password count", NULL}, {"logon-hours-reset", 'Z', POPT_ARG_NONE, &hours_reset, 0, "reset logon hours", NULL}, - {"pwd-can-change-time", 0, POPT_ARG_STRING, &pwd_can_change_time, 0, "Set password can change time (unix time if time format no provided)", NULL }, - {"pwd-must-change-time", 0, POPT_ARG_STRING, &pwd_must_change_time, 0, "Set password can change time (unix time if time format no provided)", NULL }, + {"pwd-can-change-time", 0, POPT_ARG_STRING, &pwd_can_change_time, 0, "Set password can change time (unix time in seconds since 1970 if time format not provided)", NULL }, + {"pwd-must-change-time", 0, POPT_ARG_STRING, &pwd_must_change_time, 0, "Set password can change time (unix time in seconds since 1970 if time format not provided)", NULL }, {"time-format", 0, POPT_ARG_STRING, &pwd_time_format, 0, "The time format for time parameters", NULL }, POPT_COMMON_SAMBA POPT_TABLEEND diff --git a/source/utils/profiles.c b/source/utils/profiles.c index a31674dfb2e..5b5cb7f07b2 100644 --- a/source/utils/profiles.c +++ b/source/utils/profiles.c @@ -521,7 +521,7 @@ static void process_acl(ACL *acl, const char *prefix) int main(int argc, char *argv[]) { int opt; - int fd, start = 0; + int fd; char *base; struct stat sbuf; REGF_HDR *regf_hdr; @@ -577,6 +577,8 @@ int main(int argc, char *argv[]) } } + poptGetArg(pc); /* To get argv[0] */ + if (!poptPeekArg(pc)) { poptPrintUsage(pc, stderr, 0); exit(1); @@ -588,8 +590,6 @@ int main(int argc, char *argv[]) exit(252); } - poptGetArg(pc); /* To get argv[0] */ - fd = open(poptPeekArg(pc), O_RDWR, 0000); if (fd < 0) { @@ -608,10 +608,9 @@ int main(int argc, char *argv[]) * Now, mmap the file into memory, check the header and start * dealing with the records. We are interested in the sk record */ - start = 0; #ifdef HAVE_MMAP - base = mmap(&start, sbuf.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + base = mmap(NULL, sbuf.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); #else base = (char *)-1; errno = ENOSYS; diff --git a/source/utils/status.c b/source/utils/status.c index cae4e07975a..75e7cb3de71 100644 --- a/source/utils/status.c +++ b/source/utils/status.c @@ -541,7 +541,7 @@ static int traverse_fn1(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *st return 0; } - d_printf("%-10.10s %5d %-12s %s", + d_printf("%-10s %5d %-12s %s", crec.name,(int)crec.pid, crec.machine, asctime(LocalTime(&crec.start))); |