[SCM] Samba Shared Repository - branch v3-4-test updated - release-4-0-0alpha7-994-gb5b5718

Günther Deschner gd at samba.org
Fri May 15 14:00:00 GMT 2009


The branch, v3-4-test has been updated
       via  b5b5718552f44ac4fc961c38eb3a8ff02eab18f9 (commit)
       via  51271ab739e5a239faf2367cc0e25e34a9cd9170 (commit)
       via  efaf83fadea2e7b13441d08d82a3a1d27571d16d (commit)
       via  de33ca38880aa10fbd57ce45f2defdf83c379879 (commit)
       via  afca1d6cd2a184d7b8f70847db143761d5497ac6 (commit)
       via  fb8cbd7f7e078754faf7fb0b9f071aecbb19d401 (commit)
       via  e1c76e41b9f517fea6aa79ba9c0f21b76ab31258 (commit)
       via  7f904f0b50dc59282f8804fcd87407d0ee3af918 (commit)
      from  99771d2e23b476d1a7becd9f394421363dd0dffe (commit)

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


- Log -----------------------------------------------------------------
commit b5b5718552f44ac4fc961c38eb3a8ff02eab18f9
Author: Günther Deschner <gd at samba.org>
Date:   Fri May 15 14:34:50 2009 +0200

    s3-samr: in _samr_QueryUserInfo() make sure to not return any info in error case.
    
    Guenther
    (cherry picked from commit 59192bf03f3781fe6a21be66a7374ea72cac71f4)

commit 51271ab739e5a239faf2367cc0e25e34a9cd9170
Author: Günther Deschner <gd at samba.org>
Date:   Fri May 15 00:31:16 2009 +0200

    s3-samr: use normal integer in r->in.level switch statements.
    
    Guenther

commit efaf83fadea2e7b13441d08d82a3a1d27571d16d
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 13 16:38:26 2009 +0200

    s3-netapi: implement NetShutdownInit_r and NetShutdownAbort_r.
    
    Guenther
    (cherry picked from commit 8fdb499497f8d4f4a1ca93ffc94de8b57c2c1568)

commit de33ca38880aa10fbd57ce45f2defdf83c379879
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 13 16:38:00 2009 +0200

    s3-netapi: add example code for NetShutdownInit and NetShutdownAbort.
    
    Guenther
    (cherry picked from commit 80f0d819fb85bdfbd85e910fccc62e778bea3a83)

commit afca1d6cd2a184d7b8f70847db143761d5497ac6
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 13 16:35:45 2009 +0200

    s3-netapi: add NetShutdownInit and NetShutdownAbort to public API.
    
    Guenther
    (cherry picked from commit 1ddc4829aec61d952aaf3185cc56d53d4a9b5c3c)

commit fb8cbd7f7e078754faf7fb0b9f071aecbb19d401
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 13 16:27:58 2009 +0200

    s3-netapi: add NetShutdownInit and NetShutdownAbort skeletons.
    
    Guenther
    (cherry picked from commit 8fd3c8902c5e953a0ddf184b08f9e37f954ee12e)

commit e1c76e41b9f517fea6aa79ba9c0f21b76ab31258
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 13 16:17:36 2009 +0200

    s3-build: re-run make samba3-idl.
    
    Guenther
    (cherry picked from commit 3a2c748cf4626266899103aa719ea6ac2eae3a9f)

commit 7f904f0b50dc59282f8804fcd87407d0ee3af918
Author: Günther Deschner <gd at samba.org>
Date:   Wed May 13 16:16:33 2009 +0200

    s3-netapi: add NetShutdownInit and NetShutdownAbort.
    
    I know, they don't exist as such calls on windows but having them in
    libnetapi.so would be very handy.
    
    Guenther
    (cherry picked from commit e272acf4848b6c5944acc685b0738e520b3039fb)

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

