Toggle navigation
Toggle navigation
This project
Loading...
Sign in
UT
/
clsync
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
redmine
2014-05-30 04:26:49 +0400
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e19f2ffd9b41920b37fcc425c419e1bdcf685c2e
e19f2ffd
1 parent
2a77811c
Porting to FreeBSD, chapter 8: started dtrace support
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
54 additions
and
19 deletions
Makefile.am
common.h
configuration.h
configure.ac
main.c
man/man1/clsync.1
mon_bsm.c
mon_kqueue.c
sync.c
Makefile.am
View file @
e19f2ff
...
...
@@ -24,6 +24,10 @@ if HAVE_BSM
clsync_CFLAGS
+=
-DBSM_SUPPORT
clsync_SOURCES
+=
mon_bsm.c
endif
if
HAVE_DTRACEPIPE
clsync_CFLAGS
+=
-DDTRACEPIPE_SUPPORT
clsync_SOURCES
+=
mon_dtracepipe.c
endif
if
SOCKET
clsync_SOURCES
+=
socket.c control.c
...
...
common.h
View file @
e19f2ff
...
...
@@ -22,8 +22,10 @@
#define __CLSYNC_COMMON_H
#ifndef __linux__
#undef HAVE_CAPABILITIES
#warning Capabilities support can be built only on Linux
# ifdef HAVE_CAPABILITIES
# undef HAVE_CAPABILITIES
# warning Capabilities support can be built only on Linux
# endif
#endif
#define _GNU_SOURCE
...
...
@@ -139,6 +141,7 @@ enum notifyengine_enum {
NE_INOTIFY
,
NE_KQUEUE
,
NE_BSM
,
NE_DTRACEPIPE
,
};
typedef
enum
notifyengine_enum
notifyengine_t
;
...
...
configuration.h
View file @
e19f2ff
...
...
@@ -100,3 +100,5 @@ policy:cnt\n\
filesz:1M\n\
"
#define DTRACE_PATH "dtrace"
...
...
configure.ac
View file @
e19f2ff
...
...
@@ -270,14 +270,16 @@ case "$with_bsm" in
)
;;
esac
AC_CHECK_PROG([HAVE_DTRACEPIPE], [dtrace], [found])
AS_IF([test "$HAVE_INOTIFY" != ""], [AC_CHECK_FUNC([inotify_init1], [], [INOTIFY_OLD=1])])
AM_CONDITIONAL([HAVE_KQUEUE], [test "$HAVE_KQUEUE" != ""])
AM_CONDITIONAL([HAVE_INOTIFY], [test "$HAVE_INOTIFY" != ""])
AM_CONDITIONAL([INOTIFY_OLD], [test "$INOTIFY_OLD" != ""])
AM_CONDITIONAL([HAVE_FANOTIFY], [test "$HAVE_FANOTIFY" != ""])
AM_CONDITIONAL([HAVE_BSM], [test "$HAVE_BSM" != ""])
AM_CONDITIONAL([HAVE_KQUEUE], [test "$HAVE_KQUEUE" != ""])
AM_CONDITIONAL([HAVE_INOTIFY], [test "$HAVE_INOTIFY" != ""])
AM_CONDITIONAL([INOTIFY_OLD], [test "$INOTIFY_OLD" != ""])
AM_CONDITIONAL([HAVE_FANOTIFY], [test "$HAVE_FANOTIFY" != ""])
AM_CONDITIONAL([HAVE_BSM], [test "$HAVE_BSM" != ""])
AM_CONDITIONAL([HAVE_DTRACEPIPE],[test "$HAVE_DTRACEPIPE"!= ""])
AS_IF([test "$HAVE_KQUEUE" = '' -a "$HAVE_INOTIFY" = '' -a "$HAVE_FANOTIFY" = '' -a "$HAVE_BSM" = '' ], [AC_MSG_FAILURE([kqueue, inotify and bsm are not supported on this system])])
...
...
main.c
View file @
e19f2ff
...
...
@@ -125,6 +125,7 @@ static char *const notify_engines[] = {
[
NE_KQUEUE
]
=
"kqueue"
,
[
NE_FANOTIFY
]
=
"fanotify"
,
[
NE_BSM
]
=
"bsm"
,
[
NE_DTRACEPIPE
]
=
"dtracepipe"
,
NULL
};
...
...
@@ -475,6 +476,9 @@ int parse_parameter(ctx_t *ctx_p, uint16_t param_id, char *arg, paramsource_t pa
#ifdef BSM_SUPPORT
case
NE_BSM
:
#endif
#ifdef DTRACEPIPE_SUPPORT
case
NE_DTRACEPIPE
:
#endif
break
;
default:
error
(
PROGRAM
" is compiled without %s subsystem support. Recompile with option
\"
--with-%s
\"
if you're planning to use it."
,
arg_orig
,
arg_orig
);
...
...
man/man1/clsync.1
View file @
e19f2ff
...
...
@@ -900,9 +900,6 @@ will just parse the log via
Reliable, but hacky way. It requires global audit reconfiguration that
may hopple audit analysis.
This way should be the best for FreeBSD. It's not used by default just
because it requires to modify "audit_control".
.B Not well tested. Use with caution!
Also file /etc/security/audit_control will be overwritten with:
.RS
...
...
@@ -923,13 +920,22 @@ policy:cnt
filesz:1M
.RE
.RE
.IR dtracepipe
.RS
.BR dtrace "(1) [FreeBSD]"
.B clsync
will run dtrace with special script (on "d") using
.BR popen (3)
and parse it's output.
IMHO, this way is the best for FreeBSD.
.RE
.RE
If
.B inotify
is supported (even through libinotify) then it's used by default. If not then
.B kqueue
is used.
The default value on Linux is "inotify".
.br
The default value on FreeBSD is "dtracepipe"
.RE
.PP
...
...
mon_bsm.c
View file @
e19f2ff
...
...
@@ -60,7 +60,7 @@ struct recognize_event_return {
eventobjtype_t
objtype_new
:
16
;
}
t
;
}
v
;
uint
32
_t
i
;
uint
64
_t
i
;
}
u
;
};
...
...
@@ -190,6 +190,7 @@ int bsm_config_backup(mondata_t *mondata) {
return
-
1
;
}
flock
(
fd
,
LOCK_EX
);
debug
(
3
,
"mv: "
AUDIT_CONTROL_PATH
" -> "
AUDIT_CONTROL_PATH
"-clsync_backup"
);
rename
(
AUDIT_CONTROL_PATH
,
AUDIT_CONTROL_PATH
"-clsync_backup"
);
...
...
mon_kqueue.c
View file @
e19f2ff
...
...
@@ -531,7 +531,7 @@ static inline int _kqueue_handle_oneevent_dircontent(ctx_t *ctx_p, indexes_t *in
int
fd
;
fd
=
openat
(
obj_p
->
dir_fd
,
obj_p
->
name
,
O_RDONLY
|
O_PATH
);
dir
=
fdopendir
(
obj_p
->
fd
);
dir
=
fdopendir
(
fd
);
while
((
entry
=
readdir
(
dir
)))
{
debug
(
10
,
"file/dir:
\"
%s
\"
"
,
entry
->
d_name
);
...
...
sync.c
View file @
e19f2ff
...
...
@@ -250,7 +250,7 @@ static inline ruleaction_t rules_getperm(const char *fpath, mode_t st_mode, rule
}
threadsinfo_t
*
thread_info
()
{
// TODO: optimize this
static
threadsinfo_t
threadsinfo
=
{{
{{
0
}}},{{{
0
}}
},
0
};
static
threadsinfo_t
threadsinfo
=
{{
0
},{
0
},
0
};
if
(
!
threadsinfo
.
mutex_init
)
{
int
i
=
0
;
while
(
i
<
PTHREAD_MUTEX_MAX
)
{
...
...
@@ -1206,6 +1206,7 @@ static inline void evinfo_initialevmask(ctx_t *ctx_p, eventinfo_t *evinfo_p, int
switch
(
ctx_p
->
flags
[
MONITOR
])
{
#ifdef FANOTIFY_SUPPORT
case
NE_FANOTIFY
:
critical
(
"fanotify is not supported"
);
break
;
#endif
#if INOTIFY_SUPPORT | KQUEUE_SUPPORT
...
...
@@ -1234,7 +1235,7 @@ static inline void evinfo_initialevmask(ctx_t *ctx_p, eventinfo_t *evinfo_p, int
}
static
inline
void
api_evinfo_initialevmask
(
ctx_t
*
ctx_p
,
api_eventinfo_t
*
evinfo_p
,
int
isdir
)
{
eventinfo_t
evinfo
;
eventinfo_t
evinfo
=
{
0
}
;
evinfo_initialevmask
(
ctx_p
,
&
evinfo
,
isdir
);
evinfo_p
->
evmask
=
evinfo
.
evmask
;
return
;
...
...
@@ -3507,6 +3508,13 @@ int sync_run(ctx_t *ctx_p) {
ctx_p
->
notifyenginefunct
.
handle
=
bsm_handle
;
break
;
#endif
#ifdef DTRACEPIPE_SUPPORT
case
NE_DTRACEPIPE
:
ctx_p
->
notifyenginefunct
.
add_watch_dir
=
dtracepipe_add_watch_dir
;
ctx_p
->
notifyenginefunct
.
wait
=
dtracepipe_wait
;
ctx_p
->
notifyenginefunct
.
handle
=
dtracepipe_handle
;
break
;
#endif
#ifdef VERYPARANOID
default:
critical
(
"Unknown FS monitor subsystem: %i"
,
ctx_p
->
flags
[
MONITOR
]);
...
...
@@ -3571,6 +3579,11 @@ int sync_run(ctx_t *ctx_p) {
bsm_deinit
(
ctx_p
);
break
;
#endif
#ifdef DTRACEPIPE_SUPPORT
case
NE_DTRACEPIPE
:
dtracepipe_deinit
(
ctx_p
);
break
;
#endif
}
// Closing shared libraries
...
...
Please
register
or
login
to post a comment