reg-expand-str-20040316
authorJeffrey Altman <jaltman@mit.edu>
Tue, 16 Mar 2004 22:03:00 +0000 (22:03 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Tue, 16 Mar 2004 22:03:00 +0000 (22:03 +0000)
Change the NetbiosName registry value from REG_SZ to REG_EXPAND_SZ
and add the necessary code to expand the strings.   This will allow
the use of %COMPUTERNAME%-AFS in case people want to explicitly use
a non-portable name.

====================
This delta was composed from multiple commits as part of the CVS->Git migration.
The checkin message with each commit was inconsistent.
The following are the additional commit messages.
====================

Update text for NetbiosName value.

doc/txt/winnotes/registry.txt
src/WINNT/afsd/afsd_init.c

index de2e0c6..34d6a81 100644 (file)
@@ -119,12 +119,13 @@ Variable: traceOnPanic
   Issues a breakpoint in the event of a panic. (breakpoint: _asm int 3).
 
 Value   : NetbiosName
-Type    : REG_SZ
+Type    : REG_EXPAND_SZ
 Default : "AFS"
 Variable: cm_NetbiosName
 
   Specifies the NetBIOS name to be used when binding to a Loopback
-  adapter.
+  adapter.  To provide the old behavior specify a value of 
+  "%COMPUTERNAME%-AFS"
 
 Value  : IsGateway
 Type   : DWORD {1,0}
index 3e949be..5094885 100644 (file)
@@ -439,11 +439,17 @@ int afsd_InitCM(char **reasonP)
        }
 #endif /* AFS_FREELANCE_CLIENT */
 
-    dummyLen = sizeof(cm_NetBiosName);
+    dummyLen = sizeof(buf);
     code = RegQueryValueEx(parmKey, "NetbiosName", NULL, NULL,
-                           (BYTE *) &cm_NetBiosName, &dummyLen);
+                           (BYTE *) &buf, &dummyLen);
     if (code == ERROR_SUCCESS) {
-        afsi_log("Explicit NetBios name is used %s", cm_NetBiosName);
+        DWORD len = ExpandEnvironmentStrings(buf, cm_NetBiosName, MAX_NB_NAME_LENGTH);
+        if ( len > 0 && len <= MAX_NB_NAME_LENGTH ) {
+            afsi_log("Explicit NetBios name is used %s", cm_NetBiosName);
+        } else {
+            afsi_log("Unable to Expand Explicit NetBios name: %s", buf);
+            cm_NetBiosName[0] = 0;  /* turn it off */
+        }
     }
     else {
         cm_NetBiosName[0] = 0;   /* default off */