Prevent possible bash buffer overflow, fixes #171
This commit is contained in:
parent
4df4c594b7
commit
f0ea6df5ea
|
@ -7,7 +7,7 @@ PROGRAM="osync" # Rsync based two way sync engine with fault tolerance
|
||||||
AUTHOR="(C) 2013-2019 by Orsiris de Jong"
|
AUTHOR="(C) 2013-2019 by Orsiris de Jong"
|
||||||
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
|
CONTACT="http://www.netpower.fr/osync - ozy@netpower.fr"
|
||||||
PROGRAM_VERSION=1.3.0-prerc1
|
PROGRAM_VERSION=1.3.0-prerc1
|
||||||
PROGRAM_BUILD=2019070901
|
PROGRAM_BUILD=2019080801
|
||||||
IS_STABLE=false
|
IS_STABLE=false
|
||||||
|
|
||||||
CONFIG_FILE_REVISION_REQUIRED=1.3.0
|
CONFIG_FILE_REVISION_REQUIRED=1.3.0
|
||||||
|
@ -268,7 +268,7 @@ function _CheckReplicasLocal {
|
||||||
retval=$?
|
retval=$?
|
||||||
if [ $retval -ne 0 ]; then
|
if [ $retval -ne 0 ]; then
|
||||||
Logger "Cannot create local replica path [$replicaPath]." "CRITICAL" $retval
|
Logger "Cannot create local replica path [$replicaPath]." "CRITICAL" $retval
|
||||||
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP)" "WARN"
|
Logger "Command output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP)" "WARN"
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
Logger "Created local replica path [$replicaPath]." "NOTICE"
|
Logger "Created local replica path [$replicaPath]." "NOTICE"
|
||||||
|
@ -378,7 +378,7 @@ ENDSSH
|
||||||
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP" ]; then
|
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP" ]; then
|
||||||
(
|
(
|
||||||
_LOGGER_PREFIX=""
|
_LOGGER_PREFIX=""
|
||||||
Logger "$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP)" "NOTICE"
|
Logger "$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP)" "NOTICE"
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
if [ $retval -ne 0 ]; then
|
if [ $retval -ne 0 ]; then
|
||||||
|
@ -438,14 +438,14 @@ function _HandleLocksLocal {
|
||||||
retval=$?
|
retval=$?
|
||||||
if [ $retval -ne 0 ]; then
|
if [ $retval -ne 0 ]; then
|
||||||
Logger "Cannot create state dir [$replicaStateDir]." "CRITICAL" $retval
|
Logger "Cannot create state dir [$replicaStateDir]." "CRITICAL" $retval
|
||||||
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP)" "WARN"
|
Logger "Command output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP)" "WARN"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Skip the whole part if overwrite true
|
# Skip the whole part if overwrite true
|
||||||
if [ -s "$lockfile" ] && [ $overwrite != true ]; then
|
if [ -s "$lockfile" ] && [ $overwrite != true ]; then
|
||||||
lockfileContent=$(cat $lockfile)
|
lockfileContent=$(head -c16384 $lockfile)
|
||||||
Logger "Master lock pid present: $lockfileContent" "DEBUG"
|
Logger "Master lock pid present: $lockfileContent" "DEBUG"
|
||||||
lockPid="${lockfileContent%@*}"
|
lockPid="${lockfileContent%@*}"
|
||||||
if [ $(IsInteger $lockPid) -ne 1 ]; then
|
if [ $(IsInteger $lockPid) -ne 1 ]; then
|
||||||
|
@ -535,7 +535,7 @@ function _HandleLocksRemoteSub {
|
||||||
|
|
||||||
# Skip the whole part if overwrite true
|
# Skip the whole part if overwrite true
|
||||||
if [ -s "$lockfile" ] && [ $overwrite != true ]; then
|
if [ -s "$lockfile" ] && [ $overwrite != true ]; then
|
||||||
lockfileContent=$(cat "$lockfile")
|
lockfileContent=$(head -c16384 "$lockfile")
|
||||||
RemoteLogger "Master lock pid present: $lockfileContent" "DEBUG"
|
RemoteLogger "Master lock pid present: $lockfileContent" "DEBUG"
|
||||||
lockPid="${lockfileContent%@*}"
|
lockPid="${lockfileContent%@*}"
|
||||||
if [ $(IsInteger $lockPid) -ne 1 ]; then
|
if [ $(IsInteger $lockPid) -ne 1 ]; then
|
||||||
|
@ -601,7 +601,7 @@ ENDSSH
|
||||||
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP" ]; then
|
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP" ]; then
|
||||||
(
|
(
|
||||||
_LOGGER_PREFIX=""
|
_LOGGER_PREFIX=""
|
||||||
Logger "$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP)" "NOTICE"
|
Logger "$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP)" "NOTICE"
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
if [ $retval -ne 0 ]; then
|
if [ $retval -ne 0 ]; then
|
||||||
|
@ -710,7 +710,7 @@ ENDSSH
|
||||||
retval=$?
|
retval=$?
|
||||||
if [ $retval -ne 0 ]; then
|
if [ $retval -ne 0 ]; then
|
||||||
Logger "Could not unlock $replicaType remote replica." "ERROR" $retval
|
Logger "Could not unlock $replicaType remote replica." "ERROR" $retval
|
||||||
Logger "Command Output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP)" "WARN"
|
Logger "Command Output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP)" "WARN"
|
||||||
else
|
else
|
||||||
Logger "Removed remote $replicaType replica lock." "DEBUG"
|
Logger "Removed remote $replicaType replica lock." "DEBUG"
|
||||||
fi
|
fi
|
||||||
|
@ -806,12 +806,12 @@ function treeList {
|
||||||
return $?
|
return $?
|
||||||
elif [ $retval -eq 23 ]; then
|
elif [ $retval -eq 23 ]; then
|
||||||
Logger "Some files could not be listed in $replicaType replica [$replicaPath]. Check for failing symlinks." "ERROR" $retval
|
Logger "Some files could not be listed in $replicaType replica [$replicaPath]. Check for failing symlinks." "ERROR" $retval
|
||||||
Logger "Command output\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.error.$SCRIPT_PID.$TSTAMP)" "WARN"
|
Logger "Command output\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.error.$SCRIPT_PID.$TSTAMP)" "WARN"
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
Logger "Cannot create replica file list in [$replicaPath]." "CRITICAL" $retval
|
Logger "Cannot create replica file list in [$replicaPath]." "CRITICAL" $retval
|
||||||
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN"
|
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN"
|
||||||
Logger "Command output\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.error.$SCRIPT_PID.$TSTAMP)" "WARN"
|
Logger "Command output\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.error.$SCRIPT_PID.$TSTAMP)" "WARN"
|
||||||
return $retval
|
return $retval
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -900,7 +900,7 @@ function _getFileCtimeMtimeLocal {
|
||||||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.subshellError.$replicaType.$SCRIPT_PID.$TSTAMP" ]; then
|
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.subshellError.$replicaType.$SCRIPT_PID.$TSTAMP" ]; then
|
||||||
Logger "Getting file time attributes failed [$retval] on $replicaType. Stopping execution." "CRITICAL" $retval
|
Logger "Getting file time attributes failed [$retval] on $replicaType. Stopping execution." "CRITICAL" $retval
|
||||||
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.error.$SCRIPT_PID.$TSTAMP" ]; then
|
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.error.$SCRIPT_PID.$TSTAMP" ]; then
|
||||||
Logger "Command output:\n$(cat "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.error.$SCRIPT_PID.$TSTAMP")" "WARN"
|
Logger "Command output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.error.$SCRIPT_PID.$TSTAMP")" "WARN"
|
||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
|
@ -929,7 +929,7 @@ function _getFileCtimeMtimeRemote {
|
||||||
Logger "Sending ctime required file list failed with [$retval] on $replicaType. Stopping execution." "CRITICAL" $retval
|
Logger "Sending ctime required file list failed with [$retval] on $replicaType. Stopping execution." "CRITICAL" $retval
|
||||||
_LOGGER_SILENT=true Logger "Command was [$cmd]." "WARN"
|
_LOGGER_SILENT=true Logger "Command was [$cmd]." "WARN"
|
||||||
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP" ]; then
|
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP" ]; then
|
||||||
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP)" "WARN"
|
Logger "Command output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP)" "WARN"
|
||||||
fi
|
fi
|
||||||
return $retval
|
return $retval
|
||||||
fi
|
fi
|
||||||
|
@ -979,7 +979,7 @@ ENDSSH
|
||||||
if [ $retval -ne 0 ]; then
|
if [ $retval -ne 0 ]; then
|
||||||
Logger "Getting file attributes failed [$retval] on $replicaType. Stopping execution." "CRITICAL" $retval
|
Logger "Getting file attributes failed [$retval] on $replicaType. Stopping execution." "CRITICAL" $retval
|
||||||
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP" ]; then
|
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP" ]; then
|
||||||
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP)" "WARN"
|
Logger "Command output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP)" "WARN"
|
||||||
fi
|
fi
|
||||||
return $retval
|
return $retval
|
||||||
else
|
else
|
||||||
|
@ -1135,12 +1135,12 @@ function syncAttrs {
|
||||||
Logger "Getting list of files that need updates failed [$retval]. Stopping execution." "CRITICAL" $retval
|
Logger "Getting list of files that need updates failed [$retval]. Stopping execution." "CRITICAL" $retval
|
||||||
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN"
|
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN"
|
||||||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ]; then
|
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ]; then
|
||||||
Logger "Rsync output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "NOTICE"
|
Logger "Rsync output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "NOTICE"
|
||||||
fi
|
fi
|
||||||
return $retval
|
return $retval
|
||||||
else
|
else
|
||||||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ]; then
|
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ]; then
|
||||||
Logger "List:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "VERBOSE"
|
Logger "List:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP)" "VERBOSE"
|
||||||
fi
|
fi
|
||||||
( grep -Ev "^[^ ]*(c|s|t)[^ ]* " "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" || :) | ( grep -E "^[^ ]*(p|o|g|a)[^ ]* " || :) | sed -e 's/^[^ ]* //' >> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-cleaned.$SCRIPT_PID.$TSTAMP"
|
( grep -Ev "^[^ ]*(c|s|t)[^ ]* " "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" || :) | ( grep -E "^[^ ]*(p|o|g|a)[^ ]* " || :) | sed -e 's/^[^ ]* //' >> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}-cleaned.$SCRIPT_PID.$TSTAMP"
|
||||||
retval=$?
|
retval=$?
|
||||||
|
@ -1222,12 +1222,12 @@ function syncAttrs {
|
||||||
Logger "Updating file attributes on $destReplica [$retval]. Stopping execution." "CRITICAL" $retval
|
Logger "Updating file attributes on $destReplica [$retval]. Stopping execution." "CRITICAL" $retval
|
||||||
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN"
|
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN"
|
||||||
if [ -f "$RUN_DIR/$PROGRAM.attr-update.$destReplica.$SCRIPT_PID.$TSTAMP" ]; then
|
if [ -f "$RUN_DIR/$PROGRAM.attr-update.$destReplica.$SCRIPT_PID.$TSTAMP" ]; then
|
||||||
Logger "Rsync output:\n$(cat $RUN_DIR/$PROGRAM.attr-update.$destReplica.$SCRIPT_PID.$TSTAMP)" "NOTICE"
|
Logger "Rsync output:\n$(head -c16384 $RUN_DIR/$PROGRAM.attr-update.$destReplica.$SCRIPT_PID.$TSTAMP)" "NOTICE"
|
||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
if [ -f "$RUN_DIR/$PROGRAM.attr-update.$destReplica.$SCRIPT_PID.$TSTAMP" ]; then
|
if [ -f "$RUN_DIR/$PROGRAM.attr-update.$destReplica.$SCRIPT_PID.$TSTAMP" ]; then
|
||||||
Logger "List:\n$(cat $RUN_DIR/$PROGRAM.attr-update.$destReplica.$SCRIPT_PID.$TSTAMP)" "VERBOSE"
|
Logger "List:\n$(head -c16384 $RUN_DIR/$PROGRAM.attr-update.$destReplica.$SCRIPT_PID.$TSTAMP)" "VERBOSE"
|
||||||
fi
|
fi
|
||||||
Logger "Successfully updated file attributes on $destReplica replica." "NOTICE"
|
Logger "Successfully updated file attributes on $destReplica replica." "NOTICE"
|
||||||
fi
|
fi
|
||||||
|
@ -1300,12 +1300,12 @@ function syncUpdate {
|
||||||
Logger "Updating $destinationReplica replica failed. Stopping execution." "CRITICAL" $retval
|
Logger "Updating $destinationReplica replica failed. Stopping execution." "CRITICAL" $retval
|
||||||
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN"
|
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN"
|
||||||
if [ -f "$RUN_DIR/$PROGRAM.update.$destinationReplica.$SCRIPT_PID.$TSTAMP" ]; then
|
if [ -f "$RUN_DIR/$PROGRAM.update.$destinationReplica.$SCRIPT_PID.$TSTAMP" ]; then
|
||||||
Logger "Rsync output:\n$(cat $RUN_DIR/$PROGRAM.update.$destinationReplica.$SCRIPT_PID.$TSTAMP)" "NOTICE"
|
Logger "Rsync output:\n$(head -c16384 $RUN_DIR/$PROGRAM.update.$destinationReplica.$SCRIPT_PID.$TSTAMP)" "NOTICE"
|
||||||
fi
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
if [ -f "$RUN_DIR/$PROGRAM.update.$destinationReplica.$SCRIPT_PID.$TSTAMP" ]; then
|
if [ -f "$RUN_DIR/$PROGRAM.update.$destinationReplica.$SCRIPT_PID.$TSTAMP" ]; then
|
||||||
Logger "List:\n$(cat $RUN_DIR/$PROGRAM.update.$destinationReplica.$SCRIPT_PID.$TSTAMP)" "VERBOSE"
|
Logger "List:\n$(head -c16384 $RUN_DIR/$PROGRAM.update.$destinationReplica.$SCRIPT_PID.$TSTAMP)" "VERBOSE"
|
||||||
fi
|
fi
|
||||||
Logger "Updating $destinationReplica replica succeded." "NOTICE"
|
Logger "Updating $destinationReplica replica succeded." "NOTICE"
|
||||||
return 0
|
return 0
|
||||||
|
@ -1442,7 +1442,7 @@ function _deleteRemote {
|
||||||
Logger "Cannot copy the deletion list to remote replica." "ERROR" $retval
|
Logger "Cannot copy the deletion list to remote replica." "ERROR" $retval
|
||||||
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN"
|
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN"
|
||||||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.precopy.$SCRIPT_PID.$TSTAMP" ]; then
|
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.precopy.$SCRIPT_PID.$TSTAMP" ]; then
|
||||||
Logger "$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.precopy.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
Logger "$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.precopy.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||||
fi
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -1548,7 +1548,7 @@ ENDSSH
|
||||||
if [ -s "$RUN_DIR/$PROGRAM.remote_deletion.$SCRIPT_PID.$TSTAMP" ] && ([ $retval -ne 0 ] || [ "$_LOGGER_VERBOSE" == true ]); then
|
if [ -s "$RUN_DIR/$PROGRAM.remote_deletion.$SCRIPT_PID.$TSTAMP" ] && ([ $retval -ne 0 ] || [ "$_LOGGER_VERBOSE" == true ]); then
|
||||||
(
|
(
|
||||||
_LOGGER_PREFIX="RR"
|
_LOGGER_PREFIX="RR"
|
||||||
Logger "$(cat $RUN_DIR/$PROGRAM.remote_deletion.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
Logger "$(head -c16384 $RUN_DIR/$PROGRAM.remote_deletion.$SCRIPT_PID.$TSTAMP)" "ERROR"
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1560,7 +1560,7 @@ ENDSSH
|
||||||
Logger "Cannot copy back the failed deletion list to initiator replica." "CRITICAL" $retval
|
Logger "Cannot copy back the failed deletion list to initiator replica." "CRITICAL" $retval
|
||||||
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN"
|
_LOGGER_SILENT=true Logger "Command was [$rsyncCmd]." "WARN"
|
||||||
if [ -f "$RUN_DIR/$PROGRAM.remote_failed_deletion_list_copy.$SCRIPT_PID.$TSTAMP" ]; then
|
if [ -f "$RUN_DIR/$PROGRAM.remote_failed_deletion_list_copy.$SCRIPT_PID.$TSTAMP" ]; then
|
||||||
Logger "Comand output: $(cat $RUN_DIR/$PROGRAM.remote_failed_deletion_list_copy.$SCRIPT_PID.$TSTAMP)" "NOTICE"
|
Logger "Comand output: $(head -c16384 $RUN_DIR/$PROGRAM.remote_failed_deletion_list_copy.$SCRIPT_PID.$TSTAMP)" "NOTICE"
|
||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -1696,20 +1696,20 @@ function Sync {
|
||||||
|
|
||||||
if [ "$RESUME_SYNC" != false ]; then
|
if [ "$RESUME_SYNC" != false ]; then
|
||||||
if [ -f "${INITIATOR[$__resumeCount]}" ]; then
|
if [ -f "${INITIATOR[$__resumeCount]}" ]; then
|
||||||
resumeCount=$(cat "${INITIATOR[$__resumeCount]}")
|
resumeCount=$(head -c16384 "${INITIATOR[$__resumeCount]}")
|
||||||
else
|
else
|
||||||
resumeCount=0
|
resumeCount=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $resumeCount -lt $RESUME_TRY ]; then
|
if [ $resumeCount -lt $RESUME_TRY ]; then
|
||||||
if [ -f "${INITIATOR[$__initiatorLastActionFile]}" ]; then
|
if [ -f "${INITIATOR[$__initiatorLastActionFile]}" ]; then
|
||||||
resumeInitiator=$(cat "${INITIATOR[$__initiatorLastActionFile]}")
|
resumeInitiator=$(head -c16384 "${INITIATOR[$__initiatorLastActionFile]}")
|
||||||
else
|
else
|
||||||
resumeInitiator="${SYNC_ACTION[9]}"
|
resumeInitiator="${SYNC_ACTION[9]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "${INITIATOR[$__targetLastActionFile]}" ]; then
|
if [ -f "${INITIATOR[$__targetLastActionFile]}" ]; then
|
||||||
resumeTarget=$(cat "${INITIATOR[$__targetLastActionFile]}")
|
resumeTarget=$(head -c16384 "${INITIATOR[$__targetLastActionFile]}")
|
||||||
else
|
else
|
||||||
resumeTarget="${SYNC_ACTION[9]}"
|
resumeTarget="${SYNC_ACTION[9]}"
|
||||||
fi
|
fi
|
||||||
|
@ -2202,9 +2202,9 @@ function _SoftDeleteLocal {
|
||||||
|
|
||||||
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.deleteErrors.$replicaType.$SCRIPT_PID.$TSTAMP" ]; then
|
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.deleteErrors.$replicaType.$SCRIPT_PID.$TSTAMP" ]; then
|
||||||
Logger "Error while executing cleanup on $replicaType replica." "ERROR" $retval
|
Logger "Error while executing cleanup on $replicaType replica." "ERROR" $retval
|
||||||
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.deleteErrors.$replicaType.$SCRIPT_PID.$TSTAMP)" "WARN"
|
Logger "Command output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.deleteErrors.$replicaType.$SCRIPT_PID.$TSTAMP)" "WARN"
|
||||||
else
|
else
|
||||||
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.deleteErrors.$replicaType.$SCRIPT_PID.$TSTAMP)" "VERBOSE"
|
Logger "Command output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.deleteErrors.$replicaType.$SCRIPT_PID.$TSTAMP)" "VERBOSE"
|
||||||
Logger "File cleanup complete on $replicaType replica." "NOTICE"
|
Logger "File cleanup complete on $replicaType replica." "NOTICE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -2273,10 +2273,10 @@ function _SoftDeleteRemoteSub {
|
||||||
|
|
||||||
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.deleteErrors.$replicaType.$SCRIPT_PID.$TSTAMP" ]; then
|
if [ -s "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.deleteErrors.$replicaType.$SCRIPT_PID.$TSTAMP" ]; then
|
||||||
RemoteLogger "Error while executing cleanup on $replicaType replica." "ERROR" $retval
|
RemoteLogger "Error while executing cleanup on $replicaType replica." "ERROR" $retval
|
||||||
RemoteLogger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.deleteErrors.$replicaType.$SCRIPT_PID.$TSTAMP)" "WARN"
|
RemoteLogger "Command output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.deleteErrors.$replicaType.$SCRIPT_PID.$TSTAMP)" "WARN"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
RemoteLogger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.deleteErrors.$replicaType.$SCRIPT_PID.$TSTAMP)" "VERBOSE"
|
RemoteLogger "Command output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.deleteErrors.$replicaType.$SCRIPT_PID.$TSTAMP)" "VERBOSE"
|
||||||
RemoteLogger "File cleanup complete on $replicaType replica." "NOTICE"
|
RemoteLogger "File cleanup complete on $replicaType replica." "NOTICE"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
@ -2298,13 +2298,13 @@ ENDSSH
|
||||||
Logger "Error while executing cleanup on remote $replicaType replica." "ERROR" $retval
|
Logger "Error while executing cleanup on remote $replicaType replica." "ERROR" $retval
|
||||||
(
|
(
|
||||||
_LOGGER_PREFIX=""
|
_LOGGER_PREFIX=""
|
||||||
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP)" "WARN"
|
Logger "Command output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP)" "WARN"
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
Logger "Cleanup complete on $replicaType replica." "NOTICE"
|
Logger "Cleanup complete on $replicaType replica." "NOTICE"
|
||||||
(
|
(
|
||||||
_LOGGER_PREFIX=""
|
_LOGGER_PREFIX=""
|
||||||
Logger "Command output:\n$(cat $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP)" "VERBOSE"
|
Logger "Command output:\n$(head -c16384 $RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$replicaType.$SCRIPT_PID.$TSTAMP)" "VERBOSE"
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -2363,7 +2363,7 @@ function _TriggerInitiatorRunLocal {
|
||||||
echo "$INSTANCE_ID#$(date '+%Y%m%dT%H%M%S.%N')" >> "$PUSH_FILE" 2> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP"
|
echo "$INSTANCE_ID#$(date '+%Y%m%dT%H%M%S.%N')" >> "$PUSH_FILE" 2> "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
Logger "Could not notify local initiator of file changes." "ERROR"
|
Logger "Could not notify local initiator of file changes." "ERROR"
|
||||||
Logger "$(cat "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
Logger "$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
Logger "Initiator of instance [$INSTANCE_ID] should be notified of file changes now." "NOTICE"
|
Logger "Initiator of instance [$INSTANCE_ID] should be notified of file changes now." "NOTICE"
|
||||||
|
@ -2405,7 +2405,7 @@ ENDSSH
|
||||||
Logger "SSH_CMD [$SSH_CMD]" "DEBUG"
|
Logger "SSH_CMD [$SSH_CMD]" "DEBUG"
|
||||||
(
|
(
|
||||||
_LOGGER_PREFIX="RR"
|
_LOGGER_PREFIX="RR"
|
||||||
Logger "$(cat "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
Logger "$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.error.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||||
)
|
)
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
|
@ -2528,7 +2528,7 @@ function LogConflicts {
|
||||||
|
|
||||||
(
|
(
|
||||||
_LOGGER_PREFIX=""
|
_LOGGER_PREFIX=""
|
||||||
Logger "$(cat "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/${INITIATOR[$__conflictListFile]}")" "ALWAYS"
|
Logger "$(head -c16384 "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/${INITIATOR[$__conflictListFile]}")" "ALWAYS"
|
||||||
)
|
)
|
||||||
|
|
||||||
Logger "There are $conflicts conflictual files." "ALWAYS"
|
Logger "There are $conflicts conflictual files." "ALWAYS"
|
||||||
|
@ -2538,7 +2538,7 @@ function LogConflicts {
|
||||||
|
|
||||||
if [ "$ALERT_CONFLICTS" == true ] && [ -s "$RUN_DIR/$PROGRAM.conflictList.compare.$SCRIPT_PID.$TSTAMP" ]; then
|
if [ "$ALERT_CONFLICTS" == true ] && [ -s "$RUN_DIR/$PROGRAM.conflictList.compare.$SCRIPT_PID.$TSTAMP" ]; then
|
||||||
subject="Conflictual files found in [$INSTANCE_ID]"
|
subject="Conflictual files found in [$INSTANCE_ID]"
|
||||||
body="List of conflictual files:"$'\n'"$(cat "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/${INITIATOR[$__conflictListFile]}")"
|
body="List of conflictual files:"$'\n'"$(head -c16384 "${INITIATOR[$__replicaDir]}${INITIATOR[$__stateDir]}/${INITIATOR[$__conflictListFile]}")"
|
||||||
|
|
||||||
SendEmail "$subject" "$body" "$DESTINATION_MAILS" "" "$SENDER_MAIL" "$SMTP_SERVER" "$SMTP_PORT" "$SMTP_ENCRYPTION" "$SMTP_USER" "$SMTP_PASSWORD"
|
SendEmail "$subject" "$body" "$DESTINATION_MAILS" "" "$SENDER_MAIL" "$SMTP_SERVER" "$SMTP_PORT" "$SMTP_ENCRYPTION" "$SMTP_USER" "$SMTP_PASSWORD"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#### OFUNCTIONS MINI SUBSET ####
|
#### OFUNCTIONS MINI SUBSET ####
|
||||||
#### OFUNCTIONS MICRO SUBSET ####
|
#### OFUNCTIONS MICRO SUBSET ####
|
||||||
_OFUNCTIONS_VERSION=2.3.0-dev-postRC2
|
_OFUNCTIONS_VERSION=2.3.0-dev-postRC2
|
||||||
_OFUNCTIONS_BUILD=2019080801
|
_OFUNCTIONS_BUILD=2019080802
|
||||||
#### _OFUNCTIONS_BOOTSTRAP SUBSET ####
|
#### _OFUNCTIONS_BOOTSTRAP SUBSET ####
|
||||||
_OFUNCTIONS_BOOTSTRAP=true
|
_OFUNCTIONS_BOOTSTRAP=true
|
||||||
#### _OFUNCTIONS_BOOTSTRAP SUBSET END ####
|
#### _OFUNCTIONS_BOOTSTRAP SUBSET END ####
|
||||||
|
@ -569,7 +569,7 @@ function SendEmail {
|
||||||
if [ "$MAIL_BODY_CHARSET" != "" ]; then
|
if [ "$MAIL_BODY_CHARSET" != "" ]; then
|
||||||
if type iconv > /dev/null 2>&1; then
|
if type iconv > /dev/null 2>&1; then
|
||||||
echo "$message" | iconv -f UTF-8 -t $MAIL_BODY_CHARSET -o "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.iconv.$SCRIPT_PID.$TSTAMP"
|
echo "$message" | iconv -f UTF-8 -t $MAIL_BODY_CHARSET -o "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.iconv.$SCRIPT_PID.$TSTAMP"
|
||||||
message="$(cat "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.iconv.$SCRIPT_PID.$TSTAMP")"
|
message="$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.iconv.$SCRIPT_PID.$TSTAMP")"
|
||||||
else
|
else
|
||||||
Logger "iconv utility not installed. Will not convert email charset." "NOTICE"
|
Logger "iconv utility not installed. Will not convert email charset." "NOTICE"
|
||||||
fi
|
fi
|
||||||
|
@ -1107,7 +1107,7 @@ function ExecTasks {
|
||||||
Logger "Command was [${commandsArrayPid[$pid]}]." "ERROR"
|
Logger "Command was [${commandsArrayPid[$pid]}]." "ERROR"
|
||||||
fi
|
fi
|
||||||
if [ -f "${commandsArrayOutput[$pid]}" ]; then
|
if [ -f "${commandsArrayOutput[$pid]}" ]; then
|
||||||
Logger "Command output was [$(cat "${commandsArrayOutput[$pid]}")\n]." "ERROR"
|
Logger "Command output was [$(head -c16384 "${commandsArrayOutput[$pid]}")\n]." "ERROR"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
errorcount=$((errorcount+1))
|
errorcount=$((errorcount+1))
|
||||||
|
@ -1695,14 +1695,14 @@ ENDSSH
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
Logger "Cannot connect to remote system [$REMOTE_HOST] port [$REMOTE_PORT] as [$REMOTE_USER]." "CRITICAL"
|
Logger "Cannot connect to remote system [$REMOTE_HOST] port [$REMOTE_PORT] as [$REMOTE_USER]." "CRITICAL"
|
||||||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ]; then
|
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ]; then
|
||||||
Logger "$(cat "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
Logger "$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "ERROR"
|
||||||
fi
|
fi
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ]; then
|
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ]; then
|
||||||
remoteOsVar=$(cat "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")
|
remoteOsVar="$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")"
|
||||||
case $remoteOsVar in
|
case $remoteOsVar in
|
||||||
*"Android"*)
|
*"Android"*)
|
||||||
REMOTE_OS="Android"
|
REMOTE_OS="Android"
|
||||||
|
@ -1770,7 +1770,7 @@ function RunLocalCommand {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $_LOGGER_VERBOSE == true ] || [ $retval -ne 0 ]; then
|
if [ $_LOGGER_VERBOSE == true ] || [ $retval -ne 0 ]; then
|
||||||
Logger "Command output:\n$(cat "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "NOTICE"
|
Logger "Command output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "NOTICE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$STOP_ON_CMD_ERROR" == true ] && [ $retval -ne 0 ]; then
|
if [ "$STOP_ON_CMD_ERROR" == true ] && [ $retval -ne 0 ]; then
|
||||||
|
@ -1813,7 +1813,7 @@ function RunRemoteCommand {
|
||||||
|
|
||||||
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ] && ([ $_LOGGER_VERBOSE == true ] || [ $retval -ne 0 ])
|
if [ -f "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP" ] && ([ $_LOGGER_VERBOSE == true ] || [ $retval -ne 0 ])
|
||||||
then
|
then
|
||||||
Logger "Command output:\n$(cat "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "NOTICE"
|
Logger "Command output:\n$(head -c16384 "$RUN_DIR/$PROGRAM.${FUNCNAME[0]}.$SCRIPT_PID.$TSTAMP")" "NOTICE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$STOP_ON_CMD_ERROR" == true ] && [ $retval -ne 0 ]; then
|
if [ "$STOP_ON_CMD_ERROR" == true ] && [ $retval -ne 0 ]; then
|
||||||
|
|
Loading…
Reference in New Issue