diff --git a/TODO b/TODO new file mode 100644 index 0000000000000..3ffd7cc954344 --- /dev/null +++ b/TODO @@ -0,0 +1,6 @@ +* Add support to synchronize symbolic links + - This needs a lot of work cause we have to check the symlink + + Determine if a symlink points outside the current directory tree. They + are unsafe to sync. + + Null symlinks and absolute symlinks are always unsafe. + - Check which is the best way to sync symlinks diff --git a/config/csync.conf b/config/csync.conf index 84ef0f14b7f78..7c74380016f2e 100644 --- a/config/csync.conf +++ b/config/csync.conf @@ -5,3 +5,7 @@ max_time_difference = 10 # max directory depth recursion max_depth = 50 + +# NOT IN USE: +# sync symbolic links if the remote filesystem supports it. +#sync_symbolic_links = false diff --git a/src/csync_private.h b/src/csync_private.h index 99b7eac522aaf..6bc1e2878a534 100644 --- a/src/csync_private.h +++ b/src/csync_private.h @@ -116,6 +116,7 @@ struct csync_s { enum csync_ftw_type_e { CSYNC_FTW_TYPE_FILE, + CSYNC_FTW_TYPE_SLINK, CSYNC_FTW_TYPE_DIR }; diff --git a/src/csync_propagate.c b/src/csync_propagate.c index 6b39003e61ebd..931e2e0fbec3f 100644 --- a/src/csync_propagate.c +++ b/src/csync_propagate.c @@ -537,6 +537,8 @@ static int _csync_propagation_file_visitor(void *obj, void *data) { ctx = (CSYNC *) data; switch(st->type) { + case CSYNC_FTW_TYPE_SLINK: + break; case CSYNC_FTW_TYPE_FILE: switch (st->instruction) { case CSYNC_INSTRUCTION_NEW: @@ -583,6 +585,9 @@ static int _csync_propagation_dir_visitor(void *obj, void *data) { ctx = (CSYNC *) data; switch(st->type) { + case CSYNC_FTW_TYPE_SLINK: + /* FIXME: implement symlink support */ + break; case CSYNC_FTW_TYPE_FILE: break; case CSYNC_FTW_TYPE_DIR: diff --git a/src/csync_update.c b/src/csync_update.c index 2b73d4dd65a3e..7612c2773eaad 100644 --- a/src/csync_update.c +++ b/src/csync_update.c @@ -161,24 +161,20 @@ static int csync_detect_update(CSYNC *ctx, const char *file, const csync_vio_fil int csync_walker(CSYNC *ctx, const char *file, const csync_vio_file_stat_t *fs, enum csync_ftw_flags_e flag) { switch (flag) { case CSYNC_FTW_FLAG_FILE: + CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "file: %s", file); + + return csync_detect_update(ctx, file, fs, CSYNC_FTW_TYPE_FILE); + break; case CSYNC_FTW_FLAG_SLINK: - switch (fs->mode & S_IFMT) { - case S_IFREG: - CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "file: %s", file); - - return csync_detect_update(ctx, file, fs, CSYNC_FTW_TYPE_FILE); - break; - case S_IFLNK: - /* TODO: check if plugin supports symlinks */ - if (ctx->options.sync_symbolic_links) { - CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "symlink: %s", file); - - return csync_detect_update(ctx, file, fs, CSYNC_FTW_TYPE_FILE); - } - break; - default: - break; + /* FIXME: implement support for symlinks, see csync_propagate.c too */ +#if 0 + if (ctx->options.sync_symbolic_links) { + CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "symlink: %s", file); + + return csync_detect_update(ctx, file, fs, CSYNC_FTW_TYPE_SLINK); } +#endif + break; case CSYNC_FTW_FLAG_DIR: /* enter directory */ CSYNC_LOG(CSYNC_LOG_PRIORITY_TRACE, "directory: %s", file);