Summary of changes:
 source3/Makefile.in                                |    3 +-
 source3/lib/netapi/examples/Makefile.in            |   14 +++-
 .../lib/netapi/examples/shutdown/shutdown_abort.c  |   76 ++++++++++++++
 .../lib/netapi/examples/shutdown/shutdown_init.c   |   94 +++++++++++++++++
 source3/lib/netapi/libnetapi.c                     |   88 ++++++++++++++++
 source3/lib/netapi/libnetapi.h                     |   14 +++
 source3/lib/netapi/netapi.h                        |   36 +++++++
 source3/lib/netapi/shutdown.c                      |  108 ++++++++++++++++++++
 source3/librpc/gen_ndr/libnetapi.h                 |   30 ++++++
 source3/librpc/gen_ndr/ndr_libnetapi.c             |   50 +++++++++
 source3/librpc/gen_ndr/ndr_libnetapi.h             |   12 ++-
 source3/librpc/idl/libnetapi.idl                   |   21 ++++
 source3/rpc_server/srv_samr_nt.c                   |   65 +++++++------
 13 files changed, 578 insertions(+), 33 deletions(-)
 create mode 100644 source3/lib/netapi/examples/shutdown/shutdown_abort.c
 create mode 100644 source3/lib/netapi/examples/shutdown/shutdown_init.c
 create mode 100644 source3/lib/netapi/shutdown.c


Changeset truncated at 500 lines:

diff --git a/source3/Makefile.in b/source3/Makefile.in
index 0e66f75..8285ab9 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -2017,7 +2017,8 @@ LIBNETAPI_OBJ0 = lib/netapi/netapi.o \
 		 lib/netapi/samr.o \
 		 lib/netapi/sid.o \
 		 lib/netapi/share.o \
-		 lib/netapi/file.o
+		 lib/netapi/file.o \
+		 lib/netapi/shutdown.o
 
 LIBNETAPI_OBJ  = $(LIBNETAPI_OBJ0) $(LIBNET_OBJ) \
 		 $(LIBSMBCONF_OBJ) \
diff --git a/source3/lib/netapi/examples/Makefile.in b/source3/lib/netapi/examples/Makefile.in
index 090bc50..5adedac 100644
--- a/source3/lib/netapi/examples/Makefile.in
+++ b/source3/lib/netapi/examples/Makefile.in
@@ -62,7 +62,9 @@ PROGS = bin/getdc at EXEEXT@ \
 	bin/share_setinfo at EXEEXT@ \
 	bin/file_close at EXEEXT@ \
 	bin/file_getinfo at EXEEXT@ \
-	bin/file_enum at EXEEXT@
+	bin/file_enum at EXEEXT@ \
+	bin/shutdown_init at EXEEXT@ \
+	bin/shutdown_abort at EXEEXT@
 
 all: $(PROGS)
 
@@ -137,6 +139,8 @@ SHARESETINFO_OBJ = share/share_setinfo.o $(CMDLINE_OBJ)
 FILECLOSE_OBJ = file/file_close.o $(CMDLINE_OBJ)
 FILEGETINFO_OBJ = file/file_getinfo.o $(CMDLINE_OBJ)
 FILEENUM_OBJ = file/file_enum.o $(CMDLINE_OBJ)
+SHUTDOWNINIT_OBJ = shutdown/shutdown_init.o $(CMDLINE_OBJ)
+SHUTDOWNABORT_OBJ = shutdown/shutdown_abort.o $(CMDLINE_OBJ)
 
 bin/getdc at EXEEXT@: $(BINARY_PREREQS) $(GETDC_OBJ)
 	@echo Linking $@
@@ -322,6 +326,14 @@ bin/file_enum at EXEEXT@: $(BINARY_PREREQS) $(FILEENUM_OBJ)
 	@echo Linking $@
 	@$(CC) $(CCFLAGS) -o $@ $(FILEENUM_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS)
 
