diff --git a/sspatch/all/usr/bin/S82surveillance.sh b/sspatch/all/usr/bin/S82surveillance.sh deleted file mode 100755 index f6ed9c9..0000000 --- a/sspatch/all/usr/bin/S82surveillance.sh +++ /dev/null @@ -1,143 +0,0 @@ -#!/bin/sh -# Copyright (c) 2014 Synology Inc. All rights reserved. - -SURVEILLANCE_INC_SCRP=/var/packages/SurveillanceStation/scripts/SurveillanceStationCommon -. ${SURVEILLANCE_INC_SCRP} - -SS_BIN_DIR="${SS_TARGET_DIR}/bin" -SSCTL="${SS_BIN_DIR}/ssctl" -SS_DBG_LOG_ROTATE_CONF="/usr/local/etc/logrotate.d/SurveillanceStation" - -UpdateSSDbgLogRotateConf() -{ - cat > $SS_DBG_LOG_ROTATE_CONF < /dev/null 2>&1 - if [ $? -ne ${RET_SYNO_SERVICE_ENABLED} ]; then - echo false - else - echo true - fi - fi -} - -Start() -{ - SSDebugLog "Start Surveillance [$SURVEILLANCE_PKG_VERSION] begin." - - local Ret - - UpdateSSDbgLogRotateConf - - if [ true == $(IsNonRecordingMode) -a true == $(IsServiceDataLinkAlive) ]; then - rm -f ${SS_NON_RECORDING_FILE} - fi - - if [ false == $(IsNonRecordingMode) ]; then - CheckToCreateRecDB - Ret=$? - if [ 0 -ne ${Ret} ]; then - SSDebugLog "Failed to prepare share folder." - UpdateNonRecordingMode - fi - - if [ ! -f ${SS_REC_DB} ]; then - SSDebugLog "Recording db not found." - UpdateNonRecordingMode - fi - fi - - if [ ${USE_SQLITE} == false ]; then - if [ false == $(CheckPgsqlService) ]; then - SSDebugLog "PGSQL is not enabled" - exit 1; - fi - - if [ false == $(HasSSPgsqlData) ]; then - SSDebugLog "PGSQL db have not been created yet." - exit 1 - fi - else - if [ ! -f ${SS_SYSTEM_DB} ]; then - SSDebugLog "System db not found." - exit 1 - fi - fi - - - ${SSCTL} start - sh /var/packages/SurveillanceStation/target/scripts/license.sh > /dev/null 2>&1 & echo $! - - SSDebugLog "Start Surveillance [$SURVEILLANCE_PKG_VERSION] end." -} - -Stop() -{ - SSDebugLog "Stop Surveillance [$SURVEILLANCE_PKG_VERSION] begin." - - if [ ${USE_SQLITE} == false ]; then - if [ false == $(HasSSPgsqlData) ]; then - echo "Surveillance: DB is stopped before Surveillance stops" - fi - else - if [ ! -f ${SS_SYSTEM_DB} ]; then - echo "Surveillance System DB not found." - fi - fi - - ${SSCTL} stop - sudo pkill -9 -f /var/packages/SurveillanceStation/target/scripts/license.sh - - SSDebugLog "Stop Surveillance [$SURVEILLANCE_PKG_VERSION] end" -} - -Restart() -{ - Stop - sleep 1 - Start -} - -TriggerSctrl() -{ - ${SSCTL} "$1" "$2" "$3" -} - -main() -{ - PackageInfoGet - - case $1 in - "start") - Start - ;; - "stop") - Stop - ;; - "restart") - Restart - ;; - "trigger-ssctl") - TriggerSctrl "$2" "$3" "$4" - ;; - *) - echo "Usage: $0 start|stop|restart|share_folder" - ;; - esac -} - -main "$@" diff --git a/sspatch/all/usr/bin/license.sh b/sspatch/all/usr/bin/license.sh deleted file mode 100755 index cb5f5c8..0000000 --- a/sspatch/all/usr/bin/license.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -while true -do -sleep 3600 -/var/packages/SurveillanceStation/target/bin/ssctl restart - -done diff --git a/sspatch/all/usr/bin/patchelf b/sspatch/all/usr/bin/patchelf new file mode 100755 index 0000000..f132c79 Binary files /dev/null and b/sspatch/all/usr/bin/patchelf differ diff --git a/sspatch/all/usr/bin/sspatch.sh b/sspatch/all/usr/bin/sspatch.sh index 4be3d79..857c553 100755 --- a/sspatch/all/usr/bin/sspatch.sh +++ b/sspatch/all/usr/bin/sspatch.sh @@ -1,4 +1,10 @@ #!/usr/bin/env bash +# +# Copyright (C) 2023 AuxXxilium +# +# This is free software, licensed under the MIT License. +# See /LICENSE for more information. +# if [ -d /var/packages/SurveillanceStation ]; then # Define the entries to be added @@ -30,8 +36,8 @@ if [ -d /var/packages/SurveillanceStation ]; then PATHSCRIPTS="${SSPATH}/target/scripts" SPATCHBIN="/usr/bin" - SO_FILE="${SSPATH}/target/lib/libssutils.so" - if [ ! -f "${SO_FILE}" ]; then + SO_FILE="${SSPATH}/target/lib/libssutils" + if [ ! -f "${SO_FILE}.so" ]; then echo "SSPatch: libssutils.so does not exist" exit 1 fi @@ -40,26 +46,14 @@ if [ -d /var/packages/SurveillanceStation ]; then sleep 5 # Check Sha256sum - if [ "$(sha256sum "${SO_FILE}" | cut -d' ' -f1)" = "81b64d65f4a2a65626f9280ba43ea43f031a239af3152b859b79e1b5124cc6e3" ]; then - PATCH="8548ffffff41be43000000e93dffffff/8548ffffff41be7b000000e93dffffff" - cp -f "${SO_FILE}" "${SO_FILE}.bak" - cp -f "${SO_FILE}" "${SO_FILE}.tmp" - xxd -c $(xxd -p "${SO_FILE}.tmp" 2>/dev/null | wc -c) -p "${SO_FILE}.tmp" 2>/dev/null | - sed "s/${PATCH}/" | - xxd -r -p >"${SO_FILE}" 2>/dev/null - rm -f "${SO_FILE}.tmp" - echo "SSPatch: libssutils.so is patched" - elif [ "$(sha256sum "${SO_FILE}" | cut -d' ' -f1)" = "b0fafefe820aa8ecd577313dff2ae22cf41a6ddf44051f01670c3b92ee04224d" ]; then - PATCH="850b010000e8b684e5ff83f80141bc43/850b010000e8b684e5ff83f80141bc7b" - cp -f "${SO_FILE}" "${SO_FILE}.bak" - cp -f "${SO_FILE}" "${SO_FILE}.tmp" - xxd -c $(xxd -p "${SO_FILE}.tmp" 2>/dev/null | wc -c) -p "${SO_FILE}.tmp" 2>/dev/null | - sed "s/${PATCH}/" | - xxd -r -p >"${SO_FILE}" 2>/dev/null - rm -f "${SO_FILE}.tmp" +if [ "$(sha256sum "${SO_FILE}" | cut -d' ' -f1)" = "b0fafefe820aa8ecd577313dff2ae22cf41a6ddf44051f01670c3b92ee04224d" ]; then + mv -f "${SO_FILE}.so" "${SO_FILE}.org.so" + cp -f "/usr/lib/libssutils.mitm.so" "${SO_FILE}.mitm.so" + patchelf --add-needed /var/packages/SurveillanceStation/target/lib/libssutils.org.so /var/packages/SurveillanceStation/target/lib/libssutils.mitm.so + mv -f "${SO_FILE}.mitm.so" "${SO_FILE}.so" echo "SSPatch: libssutils.so is patched" else - if [ -f "${SO_FILE}.bak" ]; then + if [ -f "${SO_FILE}.org.so" ]; then echo "SSPatch: libssutils.so is already patched" exit 0 else @@ -70,16 +64,6 @@ if [ -d /var/packages/SurveillanceStation ]; then chown SurveillanceStation:SurveillanceStation "${SO_FILE}" chmod 0644 "${SO_FILE}" - rm -f "${PATHSCRIPTS}/S82surveillance.sh" - cp -f "${SPATCHBIN}/S82surveillance.sh" "${PATHSCRIPTS}/S82surveillance.sh" - chown SurveillanceStation:SurveillanceStation "${PATHSCRIPTS}/S82surveillance.sh" - chmod 0755 "${PATHSCRIPTS}/S82surveillance.sh" - - rm -f "${PATHSCRIPTS}/license.sh" - cp -f "${SPATCHBIN}/license.sh" "${PATHSCRIPTS}/license.sh" - chown SurveillanceStation:SurveillanceStation "${PATHSCRIPTS}/license.sh" - chmod 0777 "${PATHSCRIPTS}/license.sh" - echo -e "SSPatch: Successfull!" sleep 5 diff --git a/sspatch/all/usr/lib/libssutils.mitm.so b/sspatch/all/usr/lib/libssutils.mitm.so new file mode 100755 index 0000000..1176d6e Binary files /dev/null and b/sspatch/all/usr/lib/libssutils.mitm.so differ diff --git a/sspatch/install.sh b/sspatch/install.sh index 8ad3b48..74a68aa 100755 --- a/sspatch/install.sh +++ b/sspatch/install.sh @@ -6,9 +6,14 @@ if [ "${1}" = "late" ]; then cp -vf "${0}" "/tmpRoot/usr/arc/addons/" cp -vf /usr/bin/sspatch.sh /tmpRoot/usr/bin/sspatch.sh - cp -vf /usr/bin/license.sh /tmpRoot/usr/bin/license.sh - cp -vf /usr/bin/S82surveillance.sh /tmpRoot/usr/bin/S82surveillance.sh + cp -vf /usr/bin/patchelf /tmpRoot/usr/bin/patchelf + cp -vf /usr/lib/libssutils.mitm.so /tmpRoot/usr/lib/libssutils.mitm.so + SED_PATH='/tmpRoot/usr/bin/sed' + ${SED_PATH} -i '/synopkg restart SurveillanceStation/d' /tmpRoot/etc/crontab + # Add line to crontab, execute each minute + echo "5 0 * * * root synopkg restart SurveillanceStation #arc sspatch addon" >>/tmpRoot/etc/crontab + mkdir -p "/tmpRoot/usr/lib/systemd/system" DEST="/tmpRoot/usr/lib/systemd/system/sspatch.service" cat << EOF > ${DEST} @@ -23,7 +28,7 @@ User=root Type=simple Restart=on-failure RestartSec=5s -ExecStart=/usr/bin/sspatch.sh +ExecStart=-/usr/bin/sspatch.sh [Install] WantedBy=multi-user.target diff --git a/sspatch/manifest.yml b/sspatch/manifest.yml index 908f755..15b3f18 100644 --- a/sspatch/manifest.yml +++ b/sspatch/manifest.yml @@ -1,6 +1,6 @@ version: 1 name: sspatch -description: "Dynamic License Patch for SS! (Not for DVA)" +description: "Dynamic 50 License Patch for SS 9.2.0-11289!" system: false beta: true all: