Setting custom users and groups
Joshua Root
jmr at macports.org
Tue Jul 28 06:59:38 PDT 2015
On 2015-7-28 22:28 , Björn Raupach wrote:
> Dear group,
>
> I am new to Portfile development and have a problem with permissions for users and groups. At the moment I am trying to create a Portfile for Apache Tomcat 8. I would like to run Tomcat as non-root with a user `tomcat` and group `tomcat`. I am a bit lost.
>
> set catalina_home ${destroot}${prefix}/share/java/${name}
> set tomcat_user tomcat
> set tomcat_group tomcat
> add_users ${tomcat_user} group=${tomcat_group}
>
> I saw these lines in some other ports, for example couchdb, and figured that is the way to go even though I don’t find the macro add_users anywhere in the documentation.
>
> My destroot-phase currently looks like this:
>
> destroot {
> xinstall -m 755 -g ${tomcat_group} -d ${catalina_home}
>
> file copy \
> ${worksrcpath}/LICENSE \
> ${worksrcpath}/NOTICE \
> ${worksrcpath}/RELEASE-NOTES \
> ${worksrcpath}/RUNNING.txt \
> ${worksrcpath}/bin \
> ${worksrcpath}/conf \
> ${worksrcpath}/lib \
> ${worksrcpath}/logs \
> ${worksrcpath}/temp \
> ${worksrcpath}/webapps \
> ${worksrcpath}/work \
> ${catalina_home}
>
> xinstall -m 644 ${filespath}/setenv.sh ${catalina_home}/bin/setenv.sh.default
>
> # replace @PREFIX@ to ${prefix}
> reinplace "s|@PREFIX@|${prefix}|g" ${catalina_home}/bin/setenv.sh.default
> # replace @NAME@ to ${name}
> reinplace "s|@NAME@|${name}|g" ${catalina_home}/bin/setenv.sh.default
> }
>
> However `/opt/local/share/java/tomcat8` has the ownership `root:admin` and not `root:tomcat`.
First try running the destroot target (rather than install) and check
the permissions on ${destroot}${prefix}/share/java/tomcat8. The destroot
dir will be in the path given by `port work tomcat8` BTW.
- Josh
More information about the macports-dev
mailing list