Bug 451 - net -P prompts for password
net -P prompts for password
Status: CLOSED FIXED
Product: Samba 3.0
Classification: Unclassified
Component: net utility
3.0.0preX
Other other
: P3 normal
: none
Assigned To: Jim McDonough
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2003-09-13 19:29 UTC by Ken Cross
Modified: 2005-08-24 10:27 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ken Cross 2003-09-13 19:29:05 UTC
The net utility prompts for a password when -P is specified, but the machine  
account doesn't exist.  Previously, it would exit nicely with an error 
status.  Now it prompts for a password.  For example:
 
   net ads leave -P
 
Previously this would work as desired -- if the machine account existed, it  
would remove it; if not, it would continue.  Now it hangs waiting for input, 
which is a Bad Thing in a script.

This patch disables prompt if -P is specified.


Index: net.h
===================================================================
RCS file: /cvsroot/samba/source/utils/net.h,v
retrieving revision 1.7.2.4
diff -p -u -r1.7.2.4 net.h
--- net.h	21 Apr 2003 14:09:03 -0000	1.7.2.4
+++ net.h	13 Sep 2003 18:52:49 -0000
@@ -48,6 +48,7 @@ extern const char *opt_workgroup;
 extern int opt_long_list_entries;
 extern int opt_reboot;
 extern int opt_force;
+extern int opt_machine_pass;  /* KJC */
 extern int opt_timeout;
 extern const char *opt_host;
 extern const char *opt_user_name;
Index: net_ads.c
===================================================================
RCS file: /cvsroot/samba/source/utils/net_ads.c,v
retrieving revision 1.37.2.31
diff -p -u -r1.37.2.31 net_ads.c
--- net_ads.c	5 Sep 2003 17:57:45 -0000	1.37.2.31
+++ net_ads.c	13 Sep 2003 18:52:49 -0000
@@ -145,7 +145,7 @@ static ADS_STRUCT *ads_startup(void)
 	}
 
 retry:
-	if (!opt_password && need_password) {
+	if (!opt_password && need_password && !opt_machine_pass) {   /* KJC */
 		char *prompt;
 		asprintf(&prompt,"%s password: ", opt_user_name);
 		opt_password = getpass(prompt);
Comment 1 Ken Cross 2003-09-13 19:41:08 UTC
Forgot to include this one:

Index: net.c
===================================================================
RCS file: /cvsroot/samba/source/utils/net.c,v
retrieving revision 1.43.2.35
diff -p -u -r1.43.2.35 net.c
--- net.c       7 Sep 2003 16:36:13 -0000       1.43.2.35
+++ net.c       14 Sep 2003 02:37:30 -0000
@@ -72,7 +72,7 @@ const char *opt_container = "cn=Users";
 int opt_flags = -1;
 int opt_timeout = 0;
 const char *opt_target_workgroup = NULL;
-static int opt_machine_pass = 0;
+int opt_machine_pass = 0;   /* KJC */
 
 BOOL opt_have_ip = False;
 struct in_addr opt_dest_ip;

Comment 2 Jim McDonough 2003-10-23 07:34:04 UTC
Applied something like this patch.  I also expanded it to cover the RPC and
RAP methods as well.
Comment 3 Gerald (Jerry) Carter 2005-02-07 09:06:03 UTC
originally reported against one of the 3.0.0rc[1-4] releases.
Cleaning up non-production versions.
Comment 4 Gerald (Jerry) Carter 2005-08-24 10:27:42 UTC
sorry for the same, cleaning up the database to prevent unecessary reopens of bugs.