Workgroups in net utility - patch for net.c

Ken Cross kcross at
Sat Jul 12 13:51:38 GMT 2003


The net utility is very neat and powerful.  But it has a problem for what it
uses for "workgroup".  The -w isn't used consistently.  For example:

  net -w SOMEDOMAIN ads testjoin

will use the workgroup from smb.conf, but

  net -w SOMEDOMAIN rpc testjoin

will use SOMEDOMAIN.

My current workaround is to create a temporary smb.conf and specify it with
-s, but that's obviously a nuisance.  (It would be nice to be able to
specify "-s /dev/null" for any net command and have it work as expected.)

The following patch is a hack, but it makes it work consistently.  (This
could impact -W, though -- I'm not sure how they interact.)

RCS file: /cvsroot/samba/source/utils/net.c,v
retrieving revision
diff -p -u -r1.43.2.27 net.c
--- utils/net.c 25 Jun 2003 17:41:05 -0000
+++ utils/net.c 12 Jul 2003 13:38:59 -0000
@@ -629,6 +629,9 @@ static struct functable net_func[] = {
        if (!opt_target_workgroup) {
                opt_target_workgroup = smb_xstrdup(lp_workgroup());
+       else {
+               set_global_myworkgroup(opt_target_workgroup);
+       }
        if (!init_names())


Ken Cross

Network Storage Solutions
Phone 865.675.4070 ext 31
kcross at 

More information about the samba-technical mailing list