diff --git a/kpatch.spec b/kpatch.spec index c0fbc39446046c4473e37f716eb6027cf923fbe8..072ba8f7a366e77fbcc17274e949cd01c389e0ae 100644 --- a/kpatch.spec +++ b/kpatch.spec @@ -1,7 +1,7 @@ Name: kpatch Epoch: 1 Version: 0.9.9 -Release: 14 +Release: 15 Summary: A Linux dynamic kernel patching infrastructure License: GPLv2 @@ -127,11 +127,17 @@ popd %{_mandir}/man1/*.1.gz %changelog +* Thu Jul 10 2025 fuanan - 1:0.9.9-15 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:Delete the lock after make_hotpatch single instance run. + * Thu Jun 26 2025 jinsaihang - 1:0.9.9-14 - Type:bugfix - CVE:NA - SUG:NA -- DESC:make sure make_hotpath is running in a single instance +- DESC:make sure make_hotpatch is running in a single instance * Tue Jun 03 2025 jinsaihang - 1:0.9.9-13 - Type:bugfix diff --git a/make_hotpatch b/make_hotpatch index 358754c9dbee0b1d2ed0d1819a33204bcd118eb7..e5d9f71020725ed114da528471614d03b63cbd08 100644 --- a/make_hotpatch +++ b/make_hotpatch @@ -121,7 +121,7 @@ function fn_check_reg_char() echo "error: the string is empty, check string failed" return 1 fi - ## character string length + # character string length if [ -n "$l_str_maxlen" ] && [ -z "`echo $l_str_maxlen | sed 's/[0-9]//g'`" ];then if [ $len_str -gt $l_str_maxlen ]; then echo "error: The length of $l_str exceed max length $l_str_maxlen." @@ -138,7 +138,7 @@ function fn_check_reg_char() echo "error: string $l_str must start with a character ('0-9' or 'A-Z' or 'a-z')." return 1 fi - # only '-' and '_' numbers and letters are allowed + # only '-' and '_' and numbers and letters are allowed if [ -n "`echo $l_str | grep -E '[^a-z0-9A-Z_-]'`" ];then if [ -n "$l_str_ex" ] ;then # starting with numbers and letters @@ -673,10 +673,10 @@ function fn_prepare() LOCK_FILE="/var/run/make_hotpatch.lock" # define the lock value LOCK_FD=200 - + # get the pid make_hotpatch_pid=$$ - + if [ -e "$LOCK_FILE" ]; then lock_pid=$(cat "$LOCK_FILE") # check if the lock process is running @@ -689,20 +689,27 @@ if [ -e "$LOCK_FILE" ]; then exit 1 fi fi - + # trap exception exit and delete lock file trap 'rm -f "$LOCK_FILE"' EXIT TERM INT - + # binding the lock value to Lock File exec {LOCK_FD}> "$LOCK_FILE" echo $$ > "$LOCK_FILE" - + # obtaining a Lock in Non-Block Mode if ! flock -n $LOCK_FD; then echo "[$0] Someone is making, please try again later." exit 1 fi +echo "The pid of make_hotpatch is: $make_hotpatch_pid" + fn_prepare fn_main $@ -exit $? +main_exit_code=$? + +# remove lock file +rm -f "$LOCK_FILE" + +exit $main_exit_code