source4/smbd: replace DEBUG( with DBG_
authorGary Lockyer <gary@catalyst.net.nz>
Sun, 10 Sep 2017 23:39:39 +0000 (11:39 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 19 Oct 2017 03:33:10 +0000 (05:33 +0200)
Update the debug logging to use the currently preferred debug macros

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
source4/smbd/process_model.c
source4/smbd/process_single.c
source4/smbd/process_standard.c
source4/smbd/server.c
source4/smbd/service.c
source4/smbd/service_named_pipe.c
source4/smbd/service_stream.c
source4/smbd/service_task.c

index 20a130b70c3d5dcd735a40f899269741cdc9db31..b75efac9845601994b83c36cf934d3074c83ad54 100644 (file)
@@ -57,7 +57,7 @@ _PUBLIC_ const struct model_ops *process_model_startup(const char *model)
 
        m = process_model_byname(model);
        if (m == NULL) {
-               DEBUG(0,("Unknown process model '%s'\n", model));
+               DBG_ERR("Unknown process model '%s'\n", model);
                exit(-1);
        }
 
@@ -79,8 +79,7 @@ _PUBLIC_ NTSTATUS register_process_model(const struct model_ops *ops)
 {
        if (process_model_byname(ops->name) != NULL) {
                /* its already registered! */
-               DEBUG(0,("PROCESS_MODEL '%s' already registered\n", 
-                        ops->name));
+               DBG_ERR("PROCESS_MODEL '%s' already registered\n", ops->name);
                return NT_STATUS_OBJECT_NAME_COLLISION;
        }
 
@@ -94,7 +93,7 @@ _PUBLIC_ NTSTATUS register_process_model(const struct model_ops *ops)
 
        num_models++;
 
-       DEBUG(3,("PROCESS_MODEL '%s' registered\n", ops->name));
+       DBG_NOTICE("PROCESS_MODEL '%s' registered\n", ops->name);
 
        return NT_STATUS_OK;
 }
index 1027415a5550ce0b7228c0b816f07a59edc76a59..1859c96809e68d9739377458e14575b4a60122ed 100644 (file)
@@ -56,7 +56,8 @@ static void single_accept_connection(struct tevent_context *ev,
        /* accept an incoming connection. */
        status = socket_accept(listen_socket, &connected_socket);
        if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(0,("single_accept_connection: accept: %s\n", nt_errstr(status)));
+               DBG_ERR("single_accept_connection: accept: %s\n",
+                       nt_errstr(status));
                /* this looks strange, but is correct. 
 
                   We can only be here if woken up from select, due to
@@ -121,7 +122,7 @@ static void single_terminate(struct tevent_context *ev,
                             const char *reason,
                             void *process_context)
 {
-       DEBUG(3,("single_terminate: reason[%s]\n",reason));
+       DBG_NOTICE("single_terminate: reason[%s]\n",reason);
 }
 
 /* called to set a title of a task or connection */
index 74b2a05fd018af86cf4700f8ed9a291521bd51a8..677345f2c8303aff7ca259b2204b202feb97198a 100644 (file)
@@ -74,11 +74,11 @@ static void sigterm_signal_handler(struct tevent_context *ev,
                 * We're the process group leader, send
                 * SIGTERM to our process group.
                 */
-               DEBUG(0,("SIGTERM: killing children\n"));
+               DBG_ERR("SIGTERM: killing children\n");
                kill(-getpgrp(), SIGTERM);
        }
 #endif
-       DEBUG(0,("Exiting pid %u on SIGTERM\n", (unsigned int)getpid()));
+       DBG_ERR("Exiting pid %u on SIGTERM\n", (unsigned int)getpid());
        talloc_free(ev);
        exit(127);
 }
@@ -89,7 +89,7 @@ static void sigterm_signal_handler(struct tevent_context *ev,
 static void standard_pipe_handler(struct tevent_context *event_ctx, struct tevent_fd *fde, 
                                  uint16_t flags, void *private_data)
 {
-       DEBUG(10,("Child %d exiting\n", (int)getpid()));
+       DBG_DEBUG("Child %d exiting\n", (int)getpid());
        talloc_free(event_ctx);
        exit(0);
 }
@@ -130,16 +130,16 @@ static void standard_child_pipe_handler(struct tevent_context *ev,
                         * SIGCHLD in the standard
                         * process model.
                         */
-                       DEBUG(0, ("Error in waitpid() unexpectedly got ECHILD "
-                                 "for child %d (%s) - %s, someone has set SIGCHLD "
-                                 "to SIG_IGN!\n",
-                                 (int)state->pid, state->name,
-                                 strerror(errno)));
+                       DBG_ERR("Error in waitpid() unexpectedly got ECHILD "
+                               "for child %d (%s) - %s, someone has set SIGCHLD "
+                               "to SIG_IGN!\n",
+                               (int)state->pid, state->name,
+                               strerror(errno));
                        TALLOC_FREE(state);
                        return;
                }
-               DEBUG(0, ("Error in waitpid() for child %d (%s) - %s \n",
-                         (int)state->pid, state->name, strerror(errno)));
+               DBG_ERR("Error in waitpid() for child %d (%s) - %s \n",
+                       (int)state->pid, state->name, strerror(errno));
                if (errno == 0) {
                        errno = ECHILD;
                }
@@ -154,8 +154,8 @@ static void standard_child_pipe_handler(struct tevent_context *ev,
                }
        } else if (WIFSIGNALED(status)) {
                status = WTERMSIG(status);
-               DEBUG(0, ("Child %d (%s) terminated with signal %d\n",
-                         (int)state->pid, state->name, status));
+               DBG_ERR("Child %d (%s) terminated with signal %d\n",
+                       (int)state->pid, state->name, status);
        }
        TALLOC_FREE(state);
        return;
@@ -193,8 +193,8 @@ static struct standard_child_state *setup_standard_child_pipe(struct tevent_cont
 
        ret = pipe(parent_child_pipe);
        if (ret == -1) {
-               DEBUG(0, ("Failed to create parent-child pipe to handle "
-                         "SIGCHLD to track new process for socket\n"));
+               DBG_ERR("Failed to create parent-child pipe to handle "
+                       "SIGCHLD to track new process for socket\n");
                TALLOC_FREE(state);
                return NULL;
        }
@@ -254,8 +254,8 @@ static void standard_accept_connection(
        /* accept an incoming connection. */
        status = socket_accept(sock, &sock2);
        if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(0,("standard_accept_connection: accept: %s\n",
-                       nt_errstr(status)));
+               DBG_DEBUG("standard_accept_connection: accept: %s\n",
+                         nt_errstr(status));
                /* this looks strange, but is correct. We need to throttle
                 * things until the system clears enough resources to handle
                 * this new socket
index 66f2794a38a3760509a3544d9b5db1c59cb10318..eef0f7bf3d20a5425e50f604d64000b9b938bb8f 100644 (file)
@@ -85,8 +85,8 @@ static void recursive_delete(const char *path)
                        continue;
                }
                if (unlink(fname) != 0) {
-                       DEBUG(0,("Unabled to delete '%s' - %s\n",
-                                fname, strerror(errno)));
+                       DBG_ERR("Unabled to delete '%s' - %s\n",
+                                fname, strerror(errno));
                        smb_panic("unable to cleanup tmp files");
                }
                talloc_free(fname);
@@ -125,11 +125,11 @@ static void sig_term(int sig)
                 * We're the process group leader, send
                 * SIGTERM to our process group.
                 */
-               DEBUG(0,("SIGTERM: killing children\n"));
+               DBG_ERR("SIGTERM: killing children\n");
                kill(-getpgrp(), SIGTERM);
        }
 #endif
-       DEBUG(0,("Exiting pid %d on SIGTERM\n", (int)getpid()));
+       DBG_ERR("Exiting pid %d on SIGTERM\n", (int)getpid());
        exit(127);
 }
 
@@ -141,7 +141,7 @@ static void sigterm_signal_handler(struct tevent_context *ev,
        struct server_state *state = talloc_get_type_abort(
                 private_data, struct server_state);
 
-       DEBUG(10,("Process %s got SIGTERM\n", state->binary_name));
+       DBG_DEBUG("Process %s got SIGTERM\n", state->binary_name);
        TALLOC_FREE(state);
        sig_term(SIGTERM);
 }
@@ -189,12 +189,12 @@ static void server_stdin_handler(struct tevent_context *event_ctx,
                private_data, struct server_state);
        uint8_t c;
        if (read(0, &c, 1) == 0) {
-               DEBUG(0,("%s: EOF on stdin - PID %d terminating\n",
-                               state->binary_name, (int)getpid()));
+               DBG_ERR("%s: EOF on stdin - PID %d terminating\n",
+                       state->binary_name, (int)getpid());
 #if HAVE_GETPGRP
                if (getpgrp() == getpid()) {
-                       DEBUG(0,("Sending SIGTERM from pid %d\n",
-                               (int)getpid()));
+                       DBG_ERR("Sending SIGTERM from pid %d\n",
+                               (int)getpid());
                        kill(-getpgrp(), SIGTERM);
                }
 #endif
@@ -212,12 +212,12 @@ _NORETURN_ static void max_runtime_handler(struct tevent_context *ev,
 {
        struct server_state *state = talloc_get_type_abort(
                private_data, struct server_state);
-       DEBUG(0,("%s: maximum runtime exceeded - "
+       DBG_ERR("%s: maximum runtime exceeded - "
                "terminating PID %d at %llu, current ts: %llu\n",
                 state->binary_name,
                (int)getpid(),
                (unsigned long long)t.tv_sec,
-               (unsigned long long)time(NULL)));
+               (unsigned long long)time(NULL));
        TALLOC_FREE(state);
        exit(0);
 }
@@ -471,7 +471,7 @@ static int binary_smbd_main(const char *binary_name,
        }
 
        if (opt_daemon) {
-               DEBUG(3,("Becoming a daemon.\n"));
+               DBG_NOTICE("Becoming a daemon.\n");
                become_daemon(true, false, false);
        }
 
@@ -571,10 +571,10 @@ static int binary_smbd_main(const char *binary_name,
 
        if (max_runtime) {
                struct tevent_timer *te;
-               DEBUG(0,("%s PID %d was called with maxruntime %d - "
+               DBG_ERR("%s PID %d was called with maxruntime %d - "
                        "current ts %llu\n",
                        binary_name, (int)getpid(),
-                       max_runtime, (unsigned long long) time(NULL)));
+                       max_runtime, (unsigned long long) time(NULL));
                te = tevent_add_timer(state->event_ctx, state->event_ctx,
                                 timeval_current_ofs(max_runtime, 0),
                                 max_runtime_handler,
@@ -625,7 +625,7 @@ static int binary_smbd_main(const char *binary_name,
                        NT_STATUS_V(status));
        }
 
-       DEBUG(0,("%s: using '%s' process model\n", binary_name, model));
+       DBG_ERR("%s: using '%s' process model\n", binary_name, model);
 
        {
                int child_pipe[2];
index 9a77ca80b706986433e51c0d5a9b68599d8593dd..e7808727a23230c333a947bdbb8836a4097d1b88 100644 (file)
@@ -91,13 +91,14 @@ NTSTATUS server_service_startup(struct tevent_context *event_ctx,
        const struct model_ops *model_ops;
 
        if (!server_services) {
-               DEBUG(0,("server_service_startup: no endpoint servers configured\n"));
+               DBG_ERR("server_service_startup: "
+                       "no endpoint servers configured\n");
                return NT_STATUS_INVALID_PARAMETER;
        }
 
        model_ops = process_model_startup(model);
        if (!model_ops) {
-               DEBUG(0,("process_model_startup('%s') failed\n", model));
+               DBG_ERR("process_model_startup('%s') failed\n", model);
                return NT_STATUS_INTERNAL_ERROR;
        }
 
@@ -107,8 +108,8 @@ NTSTATUS server_service_startup(struct tevent_context *event_ctx,
                status = server_service_init(server_services[i], event_ctx,
                                             lp_ctx, model_ops, from_parent_fd);
                if (!NT_STATUS_IS_OK(status)) {
-                       DEBUG(0,("Failed to start service '%s' - %s\n", 
-                                server_services[i], nt_errstr(status)));
+                       DBG_ERR("Failed to start service '%s' - %s\n",
+                                server_services[i], nt_errstr(status));
                }
                NT_STATUS_NOT_OK_RETURN(status);
        }
index 744f94217176e7bc8de2539dae8d6269aef24190..d054c6fdce68b43b263bbf18d57dc41813e572e2 100644 (file)
@@ -122,13 +122,13 @@ static void named_pipe_accept_done(struct tevent_req *subreq)
        conn->local_address = talloc_move(conn, &local_server_addr);
        conn->remote_address = talloc_move(conn, &remote_client_addr);
 
-       DEBUG(10, ("Accepted npa connection from %s. "
-                  "Client: %s (%s). Server: %s (%s)\n",
-                  tsocket_address_string(conn->remote_address, tmp_ctx),
-                  local_server_name,
-                  tsocket_address_string(local_server_addr, tmp_ctx),
-                  remote_client_name,
-                  tsocket_address_string(remote_client_addr, tmp_ctx)));
+       DBG_DEBUG("Accepted npa connection from %s. "
+                 "Client: %s (%s). Server: %s (%s)\n",
+                 tsocket_address_string(conn->remote_address, tmp_ctx),
+                 local_server_name,
+                 tsocket_address_string(local_server_addr, tmp_ctx),
+                 remote_client_name,
+                 tsocket_address_string(remote_client_addr, tmp_ctx));
 
        conn->session_info = auth_session_info_from_transport(conn, session_info_transport,
                                                              conn->lp_ctx,
@@ -145,8 +145,7 @@ static void named_pipe_accept_done(struct tevent_req *subreq)
        conn->private_data = pipe_sock->private_data;
        conn->ops->accept_connection(conn);
 
-       DEBUG(10, ("named pipe connection [%s] established\n",
-                  conn->ops->name));
+       DBG_DEBUG("named pipe connection [%s] established\n", conn->ops->name);
 
        talloc_free(tmp_ctx);
        return;
@@ -208,8 +207,8 @@ NTSTATUS tstream_setup_named_pipe(TALLOC_CTX *mem_ctx,
 
        if (!directory_create_or_exist(lpcfg_ncalrpc_dir(lp_ctx), 0755)) {
                status = map_nt_error_from_unix_common(errno);
-               DEBUG(0,(__location__ ": Failed to create ncalrpc pipe directory '%s' - %s\n",
-                        lpcfg_ncalrpc_dir(lp_ctx), nt_errstr(status)));
+               DBG_ERR("Failed to create ncalrpc pipe directory '%s' - %s\n",
+                       lpcfg_ncalrpc_dir(lp_ctx), nt_errstr(status));
                goto fail;
        }
 
@@ -220,8 +219,8 @@ NTSTATUS tstream_setup_named_pipe(TALLOC_CTX *mem_ctx,
 
        if (!directory_create_or_exist_strict(dirname, geteuid(), 0700)) {
                status = map_nt_error_from_unix_common(errno);
-               DEBUG(0,(__location__ ": Failed to create stream pipe directory '%s' - %s\n",
-                        dirname, nt_errstr(status)));
+               DBG_ERR("Failed to create stream pipe directory '%s' - %s\n",
+                       dirname, nt_errstr(status));
                goto fail;
        }
 
index 63318c686b0534dcb973021e3df9fc996aa36d15..545cd4315b3cdba5e075288ee445f27379cd8198 100644 (file)
@@ -62,9 +62,9 @@ void stream_terminate_connection(struct stream_connection *srv_conn, const char
        if (!reason) reason = "unknown reason";
 
        if (srv_conn->processing) {
-               DEBUG(3,("Terminating connection deferred - '%s'\n", reason));
+               DBG_NOTICE("Terminating connection deferred - '%s'\n", reason);
        } else {
-               DEBUG(3,("Terminating connection - '%s'\n", reason));
+               DBG_NOTICE("Terminating connection - '%s'\n", reason);
        }
 
        srv_conn->terminate = reason;
@@ -178,7 +178,7 @@ static void stream_new_connection(struct tevent_context *ev,
 
        srv_conn = talloc_zero(ev, struct stream_connection);
        if (!srv_conn) {
-               DEBUG(0,("talloc(mem_ctx, struct stream_connection) failed\n"));
+               DBG_ERR("talloc(mem_ctx, struct stream_connection) failed\n");
                return;
        }
 
@@ -366,9 +366,9 @@ NTSTATUS stream_setup_socket(TALLOC_CTX *mem_ctx,
        }
 
        if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(0,("Failed to listen on %s:%u - %s\n",
+               DBG_ERR("Failed to listen on %s:%u - %s\n",
                         sock_addr, port ? (unsigned int)(*port) : 0,
-                        nt_errstr(status)));
+                        nt_errstr(status));
                talloc_free(stream_socket);
                return status;
        }
@@ -382,7 +382,7 @@ NTSTATUS stream_setup_socket(TALLOC_CTX *mem_ctx,
                            TEVENT_FD_READ,
                            stream_accept_handler, stream_socket);
        if (!fde) {
-               DEBUG(0,("Failed to setup fd event\n"));
+               DBG_ERR("Failed to setup fd event\n");
                talloc_free(stream_socket);
                return NT_STATUS_NO_MEMORY;
        }
index 1d33a43e919cea5ead23c10dcf4296cacacf53c4..729a1094e7528b8e09517b70a67568e687bc9090 100644 (file)
@@ -32,7 +32,11 @@ void task_server_terminate(struct task_server *task, const char *reason, bool fa
 {
        struct tevent_context *event_ctx = task->event_ctx;
        const struct model_ops *model_ops = task->model_ops;
-       DEBUG(0,("task_server_terminate: [%s]\n", reason));
+       if (fatal) {
+               DBG_ERR("task_server_terminate: [%s]\n", reason);
+       } else {
+               DBG_NOTICE("task_server_terminate: [%s]\n", reason);
+       }
 
        if (fatal && task->msg_ctx != NULL) {
                struct dcerpc_binding_handle *irpc_handle;