2 Unix SMB/CIFS implementation.
4 A test server that only does logging.
6 Copyright (C) Andrew Tridgell 1992-2005
7 Copyright (C) Martin Pool 2002
8 Copyright (C) Jelmer Vernooij 2002
9 Copyright (C) James J Myers 2003 <myersjj@samba.org>
10 Copyright (C) Douglas Bagnall 2022
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 3 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 #include "lib/cmdline/cmdline.h"
29 #ifdef USING_CMDLINE_S3
30 #include "lib/util/debug_s3.h"
33 #define BINARY_NAME "test_s4_logging"
35 static int log_level = 1;
43 struct debug_class classes_table[] = {
46 {DBGC_PRINTDRIVERS, "printdrivers"},
47 {DBGC_LANMAN, "lanman"},
49 {DBGC_RPC_PARSE, "rpc_parse"},
50 {DBGC_RPC_SRV, "rpc_srv"},
51 {DBGC_RPC_CLI, "rpc_cli"},
52 {DBGC_PASSDB, "passdb"},
55 {DBGC_WINBIND, "winbind"},
57 {DBGC_IDMAP, "idmap"},
58 {DBGC_QUOTA, "quota"},
60 {DBGC_LOCKING, "locking"},
61 {DBGC_MSDFS, "msdfs"},
62 {DBGC_DMAPI, "dmapi"},
63 {DBGC_REGISTRY, "registry"},
64 {DBGC_SCAVENGER, "scavenger"},
67 {DBGC_TEVENT, "tevent"},
68 {DBGC_AUTH_AUDIT, "auth_audit"},
69 {DBGC_AUTH_AUDIT_JSON, "auth_json_audit"},
70 {DBGC_KERBEROS, "kerberos"},
71 {DBGC_DRS_REPL, "drs_repl"},
73 {DBGC_SMB2_CREDITS, "smb2_credits"},
74 {DBGC_DSDB_AUDIT, "dsdb_audit"},
75 {DBGC_DSDB_AUDIT_JSON, "dsdb_json_audit"},
76 {DBGC_DSDB_PWD_AUDIT, "dsdb_password_audit"},
77 {DBGC_DSDB_PWD_AUDIT_JSON, "dsdb_password_json_audit"},
78 {DBGC_DSDB_TXN_AUDIT, "dsdb_transaction_audit"},
79 {DBGC_DSDB_TXN_AUDIT_JSON, "dsdb_transaction_json_audit"},
80 {DBGC_DSDB_GROUP_AUDIT, "dsdb_group_audit"},
81 {DBGC_DSDB_GROUP_AUDIT_JSON, "dsdb_group_json_audit"},
85 static int log_all_classes(int level)
89 for (i = 0; i < ARRAY_SIZE(classes_table); i++) {
93 * we implicitly rely on these values staying in the
97 "expected '%s' class to have value %zu\n",
102 DEBUGC(c.dclass, level,
103 ("logging for '%s' [%d], at level %d\n",
104 c.name, c.dclass, level));
107 * That's it for the tests *here*. The invoker of this
108 * process will have set up an smb.conf that directs the
109 * output in particular ways, and will be looking to see that
117 static int init_daemon(TALLOC_CTX *mem_ctx,
125 struct poptOption long_options[] = {
130 .argInfo = POPT_ARG_INT,
132 .descrip = "log at this level",
133 .argDescrip = "LEVEL",
141 setproctitle(BINARY_NAME);
143 ok = samba_cmdline_init(mem_ctx,
144 SAMBA_CMDLINE_CONFIG_SERVER,
145 true /* require_smbconf */);
147 *error = "Failed to init cmdline parser!\n";
151 pc = samba_popt_get_context(BINARY_NAME,
157 *error = "Failed to setup popt context!\n";
158 return ENOTRECOVERABLE;
161 while((opt = poptGetNextOpt(pc)) != -1) {
162 fprintf(stderr, "\nInvalid option %s: %s\n\n",
163 poptBadOption(pc, 0), poptStrerror(opt));
164 poptPrintUsage(pc, stderr, 0);
170 #ifdef USING_CMDLINE_S3
177 int main(int argc, const char *argv[])
180 const char *error = NULL;
181 TALLOC_CTX *mem_ctx = talloc_stackframe();
182 if (mem_ctx == NULL) {
186 setproctitle_init(argc, discard_const(argv), environ);
188 rc = init_daemon(mem_ctx, argc, argv, &error);
190 fprintf(stderr, "error [%d]: %s\n", rc, error);
191 exit_daemon(error, rc);
194 rc = log_all_classes(log_level);
196 fprintf(stderr, "error in log_all_classes [%d]\n", rc);
197 exit_daemon("logging error", rc);
200 TALLOC_FREE(mem_ctx);