Re: [Samba] regpatch writing to local registry hive with -F not working (registery-utils 4.0.0~alpha15~git20110124.dfsg1-2ubuntu1)

2011-05-19 Thread Wilco Baan Hofman
On Sun, 2011-05-15 at 00:28 +0200, Michael Wood wrote:
 On 14 May 2011 22:09, Michael Wood esiot...@gmail.com wrote:
  On 14 May 2011 19:53, RiCH r...@richud.com wrote:
  Hi,
 
  I was hoping I could modify a locally mounted registry hive using
  regpatch and a .reg file but the -F argument seems to have no function.

Correct. It does not on regpatch, afaik.

  Try this patch (untested, but based on what regtree does).

Won't work. See below.

  I've either got errors like:
 
 $ bin/regpatch -F /tmp/NTUSER.DAT /tmp/test.reg
 Error adding new key 'HKEY_CURRENT_USER\Software\Microsoft\Internet
 Explorer\Main': WERR_BADFILE
 Error adding key HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main
 
 I hope the patch helps, but I'm not sure that just using
 start_key-context is the right thing to do.
 

Actually, the reason this doesn't work is that -F loads a registry hive,
not a full registry and .reg files only work on a full registry.

If you load a hive with -F you cannot patch it.

A simple python script will work, however.. something like this:

---
sys.path.append(samba_python_path)
from samba import registry
import samba.getopt as options

# Open the hive
lp = sambaopts.get_loadparm()
creds = credopts.get_credentials(lp)
hive = registry.open_hive(hivepath, lp_ctx=lp, credentials=creds)

# Mount the hive to HKEY_CURRENT_USER
reg = registry.Registry()
reg.mount_hive(hive, registry.HKEY_CURRENT_USER)
reg.diff_apply(patchfile)
---

Regards,

Wilco Baan Hofman




-- 
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba


Re: [Samba] regpatch writing to local registry hive with -F not working (registery-utils 4.0.0~alpha15~git20110124.dfsg1-2ubuntu1)

2011-05-19 Thread Wilco Baan Hofman
On Wed, 2011-05-18 at 12:33 +0200, Michael Wood wrote:

 
 Then it seems the -F option should be removed from regpatch.  Or
 should regpatch be replaced with something similar to the Python script
 you included below?

The latter would be preferable, but you'd have to be able to specify
mountpoints for the hives.

 ---
  sys.path.append(samba_python_path)
  from samba import registry
  import samba.getopt as options
 
  # Open the hive
  lp = sambaopts.get_loadparm()
  creds = credopts.get_credentials(lp)
  hive = registry.open_hive(hivepath, lp_ctx=lp, credentials=creds)
 
 So hivepath here is the path to e.g. some user's NTUSER.DAT?

Indeed.

  # Mount the hive to HKEY_CURRENT_USER
  reg = registry.Registry()
  reg.mount_hive(hive, registry.HKEY_CURRENT_USER)
  reg.diff_apply(patchfile)
 ---

Regards,

Wilco Baan Hofman


-- 
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba


Re: [Samba] regpatch writing to local registry hive with -F not working (registery-utils 4.0.0~alpha15~git20110124.dfsg1-2ubuntu1)

2011-05-19 Thread Wilco Baan Hofman
On Wed, 2011-05-18 at 16:01 +0200, denis bonnenfant wrote:
 Le mercredi 18 mai 2011 à 15:07 +0200, Wilco Baan Hofman a écrit :
  On Wed, 2011-05-18 at 12:33 +0200, Michael Wood wrote:
  
   
   Then it seems the -F option should be removed from regpatch.  Or
   should regpatch be replaced with something similar to the Python script
   you included below?
  
 
 My patch adds a -K option to regpatch for specifying the predef key
 where -F registry should be mounted. I will submit it for review soon,
 I'm currently experimenting a little bit, and there are still some bugs
 in .reg parsing

I use this quite a bit and I'm aware of two bugs, which is not directly
related to the parsing, but that on windows unicode is implicit for
certain data types even when the data is given in binary format, it's
still converted. The other 'bug' is that unicode .reg files are not yet
supported. I'd be very interested to know what other bugs there are.

Regards,

Wilco Baan Hofman

-- 
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba