redmine

Fixed runtime bugs, detected by travis

Related: https://github.com/xaionaro/clsync/issues/124
... ... @@ -32,10 +32,10 @@ build_test() {
# Cleanup functions for run_example()
run_example_cleanup_success() {
rm -rf "examples/testdir"/{to,from}/*
pkill -F "$CLSYNC_PIDFILE"
sudo pkill -F "$CLSYNC_PIDFILE"
}
run_example_cleanup_failure() {
pkill -F "$CLSYNC_PIDFILE" 2>/dev/null
sudo pkill -F "$CLSYNC_PIDFILE" 2>/dev/null
echo "$@" >&2
exit 1
}
... ... @@ -144,11 +144,10 @@ if true; then
fi
if true; then
export PATH="$(pwd):$PATH"
# Test coverage
# Functionality test
export CFLAGS="$CFLAGS --coverage -O0"
export PATH="$(pwd):$PATH"
build_test --enable-cluster --enable-debug --enable-paranoid=2 --enable-capabilities --without-mhash
run_example rsyncdirect
run_example rsyncdirect --splitting=thread --threading=off
... ...
... ... @@ -25,5 +25,5 @@ cat > rules <<EOF
+*.*
EOF
clsync -K example-cluster -c "$IPADDR" -M rsyncshell -w 2 -p safe -t 5 -W ./testdir/from -S ./clsync-synchandler-rsync.sh -R rules $@
sudo $(which clsync) -K example-cluster -c "$IPADDR" -M rsyncshell -w 2 -p safe -t 5 -W ./testdir/from -S ./clsync-synchandler-rsync.sh -R rules $@
... ...
... ... @@ -7,5 +7,5 @@ cat > rules <<EOF
+*.*
EOF
clsync -K example-simple -M rsyncdirect -w2 -p safe -t5 -W ./testdir/from -R rules -D ./testdir/to $@
sudo $(which clsync) -K example-simple -M rsyncdirect -w2 -p safe -t5 -W ./testdir/from -R rules -D ./testdir/to $@
... ...
... ... @@ -7,5 +7,5 @@ cat > rules <<EOF
+*.*
EOF
clsync -K example-rsync -l test -M rsyncshell -w2 -p safe -t5 -W ./testdir/from -S ./clsync-synchandler-rsyncshell.sh -R rules $@
sudo $(which clsync) -K example-rsync -l test -M rsyncshell -w2 -p safe -t5 -W ./testdir/from -S ./clsync-synchandler-rsyncshell.sh -R rules $@
... ...
... ... @@ -9,5 +9,5 @@ EOF
cc -ggdb3 -fPIC -shared -o clsync-synchandler-rsyncso.so clsync-synchandler-rsyncso.c &&
clsync -K example-rsyncso -M rsyncso -w2 -t5 -W ./testdir/from -S ./clsync-synchandler-rsyncso.so -R rules -D ./testdir/to $@
sudo $(which clsync) -K example-rsyncso -M rsyncso -w2 -t5 -W ./testdir/from -S ./clsync-synchandler-rsyncso.so -R rules -D ./testdir/to $@
... ...
... ... @@ -7,5 +7,5 @@ cat > rules <<EOF
+*.*
EOF
clsync -K example-simple -M simple -w2 -t5 -W ./testdir/from -S $(which echo) -R rules $@
sudo $(which clsync) -K example-simple -M simple -w2 -t5 -W ./testdir/from -S $(which echo) -R rules $@
... ...
... ... @@ -9,5 +9,5 @@ EOF
cc -ggdb3 -fPIC -shared -o clsync-synchandler-so.so clsync-synchandler-so.c &&
clsync -K example-so -M so -w2 -t5 -W ./testdir/from -S ./clsync-synchandler-so.so -R rules -D ./testdir/to $@
sudo $(which clsync) -K example-so -M so -w2 -t5 -W ./testdir/from -S ./clsync-synchandler-so.so -R rules -D ./testdir/to $@
... ...
... ... @@ -417,8 +417,10 @@ int parent_isalive() {
debug(12, "parent_pid == %u", parent_pid);
if ((rc=kill(parent_pid, 0))) {
debug(1, "kill(%u, 0) => %i", parent_pid, rc);
return 0;
if (errno == ESRCH) {
debug(1, "kill(%u, 0) => %i; errno => %s", parent_pid, rc, strerror(errno));
return 0;
}
}
return 1;
... ...
... ... @@ -108,6 +108,10 @@
SECCOMP_ALLOW_ACCUM_SYSCALL(nanosleep), \
SECCOMP_ALLOW_ACCUM_SYSCALL(shmdt), \
SECCOMP_ALLOW_ACCUM_SYSCALL(clone), /* for --threading */ \
SECCOMP_ALLOW_ACCUM_SYSCALL(set_robust_list), /* for --threading? */ \
SECCOMP_ALLOW_ACCUM_SYSCALL(madvise), \
SECCOMP_ALLOW_ACCUM_SYSCALL(exit), \
/* Syscalls allowed to non-privileged thread */
... ... @@ -938,7 +942,7 @@ int privileged_handler(ctx_t *ctx_p)
mprotect((void *)cmd_ret_p, sizeof(*cmd_ret_p), PROT_WRITE);
}
debug(10, "Got command %u", cmd_p->action);
debug(10, "Got command %u (euid:egid => %i:%i)", cmd_p->action, geteuid(), getegid());
if (!setup && cmd_p->action != PA_SETUP)
critical("A try to use commands before PA_SETUP");
... ... @@ -952,6 +956,7 @@ int privileged_handler(ctx_t *ctx_p)
critical_on(pa_setup(opts, cmd_p->arg.ctx_p, &exec_uid, &exec_gid));
mprotect(opts, sizeof(*opts), PROT_READ);
use_args_check = cmd_p->arg.ctx_p->flags[CHECK_EXECVP_ARGS];
cap_drop(ctx_p, ctx_p->caps); // TODO: Find out why "permission denined" without this line
setup++;
critical_on(errno);
break;
... ... @@ -1847,7 +1852,7 @@ int privileged_init(ctx_t *ctx_p)
}
if (ctx_p->flags[GID] || ctx_p->flags[UID])
SAFE( seteuid(0), return errno);
SAFE( seteuid(0), {error("Not enough permission to start a privileged thread/fork"); return errno;});
if (ctx_p->flags[GID]) {
SAFE( setegid(0), return errno);
... ...
... ... @@ -1308,6 +1308,9 @@ int sync_initialsync_walk(ctx_t *ctx_p, const char *dirpath, indexes_t *indexes_
char *path_rel = NULL;
size_t path_rel_len = 0;
#ifdef VERYPARANOID
errno = 0;
#endif
while ((node = privileged_fts_read(tree, PC_SYNC_INIIALSYNC_WALK_FTS_READ))) {
switch (node->fts_info) {
// Duplicates:
... ... @@ -1733,6 +1736,9 @@ int sync_mark_walk(ctx_t *ctx_p, const char *dirpath, indexes_t *indexes_p) {
char *path_rel = NULL;
size_t path_rel_len = 0;
#ifdef VERYPARANOID
errno = 0;
#endif
while ((node = privileged_fts_read(tree, PC_SYNC_MARK_WALK_FTS_READ))) {
#ifdef CLUSTER_SUPPORT
int ret;
... ...