File: 01_logfile.diff

package info (click to toggle)
empty-expect 0.6.20b-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 276 kB
  • ctags: 131
  • sloc: ansic: 743; sh: 197; makefile: 37
file content (70 lines) | stat: -rw-r--r-- 2,034 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
empty.1, empty.c: Changed default mode of the log file from 0700 to 0600,
and added option "--logfile-mode=mode".  Closes: #443448.


diff -ruN -x '*.png' -x '*.jpg' -x '*.ogg' -x '*_image_archive' ../orig/empty-0.6.16b/empty.1 ./empty.1
--- ../orig/empty-0.6.16b/empty.1	2008-11-24 10:04:45.000000000 +0100
+++ ./empty.1	2009-04-19 21:01:15.000000000 +0200
@@ -175,6 +175,10 @@
 .B empty
 session to a file. Marks >>> and <<< show the directions of data flow.
 .TP
+\-\-logfile-mode=mode
+This option allows to choose the mode of the log file created with the -L option.
+The default mode is 0600.
+.TP
 \-p file.pid
 Save PID of empty daemon process to a file
 .TP
diff -ruN -x '*.png' -x '*.jpg' -x '*.ogg' -x '*_image_archive' ../orig/empty-0.6.16b/empty.c ./empty.c
--- ../orig/empty-0.6.16b/empty.c	2008-11-21 10:41:02.000000000 +0100
+++ ./empty.c	2009-04-19 20:54:01.000000000 +0200
@@ -38,6 +38,9 @@
 #endif
 
 
+#define _GNU_SOURCE
+#include <getopt.h>
+
 #include <unistd.h>
 #include <sys/types.h>
 
@@ -206,12 +209,28 @@
 	int	pgrp;
 #endif
 
+	unsigned int logfile_mode = S_IRUSR | S_IWUSR; // was: S_IRWXU;
+
+	static struct option long_options[] =
+	{
+		{ "logfile-mode", 1, 0, 0 },
+		{ NULL, 0, 0, 0 }
+	};
+
+	int option_index = -1;
+
 #ifndef __linux__
 	while ((ch = getopt(argc, argv, "Scvhfrb:kwslp:i:o:t:L:")) != -1)
 #else
-	while ((ch = getopt(argc, argv, "+Scvhfrb:kwslp:i:o:t:L:")) != -1)
+	while ((ch = getopt_long(argc, argv, "+Scvhfrb:kwslp:i:o:t:L:", long_options, &option_index)) != -1)
 #endif
 		switch (ch) {
+			case 0:
+				if( option_index >= 0
+				&& strcmp( long_options[option_index].name, "logfile-mode" ) == 0
+				&& optarg )
+					sscanf( optarg, "%o", &logfile_mode );
+				break;
 			case 'f':
 				fflg = 1;
 				break;
@@ -481,7 +500,7 @@
 	}
 
 	if (Lflg)
-		if ((lfd = open(sl, O_CREAT|O_WRONLY|O_APPEND, S_IRWXU)) == -1)
+		if ((lfd = open(sl, O_CREAT|O_WRONLY|O_APPEND, logfile_mode)) == -1)
 			(void)syslog(LOG_NOTICE,
 				"Warning: Can't open %s for session-log %m", sl);