svn commit: samba r9620 - in branches/SOC/SAMBA_3_0/source: include libmsrpc libmsrpc/test/reg

skel at samba.org skel at samba.org
Thu Aug 25 18:08:37 GMT 2005


Author: skel
Date: 2005-08-25 18:08:36 +0000 (Thu, 25 Aug 2005)
New Revision: 9620

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

Log:
fixed up some inconsistencies in the reg functions
cac_RegCreateKey() explicitly tries to open a key now


Modified:
   branches/SOC/SAMBA_3_0/source/include/libmsrpc.h
   branches/SOC/SAMBA_3_0/source/libmsrpc/cac_winreg.c
   branches/SOC/SAMBA_3_0/source/libmsrpc/test/reg/regkeycreate.c


Changeset:
Modified: branches/SOC/SAMBA_3_0/source/include/libmsrpc.h
===================================================================
--- branches/SOC/SAMBA_3_0/source/include/libmsrpc.h	2005-08-25 17:46:13 UTC (rev 9619)
+++ branches/SOC/SAMBA_3_0/source/include/libmsrpc.h	2005-08-25 18:08:36 UTC (rev 9620)
@@ -240,7 +240,6 @@
 
    char *dial;
 
-   /*FIXME: is there a better interface?*/
    /**Possible logon hours*/
    LOGON_HRS *logon_hours;
 
@@ -428,6 +427,20 @@
  */
 void cac_InitCacTime(CacTime *cactime, NTTIME nttime);
 
