[SCM] Samba Shared Repository - branch v3-devel updated - release-3-2-0pre2-3979-g0c23274

Günther Deschner gd at samba.org
Fri Sep 5 10:33:18 GMT 2008


The branch, v3-devel has been updated
       via  0c232742561a4001909ccce2c5160d57d09edb40 (commit)
       via  95ac480e2030dc607283a8eb89b44015527efa4b (commit)
       via  69e6532e9d3fad9d1c55e33cf5f120ca8b4b8d51 (commit)
      from  d6cb5fdafbddb08d32b788674eff509cae9525c6 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-devel


- Log -----------------------------------------------------------------
commit 0c232742561a4001909ccce2c5160d57d09edb40
Author: Günther Deschner <gd at samba.org>
Date:   Thu Sep 4 15:41:45 2008 +0200

    net: use netapi for rpc_sh_share_add as well.
    
    Guenther

commit 95ac480e2030dc607283a8eb89b44015527efa4b
Author: Günther Deschner <gd at samba.org>
Date:   Thu Sep 4 15:37:03 2008 +0200

    net: use netapi to add shares.
    
    Guenther

commit 69e6532e9d3fad9d1c55e33cf5f120ca8b4b8d51
Author: Günther Deschner <gd at samba.org>
Date:   Thu Sep 4 20:23:39 2008 +0200

    netapi: fix return code in NetShareAdd_r.
    
    Guenther

-----------------------------------------------------------------------

Summary of changes:
 source/lib/netapi/share.c |    3 +
 source/utils/net_rpc.c    |  128 ++++++++++++++++++++------------------------
 2 files changed, 61 insertions(+), 70 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/lib/netapi/share.c b/source/lib/netapi/share.c
