[PATCH setup] Add new option --no-write-registry

Christian Franke Christian.Franke@t-online.de
Sat Jul 9 15:59:30 GMT 2022


IMO useful for temporary test installs or "portable" installs to USB 
devices.

The 0002-patch adds a related log message.


BTW: During testing I found that the "All Users" <> "Just Me" GUI 
setting has no effect at all. If setup is run elevated, "All Users" is 
always implied.

This is likely because read_mounts() is called again after the "Root" 
dialog. It resets root_scope and does not re-read the registry.

read_mounts (const std::string val)
{
...
   root_scope = (nt_sec.isRunAsAdmin ())? IDC_ROOT_SYSTEM : IDC_ROOT_USER;
...
}

-- 
Regards,
Christian

-------------- next part --------------
From ab3c94ebf0e78606c3660bec8e0c04c6e6b8ddd4 Mon Sep 17 00:00:00 2001
From: Christian Franke <christian.franke@t-online.de>
Date: Sat, 9 Jul 2022 16:52:47 +0200
Subject: [PATCH 1/2] Add new option --no-write-registry

If specified, the rootdir is not written to the registry and no
registry key is created.
---
 install.cc | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/install.cc b/install.cc
index 1fdc699..eb7b1b2 100644
--- a/install.cc
+++ b/install.cc
@@ -70,6 +70,7 @@ static long long int total_bytes_sofar = 0;
 static int package_bytes = 0;
 
 static BoolOption NoReplaceOnReboot (false, 'r', "no-replaceonreboot", IDS_HELPTEXT_NO_REPLACEONREBOOT);
+static BoolOption NoWriteRegistry (false, '\0', "no-write-registry" /*, TODO: IDS_HELPTEXT_... */);
 
 struct std_dirs_t {
   const char *name;
@@ -833,8 +834,9 @@ do_install_thread (HINSTANCE h, HWND owner)
   int df = diskfull (get_root_dir ().c_str());
   Progress.SetBar3 (df);
 
-  /* Writes Cygwin/setup/rootdir registry value */
-  create_install_root ();
+  if (!NoWriteRegistry)
+    /* Writes Cygwin/setup/rootdir registry value */
+    create_install_root ();
 
   std::vector <packageversion> install_q, uninstall_q, sourceinstall_q;
 
-- 
2.36.1

-------------- next part --------------
From 467b30e19e506ecb4b1e9ed9c4d7528d77db0228 Mon Sep 17 00:00:00 2001
From: Christian Franke <christian.franke@t-online.de>
Date: Sat, 9 Jul 2022 16:57:31 +0200
Subject: [PATCH 2/2] Log writes to rootdir registry entry

---
 mount.cc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/mount.cc b/mount.cc
index f63edd4..0136396 100644
--- a/mount.cc
+++ b/mount.cc
@@ -135,6 +135,12 @@ create_install_root ()
     mbox (NULL, IDS_MOUNT_REGISTRY_KEY_FAILED, MB_OK | MB_ICONWARNING);
   RegCloseKey (key);
 
+  Log (LOG_TIMESTAMP) << "Registry value set: HKEY_"
+		      << (root_scope == IDC_ROOT_USER ? "CURRENT_USER\\"
+						      : "LOCAL_MACHINE\\")
+		      << buf << "\\rootdir = \"" << get_root_dir () << "\""
+		      << endLog;
+
   // The mount table is already in the right shape at this point.
   // Reading it again is not necessary.
   //read_mounts (std::string ());
-- 
2.36.1



More information about the Cygwin-apps mailing list