+/**
+ * Default smbc_get_auth_data_fn for libmsrpc. This function is called when libmsrpc needs to get more information about the 
+ * client (username/password, workgroup). 
+ * This function provides simple prompts to the user to enter the information. This description his here so you know how to re-define this function.
+ * @see cac_SetAuthDataFn()
+ * @param pServer Name/IP of the server to connect to. 
+ * @param pShare Share name to connect to
+ * @param pWorkgroup libmsrpc passes in the workgroup/domain name from hnd->domain. It can be modified in the function.
+ * @param maxLenWorkGroup The maximum length of a string pWogroup can hold.
+ * @param pUsername libmsrpc passes in the username from hnd->username. It can be modified in the function.
+ * @param maxLenUsername The maximum length of a string pUsername can hold.
+ * @param pPassword libmsrpc pass in the password from hnd->password. It can be modified in the function.
+ * @param maxLenPassword The maximum length  of a string pPassword can hold.
+ */
 void cac_GetAuthDataFn(const char * pServer,
                  const char * pShare,
                  char * pWorkgroup,
@@ -822,7 +835,7 @@
 
 struct LsaOpenAccount {
    struct {
-      /**open lsa policy handle*/
+      /**An open LSA policy handle*/
       POLICY_HND *pol;
 
       /**(Optional) account SID - must supply either sid or name*/
@@ -853,7 +866,7 @@
 
 struct LsaAddPrivileges {
    struct {
-      /**An open handle to the LSA*/
+      /**An open LSA policy handle*/
       POLICY_HND *pol;
 
       /**(Optional) The user's SID (must specify at least sid or name)*/
@@ -1103,7 +1116,7 @@
 };
 
 /**
- * Creates a registry key, if the key already exists, it will be opened __This is not currently working__.
+ * Creates a registry key, if the key already exists, it will be opened __Creating keys is not currently working__.
  * @param hnd Initialized and connected server handle
  * @param mem_ctx Context for memory allocation
  * @param op Initialized Parmeters
@@ -1118,7 +1131,7 @@
       POLICY_HND *parent_key;
 
       /**name of the key to delete*/
-      char *key_name;
+      char *name;
 
       /**delete recursively. WARNING: this might not always work as planned*/
       BOOL recursive;
@@ -1143,7 +1156,7 @@
       POLICY_HND *parent_key;
 
       /**name of the value to delete*/
-      char *val_name;
+      char *name;
    } in;
 };
 

Modified: branches/SOC/SAMBA_3_0/source/libmsrpc/cac_winreg.c
===================================================================
--- branches/SOC/SAMBA_3_0/source/libmsrpc/cac_winreg.c	2005-08-25 17:46:13 UTC (rev 9619)
+++ branches/SOC/SAMBA_3_0/source/libmsrpc/cac_winreg.c	2005-08-25 18:08:36 UTC (rev 9620)
@@ -305,10 +305,12 @@
 
    POLICY_HND *key_out;
 
+   struct RegOpenKey rok;
+
    if(!hnd) 
       return CAC_FAILURE;
 
-   if(!hnd->_internal.ctx || !hnd->_internal.pipes[PI_WINREG]) {
+   if(!hnd->_internal.ctx) {
       hnd->status = NT_STATUS_INVALID_HANDLE;
       return CAC_FAILURE;
    }
@@ -324,6 +326,20 @@
       return CAC_FAILURE;
    }
 
+   /*first try to open the key - we use cac_RegOpenKey(). this doubles as a way to ensure the winreg pipe is initialized*/
+   ZERO_STRUCT(rok);
+
+   rok.in.name = op->in.key_name;
+   rok.in.access = op->in.access;
+   rok.in.parent_key = op->in.parent_key;
+
+   if(cac_RegOpenKey(hnd, mem_ctx, &rok)) {
+      /*then we got the key, return*/
+      op->out.key = rok.out.key;
+      return CAC_SUCCESS;
+   }
+
+   /*just be ultra-safe*/
    srv->cli.pipe_idx = PI_WINREG;
 
    key_out = talloc(mem_ctx, POLICY_HND);
@@ -406,7 +422,7 @@
       return CAC_FAILURE;
    }
 
-   if(!op || !op->in.parent_key || !op->in.key_name || !mem_ctx) {
+   if(!op || !op->in.parent_key || !op->in.name || !mem_ctx) {
       hnd->status = NT_STATUS_INVALID_PARAMETER;
       return CAC_FAILURE;
    }
@@ -425,7 +441,7 @@
       ZERO_STRUCT(rok);
 
       rok.in.parent_key = op->in.parent_key;
-      rok.in.name       = op->in.key_name;
+      rok.in.name       = op->in.name;
       rok.in.access     = REG_KEY_ALL;
 
       if(!cac_RegOpenKey(hnd, mem_ctx, &rok))
@@ -444,7 +460,7 @@
       /*now go on to actually delete the key*/
    }
 
-   err = cli_reg_delete_key( &(srv->cli), mem_ctx, op->in.parent_key, op->in.key_name);
+   err = cli_reg_delete_key( &(srv->cli), mem_ctx, op->in.parent_key, op->in.name);
    hnd->status = werror_to_ntstatus(err);
 
    if(!NT_STATUS_IS_OK(hnd->status)) {
@@ -466,7 +482,7 @@
       return CAC_FAILURE;
    }
 
-   if(!op || !op->in.parent_key || !op->in.val_name || !mem_ctx) {
+   if(!op || !op->in.parent_key || !op->in.name || !mem_ctx) {
       hnd->status = NT_STATUS_INVALID_PARAMETER;
       return CAC_FAILURE;
    }
@@ -479,7 +495,7 @@
 
    srv->cli.pipe_idx = PI_WINREG;
 
-   err = cli_reg_delete_val( &(srv->cli), mem_ctx, op->in.parent_key, op->in.val_name);
+   err = cli_reg_delete_val( &(srv->cli), mem_ctx, op->in.parent_key, op->in.name);
    hnd->status = werror_to_ntstatus(err);
 
    if(!NT_STATUS_IS_OK(hnd->status)) {

Modified: branches/SOC/SAMBA_3_0/source/libmsrpc/test/reg/regkeycreate.c
===================================================================
--- branches/SOC/SAMBA_3_0/source/libmsrpc/test/reg/regkeycreate.c	2005-08-25 17:46:13 UTC (rev 9619)
+++ branches/SOC/SAMBA_3_0/source/libmsrpc/test/reg/regkeycreate.c	2005-08-25 18:08:36 UTC (rev 9620)
@@ -16,8 +16,6 @@
  
     hnd = cac_NewServerHandle();
 
-    hnd->debug = 10;
-
     /*allocate some memory so get_auth_data_fn can do it's magic*/
     hnd->username = SMB_MALLOC_ARRAY(char, sizeof(fstring));
     hnd->domain   = SMB_MALLOC_ARRAY(char, sizeof(fstring));



More information about the samba-cvs mailing list