From owner-freebsd-ports@freebsd.org Sat Dec 16 18:48:36 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 EA46CE8AECD for ; Sat, 16 Dec 2017 18:48:36 +0000 (UTC) (envelope-from kob6558@gmail.com) Received: from mail-vk0-x233.google.com (mail-vk0-x233.google.com [IPv6:2607:f8b0:400c:c05::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 9C9DB6E1E5 for ; Sat, 16 Dec 2017 18:48:36 +0000 (UTC) (envelope-from kob6558@gmail.com) Received: by mail-vk0-x233.google.com with SMTP id s139so7449019vkb.3 for ; Sat, 16 Dec 2017 10:48:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=ZWW2+At9JLWBCLpvugr8jzyxKsPx7J2EI4wBTuGXl1Q=; b=ffzloTyAE/NmZGafJ7EOOXf8g2r2Y4wUSgDQsmuot5eVaKPtTeMyBhBfPT+hcuiGGu NiT5Duixbu4BtvifJvuat+ur72boREP2l5FhyYOrt6xuVsF2ed+QSz1JtFTW7118eC1T pAH6pI3eSue7EDFIETIBDAc8YVpSFhK45F8nQSPXqqGiCvpMk6RL1wGYIqAA6gHumWWN c1SD60g4eEqfgvmvZ/NMTEUbINAKXesiZfq+8Jng//6qMO0e0pI0UyyBugCJJQoDuz1i j6d4TZu1H+LHcMBoXAm9obFt+KLkqvvgBVYVk8KhR37uOpr+hlrFrDGx1BH33QGPFwWM i2aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=ZWW2+At9JLWBCLpvugr8jzyxKsPx7J2EI4wBTuGXl1Q=; b=qwzQvtgJoe+ahYkREEvpaheSxXObwBOKHJbID0kieGB1hg9zY6GF+5C/E9Rjj4rWUG 4AlCFIqmh9v7ZWhcUE5RUvyFlB185/lPDwIb8PFKxk3Xv6hpZN5ePpCrooLrGt9vz0tt CkqAPIqB9+hWCxoLWEElJ02KTlXMVb0eB6/mJLua2ttZBPEBuINo5RQCQ541CdyeW7Vf rWS31zo5d9iKW7RZ3uWX+j9G4IkyGo+MW6wITrqexirQLlD9ran16evVm7xunKuQiXUL +QQbZiBcFgyCG0CT3NLxWB2BtIju9jQ+qTqxANdRXnhpDUBoxyr/65Xc20wgC6LlTVvC IQPA== X-Gm-Message-State: AKGB3mKbi9ZeOL6QjmbLLRKomIF+/JcvmrhUx9PYLcPU3gI/sUGWWX6j W+y6rxALoNtJIhQiR4FDRk8a2axKwse1fmZr9vg= X-Google-Smtp-Source: ACJfBov3BgWeJwYr26TKzok//c4OEwwax+9qpeMZ9goEpFMROGgckj8QYRDfSsFeSM+wdOp/Wbt4B6a6TnkNAO74xrc= X-Received: by 10.31.48.83 with SMTP id w80mr17286070vkw.30.1513450115406; Sat, 16 Dec 2017 10:48:35 -0800 (PST) MIME-Version: 1.0 Sender: kob6558@gmail.com Received: by 10.103.147.156 with HTTP; Sat, 16 Dec 2017 10:48:34 -0800 (PST) In-Reply-To: <20171216170411.GA85559@wstan> References: <20171216094058.GA37778@wstan> <5A351515.1080805@quip.cz> <20171216135919.GA17551@wstan> <5A352BA5.9070403@quip.cz> <20171216170411.GA85559@wstan> From: Kevin Oberman Date: Sat, 16 Dec 2017 10:48:34 -0800 X-Google-Sender-Auth: UbHLmeJtj40Js09LfPy8TgGWuaE Message-ID: Subject: Re: Setting system user home directory To: Dmytro Bilokha Cc: Miroslav Lachman <000.fbsd@quip.cz>, FreeBSD Ports ML Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.25 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 18:48:37 -0000 On Sat, Dec 16, 2017 at 9:04 AM, Dmytro Bilokha wrote: > On Sat, Dec 16, 2017 at 03:20:21PM +0100, Miroslav Lachman wrote: > >> Dmytro Bilokha wrote on 2017/12/16 14:59: >> >>> On Sat, Dec 16, 2017 at 01:44:05PM +0100, Miroslav Lachman wrote: >>> >>>> 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 >>>> >>> >>> Thanks for the information. Now I'm a little bit confused. >>> I've checked and seems to me that nither www/tomcat85 (servlet >>> container) nor www/glassfish and java/wildfly10 (application servers) >>> ports follow this convention. >>> All of them has directories for logs, configuration and Java >>> applications under the >>> /usr/local. Is there something special in Java servers ports? >>> >> >> >> I know there are ports not following this convention (and I don't >> understand why). Those ports are making troubles if you want to serve >> /usr/local as read only NFS for example. >> >> Miroslav Lachman >> > > Ok, than I'll try to move everything writable from /usr/local to /var. > I plan to put system user's caches and properties to the > /var/payara/X.Y.Z/prefs, > where X.Y.Z is an application's version. > And this returns me to the first question: how to properly change user's > home > directory on port installation? > > -- > Dmytro Bilokha > dmytro@posteo.net > +38-050-607-41-43 > How did you add the user? If you did not use the adduser script or vipw, you must rebuild the database. pwd_mkdb. I would suggest always using vipw as it automatically does everything Kevin Oberman, Part time kid herder and retired Network Engineer E-mail: rkoberman@gmail.com PGP Fingerprint: D03FB98AFA78E3B78C1694B318AB39EF1B055683