1 #ifndef H_LOGROTATE
2 #define H_LOGROTATE
3 
4 #include <sys/types.h>
5 #include "queue.h"
6 #include <glob.h>
7 
8 /* needed for basename() on OS X */
9 #if HAVE_LIBGEN_H
10 #   include <libgen.h>
11 #endif
12 
13 #define LOG_FLAG_COMPRESS	(1 << 0)
14 #define LOG_FLAG_CREATE		(1 << 1)
15 #define LOG_FLAG_IFEMPTY	(1 << 2)
16 #define LOG_FLAG_DELAYCOMPRESS	(1 << 3)
17 #define LOG_FLAG_COPYTRUNCATE	(1 << 4)
18 #define LOG_FLAG_MISSINGOK	(1 << 5)
19 #define LOG_FLAG_MAILFIRST	(1 << 6)
20 #define LOG_FLAG_SHAREDSCRIPTS	(1 << 7)
21 #define LOG_FLAG_COPY		(1 << 8)
22 #define LOG_FLAG_DATEEXT	(1 << 9)
23 #define LOG_FLAG_SHRED		(1 << 10)
24 #define LOG_FLAG_SU			(1 << 11)
25 #define LOG_FLAG_DATEYESTERDAY	(1 << 12)
26 #define LOG_FLAG_OLDDIRCREATE	(1 << 13)
27 #define LOG_FLAG_TMPFILENAME	(1 << 14)
28 
29 #define NO_MODE ((mode_t) -1)
30 #define NO_UID  ((uid_t) -1)
31 #define NO_GID  ((gid_t) -1)
32 
33 #define NO_FORCE_ROTATE 0
34 #define FORCE_ROTATE    1
35 
36 #ifdef HAVE_LIBSELINUX
37 #define WITH_SELINUX 1
38 #endif
39 
40 #ifdef HAVE_LIBACL
41 #define WITH_ACL 1
42 #endif
43 
44 struct logInfo {
45     char *pattern;
46     char **files;
47     int numFiles;
48     char *oldDir;
49     enum { ROT_HOURLY, ROT_DAYS, ROT_WEEKLY, ROT_MONTHLY, ROT_YEARLY, ROT_SIZE
50             } criterium;
51     int weekday; /* used by ROT_WEEKLY only */
52     off_t threshold;
53     off_t maxsize;
54     off_t minsize;
55     int rotateCount;
56     int rotateMinAge;
57     int rotateAge;
58     int logStart;
59     char *pre, *post, *first, *last, *preremove;
60     char *logAddress;
61     char *extension;
62     char *addextension;
63     char *compress_prog;
64     char *uncompress_prog;
65     char *compress_ext;
66 	char *dateformat;		/* specify format for strftime (for dateext) */
67     int flags;
68 	int shred_cycles;		/* if !=0, pass -n shred_cycles to GNU shred */
69     mode_t createMode;		/* if any/all of these are -1, we use the */
70     uid_t createUid;		/* attributes from the log file just rotated */
71     gid_t createGid;
72     uid_t suUid;			/* switch user to this uid and group to this gid */
73     gid_t suGid;
74     mode_t olddirMode;
75     uid_t olddirUid;
76     uid_t olddirGid;
77     /* these are at the end so they end up nil */
78     const char **compress_options_list;
79     int compress_options_count;
80     TAILQ_ENTRY(logInfo) list;
81 };
82 
83 TAILQ_HEAD(logInfoHead, logInfo);
84 
85 extern int numLogs;
86 extern int debug;
87 
88 int switch_user(uid_t user, gid_t group);
89 int switch_user_back(void);
90 int readAllConfigPaths(const char **paths);
91 #if !defined(asprintf) && !defined(_FORTIFY_SOURCE)
92 int asprintf(char **string_ptr, const char *format, ...);
93 #endif
94 
95 #endif
96