Merge branch 'master' of ssh://git.samba.org/data/git/samba
authorJelmer Vernooij <jelmer@samba.org>
Thu, 23 Oct 2008 19:59:15 +0000 (21:59 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 23 Oct 2008 19:59:15 +0000 (21:59 +0200)
lib/util/util_net.c
source3/lib/util_sock.c
source4/lib/tls/tls.c
source4/lib/torture/config.mk
source4/lib/torture/subunit.c [new file with mode: 0644]
source4/lib/torture/torture.c
source4/lib/torture/torture.h
source4/param/loadparm.c
source4/param/param.h
source4/torture/smbtorture.c

index eb5e2255c99df9a41044aef788d043ebe6746c8f..228393a2bbf8cf760b87c6ff4bb17584504b8e21 100644 (file)
@@ -408,3 +408,17 @@ bool is_address_any(const struct sockaddr *psa)
        }
        return false;
 }
+
+void set_sockaddr_port(struct sockaddr *psa, uint16_t port)
+{
+#if defined(HAVE_IPV6)
+       if (psa->sa_family == AF_INET6) {
+               ((struct sockaddr_in6 *)psa)->sin6_port = htons(port);
+       }
+#endif
+       if (psa->sa_family == AF_INET) {
+               ((struct sockaddr_in *)psa)->sin_port = htons(port);
+       }
+}
+
+
index 667dbf6dad7799e4fe6c684fe15ec77f4f0cfc8f..5721f412d6225bc1d6976d6a33d6699b6065efd5 100644 (file)
@@ -241,18 +241,6 @@ static int get_socket_port(int fd)
 }
 #endif
 
