/* Message handler callback that displays the PID and a string on stdout */
-static void print_pid_string_cb(int msg_type, struct process_id pid, void *buf, size_t len)
+static void print_pid_string_cb(int msg_type, struct process_id pid, void *buf,
+ size_t len, void *private_data)
{
printf("PID %u: %.*s", (unsigned int)procid_to_pid(&pid),
(int)len, (const char *)buf);
/* Message handler callback that displays a string on stdout */
static void print_string_cb(int msg_type, struct process_id pid,
- void *buf, size_t len)
+ void *buf, size_t len, void *private_data)
{
printf("%.*s", (int)len, (const char *)buf);
num_replies++;
/* Ping a samba daemon process */
-static void pong_cb(int msg_type, struct process_id pid, void *buf, size_t len)
+static void pong_cb(int msg_type, struct process_id pid, void *buf,
+ size_t len, void *private_data)
{
char *src_string = procid_str(NULL, &pid);
printf("PONG from pid %s\n", src_string);
if (!send_message(pid, MSG_PING, NULL, 0, False))
return False;
- message_register(MSG_PONG, pong_cb);
+ message_register(MSG_PONG, pong_cb, NULL);
wait_replies(procid_to_pid(&pid) == 0);
/* Return the profiling level */
-static void profilelevel_cb(int msg_type, struct process_id pid, void *buf, size_t len)
+static void profilelevel_cb(int msg_type, struct process_id pid, void *buf,
+ size_t len, void *private_data)
{
int level;
const char *s;
}
static void profilelevel_rqst(int msg_type, struct process_id pid,
- void *buf, size_t len)
+ void *buf, size_t len, void *private_data)
{
int v = 0;
if (!send_message(pid, MSG_REQ_PROFILELEVEL, NULL, 0, False))
return False;
- message_register(MSG_PROFILELEVEL, profilelevel_cb);
- message_register(MSG_REQ_PROFILELEVEL, profilelevel_rqst);
+ message_register(MSG_PROFILELEVEL, profilelevel_cb, NULL);
+ message_register(MSG_REQ_PROFILELEVEL, profilelevel_rqst, NULL);
wait_replies(procid_to_pid(&pid) == 0);
if (!send_message(pid, MSG_REQ_DEBUGLEVEL, NULL, 0, False))
return False;
- message_register(MSG_DEBUGLEVEL, print_pid_string_cb);
+ message_register(MSG_DEBUGLEVEL, print_pid_string_cb, NULL);
wait_replies(procid_to_pid(&pid) == 0);
return False;
}
- message_register(MSG_POOL_USAGE, print_string_cb);
+ message_register(MSG_POOL_USAGE, print_string_cb, NULL);
/* Send a message and register our interest in a reply */
5 times. */
for (retry = 0; retry < 5; retry++) {
- int err;
TDB_DATA d;
+ char buf[4];
+
ZERO_STRUCT(d);
+
+ SIVAL(buf, 0, time(NULL));
+ d.dptr = buf;
+ d.dsize = 4;
+
tdb_store_bystring(tdb, "WINBINDD_OFFLINE", d, TDB_INSERT);
ret = send_message(pid, MSG_WINBIND_OFFLINE, NULL, 0, False);
/* Check that the entry "WINBINDD_OFFLINE" still exists. */
- tdb->ecode = 0;
d = tdb_fetch_bystring( tdb, "WINBINDD_OFFLINE" );
-
- /* As this is a key with no data we don't need to free, we
- check for existence by looking at tdb_err. */
-
- err = tdb_error(tdb);
-
- if (err == TDB_ERR_NOEXIST) {
+
+ if (!d.dptr || d.dsize != 4) {
+ SAFE_FREE(d.dptr);
DEBUG(10,("do_winbind_offline: offline state not set - retrying.\n"));
} else {
+ SAFE_FREE(d.dptr);
break;
}
}
return ret;
}
+static BOOL do_winbind_onlinestatus(const struct process_id pid,
+ const int argc, const char **argv)
+{
+ struct process_id myid;
+
+ myid = pid_to_procid(sys_getpid());
+
+ if (argc != 1) {
+ fprintf(stderr, "Usage: smbcontrol winbindd onlinestatus\n");
+ return False;
+ }
+
+ message_register(MSG_WINBIND_ONLINESTATUS, print_pid_string_cb, NULL);
+
+ if (!send_message(pid, MSG_WINBIND_ONLINESTATUS, &myid, sizeof(myid), False))
+ return False;
+
+ wait_replies(procid_to_pid(&pid) == 0);
+
+ /* No replies were received within the timeout period */
+
+ if (num_replies == 0)
+ printf("No replies received\n");
+
+ message_deregister(MSG_WINBIND_ONLINESTATUS);
+
+ return num_replies;
+}
+
+
static BOOL do_reload_config(const struct process_id pid,
const int argc, const char **argv)
{
{ "nodestatus", do_nodestatus, "Ask nmbd to do a node status request"},
{ "online", do_winbind_online, "Ask winbind to go into online state"},
{ "offline", do_winbind_offline, "Ask winbind to go into offline state"},
+ { "onlinestatus", do_winbind_onlinestatus, "Request winbind online status"},
{ "noop", do_noop, "Do nothing" },
{ NULL }
};