summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-08-08 22:29:44 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:31:32 -0500
commit924b3cc953182c4f72d6356b7209c4ccb5647fb1 (patch)
treed7b1987da6abe5f75e9973ef342c5a3c4489499a /source4
parenteda59a6ca0e9eae395fef339ca809d133f92902c (diff)
downloadsamba-924b3cc953182c4f72d6356b7209c4ccb5647fb1.tar.gz
samba-924b3cc953182c4f72d6356b7209c4ccb5647fb1.tar.bz2
samba-924b3cc953182c4f72d6356b7209c4ccb5647fb1.zip
r9218: make the winreg library code handle arbitrary paths more efficiently
and more conveniently (caller doesn't need to know the hive names now) (This used to be commit dadd7e22fb439f7b18c429a95c75902e4741ba8d)
Diffstat (limited to 'source4')
-rw-r--r--source4/scripting/libjs/winreg.js54
1 files changed, 38 insertions, 16 deletions
diff --git a/source4/scripting/libjs/winreg.js b/source4/scripting/libjs/winreg.js
index 129cfe0898..703b8da2a7 100644
--- a/source4/scripting/libjs/winreg.js
+++ b/source4/scripting/libjs/winreg.js
@@ -42,29 +42,48 @@ function winreg_open_path(reg, path)
var list = new Object();
list.length = 0;
+
+ /* cope with a leading slash */
+ if (components[0] == '') {
+ for (i=0;i<(components.length-1);i++) {
+ components[i] = components[i+1];
+ }
+ components.length--;
+ }
+ if (components.length == 0) {
+ return undefined;
+ }
+
var handle = winreg_open_hive(reg, components[0]);
if (handle == undefined) {
return undefined;
}
- for (i=1;i<components.length;i++) {
- io = irpcObj();
- io.input.handle = handle;
- io.input.keyname = components[i];
- io.input.unknown = 0;
- io.input.access_mask = reg.SEC_FLAG_MAXIMUM_ALLOWED;
- var status = reg.winreg_OpenKey(io);
- if (!status.is_ok) {
- return undefined;
- }
- if (io.output.result != "WERR_OK") {
- return undefined;
- }
+ if (components.length == 1) {
+ return handle;
+ }
- handle = io.output.handle;
+ var hpath = components[1];
+
+ for (i=2;i<components.length;i++) {
+ hpath = hpath + "\\" + components[i];
}
- return handle;
+
+ io = irpcObj();
+ io.input.handle = handle;
+ io.input.keyname = hpath;
+ io.input.unknown = 0;
+ io.input.access_mask = reg.SEC_FLAG_MAXIMUM_ALLOWED;
+ var status = reg.winreg_OpenKey(io);
+ if (!status.is_ok) {
+ return undefined;
+ }
+ if (io.output.result != "WERR_OK") {
+ return undefined;
+ }
+
+ return io.output.handle;
}
/*
@@ -76,6 +95,10 @@ function winreg_enum_path(reg, path)
{
var list = new Object();
list.length = 0;
+
+ if (path == null || path == "\\" || path == "") {
+ return new Array("HKLM", "HKU");
+ }
handle = winreg_open_path(reg, path);
if (handle == undefined) {
@@ -106,7 +129,6 @@ function winreg_enum_path(reg, path)
if (out.result != "WERR_OK") {
return list;
}
-
list[list.length] = out.out_name.name;
list.length++;
}