mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
added a close-share smbcontrol message that forcibly closes a share in smbd (to allow unmount)
This commit is contained in:
parent
8e982941d8
commit
15b17a80db
@ -40,5 +40,6 @@
|
||||
|
||||
/* smbd messages */
|
||||
#define MSG_SMB_CONF_UPDATED 3001
|
||||
#define MSG_SMB_FORCE_TDIS 3002
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -198,3 +198,33 @@ void conn_free(connection_struct *conn)
|
||||
ZERO_STRUCTP(conn);
|
||||
free(conn);
|
||||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
receive a smbcontrol message to forcibly unmount a share
|
||||
the message contains just a share name and all instances of that
|
||||
share are unmounted
|
||||
the special sharename '*' forces unmount of all shares
|
||||
****************************************************************************/
|
||||
void msg_force_tdis(int msg_type, pid_t pid, void *buf, size_t len)
|
||||
{
|
||||
connection_struct *conn, *next;
|
||||
fstring sharename;
|
||||
|
||||
fstrcpy(sharename, buf);
|
||||
|
||||
if (strcmp(sharename, "*") == 0) {
|
||||
DEBUG(1,("Forcing close of all shares\n"));
|
||||
conn_close_all();
|
||||
return;
|
||||
}
|
||||
|
||||
for (conn=Connections;conn;conn=next) {
|
||||
next=conn->next;
|
||||
if (strequal(lp_servicename(conn->service), sharename)) {
|
||||
DEBUG(1,("Forcing close of share %s cnum=%d\n",
|
||||
sharename, conn->cnum));
|
||||
close_cnum(conn, (uint16)-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -693,6 +693,12 @@ static int switch_message(int type,char *inbuf,char *outbuf,int size,int bufsize
|
||||
if (!(flags & AS_USER))
|
||||
unbecome_user();
|
||||
|
||||
/* does this protocol need a valid tree connection? */
|
||||
if ((flags & AS_USER) && !conn) {
|
||||
return ERROR(ERRSRV, ERRinvnid);
|
||||
}
|
||||
|
||||
|
||||
/* does this protocol need to be run as the connected user? */
|
||||
if ((flags & AS_USER) && !become_user(conn,session_tag)) {
|
||||
if (flags & AS_GUEST)
|
||||
@ -1195,6 +1201,9 @@ void smbd_process(void)
|
||||
/* re-initialise the timezone */
|
||||
TimeInit();
|
||||
|
||||
/* register our message handlers */
|
||||
message_register(MSG_SMB_FORCE_TDIS, msg_force_tdis);
|
||||
|
||||
while (True) {
|
||||
int deadtime = lp_deadtime()*60;
|
||||
int select_timeout = setup_select_timeout();
|
||||
|
@ -697,3 +697,5 @@ void close_cnum(connection_struct *conn, uint16 vuid)
|
||||
}
|
||||
conn_free(conn);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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}
|
||||
};
|
||||
|
||||
@ -206,7 +207,7 @@ static BOOL do_command(char *dest, char *msg_name, char **params)
|
||||
}
|
||||
|
||||
case MSG_PROFILE:
|
||||
if (!params[0]) {
|
||||
if (!params || !params[0]) {
|
||||
fprintf(stderr,"MSG_PROFILE needs a parameter\n");
|
||||
return(False);
|
||||
}
|
||||
@ -277,7 +278,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);
|
||||
}
|
||||
@ -285,12 +286,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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user