From 6cca9a377f4ca1e6927a79e60a357427236637c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 24 Oct 2014 22:03:46 +0200 Subject: [PATCH] qrexec: add -q option to silence "Waiting for VM's qrexec agent" message --- qrexec/qrexec-daemon.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/qrexec/qrexec-daemon.c b/qrexec/qrexec-daemon.c index d997f43..ed5d196 100644 --- a/qrexec/qrexec-daemon.c +++ b/qrexec/qrexec-daemon.c @@ -61,6 +61,8 @@ const char *default_user = "user"; const char default_user_keyword[] = "DEFAULT:"; #define default_user_keyword_len_without_colon (sizeof(default_user_keyword)-2) +int opt_quiet = 0; + #ifdef __GNUC__ # define UNUSED(x) UNUSED_ ## x __attribute__((__unused__)) #else @@ -76,7 +78,8 @@ volatile int children_count; void sigusr1_handler(int UNUSED(x)) { - fprintf(stderr, "connected\n"); + if (!opt_quiet) + fprintf(stderr, "connected\n"); exit(0); } @@ -85,7 +88,10 @@ void sigchld_parent_handler(int UNUSED(x)) children_count--; /* starting value is 0 so we see dead real qrexec-daemon as -1 */ if (children_count < 0) { - fprintf(stderr, "failed\n"); + if (!opt_quiet) + fprintf(stderr, "failed\n"); + else + fprintf(stderr, "Connection to the VM failed\n"); exit(1); } } @@ -160,10 +166,12 @@ void init(int xid) default: if (getenv("QREXEC_STARTUP_NOWAIT")) exit(0); - fprintf(stderr, "Waiting for VM's qrexec agent."); + if (!opt_quiet) + fprintf(stderr, "Waiting for VM's qrexec agent."); for (i=0;i 3) { + fprintf(stderr, "usage: %s [-q] domainid domain-name [default user]\n", argv[0]); exit(1); } - remote_domain_name = argv[2]; - if (argc == 4) - default_user = argv[3]; - remote_domain_xid = atoi(argv[1]); + remote_domain_name = argv[optind+1]; + if (argc - optind >= 3) + default_user = argv[optind+2]; + remote_domain_xid = atoi(argv[optind]); init(remote_domain_xid); sigemptyset(&chld_set); sigaddset(&chld_set, SIGCHLD);