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

Wilco Baan Hofman wilco at baanhofman.nl
Tue May 17 17:55:41 MDT 2011


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.

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






More information about the samba mailing list