2015-04-10 16:35:46 +02:00
|
|
|
From: Ludwig Nussel <ludwig.nussel@suse.de>
|
|
|
|
Date: Fri, 10 Apr 2015 14:38:22 +0200
|
|
|
|
Subject: [PATCH] suse sysv init checks
|
|
|
|
|
|
|
|
we don't use chkconfig but have different macros
|
|
|
|
---
|
2015-11-26 11:24:13 +01:00
|
|
|
InitScriptCheck.py | 48 ++++++++++++++++++++++++++++++++++--------------
|
|
|
|
1 file changed, 34 insertions(+), 14 deletions(-)
|
2015-04-10 16:35:46 +02:00
|
|
|
|
|
|
|
diff --git a/InitScriptCheck.py b/InitScriptCheck.py
|
2015-11-26 11:24:13 +01:00
|
|
|
index f9b13a1..f81a450 100644
|
2015-04-10 16:35:46 +02:00
|
|
|
--- a/InitScriptCheck.py
|
|
|
|
+++ b/InitScriptCheck.py
|
|
|
|
@@ -36,6 +36,10 @@ LSB_KEYWORDS = ('Provides', 'Required-Start', 'Required-Stop', 'Should-Start',
|
|
|
|
RECOMMENDED_LSB_KEYWORDS = ('Provides', 'Required-Start', 'Required-Stop',
|
|
|
|
'Default-Stop', 'Short-Description')
|
|
|
|
|
|
|
|
+suse = True
|
2016-05-26 02:11:08 +02:00
|
|
|
+stop_on_removal_regex=re.compile('bin/systemctl stop (?!.+\.service).+')
|
|
|
|
+restart_on_update_regex=re.compile('bin/systemctl try-restart (?!.+\.service).+')
|
2015-04-10 16:35:46 +02:00
|
|
|
+insserv_cleanup_regex=re.compile('^\s*/sbin/insserv /etc/init.d$', re.MULTILINE)
|
|
|
|
|
|
|
|
class InitScriptCheck(AbstractCheck.AbstractCheck):
|
|
|
|
|
|
|
|
@@ -44,6 +48,12 @@ class InitScriptCheck(AbstractCheck.AbstractCheck):
|
|
|
|
|
|
|
|
def check_binary(self, pkg):
|
|
|
|
initscript_list = []
|
|
|
|
+
|
|
|
|
+ # check chkconfig call in %post and %preun
|
2016-08-31 08:39:49 +02:00
|
|
|
+ postin = pkg[rpm.RPMTAG_POSTIN] or pkg.scriptprog(rpm.RPMTAG_POSTINPROG)
|
|
|
|
+ preun = pkg[rpm.RPMTAG_PREUN] or pkg.scriptprog(rpm.RPMTAG_PREUNPROG)
|
|
|
|
+ postun = pkg[rpm.RPMTAG_POSTUN] or pkg.scriptprog(rpm.RPMTAG_POSTUNPROG)
|
2015-04-10 16:35:46 +02:00
|
|
|
+
|
|
|
|
for fname, pkgfile in pkg.files().items():
|
|
|
|
|
|
|
|
if not fname.startswith('/etc/init.d/') and \
|
2015-11-26 11:24:13 +01:00
|
|
|
@@ -61,20 +71,30 @@ class InitScriptCheck(AbstractCheck.AbstractCheck):
|
2015-04-10 16:35:46 +02:00
|
|
|
if "." in basename:
|
|
|
|
printError(pkg, 'init-script-name-with-dot', fname)
|
|
|
|
|
|
|
|
- # check chkconfig call in %post and %preun
|
2015-11-26 11:24:13 +01:00
|
|
|
- postin = pkg[rpm.RPMTAG_POSTIN] or \
|
2015-04-10 16:35:46 +02:00
|
|
|
- pkg.scriptprog(rpm.RPMTAG_POSTINPROG)
|
|
|
|
- if not postin:
|
|
|
|
- printError(pkg, 'init-script-without-chkconfig-postin', fname)
|
|
|
|
- elif not chkconfig_regex.search(postin):
|
|
|
|
- printError(pkg, 'postin-without-chkconfig', fname)
|
|
|
|
-
|
2015-11-26 11:24:13 +01:00
|
|
|
- preun = pkg[rpm.RPMTAG_PREUN] or \
|
2015-04-10 16:35:46 +02:00
|
|
|
- pkg.scriptprog(rpm.RPMTAG_PREUNPROG)
|
|
|
|
- if not preun:
|
|
|
|
- printError(pkg, 'init-script-without-chkconfig-preun', fname)
|
|
|
|
- elif not chkconfig_regex.search(preun):
|
|
|
|
- printError(pkg, 'preun-without-chkconfig', fname)
|
|
|
|
+ if not suse:
|
2015-11-26 11:24:13 +01:00
|
|
|
+ # check chkconfig call in %post and %preun
|
|
|
|
+ postin = pkg[rpm.RPMTAG_POSTIN] or \
|
|
|
|
+ pkg.scriptprog(rpm.RPMTAG_POSTINPROG)
|
2015-04-10 16:35:46 +02:00
|
|
|
+ if not postin:
|
|
|
|
+ printError(pkg, 'init-script-without-chkconfig-postin', fname)
|
|
|
|
+ elif not chkconfig_regex.search(postin):
|
|
|
|
+ printError(pkg, 'postin-without-chkconfig', fname)
|
|
|
|
+
|
2015-11-26 11:24:13 +01:00
|
|
|
+ preun = pkg[rpm.RPMTAG_PREUN] or \
|
|
|
|
+ pkg.scriptprog(rpm.RPMTAG_PREUNPROG)
|
2015-04-10 16:35:46 +02:00
|
|
|
+ if not preun:
|
|
|
|
+ printError(pkg, 'init-script-without-chkconfig-preun', fname)
|
|
|
|
+ elif not chkconfig_regex.search(preun):
|
|
|
|
+ printError(pkg, 'preun-without-chkconfig', fname)
|
|
|
|
+ else:
|
|
|
|
+ if not preun or not stop_on_removal_regex.search(preun):
|
|
|
|
+ printError(pkg, 'init-script-without-%stop_on_removal-preun', fname)
|
|
|
|
+
|
|
|
|
+ if not postun or not restart_on_update_regex.search(postun):
|
|
|
|
+ printError(pkg, 'init-script-without-%restart_on_update-postun', fname)
|
|
|
|
+
|
|
|
|
+ if not postun or not insserv_cleanup_regex.search(postun):
|
|
|
|
+ printError(pkg, 'init-script-without-%insserv_cleanup-postun', fname)
|
|
|
|
|
|
|
|
status_found = False
|
|
|
|
reload_found = False
|