Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 Apr 2023 18:21:59 GMT
From:      =?utf-8?Q?Fernando=20Apestegu=C3=ADa?= <fernape@FreeBSD.org>
To:        ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org
Subject:   git: 98513a913963 - main - sysutils/tuptime: installation upgrade with _tuptime UID/GID
Message-ID:  <202304061821.336ILxHS040709@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by fernape:

URL: https://cgit.FreeBSD.org/ports/commit/?id=98513a91396304c764dd40563b479c6ef4b17755

commit 98513a91396304c764dd40563b479c6ef4b17755
Author:     Ricardo Fraile <r@rfmoz.eu>
AuthorDate: 2023-04-05 08:12:20 +0000
Commit:     Fernando ApesteguĂ­a <fernape@FreeBSD.org>
CommitDate: 2023-04-06 18:16:48 +0000

    sysutils/tuptime: installation upgrade with _tuptime UID/GID
    
    Create an unprivileged user/group for their execution.
    Also, add the cron file and update the rc.d script.
    
    PR:             270433
    Reported by:    r@rfmoz.eu
    Approved by:    jeremy@smart-serv.net (maintainer)
---
 GIDs                                  |  2 +-
 UIDs                                  |  2 +-
 sysutils/tuptime/Makefile             | 16 +++++++++++++++-
 sysutils/tuptime/files/cron           |  1 +
 sysutils/tuptime/files/pkg-message.in | 11 ++++++-----
 sysutils/tuptime/files/tuptime.in     | 16 +++++-----------
 6 files changed, 29 insertions(+), 19 deletions(-)

diff --git a/GIDs b/GIDs
index 6c9cf673798f..69267ee6f06d 100644
--- a/GIDs
+++ b/GIDs
@@ -768,7 +768,7 @@ dotlrn:*:821:
 selenium:*:824:
 polw:*:825:
 statsd:*:826:
-# free: 827
+_tuptime:*:827:
 # free: 828
 # free: 829
 # free: 830
diff --git a/UIDs b/UIDs
index a38e84c282ce..6dcd18e18374 100644
--- a/UIDs
+++ b/UIDs
@@ -773,7 +773,7 @@ titus-keys:*:823:65533::0:0:Titus Keyserver User:/nonexistent:/usr/sbin/nologin
 selenium:*:824:824::0:0:Selenium Daemon User:/usr/local/selenium:/bin/sh
 polw:*:825:825::0:0:Policyd-weight Cache Owner:/nonexistent:/sbin/nologin
 statsd:*:826:826::0:0:Statsd Daemon:/nonexistent:/sbin/nologin
-# free: 827
+_tuptime:*:827:827::0:0:Tuptime:/var/lib/tuptime:/usr/sbin/nologin
 # free: 828
 # free: 829
 # free: 830
diff --git a/sysutils/tuptime/Makefile b/sysutils/tuptime/Makefile
index e3fc4c40045c..1e9d1e52a6ef 100644
--- a/sysutils/tuptime/Makefile
+++ b/sysutils/tuptime/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	tuptime
 DISTVERSION=	5.2.2
+PORTREVISION=	1
 CATEGORIES=	sysutils
 
 MAINTAINER=	jeremy@smart-serv.net
@@ -21,11 +22,24 @@ NO_ARCH=	yes
 NO_BUILD=	yes
 SUB_FILES=	pkg-message
 
-PLIST_FILES=	bin/tuptime \
+USERS=         _tuptime
+GROUPS=        _tuptime
+
+PLIST_FILES=    bin/tuptime \
+		"@rmtry /var/lib/tuptime/tuptime.db" \
+		"@dir /var/lib" \
+		"@dir(${USERS},${GROUPS},755) /var/lib/tuptime" \
+		"@dir etc/cron.d" \
+		"etc/cron.d/tuptime" \
 		man/man1/tuptime.1.gz
 
 do-install:
 	${INSTALL_SCRIPT} ${WRKSRC}/src/tuptime ${STAGEDIR}${PREFIX}/bin/tuptime
 	${INSTALL_MAN} ${WRKSRC}/src/man/tuptime.1 ${STAGEDIR}${MANPREFIX}/man/man1
 
+post-install:
+	${MKDIR} ${STAGEDIR}/var/lib/tuptime
+	${MKDIR} ${STAGEDIR}${LOCALBASE}/etc/cron.d
+	${INSTALL_DATA} ${FILESDIR}/cron ${STAGEDIR}${LOCALBASE}/etc/cron.d/tuptime
+
 .include <bsd.port.mk>
diff --git a/sysutils/tuptime/files/cron b/sysutils/tuptime/files/cron
new file mode 100644
index 000000000000..833de2151cab
--- /dev/null
+++ b/sysutils/tuptime/files/cron
@@ -0,0 +1 @@
+*/5	*	*	*	*	_tuptime	(grep '^tuptime_enable="YES"' /etc/rc.conf) && /usr/local/bin/tuptime -q
diff --git a/sysutils/tuptime/files/pkg-message.in b/sysutils/tuptime/files/pkg-message.in
index 4b7aad1c04c7..15b3e98f048d 100644
--- a/sysutils/tuptime/files/pkg-message.in
+++ b/sysutils/tuptime/files/pkg-message.in
@@ -1,16 +1,17 @@
 [
 { type: install
   message: <<EOM
+#####################################################################
+
 tuptime requires execution at startup and shutdown on rc.d, please
-add it to /etc/rc.conf and start:
+enable it on "/etc/rc.conf" and start:
 
-	sysrc tuptime_enable=YES
+	sysrc tuptime_enable="YES"
 	service tuptime start
 
-tuptime requires a scheduled execution on cron, please add to
-/etc/crontab:
+that also enables "%%LOCALBASE%%/etc/cron.d/tuptime" execution.
 
-	*/5 * * * * root %%PREFIX%%/bin/tuptime -q > /dev/null
+#####################################################################
 EOM
 }
 ]
diff --git a/sysutils/tuptime/files/tuptime.in b/sysutils/tuptime/files/tuptime.in
index e3badf86f97c..1450ed64542c 100644
--- a/sysutils/tuptime/files/tuptime.in
+++ b/sysutils/tuptime/files/tuptime.in
@@ -4,11 +4,13 @@
 # REQUIRE: DAEMON
 # KEYWORD: nojail shutdown
 
+tuptime_enable=${tuptime_enable:-"NO"}
+
 . /etc/rc.subr
 
 name="tuptime"
 rcvar=tuptime_enable
-tuptime_user="tuptime"
+tuptime_user="_tuptime"
 
 start_cmd="${name}_start"
 stop_cmd="${name}_stop"
@@ -20,11 +22,7 @@ tuptime_start()
 	echo "Starting $name."
 	command_args="-q"
 
-	if /usr/sbin/pw usershow "${tuptime_user}" >/dev/null 2>&1; then
-		su -m ${tuptime_user} -c "$name $command_args"
-	else
-		$name $command_args
-	fi
+	su -m ${tuptime_user} -c "$name $command_args" 2> /dev/null || $name $command_args 2> /dev/null
 }
 
 tuptime_stop()
@@ -32,11 +30,7 @@ tuptime_stop()
 	echo "Stopping $name."
 	command_args="-qg"
 
-	if /usr/sbin/pw usershow "${tuptime_user}" >/dev/null 2>&1; then
-		su -m ${tuptime_user} -c "$name $command_args"
-	else
-		$name $command_args
-	fi
+	su -m ${tuptime_user} -c "$name $command_args" 2> /dev/null || $name $command_args 2> /dev/null
 }
 
 load_rc_config $name



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