[Samba] regpatch writing to local registry hive with -F not working (registery-utils 4.0.0~alpha15~git20110124.dfsg1-2ubuntu1)
esiotrot at gmail.com
Wed May 18 04:33:09 MDT 2011
On 18 May 2011 01:55, Wilco Baan Hofman <wilco at baanhofman.nl> wrote:
> On Sun, 2011-05-15 at 00:28 +0200, Michael Wood wrote:
>> On 14 May 2011 22:09, Michael Wood <esiotrot at gmail.com> wrote:
>> > On 14 May 2011 19:53, RiCH <rich at 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.
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?
> A simple python script will work, however.. something like this:
> 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"?
> # Mount the hive to HKEY_CURRENT_USER
> reg = registry.Registry()
> reg.mount_hive(hive, registry.HKEY_CURRENT_USER)
> Wilco Baan Hofman
Michael Wood <esiotrot at gmail.com>
More information about the samba