multipath: Allow whitespace before or after exit and quit command in multipathd
PATCH RESEND 1/1 multipath: Allow whitespace before or after exit and quit command in multipathd
This problem is reported by IBM internal test team.
In multipathd interactive mode, commands allow preceding and appending whitespace while quit and exit do not. If we have whitespace before or after quit|exit command, multipathd won't recognize exit and quit command and exit the interactive mode.
This patch provide support whitespace in the quit and exit command.
Signed-off-by Zheng Huai Cheng <[email protected]>
--- multipathd/uxclnt.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-)
multipathd/uxclnt.c +25 -3
@@ -37,6 +37,29 @@ static void print_reply(char *s)putchar (*s++); } } + +static int need_quit (char *str,size_t len) +{ +char *ptr, *start; +size_t trimed_len = len; + +for (ptr = str; trimed_len &&isspace (*ptr); + trimed_len--, ptr++) + ; + + start = ptr; + +for (ptr = str + len -1 ; trimed_len &&isspace (*ptr); + trimed_len--, ptr--) + ; + +if ((trimed_len ==4 && !strncmp (start,"exit" ,4 )) || + (trimed_len ==4 && !strncmp (start,"quit" ,4 ))) +return 1 ; + +return 0 ; +} +/* * process the client */
@@ -56,9 +79,8 @@ static void process(int fd)free (line);continue ; } -if (!strncmp (line,"exit" ,4 ) && llen ==4 ) -break ; -if (!strncmp (line,"quit" ,4 ) && llen ==4 ) + +if (need_quit (line, llen))break ;if (send_packet (fd, line, llen +1 ) !=0 )break ;
Signature · 1 line
1.7.9.5