[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] xenconsole: add option to avoid escape sequences in log



On Sat, Jul 21, 2018 at 02:14:12AM +0200, Marek Marczykowski-Górecki wrote:
> Add --replace-escape, -e option to xenconsoled, which replaces ESC with
> '.' in console output written to log file. This makes it slightly safer
> to do tail -f on a console output of untrusted guest.
> The pty output is unaffected by this option.

I would rather only have the long option, not the short one.

> 
> Signed-off-by: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
> ---
> Is there any more documentation to be updated? I didn't found
> xenconsoled man page or such.

No. But you're welcome to expand the help string in usage() to be more
verbose. :-)

> ---
>  tools/console/daemon/io.c   | 18 ++++++++++++++++++
>  tools/console/daemon/main.c |  9 +++++++--
>  2 files changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
> index e22009aa39..c8280e0b7c 100644
> --- a/tools/console/daemon/io.c
> +++ b/tools/console/daemon/io.c
> @@ -68,6 +68,7 @@ extern int log_time_hv;
>  extern int log_time_guest;
>  extern char *log_dir;
>  extern int discard_overflowed_data;
> +extern int replace_escape;
>  
>  static int log_time_hv_needts = 1;
>  static int log_time_guest_needts = 1;
> @@ -227,8 +228,25 @@ static inline int console_iter_int_arg3(struct domain *d,
>       return ret;
>  }
>  
> +static void do_replace_escape(const char *buf, char *dest, int len) {

Coding style - { should be on a new line.

> +     int i;
> +
> +     memcpy(dest, buf, len);
> +     for (i = 0; i < len; i++) {
> +             if (dest[i] == '\033')
> +                     dest[i] = '.';
> +     }

This could be made more efficient by using:

        for (i = 0; i < len; i++) {
             if (src[i] == '\033')
                 dst[i] = '.';
             else
                 dst[i] = src[i];
        }

You need to go over the array once anyway, you can do without that
memcpy.

Wei.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.