[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#808369: [checks/systemd] please check if Alias entry conforms the spec



control: tags -1 + patch
>From 5628625c10222427122beb97196dbcdeb1017edb Mon Sep 17 00:00:00 2001
From: Evgeni Golov <evgeni@debian.org>
Date: Sat, 19 Dec 2015 09:31:02 +0100
Subject: [PATCH] check if systemd service alias has an .service extension
 Closes: #808369

---
 checks/systemd.desc                                | 9 +++++++++
 checks/systemd.pm                                  | 2 ++
 t/tests/systemd-general/debian/debian/test.service | 1 +
 t/tests/systemd-general/desc                       | 1 +
 t/tests/systemd-general/tags                       | 2 ++
 5 files changed, 15 insertions(+)

diff --git a/checks/systemd.desc b/checks/systemd.desc
index 828b66b..e895606 100644
--- a/checks/systemd.desc
+++ b/checks/systemd.desc
@@ -108,3 +108,12 @@ Info: The systemd service file contains space in the key definitions
  have been known to break.
  .
  Please remove the spaces surrounding the key definition.
+
+Tag: systemd-service-alias-without-extension
+Severity: normal
+Certainty: certain
+Ref: http://www.freedesktop.org/software/systemd/man/systemd.unit.html#Alias=
+Info: The service file lists an alias without an file extension.
+ .
+ The spec mandates that the extension of the listed alias matches
+ the extension of the unit itself.
diff --git a/checks/systemd.pm b/checks/systemd.pm
index e59510e..8aa7372 100644
--- a/checks/systemd.pm
+++ b/checks/systemd.pm
@@ -164,6 +164,8 @@ sub get_systemd_service_names {
           = extract_service_file_values($info, $file, 'Install', 'Alias', 1);
 
         for my $alias (@aliases) {
+            tag 'systemd-service-alias-without-extension', $file
+              if ($alias !~ m/\.service$/);
             $safe_add_service->($alias, $file);
         }
     }
diff --git a/t/tests/systemd-general/debian/debian/test.service b/t/tests/systemd-general/debian/debian/test.service
index a327823..b283e6e 100644
--- a/t/tests/systemd-general/debian/debian/test.service
+++ b/t/tests/systemd-general/debian/debian/test.service
@@ -8,3 +8,4 @@ ExecStart=/usr/bin/test
 
 [Install]
 WantedBy=multi-user.target
+Alias=anothertest
diff --git a/t/tests/systemd-general/desc b/t/tests/systemd-general/desc
index f865251..4d12ddb 100644
--- a/t/tests/systemd-general/desc
+++ b/t/tests/systemd-general/desc
@@ -13,3 +13,4 @@ Test-For:
  systemd-service-file-refers-to-obsolete-target
  systemd-no-service-for-init-script
  systemd-no-service-for-init-rcS-script
+ systemd-service-alias-without-extension
diff --git a/t/tests/systemd-general/tags b/t/tests/systemd-general/tags
index 9f35134..c1651ef 100644
--- a/t/tests/systemd-general/tags
+++ b/t/tests/systemd-general/tags
@@ -15,5 +15,7 @@ W: systemd-general: maintainer-script-calls-systemctl postrm:6
 W: systemd-general: script-in-etc-init.d-not-registered-via-update-rc.d etc/init.d/bootmisc.sh
 W: systemd-general: script-in-etc-init.d-not-registered-via-update-rc.d etc/init.d/fifo-pipe-as-init
 W: systemd-general: script-in-etc-init.d-not-registered-via-update-rc.d etc/init.d/masked
+W: systemd-general: systemd-service-alias-without-extension etc/systemd/system/test.service
+W: systemd-general: systemd-service-alias-without-extension usr/lib/systemd/system/test.service
 W: systemd-general: systemd-service-file-refers-to-obsolete-target etc/systemd/system/test.service syslog.target
 W: systemd-general: systemd-service-file-refers-to-obsolete-target usr/lib/systemd/system/test.service syslog.target
-- 
2.6.4


Reply to: