diff options
author | James Harvey <jamespharvey20@gmail.com> | 2015-08-03 07:00:16 +0000 |
---|---|---|
committer | Kyle Keen <keenerd@gmail.com> | 2016-01-31 17:59:27 -0500 |
commit | 9e8a45ceeeb5142cc8f1e1e387a4adf7c8bccb09 (patch) | |
tree | c5076b265a362a58d9d324f7d8a5c90e586174bf | |
parent | 805ed84f6c476333973e91d9f8059434297ce28f (diff) | |
download | namcap-9e8a45ceeeb5142cc8f1e1e387a4adf7c8bccb09.tar.gz namcap-9e8a45ceeeb5142cc8f1e1e387a4adf7c8bccb09.zip |
Add a test for systemd files in /etc/systemd/system/
Signed-off-by: Kyle Keen <keenerd@gmail.com>
-rw-r--r-- | Namcap/rules/__init__.py | 1 | ||||
-rw-r--r-- | Namcap/rules/systemdlocation.py | 46 | ||||
-rw-r--r-- | namcap-tags | 1 |
3 files changed, 48 insertions, 0 deletions
diff --git a/Namcap/rules/__init__.py b/Namcap/rules/__init__.py index 6c8c708..d7b86c3 100644 --- a/Namcap/rules/__init__.py +++ b/Namcap/rules/__init__.py @@ -48,6 +48,7 @@ from . import ( shebangdepends, sodepends, symlink, + systemdlocation, unusedsodepends ) diff --git a/Namcap/rules/systemdlocation.py b/Namcap/rules/systemdlocation.py new file mode 100644 index 0000000..94915d1 --- /dev/null +++ b/Namcap/rules/systemdlocation.py @@ -0,0 +1,46 @@ +# +# namcap rules - systemdlocation +# Copyright (C) 2015 James Harvey <jamespharvey20@gmail.com> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +import os +from Namcap.ruleclass import * + +class systemdlocationRule(TarballRule): + name = "systemdlocation" + description = "Checks for systemd files in /etc/systemd/system/" + def analyze(self, pkginfo, tar): + # don't have this warning for the systemd package + if 'name' in pkginfo: + if pkginfo['name'] == 'systemd': + return + # don't have this warning for packages that provides systemd + if 'provides' in pkginfo: + if 'systemd' in pkginfo['provides']: + return + for entry in tar: + # ignore the actual directory, as that's handled by emptydirs + if entry.isdir(): + continue; + + name = os.path.normpath(entry.name) + + # check for files in /etc/systemd/system/ + if name.startswith('etc/systemd/system/'): + self.warnings.append(("systemd-location %s", name)) + +# vim: set ts=4 sw=4 noet: diff --git a/namcap-tags b/namcap-tags index a5c348c..c60c88a 100644 --- a/namcap-tags +++ b/namcap-tags @@ -76,6 +76,7 @@ site-ruby :: Found usr/lib/ruby/site_ruby in package, usr/lib/ruby/vendor_ruby s specific-host-type-used %s :: Reference to %s should be changed to $CARCH specific-sourceforge-mirror :: Attempting to use specific sourceforge mirror, use downloads.sourceforge.net instead symlink-found %s points to %s :: Symlink (%s) found that points to %s +systemd-location %s :: File %s should be in /usr/lib/systemd/system/ too-many-checksums %s %i needed :: Too many %s: %i needed unused-sodepend %s %s :: Unused shared library '%s' by file ('%s') use-pkgdir :: Use $pkgdir instead of $startdir/pkg |