This patch fixes logread and now appends to files instead of writting to the 
beginning the specified logfile. 
It also sets the access rights to 0600.

Signed-off-by: Peter Wagner <tripo...@gmx.at>
diff --git a/logread.c b/logread.c
index fc1d0ce..77a810b 100644
--- a/logread.c
+++ b/logread.c
@@ -116,7 +116,7 @@ static int log_notify(struct ubus_context *ctx, struct ubus_object *obj,
 			rename(log_file, old);
 			free(old);
 		}
-		sender.fd = open(log_file, O_CREAT | O_WRONLY | O_TRUNC);
+		sender.fd = open(log_file, O_CREAT | O_WRONLY | O_APPEND, 0600);
 		if (sender.fd < 0) {
 //			fprintf(stderr, "failed to open %s: %s\n", log_file, strerror(errno));
 			exit(-1);
@@ -180,7 +180,7 @@ static void follow_log(struct ubus_context *ctx, int id)
 		uloop_timeout_set(&retry, 1000);
 	} else if (log_file) {
 		log_type = LOG_FILE;
-		sender.fd = open(log_file, O_CREAT | O_WRONLY);
+		sender.fd = open(log_file, O_CREAT | O_WRONLY| O_APPEND, 0600);
 		if (sender.fd < 0) {
 			fprintf(stderr, "failed to open %s: %s\n", log_file, strerror(errno));
 			exit(-1);
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to