index 3b99a8d..9983471 100644
--- a/source/lib/netapi/share.c
+++ b/source/lib/netapi/share.c
@@ -84,6 +84,9 @@ WERROR NetShareAdd_r(struct libnetapi_ctx *ctx,
 	switch (r->in.level) {
 		case 2:
 			break;
+		case 502:
+		case 503:
+			return WERR_NOT_SUPPORTED;
 		default:
 			return WERR_UNKNOWN_LEVEL;
 	}
diff --git a/source/utils/net_rpc.c b/source/utils/net_rpc.c
index 6db5bc7..18abc80 100644
--- a/source/utils/net_rpc.c
+++ b/source/utils/net_rpc.c
@@ -2789,77 +2789,60 @@ static int rpc_share_usage(struct net_context *c, int argc, const char **argv)
 /**
  * Add a share on a remote RPC server.
  *
- * All parameters are provided by the run_rpc_command function, except for
- * argc, argv which are passed through.
- *
- * @param domain_sid The domain sid acquired from the remote server.
- * @param cli A cli_state connected to the server.
- * @param mem_ctx Talloc context, destroyed on completion of the function.
  * @param argc  Standard main() style argc.
  * @param argv  Standard main() style argv. Initial components are already
  *              stripped.
  *
- * @return Normal NTSTATUS return.
+ * @return A shell status integer (0 for success).
  **/
-static NTSTATUS rpc_share_add_internals(struct net_context *c,
-					const DOM_SID *domain_sid,
-					const char *domain_name,
-					struct cli_state *cli,
-					struct rpc_pipe_client *pipe_hnd,
-					TALLOC_CTX *mem_ctx,int argc,
-					const char **argv)
+
+static int rpc_share_add(struct net_context *c, int argc, const char **argv)
 {
-	WERROR result;
-	NTSTATUS status;
+	NET_API_STATUS status;
 	char *sharename;
 	char *path;
 	uint32 type = STYPE_DISKTREE; /* only allow disk shares to be added */
 	uint32 num_users=0, perms=0;
 	char *password=NULL; /* don't allow a share password */
-	uint32 level = 2;
-	union srvsvc_NetShareInfo info;
-	struct srvsvc_NetShareInfo2 info2;
+	struct SHARE_INFO_2 i2;
 	uint32_t parm_error = 0;
 
-	if ((sharename = talloc_strdup(mem_ctx, argv[0])) == NULL) {
-		return NT_STATUS_NO_MEMORY;
+	if ((argc < 1) || !strchr(argv[0], '=') || c->display_usage) {
+		return rpc_share_usage(c, argc, argv);
+	}
+
+	if ((sharename = talloc_strdup(c, argv[0])) == NULL) {
+		return -1;
 	}
 
 	path = strchr(sharename, '=');
-	if (!path)
-		return NT_STATUS_UNSUCCESSFUL;
-	*path++ = '\0';
+	if (!path) {
+		return -1;
+	}
 
-	info2.name		= sharename;
-	info2.type		= type;
-	info2.comment		= c->opt_comment;
-	info2.permissions	= perms;
-	info2.max_users		= c->opt_maxusers;
-	info2.current_users	= num_users;
-	info2.path		= path;
-	info2.password		= password;
+	*path++ = '\0';
 
-	info.info2 = &info2;
+	i2.shi2_netname		= sharename;
+	i2.shi2_type		= type;
+	i2.shi2_remark		= c->opt_comment;
+	i2.shi2_permissions	= perms;
+	i2.shi2_max_uses	= c->opt_maxusers;
+	i2.shi2_current_uses	= num_users;
+	i2.shi2_path		= path;
+	i2.shi2_passwd		= password;
+
+	status = NetShareAdd(c->opt_host,
+			     2,
+			     (uint8_t *)&i2,
+			     &parm_error);
+	if (status != 0) {
+		printf("NetShareAdd failed with: %s\n",
+			libnetapi_get_error_string(c->netapi_ctx, status));
+	}
 
-	status = rpccli_srvsvc_NetShareAdd(pipe_hnd, mem_ctx,
-					   pipe_hnd->desthost,
-					   level,
-					   &info,
-					   &parm_error,
-					   &result);
 	return status;
 }
 
-static int rpc_share_add(struct net_context *c, int argc, const char **argv)
-{
-	if ((argc < 1) || !strchr(argv[0], '=') || c->display_usage) {
-		return rpc_share_usage(c, argc, argv);
-	}
-	return run_rpc_command(c, NULL, &ndr_table_srvsvc.syntax_id, 0,
-			       rpc_share_add_internals,
-			       argc, argv);
-}
-
 /**
  * Delete a share on a remote RPC server.
  *
@@ -4602,6 +4585,8 @@ int net_usersidlist_usage(struct net_context *c, int argc, const char **argv)
 
 int net_rpc_share(struct net_context *c, int argc, const char **argv)
 {
+	NET_API_STATUS status;
+
 	struct functable func[] = {
 		{
 			"add",
@@ -4646,6 +4631,15 @@ int net_rpc_share(struct net_context *c, int argc, const char **argv)
 		{NULL, NULL, 0, NULL, NULL}
 	};
 
+	status = libnetapi_init(&c->netapi_ctx);
+	if (status != 0) {
+		return -1;
+	}
+	libnetapi_set_username(c->netapi_ctx, c->opt_user_name);
+	libnetapi_set_password(c->netapi_ctx, c->opt_password);
+	if (c->opt_kerberos) {
+		libnetapi_set_use_kerberos(c->netapi_ctx);
+	}
 
 	if (argc == 0) {
 		if (c->display_usage) {
@@ -4682,11 +4676,9 @@ static NTSTATUS rpc_sh_share_add(struct net_context *c,
 				 struct rpc_pipe_client *pipe_hnd,
 				 int argc, const char **argv)
 {
-	WERROR result;
-	NTSTATUS status;
+	NET_API_STATUS status;
 	uint32_t parm_err = 0;
-	union srvsvc_NetShareInfo info;
-	struct srvsvc_NetShareInfo2 info2;
+	struct SHARE_INFO_2 i2;
 
 	if ((argc < 2) || (argc > 3)) {
 		d_fprintf(stderr, "usage: %s <share> <path> [comment]\n",
@@ -4694,25 +4686,21 @@ static NTSTATUS rpc_sh_share_add(struct net_context *c,
 		return NT_STATUS_INVALID_PARAMETER;
 	}
 
-	info2.name		= argv[0];
-	info2.type		= STYPE_DISKTREE;
-	info2.comment		= (argc == 3) ? argv[2] : "";
-	info2.permissions	= 0;
-	info2.max_users		= 0;
-	info2.current_users	= 0;
-	info2.path		= argv[1];
-	info2.password		= NULL;
+	i2.shi2_netname		= argv[0];
+	i2.shi2_type		= STYPE_DISKTREE;
+	i2.shi2_remark		= (argc == 3) ? argv[2] : "";
+	i2.shi2_permissions	= 0;
+	i2.shi2_max_uses	= 0;
+	i2.shi2_current_uses	= 0;
+	i2.shi2_path		= argv[1];
+	i2.shi2_passwd		= NULL;
 
-	info.info2 = &info2;
+	status = NetShareAdd(pipe_hnd->desthost,
+			     2,
+			     (uint8_t *)&i2,
+			     &parm_err);
 
-	status = rpccli_srvsvc_NetShareAdd(pipe_hnd, mem_ctx,
-					   pipe_hnd->desthost,
-					   2,
-					   &info,
-					   &parm_err,
-					   &result);
-
-	return status;
+	return werror_to_ntstatus(W_ERROR(status));
 }
 
 static NTSTATUS rpc_sh_share_delete(struct net_context *c,


-- 
Samba Shared Repository


More information about the samba-cvs mailing list