+bin/shutdown_init at EXEEXT@: $(BINARY_PREREQS) $(SHUTDOWNINIT_OBJ)
+	@echo Linking $@
+	@$(CC) $(CCFLAGS) -o $@ $(SHUTDOWNINIT_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS)
+
+bin/shutdown_abort at EXEEXT@: $(BINARY_PREREQS) $(SHUTDOWNABORT_OBJ)
+	@echo Linking $@
+	@$(CC) $(CCFLAGS) -o $@ $(SHUTDOWNABORT_OBJ) $(LDFLAGS) $(DYNEXP) $(CMDLINE_LIBS)
+
 clean:
 	-rm -f $(PROGS)
 	-rm -f core */*~ *~ \
diff --git a/source3/lib/netapi/examples/shutdown/shutdown_abort.c b/source3/lib/netapi/examples/shutdown/shutdown_abort.c
new file mode 100644
index 0000000..8f24a7a
--- /dev/null
+++ b/source3/lib/netapi/examples/shutdown/shutdown_abort.c
@@ -0,0 +1,76 @@
+/*
+ *  Unix SMB/CIFS implementation.
+ *  NetShutdownAbort query
+ *  Copyright (C) Guenther Deschner 2009
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <sys/types.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netapi.h>
+
+#include "common.h"
+
+int main(int argc, const char **argv)
+{
+	NET_API_STATUS status;
+	struct libnetapi_ctx *ctx = NULL;
+	const char *hostname = NULL;
+
+	poptContext pc;
+	int opt;
+
+	struct poptOption long_options[] = {
+		POPT_AUTOHELP
+		POPT_COMMON_LIBNETAPI_EXAMPLES
+		POPT_TABLEEND
+	};
+
+	status = libnetapi_init(&ctx);
+	if (status != 0) {
+		return status;
+	}
+
+	pc = poptGetContext("shutdown_abort", argc, argv, long_options, 0);
+
+	poptSetOtherOptionHelp(pc, "hostname");
+	while((opt = poptGetNextOpt(pc)) != -1) {
+	}
+
+	if (!poptPeekArg(pc)) {
+		poptPrintHelp(pc, stderr, 0);
+		goto out;
+	}
+	hostname = poptGetArg(pc);
+
+	/* NetShutdownAbort */
+
+	status = NetShutdownAbort(hostname);
+	if (status != 0) {
+		printf("NetShutdownAbort failed with: %s\n",
+			libnetapi_get_error_string(ctx, status));
+		goto out;
+	}
+
+ out:
+	libnetapi_free(ctx);
+	poptFreeContext(pc);
+
+	return status;
+}
diff --git a/source3/lib/netapi/examples/shutdown/shutdown_init.c b/source3/lib/netapi/examples/shutdown/shutdown_init.c
new file mode 100644
index 0000000..73d23bb
--- /dev/null
+++ b/source3/lib/netapi/examples/shutdown/shutdown_init.c
@@ -0,0 +1,94 @@
+/*
+ *  Unix SMB/CIFS implementation.
+ *  NetShutdownInit query
+ *  Copyright (C) Guenther Deschner 2009
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <sys/types.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <netapi.h>
+
+#include "common.h"
+
+int main(int argc, const char **argv)
+{
+	NET_API_STATUS status;
+	struct libnetapi_ctx *ctx = NULL;
+	const char *hostname = NULL;
+	const char *message = NULL;
+	uint32_t timeout = 30;
+
+	poptContext pc;
+	int opt;
+
+	struct poptOption long_options[] = {
+		POPT_AUTOHELP
+		POPT_COMMON_LIBNETAPI_EXAMPLES
+		POPT_TABLEEND
+	};
+
+	status = libnetapi_init(&ctx);
+	if (status != 0) {
+		return status;
+	}
+
+	pc = poptGetContext("shutdown_init", argc, argv, long_options, 0);
+
+	poptSetOtherOptionHelp(pc, "hostname message timeout");
+	while((opt = poptGetNextOpt(pc)) != -1) {
+	}
+
+	if (!poptPeekArg(pc)) {
+		poptPrintHelp(pc, stderr, 0);
+		goto out;
+	}
+	hostname = poptGetArg(pc);
+
+	if (!poptPeekArg(pc)) {
+		poptPrintHelp(pc, stderr, 0);
+		goto out;
+	}
+	message = poptGetArg(pc);
+
+	if (!poptPeekArg(pc)) {
+		poptPrintHelp(pc, stderr, 0);
+		goto out;
+	}
+	timeout = atoi(poptGetArg(pc));
+
+	/* NetShutdownInit */
+
+	status = NetShutdownInit(hostname,
+				 message,
+				 timeout,
+				 1, /* close apps */
+				 1); /* reboot */
+	if (status != 0) {
+		printf("NetShutdownInit failed with: %s\n",
+			libnetapi_get_error_string(ctx, status));
+		goto out;
+	}
+
+ out:
+	libnetapi_free(ctx);
+	poptFreeContext(pc);
+
+	return status;
+}
diff --git a/source3/lib/netapi/libnetapi.c b/source3/lib/netapi/libnetapi.c
index 043190a..6e36667 100644
--- a/source3/lib/netapi/libnetapi.c
+++ b/source3/lib/netapi/libnetapi.c
@@ -2353,3 +2353,91 @@ NET_API_STATUS NetFileEnum(const char * server_name /* [in] */,
 	return r.out.result;
 }
 
