From owner-svn-ports-all@freebsd.org Sat Jun 17 10:54:55 2017 Return-Path: Delivered-To: svn-ports-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DBDCEBF8124; Sat, 17 Jun 2017 10:54:55 +0000 (UTC) (envelope-from joneum@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AA21E65584; Sat, 17 Jun 2017 10:54:55 +0000 (UTC) (envelope-from joneum@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v5HAssAH006370; Sat, 17 Jun 2017 10:54:54 GMT (envelope-from joneum@FreeBSD.org) Received: (from joneum@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v5HAssMs006368; Sat, 17 Jun 2017 10:54:54 GMT (envelope-from joneum@FreeBSD.org) Message-Id: <201706171054.v5HAssMs006368@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: joneum set sender to joneum@FreeBSD.org using -f From: Jochen Neumeister Date: Sat, 17 Jun 2017 10:54:54 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r443770 - in head/security/tor: . files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Jun 2017 10:54:56 -0000 Author: joneum Date: Sat Jun 17 10:54:54 2017 New Revision: 443770 URL: https://svnweb.freebsd.org/changeset/ports/443770 Log: - security/tor: Implemented setuid feature *The user should add tor_setuid=YES to /etc/rc.conf to make tor do setuid in runtime after opening the externally provided files. PR: 218587 Submitted by: xmj Approved by: Yuri Victorovich (maintainer) Approved by: miwi (mentor) Differential Revision: https://reviews.freebsd.org/D11223 Modified: head/security/tor/Makefile head/security/tor/files/tor.in Modified: head/security/tor/Makefile ============================================================================== --- head/security/tor/Makefile Sat Jun 17 10:54:15 2017 (r443769) +++ head/security/tor/Makefile Sat Jun 17 10:54:54 2017 (r443770) @@ -3,6 +3,7 @@ PORTNAME= tor PORTVERSION= 0.3.0.8 +PORTREVISION= 1 CATEGORIES= security net ipv6 MASTER_SITES= TOR Modified: head/security/tor/files/tor.in ============================================================================== --- head/security/tor/files/tor.in Sat Jun 17 10:54:15 2017 (r443769) +++ head/security/tor/files/tor.in Sat Jun 17 10:54:54 2017 (r443770) @@ -21,6 +21,7 @@ # tor_disable_default_instance (str): Doesn't run the default instance. # Only valid when tor_instances is used. # Default: NO +# tor_setuid (str): Runtime setuid. Default: NO # # The instance definition that tor_instances expects: # inst_name{:inst_conf:inst_user:inst_group:inst_pidfile:inst_data_dir} @@ -42,6 +43,7 @@ load_rc_config ${name} : ${tor_pidfile="/var/run/tor/tor.pid"} : ${tor_datadir="/var/db/tor"} : ${tor_disable_default_instance="NO"} +: ${tor_setuid="NO"} instance=${slave_instance} if [ -n "${instance}" ]; then @@ -111,6 +113,18 @@ pidfile=${tor_pidfile} command="%%PREFIX%%/bin/${name}" command_args="-f ${tor_conf} --PidFile ${tor_pidfile} --RunAsDaemon 1 --DataDirectory ${tor_datadir}" extra_commands="reload" + +if [ $tor_setuid = "YES" ]; then + if ! grep -q "^User ${tor_user}$" ${tor_conf}; then + echo "User ${tor_user}" >> ${tor_conf} + fi + tor_user="root" + tor_group="wheel" +else + if grep -q "^User ${tor_user}$" ${tor_conf}; then + sed -i '' -e "s/^User ${tor_user}$//" ${tor_conf} + fi +fi if ! run_rc_command "$1"; then exit_code=1