From owner-freebsd-ports@freebsd.org Sat Dec 16 12:44:16 2017 Return-Path: Delivered-To: freebsd-ports@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 D4952E81769 for ; Sat, 16 Dec 2017 12:44:16 +0000 (UTC) (envelope-from SRS0=PBBM=DM=quip.cz=000.fbsd@elsa.codelab.cz) Received: from elsa.codelab.cz (elsa.codelab.cz [94.124.105.4]) (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 98E7537BC for ; Sat, 16 Dec 2017 12:44:15 +0000 (UTC) (envelope-from SRS0=PBBM=DM=quip.cz=000.fbsd@elsa.codelab.cz) Received: from elsa.codelab.cz (localhost [127.0.0.1]) by elsa.codelab.cz (Postfix) with ESMTP id 007CB28412; Sat, 16 Dec 2017 13:44:07 +0100 (CET) Received: from illbsd.quip.test (ip-86-49-16-209.net.upcbroadband.cz [86.49.16.209]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by elsa.codelab.cz (Postfix) with ESMTPSA id 0E55D28417; Sat, 16 Dec 2017 13:44:06 +0100 (CET) Subject: Re: Setting system user home directory To: Dmytro Bilokha , freebsd-ports@freebsd.org References: <20171216094058.GA37778@wstan> From: Miroslav Lachman <000.fbsd@quip.cz> Message-ID: <5A351515.1080805@quip.cz> Date: Sat, 16 Dec 2017 13:44:05 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:42.0) Gecko/20100101 Firefox/42.0 SeaMonkey/2.39 MIME-Version: 1.0 In-Reply-To: <20171216094058.GA37778@wstan> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 16 Dec 2017 12:44:16 -0000 Dmytro Bilokha wrote on 2017/12/16 10:40: > Hello, Everyone! > > I'm trying to change www/payara port to make it run under the payara > user instead of root. > I've added the following line to the UIDs file: > > payara:*:221:221::0:0:Payara Application Server > user:/nonexistent:/usr/sbin/nologin > > And this line to the port makefile: > > USERS= payara > > Also, I've made some another changes to the port's scripts to start > service under payara user. > Everything seems to be fine, but the service on start/shutdown creates > some preferences files, > caches, etc in the payara user's homedir. > The problem is, that it is impossible to create these files in > /nonexistent. This fact makes > service to show some annoying warnings on every startup/shutdown. > To make service to work properly I want to create directory writable by > the payara user and > set it as payara's homedir. > And I don't want to put these dir under the /usr/home/, it should be > somewhere in the application, > like /usr/local/payara-4.1.2.173/prefs. > As far as I understand, payara user will be created automatically by the > bsd.port.pre.mk file included in the port's makefile. But, during every > installation somehow payara user's homedir > should be changed. I can do it with the following one-liner: > > /usr/sbin/pw usermod payara -d ${DATADIR}/prefs > > So, the questions are: > 1. Is it a proper way of doing such kind of things? > 2. Where in the port's makefile should I put my one-liner? Will it be OK > to make it like this: > > .......head of the make file with setting variables and so on is here...... > .include > do-install: > .........doing some work here...... > @/usr/sbin/pw usermod payara -d ${DATADIR}/prefs > .include > ....end of the makefile..... > > Many thanks for your attention and help. I don't know Payara but applications should not write its files to /usr/local. This should work even if /usr/local is mounted Read Only. If you need to store configuration (preferences) then it should be in /usr/local/etc/payara. If the application writes some data files like databases, it goes under /var/db/payara and log in to /var/log/payara.log or /var/log/payara (directory) Miroslav Lachman