From nobody Thu Apr 6 18:21:59 2023 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PsqbC3Jggz44gDv; Thu, 6 Apr 2023 18:21:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PsqbC2WGcz46n9; Thu, 6 Apr 2023 18:21:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680805319; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yOp5q3PT4ADUxjcFl1RZLa3lpPZiWuLQLdEFBnR9Czk=; b=IkT9YLjmVY7eWnY2FoNfWm/i2e8XpCJHs30sZG56h0vQgSmSOi3eVO/6UVuWNrvBXVrsmT A38f+O3D8/FBySlmPJwiwhrIi8ntZsbmi0QcBmdXT7BVRm5neKYhV1/8c+Wx2L2FzH4EKu 8uFKqh1HgevqR9Rw2hmSpgNjQF5jljULTQ+bwQq1pH7bT/9nBkcLkRbLDYHcdUcWbZ4WBl HFgNJS4Boq/vzQ3xhvBRCHbrp1FZUn/9EbFty2rlr/U/mp6UAxj5gQzIYVjZl3UK7NuSY1 btEMz02kl+vJYWlIPrlc5R2k3oyrDD51ylnnsNskW6w94yAozLd2MIn7yfTg+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1680805319; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=yOp5q3PT4ADUxjcFl1RZLa3lpPZiWuLQLdEFBnR9Czk=; b=PuJwb5NvT/ToPbCWduTiXQP1r/8gAC7SkAbpBfmv6t3kmbZZKBAd1u0BFMw/SNKayzRe8V FnJRe8/QzlNj302CTFcT42xzmnULdeHl/WVkEF5P2MU7ToPQ1kbbulI3iRuspoVA8W4E/V 3Ukn4KmIopHvbGSSpnNx/7jSnnH4WMTIVeplblss8AFIu8jiV+Bim3cLxmfiad8J3TRJ70 bIgW//Y3v35yJ0YKLQsf7akZD06G3b9FwY4jzaSV1um3ae0Bxldyc3MlTvuHlydBvQCmIc o0ZK5Z5l8HagoBtqfQ81RnTbX2rs5IHIVtgIgybLOvCgi6xdNB7Yqst7mFmbGg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1680805319; a=rsa-sha256; cv=none; b=RpWekeoZw5LdFw7/hMWnj1OWTcbPtrUR83W8dG2WfXUXiLBD+8eE0RT5zKajmTxSuttIn5 fDbcLrajsbeKugm3LkH0w6vZqWy+HVtJD1zA0hbWV11rMbw7iUIcQj1aJCyfs9LVQHdzMW dSVwKdmaO5L8PYNqNaIDJA9q+uWCsrV87aOc/brFxS4mAuX2QPWJQo3EykL14IzJDQ1LQx +AJlbtKCdui4I9fHxW7E3XCg5zwdgul4wtSAo6aJqcW/xtBcVD1N154h8KlF7/DIftAhMO 2QnCk9fojW1xZrn4dyWBVb3Lid6eu4KLNXC9kowvoeUS3wYFyF3do12SY1+LNg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PsqbC1bPxzF1S; Thu, 6 Apr 2023 18:21:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 336ILxLl040720; Thu, 6 Apr 2023 18:21:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 336ILxHS040709; Thu, 6 Apr 2023 18:21:59 GMT (envelope-from git) Date: Thu, 6 Apr 2023 18:21:59 GMT Message-Id: <202304061821.336ILxHS040709@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: =?utf-8?Q?Fernando=20Apestegu=C3=ADa?= Subject: git: 98513a913963 - main - sysutils/tuptime: installation upgrade with _tuptime UID/GID List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: fernape X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 98513a91396304c764dd40563b479c6ef4b17755 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by fernape: URL: https://cgit.FreeBSD.org/ports/commit/?id=98513a91396304c764dd40563b479c6ef4b17755 commit 98513a91396304c764dd40563b479c6ef4b17755 Author: Ricardo Fraile AuthorDate: 2023-04-05 08:12:20 +0000 Commit: Fernando ApesteguĂ­a 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 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: < /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