diff options
author | Simo Sorce <idra@samba.org> | 2006-05-30 22:10:09 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:17:15 -0500 |
commit | c2ff57e32670d02f5372d28f3363c8f80658028f (patch) | |
tree | 3ae606509e45adf6c43b334bf5970332cefaabb7 /source3 | |
parent | 92307d5b17f8a6705516ee05e0a41fc4d044403f (diff) | |
download | samba-c2ff57e32670d02f5372d28f3363c8f80658028f.tar.gz samba-c2ff57e32670d02f5372d28f3363c8f80658028f.tar.bz2 samba-c2ff57e32670d02f5372d28f3363c8f80658028f.zip |
r15971: Obey the manpage description and make changesecretpw accept a password via stdin
(This used to be commit 60d4aabc3205aa80f8d49c3c2db95927c61a81a5)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/Makefile.in | 3 | ||||
-rw-r--r-- | source3/utils/net.c | 15 |
2 files changed, 16 insertions, 2 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in index 46393fdcd8..fa9af249e0 100644 --- a/source3/Makefile.in +++ b/source3/Makefile.in @@ -577,7 +577,8 @@ NET_OBJ1 = utils/net.o utils/net_ads.o utils/net_domain.o utils/net_help.o \ utils/net_status.o utils/net_rpc_printer.o utils/net_rpc_rights.o \ utils/net_rpc_service.o utils/net_rpc_registry.o utils/net_usershare.o \ utils/netlookup.o utils/net_sam.o utils/net_rpc_shell.o \ - utils/net_util.o utils/net_rpc_sh_acct.o utils/net_rpc_audit.o + utils/net_util.o utils/net_rpc_sh_acct.o utils/net_rpc_audit.o \ + utils/passwd_util.o NET_OBJ = $(NET_OBJ1) $(PARAM_OBJ) $(SECRETS_OBJ) $(LIBSMB_OBJ) \ $(RPC_PARSE_OBJ) $(PASSDB_OBJ) $(GROUPDB_OBJ) \ diff --git a/source3/utils/net.c b/source3/utils/net.c index 27b64aa96e..bef2a0a83c 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -65,6 +65,7 @@ const char *opt_workgroup = NULL; int opt_long_list_entries = 0; int opt_reboot = 0; int opt_force = 0; +int opt_stdin = 0; int opt_port = 0; int opt_verbose = 0; int opt_maxusers = -1; @@ -496,13 +497,24 @@ static int net_changetrustpw(int argc, const char **argv) return net_rpc_changetrustpw(argc, argv); } +static void set_line_buffering(FILE *f) +{ + setvbuf(f, NULL, _IOLBF, 0); +} + static int net_changesecretpw(int argc, const char **argv) { char *trust_pw; uint32 sec_channel_type = SEC_CHAN_WKSTA; if(opt_force) { - trust_pw = getpass("Enter machine password: "); + if (opt_stdin) { + set_line_buffering(stdin); + set_line_buffering(stdout); + set_line_buffering(stderr); + } + + trust_pw = get_pass("Enter machine password: ", opt_stdin); if (!secrets_store_machine_password(trust_pw, lp_workgroup(), sec_channel_type)) { d_fprintf(stderr, "Unable to write the machine account password in the secrets database"); @@ -856,6 +868,7 @@ static struct functable net_func[] = { {"long", 'l', POPT_ARG_NONE, &opt_long_list_entries}, {"reboot", 'r', POPT_ARG_NONE, &opt_reboot}, {"force", 'f', POPT_ARG_NONE, &opt_force}, + {"stdin", 'i', POPT_ARG_NONE, &opt_stdin}, {"timeout", 't', POPT_ARG_INT, &opt_timeout}, {"machine-pass",'P', POPT_ARG_NONE, &opt_machine_pass}, {"myworkgroup", 'W', POPT_ARG_STRING, &opt_workgroup}, |