svn commit: samba r1915 - branches/SAMBA_4_0/source/utils/net

metze at samba.org metze at samba.org
Thu Aug 19 12:36:09 GMT 2004


Author: metze
Date: 2004-08-19 12:36:05 +0000 (Thu, 19 Aug 2004)
New Revision: 1915

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/&rev=1915&nolog=1

Log:
use popt's cmdline_auth_info to fill the net_context
and print the user domain when prompting for a new password

metze

Modified:
   branches/SAMBA_4_0/source/utils/net/net.c
   branches/SAMBA_4_0/source/utils/net/net_password.c


Changeset:
Modified: branches/SAMBA_4_0/source/utils/net/net.c
===================================================================
--- branches/SAMBA_4_0/source/utils/net/net.c	2004-08-19 12:24:58 UTC (rev 1914)
+++ branches/SAMBA_4_0/source/utils/net/net.c	2004-08-19 12:36:05 UTC (rev 1915)
@@ -156,6 +156,7 @@
 	const char **argv_new;
 	TALLOC_CTX *mem_ctx;
 	struct net_context *ctx;
+	const char *domain;
 	poptContext pc;
 	struct poptOption long_options[] = {
 		POPT_AUTOHELP
@@ -172,16 +173,6 @@
 	setbuffer(stdout, NULL, 0);
 #endif
 
-	mem_ctx = talloc_init("net_context");
-	ctx = talloc_p(mem_ctx, struct net_context);
-	if (!ctx) {
-		d_printf("talloc_init(net_context) failed\n");
-		exit(1);
-	}
-
-	ZERO_STRUCTP(ctx);
-	ctx->mem_ctx = mem_ctx;
-
 	pc = poptGetContext("net", argc, (const char **) argv, long_options, 
 				POPT_CONTEXT_KEEP_FIRST);
 
@@ -213,6 +204,25 @@
 		return 1;
 	}
 
+	if (cmdline_auth_info.domain[0]) {
+		domain = cmdline_auth_info.domain;
+	} else {
+		domain = lp_workgroup();
+	}
+
+	mem_ctx = talloc_init("net_context");
+	ctx = talloc_p(mem_ctx, struct net_context);
+	if (!ctx) {
+		d_printf("talloc_init(net_context) failed\n");
+		exit(1);
+	}
+
+	ZERO_STRUCTP(ctx);
+	ctx->mem_ctx = mem_ctx;
+	ctx->user.account_name = talloc_strdup(ctx->mem_ctx, cmdline_auth_info.username);
+	ctx->user.domain_name = talloc_strdup(ctx->mem_ctx, domain);
+	ctx->user.password = talloc_strdup(ctx->mem_ctx, cmdline_auth_info.password);
+
 	rc = net_run_function(ctx, argc_new-1, argv_new+1, net_functable, net_usage);
 
 	if (rc != 0) {

Modified: branches/SAMBA_4_0/source/utils/net/net_password.c
===================================================================
--- branches/SAMBA_4_0/source/utils/net/net_password.c	2004-08-19 12:24:58 UTC (rev 1914)
+++ branches/SAMBA_4_0/source/utils/net/net_password.c	2004-08-19 12:36:05 UTC (rev 1915)
@@ -37,7 +37,8 @@
 	if (argc > 0 && argv[0]) {
 		new_password = argv[0];
 	} else {
-		password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for %s:", ctx->user.account_name);
+		password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for account [%s\\%s]:", 
+							ctx->user.domain_name, ctx->user.account_name);
 		new_password = getpass(password_prompt);
 	}
 



More information about the samba-cvs mailing list