Bug 3589 - net -P option assumes you're using ADS
net -P option assumes you're using ADS
Status: RESOLVED FIXED
Product: Samba 3.0
Classification: Unclassified
Component: net utility
3.0.21c
All All
: P3 normal
: none
Assigned To: Jim McDonough
Samba QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-03-07 15:23 UTC by Waider
Modified: 2009-02-24 07:51 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 Waider 2006-03-07 15:23:30 UTC
The net -P option fails unless you're in an ADS environment due to using machine$@realm as the username. The attached patch against SAMBA_3_0 fixes the problem by checking for ads first, and using just machine$ for non-ADS environments. I'm not happy that it may result in more than one call to net_ads_check(), however.

Index: source/utils/net.c
===================================================================
--- source/utils/net.c  (revision 13996)
+++ source/utils/net.c  (working copy)
@@ -286,8 +286,15 @@
 
        user_name = NULL;
        opt_password = secrets_fetch_machine_password(opt_target_workgroup, NULL, NULL);
-       if (asprintf(&user_name, "%s$@%s", global_myname(), lp_realm()) == -1) {
-               return -1;
+
+       if ( net_ads_check() == 0 ) {
+               if (asprintf(&user_name, "%s$@%s", global_myname(), lp_realm()) == -1) {
+                       return -1;
+               }
+       } else {
+               if (asprintf(&user_name, "%s$", global_myname(), lp_realm()) == -1) {
+                       return -1;
+               }
        }
        opt_user_name = user_name;
        return 0;
Comment 1 Guenther Deschner 2009-02-24 07:51:28 UTC
The "-P" option has been addressed and the fix is all active branches.