Re: [Samba] Access registry on remote Windows machine?

2011-10-13 Thread Gregor Beck
On Wednesday, October 05, 2011 11:08:46 PM Ken D'Ambrosio wrote:
 Hi, all.  I just bumped into an old script that used SambaTNG's rpcclient
 to access a remote Windows machine's registry:
 
 rpcclient -S $ip -U administrator\%pwd -c 'registry key enum $query'
 
 That's pretty slick -- but I see no way to accomplish this through stock
 Samba, be it rppcclient or something else.  Am I missing something?

try
net rpc -I $ip -U administrator%pwd  registry enumerate  $key

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


Re: [Samba] Problem exporting samba 3.6 registry

2011-09-10 Thread Gregor Beck
On Wednesday, September 07, 2011 09:56:59 AM Alejandro Escanero Blanco wrote:
 In samba3.6 I get a reject:
rebased on release-3-6-0rc1-1-g69ee029

Gregor
From 69ee029c470c9942e3c1dccbab1df8c9a9684cbb Mon Sep 17 00:00:00 2001
From: Gregor Beck gb...@sernet.de
Date: Tue, 6 Sep 2011 09:24:10 +0200
Subject: [PATCH] s3:registry: reg_format: handle unterminated REG_SZ blobs

---
 source3/registry/reg_format.c |   10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/source3/registry/reg_format.c b/source3/registry/reg_format.c
index f2b0846..c9f8233 100644
--- a/source3/registry/reg_format.c
+++ b/source3/registry/reg_format.c
@@ -325,6 +325,12 @@ done:
 	return ret;
 }
 
+static bool is_zero_terminated_ucs2(const uint8_t* data, size_t len) {
+	const size_t idx = len/sizeof(smb_ucs2_t);
+	const smb_ucs2_t *str = (const smb_ucs2_t*)data;
+	return (idx  0)  (str[idx] == 0);
+}
+
 int reg_format_value(struct reg_format* f, const char* name, uint32_t type,
 		 const uint8_t* data, size_t len)
 {
@@ -333,7 +339,9 @@ int reg_format_value(struct reg_format* f, const char* name, uint32_t type,
 
 	switch (type) {
 	case REG_SZ:
-		if (!(f-flags  REG_FMT_HEX_SZ)) {
+		if (!(f-flags  REG_FMT_HEX_SZ)
+		 is_zero_terminated_ucs2(data, len))
+		{
 			char* str = NULL;
 			size_t dlen;
 			if (pull_ucs2_talloc(mem_ctx, str, (const smb_ucs2_t*)data, dlen)) {
-- 
1.7.6

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

Re: [Samba] Problem exporting samba 3.6 registry

2011-09-06 Thread Gregor Beck
: gencache_get (in /usr/local/samba/bin/net)
 ==25578==by 0x327147: sitename_fetch (in /usr/local/samba/bin/net)
 ==25578==by 0x3211C9: resolve_name (in /usr/local/samba/bin/net)
 ==25578==by 0x1EB62D: net_find_server (in /usr/local/samba/bin/net)
 ==25578==by 0x1EC2C6: net_make_ipc_connection_ex (in
 /usr/local/samba/bin/net)
 ==25578==
 --25578--
 --25578-- used_suppression: 71 dl-hack3
 ==25578==
 ==25578== ERROR SUMMARY: 496 errors from 6 contexts (suppressed: 71 from
 10)
 
 El 18/08/11 23:15, Volker Lendecke escribió:
  On Thu, Aug 18, 2011 at 02:12:57PM -0700, Jeremy Allison wrote:
  On Thu, Aug 18, 2011 at 01:31:36PM +0200, Alejandro Escanero Blanco 
wrote:
  I'm triing to put some samba3.6 server like print server, the load
  of ntprinters and ntdrivers is ok, but when I try to do a backup of
  the registry I find it:
  
  #net rpc registry export
  'HKLM\System\CurrentControlSet\Control\Print\Environments\Windows NT
  x86\Drivers\Version-3\Canon iR2270/iR2870 PCL6' printers.reg
  Violación de segmento (Segmentation Fault)
  
  Export fail but enumerate runs correctly. Where is the problem?

There are 2 problems. The first seams there are invalid REG_SZ values within 
this registry key, the second net registry export couldn't cope with them.
For the second problem please try the attached patch, the first needs further 
investigations.

Gregor
From 913836f0f7495c97ebf7e91044a62c425e1da6f9 Mon Sep 17 00:00:00 2001
From: Gregor Beck gb...@sernet.de
Date: Tue, 6 Sep 2011 09:24:10 +0200
Subject: [PATCH] s3:registry: reg_format: handle unterminated REG_SZ blobs

---
 source3/registry/reg_format.c |   10 +-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/source3/registry/reg_format.c b/source3/registry/reg_format.c
index 266629a..315db47 100644
--- a/source3/registry/reg_format.c
+++ b/source3/registry/reg_format.c
@@ -339,6 +339,12 @@ done:
 	return ret;
 }
 
+static bool is_zero_terminated_ucs2(const uint8_t* data, size_t len) {
+	const size_t idx = len/sizeof(smb_ucs2_t);
+	const smb_ucs2_t *str = (const smb_ucs2_t*)data;
+	return (idx  0)  (str[idx] == 0);
+}
+
 int reg_format_value(struct reg_format* f, const char* name, uint32_t type,
 		 const uint8_t* data, size_t len)
 {
@@ -347,7 +353,9 @@ int reg_format_value(struct reg_format* f, const char* name, uint32_t type,
 
 	switch (type) {
 	case REG_SZ:
-		if (!(f-hex_fmt  REG_FMT_HEX_SZ)) {
+		if (!(f-hex_fmt  REG_FMT_HEX_SZ)
+		 is_zero_terminated_ucs2(data, len))
+		{
 			char* str = NULL;
 			size_t dlen;
 			if (pull_ucs2_talloc(mem_ctx, str, (const smb_ucs2_t*)data, dlen)) {
-- 
1.7.6

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