Do not check SmackProcessLabel for .service units without [Service] section 61/314361/1 accepted/tizen/unified/20240716.112358 accepted/tizen/unified/20240716.140240 accepted/tizen/unified/dev/20240717.110327 accepted/tizen/unified/x/20240717.012454
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 10 Jul 2024 18:41:04 +0000 (20:41 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 10 Jul 2024 18:41:04 +0000 (20:41 +0200)
Such units are provided by new systemd (>= 255).

We retain old logic and service exceptions for package to work with both new
and old systemd versions.

Change-Id: Ia01365e0ba76053932b61bf3f143e0bcdbddf573

test/new_service_test/check_systemd_service.sh

index 32c18df966ed3ec59bda6af15503f13fb90c1fab..a4597754ffc077cdc1e1d8bff209a5af3397f0d4 100755 (executable)
@@ -23,7 +23,13 @@ function check_system_service
        else
                gid="$3"
        fi
-       result=$(cat $systemd_service_list | grep ";$service_name;$uid;$gid;$4;")
+       # systemd does provide special .service units with no [Service] section, these have to be treated specially
+       if grep -qE '^\[Service\]$' $1; then
+               check_smack_label="$4;"
+       else
+               check_smack_label=""
+       fi
+       result=$(cat $systemd_service_list | grep ";$service_name;$uid;$gid;$check_smack_label")
        if [ "$result" == "" ]
        then
                echo "Not permitted Systemd Service (system session) : $1"