lsq726 has forwarded me a patch (attached for reference) that adds support to
sanbootconf for setting the system hostname. I'd like to get some input on
this from other people using sanbootconf.
The iBFT includes a single "hostname" string, which gPXE already populates
with the value of DHCP option 12. sanbootconf currently ignores this value
in the iBFT.
The proposed patch essentially takes this value from the iBFT and stores it in
the following registry entries:
CCS\Control\ComputerName\ComputerName\ComputerName
CCS\Services\Tcpip\Parameters\Hostname
CCS\Services\Tcpip\Parameters\NV Hostname
This appears to be sufficient for renaming a computer that is *not* a domain
member. I am not sure how this would interact with computers that *are*
domain members, and I don't have time to test it right now, so any input
would be welcome.
Michael
--- /home/mcb30/tmp/iscsiboot.c 2010-03-20 06:45:02.000000000 +0000
+++ /home/mcb30/tmp/iscsiboot-Modify_by_hbxfwjww.c 2010-03-20 06:46:27.000000000 +0000
@@ -742,6 +742,60 @@
}
/**
+ * Store hostname parameters in registry
+ *
+ * @v hostname ComputerName
+ * @ret ntstatus NT status
+ */
+static NTSTATUS store_hostname_parameters(LPSTR hostname) {
+ LPWSTR value_name;
+ HANDLE reg_key;
+ NTSTATUS status;
+ WCHAR buf[256];
+ LPCWSTR star = L"star";
+ WCHAR key_name_computername[] = ( L"\\Registry\\Machine\\SYSTEM\\"
+ L"CurrentControlSet\\Control\\ComputerName\\ComputerName\\");
+
+ WCHAR key_name_hostname[] = ( L"\\Registry\\Machine\\SYSTEM\\"
+ L"CurrentControlSet\\Services\\"
+ L"Tcpip\\Parameters\\" );
+
+ RtlStringCbPrintfW ( buf, sizeof ( buf ),
+ L"%wS-%S", star, hostname );
+ value_name = buf;
+ /* Open key */
+ status = reg_open ( key_name_computername, ®_key );
+ if ( ! NT_SUCCESS ( status ) )
+ goto err_reg_open;
+
+ /* Store computername */
+ status = reg_store_sz ( reg_key, L"ComputerName", value_name );
+ if ( ! NT_SUCCESS ( status ) )
+ goto err_reg_store;
+
+ /* Close key */
+ reg_close(reg_key);
+
+ /* open key */
+ status = reg_open(key_name_hostname, ®_key);
+ if (!NT_SUCCESS(status))
+ goto err_reg_open;
+
+ /* Store hostname */
+ status = reg_store_sz ( reg_key, L"Hostname", value_name );
+ if ( ! NT_SUCCESS ( status ) )
+ goto err_reg_store;
+ status = reg_store_sz ( reg_key, L"NV Hostname", value_name );
+ if ( ! NT_SUCCESS ( status ) )
+ goto err_reg_store;
+ /* Store hostname end */
+ err_reg_store:
+ reg_close ( reg_key );
+ err_reg_open:
+ return status;
+}
+
+/**
* Store TCP/IP parameters in registry
*
* @v nic iBFT NIC structure
@@ -904,6 +957,11 @@
UNICODE_STRING u_symlink;
NTSTATUS status;
+ /* get computername */
+ status = store_hostname_parameters(ibft_string(ibft, &nic->hostname));
+ if(!NT_SUCCESS(status))
+ DbgPrint("Set ComputerName Fail!\n");
+
/* Dump structure information */
DbgPrint ( "Found iBFT NIC %d:\n", header->index );
DbgPrint ( " Flags = %#02x%s%s\n", header->flags,
_______________________________________________
gPXE mailing list
[email protected]
http://etherboot.org/mailman/listinfo/gpxe