From cf15e9eac653ee4a2d3eeed28e5fd25a299f85fb Mon Sep 17 00:00:00 2001
From: Luiz Angelo Daros de Luca <luizluca@gmail.com>
Date: Tue, 15 Sep 2020 14:22:14 -0300
Subject: [PATCH] SSSCTL: fix logs-remove when log directory is empty
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

"sssctl logs-remove" calls "truncate --size 0 *.log" and "*.log"
will expand to literal '*.log' when directory is empty. The result
is a new empty '*.log' file.

Add '--no-create' to truncate call.

Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>

Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
---
 src/tools/sssctl/sssctl_logs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/tools/sssctl/sssctl_logs.c b/src/tools/sssctl/sssctl_logs.c
index 04a32bad85..9ff2be05b6 100644
--- a/src/tools/sssctl/sssctl_logs.c
+++ b/src/tools/sssctl/sssctl_logs.c
@@ -254,7 +254,7 @@ errno_t sssctl_logs_remove(struct sss_cmdline *cmdline,
         sss_signal(SIGHUP);
     } else {
         PRINT("Truncating log files...\n");
-        ret = sssctl_run_command("truncate --size 0 " LOG_FILES);
+        ret = sssctl_run_command("truncate --no-create --size 0 " LOG_FILES);
         if (ret != EOK) {
             ERROR("Unable to truncate log files\n");
             return ret;
-- 
2.23.0

