Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 Apr 2020 11:58:03 +0000 (UTC)
From:      =?UTF-8?Q?Fernando_Apestegu=c3=ada?= <fernape@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r530648 - in head/sysutils/checkrestart: . files
Message-ID:  <202004041158.034Bw3UT015291@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: fernape
Date: Sat Apr  4 11:58:03 2020
New Revision: 530648
URL: https://svnweb.freebsd.org/changeset/ports/530648

Log:
  sysutils/checkrestart: improve rc script
  
  * Use %%PREFIX%% in checkrestart.in
  * Use check_yesno_period instead of handmade solution
  
  PR:	245283
  Submitted by:	tom@hur.st (maintainer)
  Reported by:	0mp@

Modified:
  head/sysutils/checkrestart/Makefile
  head/sysutils/checkrestart/files/checkrestart.in
  head/sysutils/checkrestart/pkg-message

Modified: head/sysutils/checkrestart/Makefile
==============================================================================
--- head/sysutils/checkrestart/Makefile	Sat Apr  4 11:47:03 2020	(r530647)
+++ head/sysutils/checkrestart/Makefile	Sat Apr  4 11:58:03 2020	(r530648)
@@ -3,6 +3,7 @@
 PORTNAME=	checkrestart
 DISTVERSIONPREFIX=	v
 DISTVERSION=	0.5.0
+PORTREVISION=	1
 CATEGORIES=	sysutils
 
 MAINTAINER=	tom@hur.st
@@ -18,14 +19,14 @@ SUB_FILES=	checkrestart
 
 PLIST_FILES=	bin/checkrestart \
 		share/man/man1/checkrestart.1.gz \
-		etc/periodic/daily/checkrestart
+		${PERIODIC_SECURITY}/checkrestart
 
-PERIODIC_DAILY=	etc/periodic/daily
+PERIODIC_SECURITY=	etc/periodic/security/
 
 do-install:
 	${INSTALL_PROGRAM} ${WRKSRC}/checkrestart ${STAGEDIR}${PREFIX}/bin
 	${INSTALL_MAN} ${WRKSRC}/checkrestart.1 ${STAGEDIR}${MAN1PREFIX}/share/man/man1
-	@${MKDIR} ${STAGEDIR}${PREFIX}/${PERIODIC_DAILY}
-	${INSTALL_SCRIPT} ${WRKDIR}/checkrestart ${STAGEDIR}${PREFIX}/${PERIODIC_DAILY}
+	@${MKDIR} ${STAGEDIR}${PREFIX}/${PERIODIC_SECURITY}
+	${INSTALL_SCRIPT} ${WRKDIR}/checkrestart ${STAGEDIR}${PREFIX}/${PERIODIC_SECURITY}
 
 .include <bsd.port.mk>

Modified: head/sysutils/checkrestart/files/checkrestart.in
==============================================================================
--- head/sysutils/checkrestart/files/checkrestart.in	Sat Apr  4 11:47:03 2020	(r530647)
+++ head/sysutils/checkrestart/files/checkrestart.in	Sat Apr  4 11:58:03 2020	(r530648)
@@ -6,13 +6,13 @@ if [ -r /etc/defaults/periodic.conf ]; then
     source_periodic_confs
 fi
 
-: "${daily_checkrestart_enable:=NO}"
-: "${daily_checkrestart_weekdays:=1234567}" # Days of the week to run, Monday=1
-: "${daily_checkrestart_users:=}"           # User names or IDs to check
-: "${daily_checkrestart_jails:=}"           # Jail names or IDs to check
-: "${daily_checkrestart_procs:=}"           # Process names or IDs to check
+: "${security_checkrestart_enable:=NO}"
+: "${security_checkrestart_period:=DAILY}"
+: "${security_checkrestart_users:=}"           # User names or IDs to check
+: "${security_checkrestart_jails:=}"           # Jail names or IDs to check
+: "${security_checkrestart_procs:=}"           # Process names or IDs to check
 
