#include "passdb/lookup_sid.h"
#include "auth.h"
#include "../auth/auth_util.h"
-#include "lib/util/time_basic.h"
-
-struct smbd_impersonate_debug_state {
- int dbg_lvl;
- const char *name;
-};
-
-static bool smbd_impersonate_debug_before_use(struct tevent_context *wrap_ev,
- void *private_data,
- struct tevent_context *main_ev,
- const char *location)
-{
- struct smbd_impersonate_debug_state *state =
- (struct smbd_impersonate_debug_state *)private_data;
-
- DEBUG(state->dbg_lvl, (
- "%s: name[%s] wrap_ev[%p] state[%p] main_ev[%p] location[%s]\n",
- __func__, state->name, wrap_ev, state, main_ev, location));
-
- return true;
-}
-
-static void smbd_impersonate_debug_after_use(struct tevent_context *wrap_ev,
- void *private_data,
- struct tevent_context *main_ev,
- const char *location)
-{
- struct smbd_impersonate_debug_state *state =
- (struct smbd_impersonate_debug_state *)private_data;
-
- DEBUG(state->dbg_lvl, (
- "%s: name[%s] wrap_ev[%p] state[%p] main_ev[%p] location[%s]\n",
- __func__, state->name, wrap_ev, state, main_ev, location));
-}
-
-static void smbd_impersonate_debug_before_fd_handler(struct tevent_context *wrap_ev,
- void *private_data,
- struct tevent_context *main_ev,
- struct tevent_fd *fde,
- uint16_t flags,
- const char *handler_name,
- const char *location)
-{
- struct smbd_impersonate_debug_state *state =
- (struct smbd_impersonate_debug_state *)private_data;
-
- DEBUG(state->dbg_lvl, (
- "%s: name[%s] wrap_ev[%p] state[%p] main_ev[%p] "
- "fde[%p] flags[0x%X] handler_name[%s] location[%s]\n",
- __func__, state->name, wrap_ev, state, main_ev,
- fde, flags, handler_name, location));
-}
-
-static void smbd_impersonate_debug_after_fd_handler(struct tevent_context *wrap_ev,
- void *private_data,
- struct tevent_context *main_ev,
- struct tevent_fd *fde,
- uint16_t flags,
- const char *handler_name,
- const char *location)
-{
- struct smbd_impersonate_debug_state *state =
- (struct smbd_impersonate_debug_state *)private_data;
-
- DEBUG(state->dbg_lvl, (
- "%s: name[%s] wrap_ev[%p] state[%p] main_ev[%p] "
- "fde[%p] flags[0x%X] handler_name[%s] location[%s]\n",
- __func__, state->name, wrap_ev, state, main_ev,
- fde, flags, handler_name, location));
-}
-
-static void smbd_impersonate_debug_before_timer_handler(struct tevent_context *wrap_ev,
- void *private_data,
- struct tevent_context *main_ev,
- struct tevent_timer *te,
- struct timeval requested_time,
- struct timeval trigger_time,
- const char *handler_name,
- const char *location)
-{
- struct smbd_impersonate_debug_state *state =
- (struct smbd_impersonate_debug_state *)private_data;
- struct timeval_buf requested_buf;
- struct timeval_buf trigger_buf;
-
- DEBUG(state->dbg_lvl, (
- "%s: name[%s] wrap_ev[%p] state[%p] main_ev[%p] "
- "te[%p] requested_time[%s] trigger_time[%s] handler_name[%s] location[%s]\n",
- __func__, state->name, wrap_ev, state, main_ev, te,
- timeval_str_buf(&requested_time, true, true, &requested_buf),
- timeval_str_buf(&trigger_time, true, true, &trigger_buf),
- handler_name, location));
-}
-
-static void smbd_impersonate_debug_after_timer_handler(struct tevent_context *wrap_ev,
- void *private_data,
- struct tevent_context *main_ev,
- struct tevent_timer *te,
- struct timeval requested_time,
- struct timeval trigger_time,
- const char *handler_name,
- const char *location)
-{
- struct smbd_impersonate_debug_state *state =
- (struct smbd_impersonate_debug_state *)private_data;
- struct timeval_buf requested_buf;
- struct timeval_buf trigger_buf;
-
- DEBUG(state->dbg_lvl, (
- "%s: name[%s] wrap_ev[%p] state[%p] main_ev[%p] "
- "te[%p] requested_time[%s] trigger_time[%s] handler_name[%s] location[%s]\n",
- __func__, state->name, wrap_ev, state, main_ev, te,
- timeval_str_buf(&requested_time, true, true, &requested_buf),
- timeval_str_buf(&trigger_time, true, true, &trigger_buf),
- handler_name, location));
-}
-
-static void smbd_impersonate_debug_before_immediate_handler(struct tevent_context *wrap_ev,
- void *private_data,
- struct tevent_context *main_ev,
- struct tevent_immediate *im,
- const char *handler_name,
- const char *location)
-{
- struct smbd_impersonate_debug_state *state =
- (struct smbd_impersonate_debug_state *)private_data;
-
- DEBUG(state->dbg_lvl, (
- "%s: name[%s] wrap_ev[%p] state[%p] main_ev[%p] "
- "im[%p] handler_name[%s] location[%s]\n",
- __func__, state->name, wrap_ev, state, main_ev,
- im, handler_name, location));
-}
-
-static void smbd_impersonate_debug_after_immediate_handler(struct tevent_context *wrap_ev,
- void *private_data,
- struct tevent_context *main_ev,
- struct tevent_immediate *im,
- const char *handler_name,
- const char *location)
-{
- struct smbd_impersonate_debug_state *state =
- (struct smbd_impersonate_debug_state *)private_data;
-
- DEBUG(state->dbg_lvl, (
- "%s: name[%s] wrap_ev[%p] state[%p] main_ev[%p] "
- "im[%p] handler_name[%s] location[%s]\n",
- __func__, state->name, wrap_ev, state, main_ev,
- im, handler_name, location));
-}
-
-static void smbd_impersonate_debug_before_signal_handler(struct tevent_context *wrap_ev,
- void *private_data,
- struct tevent_context *main_ev,
- struct tevent_signal *se,
- int signum,
- int count,
- void *siginfo,
- const char *handler_name,
- const char *location)
-{
- struct smbd_impersonate_debug_state *state =
- (struct smbd_impersonate_debug_state *)private_data;
-
- DEBUG(state->dbg_lvl, (
- "%s: name[%s] wrap_ev[%p] state[%p] main_ev[%p] "
- "se[%p] signum[%d] count[%d] siginfo[%p] handler_name[%s] location[%s]\n",
- __func__, state->name, wrap_ev, state, main_ev,
- se, signum, count, siginfo, handler_name, location));
-}
-
-static void smbd_impersonate_debug_after_signal_handler(struct tevent_context *wrap_ev,
- void *private_data,
- struct tevent_context *main_ev,
- struct tevent_signal *se,
- int signum,
- int count,
- void *siginfo,
- const char *handler_name,
- const char *location)
-{
- struct smbd_impersonate_debug_state *state =
- (struct smbd_impersonate_debug_state *)private_data;
-
- DEBUG(state->dbg_lvl, (
- "%s: name[%s] wrap_ev[%p] state[%p] main_ev[%p] "
- "se[%p] signum[%d] count[%d] siginfo[%p] handler_name[%s] location[%s]\n",
- __func__, state->name, wrap_ev, state, main_ev,
- se, signum, count, siginfo, handler_name, location));
-}
-
-static const struct tevent_wrapper_ops smbd_impersonate_debug_ops = {
- .name = "smbd_impersonate_debug",
- .before_use = smbd_impersonate_debug_before_use,
- .after_use = smbd_impersonate_debug_after_use,
- .before_fd_handler = smbd_impersonate_debug_before_fd_handler,
- .after_fd_handler = smbd_impersonate_debug_after_fd_handler,
- .before_timer_handler = smbd_impersonate_debug_before_timer_handler,
- .after_timer_handler = smbd_impersonate_debug_after_timer_handler,
- .before_immediate_handler = smbd_impersonate_debug_before_immediate_handler,
- .after_immediate_handler = smbd_impersonate_debug_after_immediate_handler,
- .before_signal_handler = smbd_impersonate_debug_before_signal_handler,
- .after_signal_handler = smbd_impersonate_debug_after_signal_handler,
-};
-
-struct tevent_context *_smbd_impersonate_debug_create(struct tevent_context *main_ev,
- const char *name,
- int dbg_lvl,
- const char *location)
-{
- struct tevent_context *wrap_ev = NULL;
- struct smbd_impersonate_debug_state *state = NULL;
-
- wrap_ev = tevent_context_wrapper_create(main_ev,
- main_ev,
- &smbd_impersonate_debug_ops,
- &state,
- struct smbd_impersonate_debug_state);
- if (wrap_ev == NULL) {
- return NULL;
- }
- state->name = name;
- state->dbg_lvl = dbg_lvl;
- DEBUG(state->dbg_lvl, (
- "%s: name[%s] wrap_ev[%p] state[%p] main_ev[%p] location[%s]\n",
- __func__, state->name, wrap_ev, state, main_ev, location));
-
- return wrap_ev;
-}
/* what user is current? */
extern struct current_user current_user;