-void set_sockaddr_port(struct sockaddr_storage *psa, uint16 port)
-{
-#if defined(HAVE_IPV6)
-       if (psa->ss_family == AF_INET6) {
-               ((struct sockaddr_in6 *)psa)->sin6_port = htons(port);
-       }
-#endif
-       if (psa->ss_family == AF_INET) {
-               ((struct sockaddr_in *)psa)->sin_port = htons(port);
-       }
-}
-
 const char *client_name(int fd)
 {
        return get_peer_name(fd,false);
index f72aafe542fc271e0e67cc9a14b05ab3bed91c82..24e4632a491685c294b17b19130fe4eb5f024ff8 100644 (file)
@@ -357,11 +357,11 @@ struct tls_params *tls_initialise(TALLOC_CTX *mem_ctx, struct loadparm_context *
        struct tls_params *params;
        int ret;
        TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
-       const char *keyfile = private_path(tmp_ctx, lp_ctx, lp_tls_keyfile(lp_ctx));
-       const char *certfile = private_path(tmp_ctx, lp_ctx, lp_tls_certfile(lp_ctx));
-       const char *cafile = private_path(tmp_ctx, lp_ctx, lp_tls_cafile(lp_ctx));
-       const char *crlfile = private_path(tmp_ctx, lp_ctx, lp_tls_crlfile(lp_ctx));
-       const char *dhpfile = private_path(tmp_ctx, lp_ctx, lp_tls_dhpfile(lp_ctx));
+       const char *keyfile = lp_tls_keyfile(tmp_ctx, lp_ctx);
+       const char *certfile = lp_tls_certfile(tmp_ctx, lp_ctx);
+       const char *cafile = lp_tls_cafile(tmp_ctx, lp_ctx);
+       const char *crlfile = lp_tls_crlfile(tmp_ctx, lp_ctx);
+       const char *dhpfile = lp_tls_dhpfile(tmp_ctx, lp_ctx);
        void tls_cert_generate(TALLOC_CTX *, const char *, const char *, const char *);
        params = talloc(mem_ctx, struct tls_params);
        if (params == NULL) {
index 49e7b1a171d926a3eb9edde3bb5f3cc46bfef77e..8a7f2a3b6b19f43847e965997487e26b1d65409d 100644 (file)
@@ -9,6 +9,6 @@ torture_VERSION = 0.0.1
 torture_SOVERSION = 0
 
 PC_FILES += $(libtorturesrcdir)/torture.pc
-torture_OBJ_FILES = $(addprefix $(libtorturesrcdir)/, torture.o)
+torture_OBJ_FILES = $(addprefix $(libtorturesrcdir)/, torture.o subunit.o)
 
 PUBLIC_HEADERS += $(libtorturesrcdir)/torture.h
diff --git a/source4/lib/torture/subunit.c b/source4/lib/torture/subunit.c
new file mode 100644 (file)
index 0000000..40d9b97
--- /dev/null
@@ -0,0 +1,96 @@
+/* 
+   Unix SMB/CIFS implementation.
+   Samba utility functions
+   Copyright (C) Jelmer Vernooij <jelmer@samba.org> 2008
+   
+   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 "lib/torture/torture.h"
+
+static void subunit_init(struct torture_context *ctx) 
+{
+       /* FIXME: register segv and bus handler */
+}
+
+static void subunit_suite_start(struct torture_context *ctx,
+                               struct torture_suite *suite)
+{
+}
+
+static void subunit_print_testname(struct torture_context *ctx, 
+                                  struct torture_tcase *tcase,
+                                  struct torture_test *test)
+{
+       if (!strcmp(tcase->name, test->name)) {
+               printf("%s", test->name);
+       } else {
+               printf("%s.%s", tcase->name, test->name);
+       }
+}
+
+static void subunit_test_start(struct torture_context *ctx, 
+                              struct torture_tcase *tcase,
+                              struct torture_test *test)
+{
+       printf("test: ");
+       subunit_print_testname(ctx, tcase, test);       
+       printf("\n");
+}
+
+static void subunit_test_result(struct torture_context *context, 
+                               enum torture_result res, const char *reason)
+{
+       switch (res) {
+       case TORTURE_OK:
+               printf("success: ");
+               break;
+       case TORTURE_FAIL:
+               printf("failure: ");
+               break;
+       case TORTURE_ERROR:
+               printf("error: ");
+               break;
+       case TORTURE_SKIP:
+               printf("skip: ");
+               break;
+       }
+       subunit_print_testname(context, context->active_tcase, context->active_test);   
+
+       if (reason)
+               printf(" [\n%s\n]", reason);
+       printf("\n");
+}
+
+static void subunit_comment(struct torture_context *test,
+                           const char *comment)
+{
+       fprintf(stderr, "%s", comment);
+}
+
+static void subunit_warning(struct torture_context *test,
+                           const char *comment)
+{
+       fprintf(stderr, "WARNING!: %s\n", comment);
+}
+
+const struct torture_ui_ops torture_subunit_ui_ops = {
+       .init = subunit_init,
+       .comment = subunit_comment,
+       .warning = subunit_warning,
+       .test_start = subunit_test_start,
+       .test_result = subunit_test_result,
+       .suite_start = subunit_suite_start
+};
index ba7168f3fe25accd2bb0ca1758889bf94a325a9e..54ddc79be7f0de9c0f1fc8183e8dd8615d4790ee 100644 (file)
 #include "param/param.h"
 #include "system/filesys.h"
 
+/**
+ * Initialize a torture context
+ */
 struct torture_context *torture_context_init(struct event_context *event_ctx, 
-                                            const struct torture_ui_ops *ui_ops)
+                                                                                        const struct torture_ui_ops *ui_ops)
 {
        struct torture_context *torture = talloc_zero(event_ctx, 
                                                      struct torture_context);
@@ -59,6 +62,9 @@ _PUBLIC_ NTSTATUS torture_temp_dir(struct torture_context *tctx,
        return NT_STATUS_OK;
 }
 
+/**
+ * Comment on the status/progress of a test
+ */
 void torture_comment(struct torture_context *context, const char *comment, ...)
 {
        va_list ap;
@@ -75,6 +81,9 @@ void torture_comment(struct torture_context *context, const char *comment, ...)
        talloc_free(tmp);
 }
 
+/**
+ * Print a warning about the current test
+ */
 void torture_warning(struct torture_context *context, const char *comment, ...)
 {
        va_list ap;
@@ -91,6 +100,9 @@ void torture_warning(struct torture_context *context, const char *comment, ...)
        talloc_free(tmp);
 }
 
+/**
+ * Store the result of a torture test.
+ */
 void torture_result(struct torture_context *context, 
                    enum torture_result result, const char *fmt, ...)
 {
@@ -108,6 +120,9 @@ void torture_result(struct torture_context *context,
        va_end(ap);
 }
 
+/**
+ * Create a new torture suite
+ */
 struct torture_suite *torture_suite_create(TALLOC_CTX *ctx, const char *name)
 {
        struct torture_suite *suite = talloc_zero(ctx, struct torture_suite);
@@ -119,6 +134,9 @@ struct torture_suite *torture_suite_create(TALLOC_CTX *ctx, const char *name)
        return suite;
 }
 
+/**
+ * Set the setup() and teardown() functions for a testcase.
+ */
 void torture_tcase_set_fixture(struct torture_tcase *tcase, 
                bool (*setup) (struct torture_context *, void **),
                bool (*teardown) (struct torture_context *, void *))
@@ -140,6 +158,9 @@ static bool wrap_test_with_testcase_const(struct torture_context *torture_ctx,
        return fn(torture_ctx, tcase->data, test->data);
 }
 
+/**
+ * Add a test that uses const data to a testcase
+ */
 struct torture_test *torture_tcase_add_test_const(struct torture_tcase *tcase,
                const char *name,
                bool (*run) (struct torture_context *, const void *tcase_data,
@@ -160,7 +181,9 @@ struct torture_test *torture_tcase_add_test_const(struct torture_tcase *tcase,
        return test;
 }
 
-
+/**
+ * Add a new testcase
+ */
 bool torture_suite_init_tcase(struct torture_suite *suite, 
                              struct torture_tcase *tcase, 
                              const char *name)
@@ -189,6 +212,9 @@ struct torture_tcase *torture_suite_add_tcase(struct torture_suite *suite,
        return tcase;
 }
 
+/**
+ * Run a torture test suite.
+ */
 bool torture_run_suite(struct torture_context *context, 
                       struct torture_suite *suite)
 {
@@ -472,6 +498,9 @@ struct torture_tcase *torture_suite_add_simple_test(
        return tcase;
 }
 
+/**
+ * Add a child testsuite to a testsuite.
+ */
 bool torture_suite_add_suite(struct torture_suite *suite, 
                             struct torture_suite *child)
 {
@@ -486,7 +515,9 @@ bool torture_suite_add_suite(struct torture_suite *suite,
        return true;
 }
 
-
+/**
+ * Find the child testsuite with the specified name.
+ */
 struct torture_suite *torture_find_suite(struct torture_suite *parent, 
                                         const char *name)
 {
index 0f966a52d131532546474973652b79d6c8427caf..ea5cd709617c1d4f3611f2683d864cee0afee120 100644 (file)
@@ -393,4 +393,6 @@ bool torture_suite_init_tcase(struct torture_suite *suite,
 struct torture_context *torture_context_init(struct event_context *event_ctx, 
                                             const struct torture_ui_ops *ui_ops);
 
+extern const struct torture_ui_ops torture_subunit_ui_ops;
+
 #endif /* __TORTURE_UI_H__ */
index 0c29de64c348412bbbeaa67a88f7ee88cbe374b3..2808cb9f28cc7e6b30c5257d5fd263ca31421897 100644 (file)
@@ -616,11 +616,6 @@ _PUBLIC_ FN_GLOBAL_INTEGER(lp_kpasswd_port, kpasswd_port)
 _PUBLIC_ FN_GLOBAL_INTEGER(lp_web_port, web_port)
 _PUBLIC_ FN_GLOBAL_STRING(lp_swat_directory, swat_directory)
 _PUBLIC_ FN_GLOBAL_BOOL(lp_tls_enabled, tls_enabled)
-_PUBLIC_ FN_GLOBAL_STRING(lp_tls_keyfile, tls_keyfile)
-_PUBLIC_ FN_GLOBAL_STRING(lp_tls_certfile, tls_certfile)
-_PUBLIC_ FN_GLOBAL_STRING(lp_tls_cafile, tls_cafile)
-_PUBLIC_ FN_GLOBAL_STRING(lp_tls_crlfile, tls_crlfile)
-_PUBLIC_ FN_GLOBAL_STRING(lp_tls_dhpfile, tls_dhpfile)
 _PUBLIC_ FN_GLOBAL_STRING(lp_share_backend, szShareBackend)
 _PUBLIC_ FN_GLOBAL_STRING(lp_sam_url, szSAM_URL)
 _PUBLIC_ FN_GLOBAL_STRING(lp_idmap_url, szIDMAP_URL)
@@ -2638,3 +2633,29 @@ void lp_smbcli_session_options(struct loadparm_context *lp_ctx,
        options->ntlmv2_auth = lp_client_ntlmv2_auth(lp_ctx);
        options->plaintext_auth = lp_client_plaintext_auth(lp_ctx);
 }
+
+_PUBLIC_ const char *lp_tls_keyfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
+{
+       return private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_keyfile);
+}
+
+_PUBLIC_ const char *lp_tls_certfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
+{
+       return private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_certfile);
+}
+
+_PUBLIC_ const char *lp_tls_cafile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
+{
+       return private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_cafile);
+}
+
+_PUBLIC_ const char *lp_tls_crlfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
+{
+       return private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_crlfile);
+}
+
+_PUBLIC_ const char *lp_tls_dhpfile(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
+{
+       return private_path(mem_ctx, lp_ctx, lp_ctx->globals->tls_dhpfile);
+}
+
index 4c6e8b79a2283eabed1ed18ef3833445f04d6a22..9c20931186d50157791b6c1ad4cdd527a2419b53 100644 (file)
@@ -78,11 +78,11 @@ int lp_kpasswd_port(struct loadparm_context *);
 int lp_web_port(struct loadparm_context *);
 const char *lp_swat_directory(struct loadparm_context *);
 bool lp_tls_enabled(struct loadparm_context *);
-const char *lp_tls_keyfile(struct loadparm_context *);
-const char *lp_tls_certfile(struct loadparm_context *);
-const char *lp_tls_cafile(struct loadparm_context *);
-const char *lp_tls_crlfile(struct loadparm_context *);
-const char *lp_tls_dhpfile(struct loadparm_context *);
+const char *lp_tls_keyfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
+const char *lp_tls_certfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
+const char *lp_tls_cafile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
+const char *lp_tls_crlfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
+const char *lp_tls_dhpfile(TALLOC_CTX *mem_ctx, struct loadparm_context *);
 const char *lp_share_backend(struct loadparm_context *);
 const char *lp_sam_url(struct loadparm_context *);
 const char *lp_idmap_url(struct loadparm_context *);
index 8d195f1253512644f521a93c9db184d3ea3a8711..19f1d1ae35414e5bad476ee0e972f106119f190d 100644 (file)
@@ -365,80 +365,6 @@ const static struct torture_ui_ops std_ui_ops = {
        .test_result = simple_test_result
 };
 
-static void subunit_init(struct torture_context *ctx) 
-{
-       /* FIXME: register segv and bus handler */
-}
-
-static void subunit_suite_start(struct torture_context *ctx,
-                               struct torture_suite *suite)
-{
-}
-
-static void subunit_print_testname(struct torture_context *ctx, 
-                                  struct torture_tcase *tcase,
-                                  struct torture_test *test)
-{
-       if (!strcmp(tcase->name, test->name)) {
-               printf("%s", test->name);
-       } else {
-               printf("%s.%s", tcase->name, test->name);
-       }
-}
-
-static void subunit_test_start(struct torture_context *ctx, 
-                              struct torture_tcase *tcase,
-                              struct torture_test *test)
-{
-       printf("test: ");
-       subunit_print_testname(ctx, tcase, test);       
-       printf("\n");
-}
-
-static void subunit_test_result(struct torture_context *context, 
-                               enum torture_result res, const char *reason)
-{
-       switch (res) {
-       case TORTURE_OK:
-               printf("success: ");
-               break;
-       case TORTURE_FAIL:
-               printf("failure: ");
-               break;
-       case TORTURE_ERROR:
-               printf("error: ");
-               break;
-       case TORTURE_SKIP:
-               printf("skip: ");
-               break;
-       }
-       subunit_print_testname(context, context->active_tcase, context->active_test);   
-
-       if (reason)
-               printf(" [\n%s\n]", reason);
-       printf("\n");
-}
-
-static void subunit_comment(struct torture_context *test,
-                           const char *comment)
-{
-       fprintf(stderr, "%s", comment);
-}
-
-static void subunit_warning(struct torture_context *test,
-                           const char *comment)
-{
-       fprintf(stderr, "WARNING!: %s\n", comment);
-}
-
-const static struct torture_ui_ops subunit_ui_ops = {
-       .init = subunit_init,
-       .comment = subunit_comment,
-       .warning = subunit_warning,
-       .test_start = subunit_test_start,
-       .test_result = subunit_test_result,
-       .suite_start = subunit_suite_start
-};
 
 static void quiet_suite_start(struct torture_context *ctx,
                              struct torture_suite *suite)
@@ -693,7 +619,7 @@ int main(int argc,char *argv[])
        if (!strcmp(ui_ops_name, "simple")) {
                ui_ops = &std_ui_ops;
        } else if (!strcmp(ui_ops_name, "subunit")) {
-               ui_ops = &subunit_ui_ops;
+               ui_ops = &torture_subunit_ui_ops;
        } else if (!strcmp(ui_ops_name, "quiet")) {
                ui_ops = &quiet_ui_ops;
        } else {