diff options
Diffstat (limited to 'source/utils/smbcontrol.c')
-rw-r--r-- | source/utils/smbcontrol.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/source/utils/smbcontrol.c b/source/utils/smbcontrol.c index c5462ea1fb7..631bcf9bb90 100644 --- a/source/utils/smbcontrol.c +++ b/source/utils/smbcontrol.c @@ -32,6 +32,7 @@ static struct { {"profilelevel", MSG_REQ_PROFILELEVEL}, {"debuglevel", MSG_REQ_DEBUGLEVEL}, {"printer-notify", MSG_PRINTER_NOTIFY}, + {"close-share", MSG_SMB_FORCE_TDIS}, {NULL, -1} }; @@ -69,7 +70,7 @@ a useful function for testing the message system void pong_function(int msg_type, pid_t src, void *buf, size_t len) { pong_count++; - printf("PONG from PID %d\n",src); + printf("PONG from PID %u\n",(unsigned int)src); } /**************************************************************************** @@ -82,7 +83,7 @@ void debuglevel_function(int msg_type, pid_t src, void *buf, size_t len) memcpy(debuglevel_class, buf, len); - printf("Current debug level of PID %d is %d ",src, debuglevel_class[0]); + printf("Current debug level of PID %u is %d ",(unsigned int)src, debuglevel_class[0]); for (i=1;i<DBGC_LAST;i++) if (debuglevel_class[i]) printf("%s:%d ", debug_classname_from_index(i), debuglevel_class[i]); @@ -112,9 +113,9 @@ void profilelevel_function(int msg_type, pid_t src, void *buf, size_t len) s = "count and time"; break; } - printf("Profiling %s on PID %d\n",s,src); + printf("Profiling %s on PID %u\n",s,(unsigned int)src); } else { - printf("Profiling not available on PID %d\n",src); + printf("Profiling not available on PID %u\n",(unsigned int)src); } got_level = True; } @@ -127,7 +128,7 @@ static BOOL send_message(char *dest, int msg_type, void *buf, int len, BOOL dupl pid_t pid; TDB_CONTEXT *the_tdb; - the_tdb = tdb_open(lock_path("connections.tdb"), 0, 0, O_RDONLY, 0); + the_tdb = tdb_open_log(lock_path("connections.tdb"), 0, 0, O_RDONLY, 0); if (!the_tdb) { fprintf(stderr,"Failed to open connections database in send_message.\n"); return False; @@ -171,7 +172,7 @@ static int parse_type(char *mtype) /**************************************************************************** do command ****************************************************************************/ -static BOOL do_command(char *dest, char *msg_name, char *params[]) +static BOOL do_command(char *dest, char *msg_name, char **params) { int i, n, v; int mtype; @@ -186,7 +187,7 @@ static BOOL do_command(char *dest, char *msg_name, char *params[]) switch (mtype) { case MSG_DEBUG: - if (!params[0]) { + if (!params || !params[0]) { fprintf(stderr,"MSG_DEBUG needs a parameter\n"); return(False); } @@ -200,7 +201,7 @@ static BOOL do_command(char *dest, char *msg_name, char *params[]) break; case MSG_PROFILE: - if (!params[0]) { + if (!params || !params[0]) { fprintf(stderr,"MSG_PROFILE needs a parameter\n"); return(False); } @@ -271,7 +272,7 @@ static BOOL do_command(char *dest, char *msg_name, char *params[]) fprintf(stderr,"printer-notify can only be sent to smbd\n"); return(False); } - if (!params[0]) { + if (!params || !params[0]) { fprintf(stderr, "printer-notify needs a printer name\n"); return (False); } @@ -279,12 +280,25 @@ static BOOL do_command(char *dest, char *msg_name, char *params[]) strlen(params[0]) + 1, False); break; + case MSG_SMB_FORCE_TDIS: + if (!strequal(dest, "smbd")) { + fprintf(stderr,"close-share can only be sent to smbd\n"); + return(False); + } + if (!params || !params[0]) { + fprintf(stderr, "close-share needs a share name or '*'\n"); + return (False); + } + retval = send_message(dest, MSG_SMB_FORCE_TDIS, params[0], + strlen(params[0]) + 1, False); + break; + case MSG_PING: if (!pong_registered) { message_register(MSG_PONG, pong_function); pong_registered = True; } - if (!params[0]) { + if (!params || !params[0]) { fprintf(stderr,"MSG_PING needs a parameter\n"); return(False); } |