svn commit: samba r9568 - in branches/SAMBA_4_0/source/scripting: bin libjs

tridge at samba.org tridge at samba.org
Wed Aug 24 08:32:55 GMT 2005


Author: tridge
Date: 2005-08-24 08:32:51 +0000 (Wed, 24 Aug 2005)
New Revision: 9568

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9568

Log:

updated the winreg js library for CreateKey, and add a --createkey
option to the winreg tool

Modified:
   branches/SAMBA_4_0/source/scripting/bin/winreg
   branches/SAMBA_4_0/source/scripting/libjs/winreg.js


Changeset:
Modified: branches/SAMBA_4_0/source/scripting/bin/winreg
===================================================================
--- branches/SAMBA_4_0/source/scripting/bin/winreg	2005-08-24 08:31:39 UTC (rev 9567)
+++ branches/SAMBA_4_0/source/scripting/bin/winreg	2005-08-24 08:32:51 UTC (rev 9568)
@@ -12,7 +12,8 @@
 var options = GetOptions(ARGV,
 			 "POPT_AUTOHELP",
 			 "POPT_COMMON_SAMBA",
-			 "POPT_COMMON_CREDENTIALS");
+			 "POPT_COMMON_CREDENTIALS",
+			 "createkey=s");
 if (options == undefined) {
 	println("Failed to parse options");
 	return -1;
@@ -61,6 +62,10 @@
 
 function list_path(path) {
 	var list = reg.enum_path(path);
+	if (list == undefined) {
+		println("Unable to list " + path);
+		return;
+	}
 	var i;
 	list_values(path);
 	for (i=0;i<list.length;i++) {
@@ -83,6 +88,13 @@
 	root = '';
 }
 
-printf("Listing registry tree '%s'\n", root);
-list_path(root);
+if (options.createkey) {
+	var ok = reg.create_key("HKLM\\SOFTWARE", options.createkey);
+	if (!ok) {
+		
+	}
+} else {
+	printf("Listing registry tree '%s'\n", root);
+	list_path(root);
+}
 return 0;

Modified: branches/SAMBA_4_0/source/scripting/libjs/winreg.js
===================================================================
--- branches/SAMBA_4_0/source/scripting/libjs/winreg.js	2005-08-24 08:31:39 UTC (rev 9567)
+++ branches/SAMBA_4_0/source/scripting/libjs/winreg.js	2005-08-24 08:32:51 UTC (rev 9568)
@@ -35,7 +35,7 @@
 	} else if (hive == "HKU") {
 		status = this.winreg_OpenHKU(io);
 	} else {
-		println("Unknown hive " + hive);
+		this._last_error = "Unknown hive " + hive;
 		return undefined;
 	}
 	if (!status.is_ok) {
@@ -231,7 +231,41 @@
 	return list;
 }
 
+
 /*
+  create a new key
+    ok = reg.create_key(path, key);
+*/
+function __winreg_create_key(path, key)
+{
+	var handle = this.open_path(path);
+	if (handle == undefined) {
+		return undefined;
+	}
+
+	var io = irpcObj();
+	io.input.handle = handle;
+	io.input.name = key;
+	io.input.class = NULL;
+	io.input.options = 0;
+	io.input.access_required = this.SEC_FLAG_MAXIMUM_ALLOWED;
+	io.input.secdesc = NULL;
+	io.input.action_taken = 0;	
+
+	var status = this.winreg_CreateKey(io);
+	this.close(handle);
+	if (!status.is_ok) {
+		return false;
+	}
+	if (io.output.result != "WERR_OK") {
+		return false;
+	}
+	this.close(io.output.new_handle);
+	return true;
+}
+
+
+/*
   return a string for a winreg type
 */
 function __winreg_typestring(type)
@@ -252,12 +286,13 @@
 				  "REG_RESOURCE_LIST", "REG_FULL_RESOURCE_DESCRIPTOR", 
 				  "REG_RESOURCE_REQUIREMENTS_LIST", "REG_QWORD");
 
-	reg.close = __winreg_close;
-	reg.open_hive = __winreg_open_hive;
-	reg.open_path = __winreg_open_path;
-	reg.enum_path = __winreg_enum_path;
+	reg.close       = __winreg_close;
+	reg.open_hive   = __winreg_open_hive;
+	reg.open_path   = __winreg_open_path;
+	reg.enum_path   = __winreg_enum_path;
 	reg.enum_values = __winreg_enum_values;
-	reg.typestring = __winreg_typestring;
+	reg.create_key  = __winreg_create_key;
+	reg.typestring  = __winreg_typestring;
 
 	return reg;
 }



More information about the samba-cvs mailing list