2008-11-27 20:28:01 +01:00
|
|
|
# $NetBSD: unprivileged.mk,v 1.17 2008/11/27 19:28:01 rillig Exp $
|
2005-05-29 19:12:15 +02:00
|
|
|
#
|
2006-07-15 22:47:43 +02:00
|
|
|
# This file collects definitions that are useful when using pkgsrc as an
|
|
|
|
# unprivileged (non-root) user. It is included automatically by the
|
|
|
|
# pkgsrc infrastructure.
|
2005-05-29 19:12:15 +02:00
|
|
|
#
|
2007-09-04 10:42:30 +02:00
|
|
|
# === User-settable variables ===
|
2005-05-29 19:12:15 +02:00
|
|
|
#
|
2007-09-04 10:42:30 +02:00
|
|
|
# UNPRIVILEGED
|
|
|
|
# Whether to build packages as unprivileged user.
|
2005-05-29 19:12:15 +02:00
|
|
|
#
|
2007-09-04 10:42:30 +02:00
|
|
|
# Default: (undefined)
|
|
|
|
# Possible: yes no
|
|
|
|
#
|
|
|
|
# UNPRIVILEGED_USER
|
|
|
|
# The user name (or numeric uid) that will be used to install
|
2006-07-15 22:47:43 +02:00
|
|
|
# files.
|
|
|
|
#
|
2007-09-04 10:42:30 +02:00
|
|
|
# Default: The user building the package
|
|
|
|
#
|
|
|
|
# UNPRIVILEGED_GROUP
|
|
|
|
# The group name (or numeric gid) that will be used to install
|
2006-07-15 22:47:43 +02:00
|
|
|
# files.
|
2007-09-04 10:42:30 +02:00
|
|
|
#
|
|
|
|
# Default: The primary group of the user building the package
|
|
|
|
#
|
2007-10-20 08:57:17 +02:00
|
|
|
# UNPRIVILEGED_GROUPS
|
|
|
|
# The group names that can be used to install files. Where a
|
|
|
|
# per-package custom group is declared that matches a group name
|
|
|
|
# in this variable, it will be left unmodified. Any per-package
|
|
|
|
# custom group not in this list will be forced to the value of
|
|
|
|
# UNPRIVILEGED_GROUP.
|
|
|
|
#
|
|
|
|
# Default: The complete group membership of the user building
|
|
|
|
# the package
|
|
|
|
#
|
2007-09-04 10:42:30 +02:00
|
|
|
# === Package-settable variables ===
|
|
|
|
#
|
|
|
|
# PKG_USERS_VARS
|
|
|
|
# A list of variables that hold bare user names, e.g APACHE_USER, etc.
|
|
|
|
#
|
|
|
|
# PKG_GROUPS_VARS
|
|
|
|
# A list of variables that hold bare group names, e.g UUCP_GROUP, etc.
|
|
|
|
#
|
|
|
|
# XXX: How can the user say that some of the packages shouldn't override
|
|
|
|
# the user and group names?
|
|
|
|
#
|
2008-02-01 09:54:53 +01:00
|
|
|
# PRIVILEGED_STAGES
|
|
|
|
# A list of phases (not stages) that are run as the privileged
|
|
|
|
# user. Some packages, when installed with just-in-time-su, leave
|
|
|
|
# temporary files in the working directory, so the "clean" phase
|
|
|
|
# must have enough priviledges to clean them up.
|
|
|
|
#
|
|
|
|
# Possible: clean
|
|
|
|
# Default: (undefined)
|
|
|
|
#
|
2007-09-04 10:42:30 +02:00
|
|
|
# === System-defined variables ===
|
|
|
|
#
|
|
|
|
# REAL_ROOT_USER
|
|
|
|
# The name of an omnipotent user account on the system.
|
|
|
|
#
|
|
|
|
# XXX: Why do we have this variable when it is set to ${ROOT_USER}
|
|
|
|
# anyway for unprivileged builds? Shouldn't packages that require
|
|
|
|
# such a user just fail in unprivileged mode?
|
|
|
|
# (See NOT_FOR_UNPRIVILEGED.)
|
|
|
|
#
|
|
|
|
# REAL_ROOT_GROUP
|
|
|
|
# The primary group of the REAL_ROOT_USER.
|
|
|
|
#
|
|
|
|
# ROOT_USER
|
|
|
|
# XXX: ???
|
|
|
|
#
|
|
|
|
# ROOT_GROUP
|
|
|
|
# The primary group of the ROOT_USER.
|
|
|
|
#
|
|
|
|
# BINOWN, BINGRP, GAMEOWN, GAMEGRP, MANOWN, MANGRP, SHAREOWN, SHAREGRP,
|
|
|
|
# DOCOWN, DOCGRP, BINMODE, NONBINMODE
|
|
|
|
# Ownership and permissions of the various types of files that are
|
|
|
|
# installed by the packages.
|
|
|
|
#
|
|
|
|
# XXX: What do we need all these different variables for? Wouldn't
|
|
|
|
# it be ok to install all files as ROOT_USER:ROOT_GROUP?
|
|
|
|
#
|
|
|
|
# PKG_CREATE_USERGROUP
|
|
|
|
# Since an unprivileged user normally cannot create other users
|
|
|
|
# and groups, this pkgsrc feature is disabled.
|
|
|
|
#
|
|
|
|
# XXX: This setting should be moved into pkg_add.
|
|
|
|
#
|
|
|
|
# PKG_REGISTER_SHELLS
|
|
|
|
# Since an unprivileged user normally cannot add entries to
|
|
|
|
# /etc/shells, this pkgsrc feature is disabled.
|
|
|
|
#
|
|
|
|
# XXX: See PKG_CREATE_USERGROUP
|
|
|
|
#
|
|
|
|
# TOOLS_PLATFORM.chown, TOOLS_PLATFORM.chgrp
|
|
|
|
# These tools cannot be used in their full extent by unprivileged
|
|
|
|
# users.
|
|
|
|
#
|
|
|
|
# XXX: chgrp may work for some groups.
|
|
|
|
#
|
|
|
|
# Keywords: unprivileged root override
|
|
|
|
#
|
|
|
|
|
|
|
|
_VARGROUPS+= unprivileged
|
|
|
|
_USER_VARS.unprivileged= \
|
2007-10-20 08:57:17 +02:00
|
|
|
UNPRIVILEGED UNPRIVILEGED_GROUP UNPRIVILEGED_GROUPS UNPRIVILEGED_USER
|
2007-09-04 10:42:30 +02:00
|
|
|
_PKG_VARS.unprivileged= \
|
2008-11-27 20:28:01 +01:00
|
|
|
PKG_USERS_VARS PKG_GROUPS_VARS
|
2007-09-04 10:42:30 +02:00
|
|
|
_SYS_VARS.unprivileged= \
|
|
|
|
REAL_ROOT_USER REAL_ROOT_GROUP ROOT_USER ROOT_GROUP \
|
|
|
|
BINOWN BINGRP GAMEOWN GAMEGRP MANOWN MANGRP SHAREOWN SHAREGRP DOCOWN DOCGRP \
|
|
|
|
BINMODE NONBINMODE \
|
|
|
|
PKG_CREATE_USERGROUP PKG_REGISTER_SHELLS \
|
|
|
|
TOOLS_PLATFORM.chgrp TOOLS_PLATFORM.chown SU_CMD
|
2005-05-29 19:12:15 +02:00
|
|
|
|
2007-07-04 22:54:31 +02:00
|
|
|
_UNPRIVILEGED= # empty
|
|
|
|
.if defined(UNPRIVILEGED) && !empty(UNPRIVILEGED:M[Yy][Ee][Ss])
|
|
|
|
_UNPRIVILEGED+= unprivileged
|
|
|
|
.endif
|
|
|
|
.if (${_USE_DESTDIR} == "user-destdir")
|
|
|
|
_UNPRIVILEGED+= user-destdir
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !empty(_UNPRIVILEGED)
|
2005-05-29 19:12:15 +02:00
|
|
|
|
|
|
|
# Guess which user/group has to be used.
|
|
|
|
. if !defined(UNPRIVILEGED_USER) || empty(UNPRIVILEGED_USER)
|
|
|
|
UNPRIVILEGED_USER!= ${ID} -n -u
|
|
|
|
. endif
|
|
|
|
. if !defined(UNPRIVILEGED_GROUP) || empty(UNPRIVILEGED_GROUP)
|
|
|
|
UNPRIVILEGED_GROUP!= ${ID} -n -g
|
|
|
|
. endif
|
2007-10-20 08:57:17 +02:00
|
|
|
. if !defined(UNPRIVILEGED_GROUPS) || empty(UNPRIVILEGED_GROUPS)
|
|
|
|
UNPRIVILEGED_GROUPS!= ${ID} -n -G
|
|
|
|
. endif
|
2005-05-29 19:12:15 +02:00
|
|
|
|
2007-07-04 22:54:31 +02:00
|
|
|
. if empty(_UNPRIVILEGED:Munprivileged) && !empty(_UNPRIVILEGED:Muser-destdir)
|
|
|
|
# Only do following for privileged, user-destdir builds.
|
2006-10-09 14:25:44 +02:00
|
|
|
_SU_ROOT_USER:= ${ROOT_USER}
|
2006-11-05 16:10:08 +01:00
|
|
|
REAL_ROOT_USER:= ${ROOT_USER}
|
|
|
|
REAL_ROOT_GROUP:= ${ROOT_GROUP}
|
2007-06-06 14:41:53 +02:00
|
|
|
. endif
|
2006-10-09 14:25:44 +02:00
|
|
|
|
2005-05-29 19:12:15 +02:00
|
|
|
# Override super-user account.
|
|
|
|
ROOT_GROUP= ${UNPRIVILEGED_GROUP}
|
|
|
|
ROOT_USER= ${UNPRIVILEGED_USER}
|
|
|
|
|
|
|
|
# Override user/group pairs used to install files.
|
|
|
|
BINGRP= ${UNPRIVILEGED_GROUP}
|
|
|
|
BINOWN= ${UNPRIVILEGED_USER}
|
|
|
|
GAMEGRP= ${UNPRIVILEGED_GROUP}
|
|
|
|
GAMEOWN= ${UNPRIVILEGED_USER}
|
|
|
|
MANGRP= ${UNPRIVILEGED_GROUP}
|
|
|
|
MANOWN= ${UNPRIVILEGED_USER}
|
|
|
|
SHAREGRP= ${UNPRIVILEGED_GROUP}
|
|
|
|
SHAREOWN= ${UNPRIVILEGED_USER}
|
2006-11-05 15:36:13 +01:00
|
|
|
DOCGRP= ${UNPRIVILEGED_GROUP}
|
|
|
|
DOCOWN= ${UNPRIVILEGED_USER}
|
2005-05-29 19:12:15 +02:00
|
|
|
|
|
|
|
# Override installation modes. As a regular user, we may have problems
|
|
|
|
# when overwriting files if they are not writable.
|
|
|
|
BINMODE= 755
|
|
|
|
NONBINMODE= 644
|
2007-07-04 22:54:31 +02:00
|
|
|
|
|
|
|
. if !empty(_UNPRIVILEGED:Munprivileged) && empty(_UNPRIVILEGED:Muser-destdir)
|
|
|
|
# Only do the following for unprivileged, normal builds.
|
|
|
|
|
|
|
|
PKG_USERS_VARS?= # empty
|
|
|
|
PKG_GROUPS_VARS?= # empty
|
|
|
|
BUILD_DEFS+= ${PKG_USERS_VARS} ${PKG_GROUPS_VARS}
|
|
|
|
|
2008-03-04 07:45:33 +01:00
|
|
|
.if defined(SETGIDGAME) && !empty(SETGIDGAME:M[yY][eE][sS])
|
|
|
|
. if defined(GAMES_USER)
|
|
|
|
PKG_USERS_VARS+= GAMES_USER
|
|
|
|
. endif
|
|
|
|
. if defined(GAMES_GROUP)
|
|
|
|
PKG_GROUPS_VARS+= GAMES_GROUP
|
|
|
|
. endif
|
|
|
|
.endif
|
|
|
|
|
2007-10-20 08:57:17 +02:00
|
|
|
# Override per-package custom users and groups, except for groups listed
|
|
|
|
# in UNPRIVILEGED_GROUPS.
|
2007-07-04 22:54:31 +02:00
|
|
|
. for _var_ in ${PKG_USERS_VARS}
|
|
|
|
${_var_}= ${UNPRIVILEGED_USER}
|
|
|
|
. endfor
|
|
|
|
. for _var_ in ${PKG_GROUPS_VARS}
|
2007-10-20 08:57:17 +02:00
|
|
|
. if empty(UNPRIVILEGED_GROUPS:M${${_var_}})
|
2007-07-04 22:54:31 +02:00
|
|
|
${_var_}= ${UNPRIVILEGED_GROUP}
|
2007-10-20 08:57:17 +02:00
|
|
|
. endif
|
2007-07-04 22:54:31 +02:00
|
|
|
. endfor
|
|
|
|
. endif
|
|
|
|
|
2006-10-09 14:25:44 +02:00
|
|
|
.endif
|
2005-05-29 19:12:15 +02:00
|
|
|
|
2007-07-04 22:54:31 +02:00
|
|
|
.if !empty(_UNPRIVILEGED:Munprivileged)
|
2005-05-29 19:12:15 +02:00
|
|
|
# As a regular user, creation of other users and groups won't work, so
|
|
|
|
# disable this step by default.
|
2005-08-22 19:13:28 +02:00
|
|
|
PKG_CREATE_USERGROUP= NO
|
2005-05-29 19:12:15 +02:00
|
|
|
|
|
|
|
# Override commands that won't work as a regular user.
|
2006-08-31 18:21:20 +02:00
|
|
|
TOOLS_PLATFORM.chgrp= ${TRUE} chgrp
|
|
|
|
TOOLS_PLATFORM.chown= ${TRUE} chown
|
2005-05-29 19:12:15 +02:00
|
|
|
SU_CMD= ${SH} -c
|
|
|
|
|
2005-08-22 19:13:28 +02:00
|
|
|
# Do not attempt to modify /etc/shells as a regular user.
|
|
|
|
PKG_REGISTER_SHELLS= NO
|
2005-05-29 19:12:15 +02:00
|
|
|
.endif
|