-checkrestartcmd=/usr/local/bin/checkrestart
+checkrestartcmd=%%PREFIX%%/bin/checkrestart
 hflag=""
 rc=0
 
@@ -20,7 +20,7 @@ export COLUMNS=80
 
 checkrestart() {
     local result
-    result="$(${checkrestartcmd} ${hflag} "$@" -- ${daily_checkrestart_procs} 2>&1)"
+    result="$(${checkrestartcmd} ${hflag} "$@" -- ${security_checkrestart_procs} 2>&1)"
     if [ "$result" ]; then
         echo "${result}"
         rc=3
@@ -29,8 +29,8 @@ checkrestart() {
 }
 
 checkrestart_each_user() {
-    if [ -n "${daily_checkrestart_users}" ]; then
-        for user in ${daily_checkrestart_users}; do
+    if [ -n "${security_checkrestart_users}" ]; then
+        for user in ${security_checkrestart_users}; do
             checkrestart -u "${user}" "$@"
         done
     else
@@ -39,8 +39,8 @@ checkrestart_each_user() {
 }
 
 checkrestart_start() {
-    if [ -n "${daily_checkrestart_jails}" ]; then
-        for jail in ${daily_checkrestart_jails}; do
+    if [ -n "${security_checkrestart_jails}" ]; then
+        for jail in ${security_checkrestart_jails}; do
             checkrestart_each_user -j "${jail}"
         done
     else
@@ -48,23 +48,11 @@ checkrestart_start() {
     fi
 }
 
-checkday() {
-    if echo "${daily_checkrestart_weekdays}" | grep -vq '^[1-7, ]*$'; then
-        echo "daily_checkrestart_weekdays must have values 1-7"
-        exit 2
-    fi
-
-    echo "${daily_checkrestart_weekdays}" | grep -Fq "$(date +%u)"
-}
-
-case "${daily_checkrestart_enable}" in
-    [Yy][Ee][Ss])
-    if checkday; then
-        echo
-        echo 'Checking for stale processes:'
-        checkrestart_start
-    fi
-    ;;
-esac
+if check_yesno_period security_checkrestart_enable
+then
+    echo
+    echo 'Checking for stale processes:'
+    checkrestart_start
+fi
 
 exit $rc

Modified: head/sysutils/checkrestart/pkg-message
==============================================================================
--- head/sysutils/checkrestart/pkg-message	Sat Apr  4 11:47:03 2020	(r530647)
+++ head/sysutils/checkrestart/pkg-message	Sat Apr  4 11:58:03 2020	(r530648)
@@ -4,13 +4,33 @@
 In order to enable periodic(8) checks, set the following in /etc/periodic.conf
 
 # Required
-daily_checkrestart_enable="YES"
+security_checkrestart_enable="YES"
 
 # Optional
-daily_checkrestart_weekdays="1 4"     # only run on Monday and Thursday
-daily_checkrestart_jails="0 web"      # limit to jails 0 and web
-daily_checkrestart_users="root www"   # limit to root and www users
-daily_checkrestart_procs="smbd httpd" # limit to samba and httpd
+security_checkrestart_period="DAILY"     # or WEEKY, or MONTHLY
+security_checkrestart_jails="0 web"      # limit to jails 0 and web
+security_checkrestart_users="root www"   # limit to root and www users
+security_checkrestart_procs="smbd httpd" # limit to samba and httpd
+EOM,
+},
+{ type: upgrade,
+  maximum_version: "0.5.0_1",
+  message: <<EOM
+The periodic(8) script is now a security script.  All 'daily_checkrestart_'
+instances in /etc/periodic.conf should be changed to 'security_checkrestart_'.
+
+i.e.
+
+daily_checkrestart_enable="YES"
+
+is now:
+
+security_checkrestart_enable="YES"
+
+daily_checkrestart_weekdays is no longer supported.  The security period
+mechanism should be used instead:
+
+security_checkrestart_period="DAILY" # or WEEKLY, or MONTHLY
 EOM
 }
 ]



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202004041158.034Bw3UT015291>