+/****************************************************************
+ NetShutdownInit
+****************************************************************/
+
+NET_API_STATUS NetShutdownInit(const char * server_name /* [in] */,
+			       const char * message /* [in] */,
+			       uint32_t timeout /* [in] */,
+			       uint8_t force_apps /* [in] */,
+			       uint8_t do_reboot /* [in] */)
+{
+	struct NetShutdownInit r;
+	struct libnetapi_ctx *ctx = NULL;
+	NET_API_STATUS status;
+	WERROR werr;
+
+	status = libnetapi_getctx(&ctx);
+	if (status != 0) {
+		return status;
+	}
+
+	/* In parameters */
+	r.in.server_name = server_name;
+	r.in.message = message;
+	r.in.timeout = timeout;
+	r.in.force_apps = force_apps;
+	r.in.do_reboot = do_reboot;
+
+	/* Out parameters */
+
+	if (DEBUGLEVEL >= 10) {
+		NDR_PRINT_IN_DEBUG(NetShutdownInit, &r);
+	}
+
+	if (LIBNETAPI_LOCAL_SERVER(server_name)) {
+		werr = NetShutdownInit_l(ctx, &r);
+	} else {
+		werr = NetShutdownInit_r(ctx, &r);
+	}
+
+	r.out.result = W_ERROR_V(werr);
+
+	if (DEBUGLEVEL >= 10) {
+		NDR_PRINT_OUT_DEBUG(NetShutdownInit, &r);
+	}
+
+	return r.out.result;
+}
+
+/****************************************************************
+ NetShutdownAbort
+****************************************************************/
+
+NET_API_STATUS NetShutdownAbort(const char * server_name /* [in] */)
+{
+	struct NetShutdownAbort r;
+	struct libnetapi_ctx *ctx = NULL;
+	NET_API_STATUS status;
+	WERROR werr;
+
+	status = libnetapi_getctx(&ctx);
+	if (status != 0) {
+		return status;
+	}
+
+	/* In parameters */
+	r.in.server_name = server_name;
+
+	/* Out parameters */
+
+	if (DEBUGLEVEL >= 10) {
+		NDR_PRINT_IN_DEBUG(NetShutdownAbort, &r);
+	}
+
+	if (LIBNETAPI_LOCAL_SERVER(server_name)) {
+		werr = NetShutdownAbort_l(ctx, &r);
+	} else {
+		werr = NetShutdownAbort_r(ctx, &r);
+	}
+
+	r.out.result = W_ERROR_V(werr);
+
+	if (DEBUGLEVEL >= 10) {
+		NDR_PRINT_OUT_DEBUG(NetShutdownAbort, &r);
+	}
+
+	return r.out.result;
+}
+
diff --git a/source3/lib/netapi/libnetapi.h b/source3/lib/netapi/libnetapi.h
index 1b84b75..3eab6e6 100644
--- a/source3/lib/netapi/libnetapi.h
+++ b/source3/lib/netapi/libnetapi.h
@@ -426,4 +426,18 @@ WERROR NetFileEnum_r(struct libnetapi_ctx *ctx,
 		     struct NetFileEnum *r);
 WERROR NetFileEnum_l(struct libnetapi_ctx *ctx,
 		     struct NetFileEnum *r);
+NET_API_STATUS NetShutdownInit(const char * server_name /* [in] */,
+			       const char * message /* [in] */,
+			       uint32_t timeout /* [in] */,
+			       uint8_t force_apps /* [in] */,
+			       uint8_t do_reboot /* [in] */);
+WERROR NetShutdownInit_r(struct libnetapi_ctx *ctx,
+			 struct NetShutdownInit *r);
+WERROR NetShutdownInit_l(struct libnetapi_ctx *ctx,
+			 struct NetShutdownInit *r);
+NET_API_STATUS NetShutdownAbort(const char * server_name /* [in] */);
+WERROR NetShutdownAbort_r(struct libnetapi_ctx *ctx,
+			  struct NetShutdownAbort *r);
+WERROR NetShutdownAbort_l(struct libnetapi_ctx *ctx,
+			  struct NetShutdownAbort *r);
 #endif /* __LIBNETAPI_LIBNETAPI__ */
diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h
index e8cd71e..e3ab03e 100644
--- a/source3/lib/netapi/netapi.h
+++ b/source3/lib/netapi/netapi.h
@@ -2445,6 +2445,42 @@ NET_API_STATUS NetFileEnum(const char * server_name /* [in] */,
 			   uint32_t *total_entries /* [out] [ref] */,
 			   uint32_t *resume_handle /* [in,out] [ref] */);
 
+/************************************************************//**
+ *
+ * NetShutdownInit
+ *
+ * @brief Start a machine shutdown
+ *
+ * @param[in] server_name The server name to connect to
+ * @param[in] message The message that is displayed before the shutdown
+ * @param[in] timeout The amount of seconds to wait until shutting down
+ * @param[in] force_apps Whether to close all applications before the shutdown
+ * @param[in] do_reboot Whether to reboot after the shutdown
+ * @return NET_API_STATUS
+ *
+ * example shutdown/shutdown_init.c
+ ***************************************************************/
+
+NET_API_STATUS NetShutdownInit(const char * server_name /* [in] */,
+			       const char * message /* [in] */,
+			       uint32_t timeout /* [in] */,
+			       uint8_t force_apps /* [in] */,
+			       uint8_t do_reboot /* [in] */);
+
+/************************************************************//**
+ *
+ * NetShutdownAbort
+ *
+ * @brief Abort an initiated machine shutdown
+ *
+ * @param[in] server_name The server name to connect to
+ * @return NET_API_STATUS
+ *
+ * example shutdown/shutdown_abort.c
+ ***************************************************************/
+
+NET_API_STATUS NetShutdownAbort(const char * server_name /* [in] */);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/source3/lib/netapi/shutdown.c b/source3/lib/netapi/shutdown.c
new file mode 100644
index 0000000..f9eb93b
--- /dev/null
+++ b/source3/lib/netapi/shutdown.c
@@ -0,0 +1,108 @@
+/*
+ *  Unix SMB/CIFS implementation.
+ *  NetApi Shutdown Support
+ *  Copyright (C) Guenther Deschner 2009
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 3 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "includes.h"
+
+#include "librpc/gen_ndr/libnetapi.h"
+#include "lib/netapi/netapi.h"
+#include "lib/netapi/netapi_private.h"
+#include "lib/netapi/libnetapi.h"
+
+/****************************************************************
+****************************************************************/
+
+WERROR NetShutdownInit_r(struct libnetapi_ctx *ctx,
+			 struct NetShutdownInit *r)
+{
+	WERROR werr;
+	NTSTATUS status;
+	struct rpc_pipe_client *pipe_cli = NULL;
+	struct lsa_StringLarge message;
+
+	werr = libnetapi_open_pipe(ctx, r->in.server_name,
+				   &ndr_table_initshutdown.syntax_id,
+				   &pipe_cli);
+	if (!W_ERROR_IS_OK(werr)) {
+		goto done;
+	}
+
+	init_lsa_StringLarge(&message, r->in.message);
+
+	status = rpccli_initshutdown_Init(pipe_cli, ctx,
+					  NULL,
+					  &message,
+					  r->in.timeout,
+					  r->in.force_apps,
+					  r->in.do_reboot,
+					  &werr);
+	if (!NT_STATUS_IS_OK(status)) {
+		werr = ntstatus_to_werror(status);
+		goto done;
+	}
+
+ done:
+	return werr;
+}
+
+/****************************************************************
+****************************************************************/
+
+WERROR NetShutdownInit_l(struct libnetapi_ctx *ctx,
+			 struct NetShutdownInit *r)
+{
+	LIBNETAPI_REDIRECT_TO_LOCALHOST(ctx, r, NetShutdownInit);
+}
+
+/****************************************************************
+****************************************************************/
+
+WERROR NetShutdownAbort_r(struct libnetapi_ctx *ctx,
+			  struct NetShutdownAbort *r)
+{
+	WERROR werr;
+	NTSTATUS status;
+	struct rpc_pipe_client *pipe_cli = NULL;
+
+	werr = libnetapi_open_pipe(ctx, r->in.server_name,
+				   &ndr_table_initshutdown.syntax_id,
+				   &pipe_cli);
+	if (!W_ERROR_IS_OK(werr)) {
+		goto done;
+	}
+
+	status = rpccli_initshutdown_Abort(pipe_cli, ctx,
+					   NULL,
+					   &werr);
+	if (!NT_STATUS_IS_OK(status)) {
+		werr = ntstatus_to_werror(status);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list