mirror of
https://git.FreeBSD.org/ports.git
synced 2025-01-31 10:46:16 +00:00
Add support to create users and groups from information stored in UIDs/GIDs
files. Users and groups won't be deleted at deinstall time as we're lacking a refcount to know if any port is using them. Also convert a few ports while I'm here. PR: ports/108514 Submitted by: mm, self
This commit is contained in:
parent
082f117cfc
commit
80ce349ead
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=240964
@ -593,6 +593,10 @@ FreeBSD_MAINTAINER= portmgr@FreeBSD.org
|
||||
# Default: ${MASTERDIR}/files
|
||||
# PKGDIR - A directory containing any package creation files.
|
||||
# Default: ${MASTERDIR}
|
||||
# UID_FILES - A list of files containing information about registered UIDs.
|
||||
# Note that files have decreasing priority.
|
||||
# GID_FILES - A list of files containing information about registered GIDs.
|
||||
# Note that files have decreasing priority.
|
||||
#
|
||||
# Variables that serve as convenient "aliases" for your *-install targets.
|
||||
# Use these like: "${INSTALL_PROGRAM} ${WRKSRC}/prog ${PREFIX}/bin".
|
||||
@ -1027,6 +1031,11 @@ FreeBSD_MAINTAINER= portmgr@FreeBSD.org
|
||||
# Default: ${PREFIX}/www/${PORTNAME}
|
||||
# WWWDIR_REL - The WWWDIR relative to ${PREFIX}
|
||||
#
|
||||
# USERS - List of users to create at install time. Each login must have a
|
||||
# corresponding entry in ${UID_FILES}.
|
||||
# GROUPS - List of groups to create at install time. Each group must have a
|
||||
# corresponding entry in ${GID_FILES}.
|
||||
#
|
||||
# DESKTOPDIR - Name of the directory to install ${DESKTOP_ENTRIES} in.
|
||||
# Default: ${PREFIX}/share/applications
|
||||
# DESKTOP_ENTRIES
|
||||
@ -1256,6 +1265,11 @@ USE_SUBMAKE= yes
|
||||
# where 'make config' records user configuration options
|
||||
PORT_DBDIR?= /var/db/ports
|
||||
|
||||
UID_FILES?= ${PORTSDIR}/UIDs
|
||||
GID_FILES?= ${PORTSDIR}/GIDs
|
||||
UID_OFFSET?= 0
|
||||
GID_OFFSET?= 0
|
||||
|
||||
LDCONFIG_DIR= libdata/ldconfig
|
||||
LDCONFIG32_DIR= libdata/ldconfig32
|
||||
|
||||
@ -4003,6 +4017,78 @@ install-ldconfig-file:
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.if !target(create-users-groups)
|
||||
create-users-groups:
|
||||
.if defined(GROUPS) || defined(USERS)
|
||||
.if defined(GROUPS)
|
||||
.for _file in ${GID_FILES}
|
||||
.if !exists(${_file})
|
||||
@${ECHO_CMD} "** ${_file} doesn't exist. Exiting."; exit 1
|
||||
.endif
|
||||
.endfor
|
||||
@${ECHO_MSG} "===> Creating users and/or groups."
|
||||
.for _group in ${GROUPS}
|
||||
# _bgpd:*:130:
|
||||
@if ! ${GREP} -h ^${_group}: ${GID_FILES} >/dev/null 2>&1; then \
|
||||
${ECHO_CMD} "** Cannot find any information about group \`${_group}' in ${GID_FILES}."; \
|
||||
exit 1; \
|
||||
fi
|
||||
@IFS=":"; ${GREP} -h ^${_group}: ${GID_FILES} | head -n 1 | while read group foo gid members; do \
|
||||
gid=$$(($$gid+${GID_OFFSET}));\
|
||||
if ! ${PW} groupshow $$group >/dev/null 2>&1; then \
|
||||
${ECHO_MSG} "Creating group \`$$group' with gid \`$$gid'."; \
|
||||
${PW} groupadd $$group -g $$gid; \
|
||||
else \
|
||||
${ECHO_MSG} "Using existing group \`$$group'."; \
|
||||
fi; \
|
||||
${ECHO_CMD} "@exec if ! ${PW} groupshow $$group >/dev/null 2>&1; then ${PW} groupadd $$group -g $$gid; fi" >> ${TMPPLIST}; \
|
||||
done
|
||||
.endfor
|
||||
.endif
|
||||
.if defined(USERS)
|
||||
.for _file in ${UID_FILES}
|
||||
.if !exists(${_file})
|
||||
@${ECHO_CMD} "** ${_file} doesn't exist. Exiting."; exit 1
|
||||
.endif
|
||||
.endfor
|
||||
.for _user in ${USERS}
|
||||
# _bgpd:*:130:130:BGP Daemon:/var/empty:/sbin/nologin
|
||||
@if ! ${GREP} -h ^${_user}: ${UID_FILES} >/dev/null 2>&1; then \
|
||||
${ECHO_CMD} "** Cannot find any information about user \`${_user}' in ${UID_FILES}."; \
|
||||
exit 1; \
|
||||
fi
|
||||
@IFS=":"; ${GREP} -h ^${_user}: ${UID_FILES} | head -n 1 | while read login passwd uid gid class change expire gecos homedir shell; do \
|
||||
uid=$$(($$uid+${UID_OFFSET}));\
|
||||
gid=$$(($$gid+${GID_OFFSET}));\
|
||||
if ! ${PW} usershow $$login >/dev/null 2>&1; then \
|
||||
${ECHO_MSG} "Creating user \`$$login' with uid \`$$uid'."; \
|
||||
${PW} useradd $$login -u $$uid -g $$gid -c "$$gecos" -d $$homedir -s $$shell; \
|
||||
else \
|
||||
${ECHO_MSG} "Using existing user \`$$login'."; \
|
||||
fi; \
|
||||
${ECHO_CMD} "@exec if ! ${PW} usershow $$login >/dev/null 2>&1; then ${PW} useradd $$login -u $$uid -g $$gid -c \"$$gecos\" -d $$homedir -s $$shell; fi" >> ${TMPPLIST}; \
|
||||
done
|
||||
.endfor
|
||||
.if defined(GROUPS)
|
||||
.for _group in ${GROUPS}
|
||||
# _bgpd:*:130:
|
||||
@IFS=":"; ${GREP} -h ^${_group}: ${GID_FILES} | head -n 1 | while read group foo gid members; do \
|
||||
gid=$$(($$gid+${GID_OFFSET}));\
|
||||
IFS=","; for _login in $$members; do \
|
||||
list=`${PW} usershow $${_login} -P | ${SED} -ne 's/.*Groups: //p'`; \
|
||||
${ECHO_MSG} "Setting \`$${_login}' groups to \`$$list$${list:+,}${_group}'."; \
|
||||
${PW} usermod $${_login} -G $$list$${list:+,}${_group}; \
|
||||
${ECHO_CMD} "@exec list=\`${PW} usershow $${_login} -P | ${SED} -ne 's/.*Groups: //p'\`; ${PW} usermod $${_login} -G \$${list},${_group}" >> ${TMPPLIST}; \
|
||||
done; \
|
||||
done
|
||||
.endfor
|
||||
.endif
|
||||
.endif
|
||||
.else
|
||||
@${DO_NADA}
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.if !defined(DISABLE_SECURITY_CHECK)
|
||||
.if !target(security-check)
|
||||
.if !defined(OLD_SECURITY_CHECK)
|
||||
@ -4187,8 +4273,8 @@ _INSTALL_SEQ= install-message check-conflicts \
|
||||
pre-install-script generate-plist check-already-installed
|
||||
_INSTALL_SUSEQ= check-umask install-mtree pre-su-install \
|
||||
pre-su-install-script do-install install-desktop-entries \
|
||||
post-install post-install-script add-plist-info \
|
||||
add-plist-docs add-plist-examples add-plist-data \
|
||||
create-users-groups post-install post-install-script \
|
||||
add-plist-info add-plist-docs add-plist-examples add-plist-data \
|
||||
add-plist-post install-rc-script compress-man \
|
||||
install-ldconfig-file fake-pkg security-check
|
||||
_PACKAGE_DEP= install
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
PORTNAME= pulseaudio
|
||||
PORTVERSION= 0.9.15
|
||||
PORTREVISION= 4
|
||||
PORTREVISION= 5
|
||||
CATEGORIES= audio
|
||||
MASTER_SITES= http://0pointer.de/lennart/projects/${PORTNAME}/
|
||||
|
||||
@ -41,6 +41,9 @@ CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" \
|
||||
CONFIGURE_ARGS= --localstatedir=/var \
|
||||
--disable-lirc # untested
|
||||
|
||||
USERS= pulse
|
||||
GROUPS= pulse pulse-access pulse-rt
|
||||
|
||||
OPTIONS= JACK "JACK audio support" Off \
|
||||
AVAHI "Enable Avahi mDNS support" On \
|
||||
HAL "Enable HAL support" On \
|
||||
@ -114,9 +117,6 @@ post-install:
|
||||
${INSTALL_DATA} ${WRKSRC}/src/${ii} \
|
||||
${PREFIX}/etc/pulse/${ii}-dist
|
||||
.endfor
|
||||
.if !defined(PACKAGE_BUILDING)
|
||||
@${SETENV} PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
|
||||
.endif
|
||||
@${CAT} ${PKGMESSAGE}
|
||||
|
||||
.include <bsd.port.post.mk>
|
||||
|
@ -1,63 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
case $2 in
|
||||
POST-INSTALL)
|
||||
RGROUP=pulse-rt
|
||||
SUSER=pulse
|
||||
SGROUP=${SUSER}
|
||||
AGROUP=pulse-access
|
||||
SUID=563
|
||||
RGID=557
|
||||
SGID=${SUID}
|
||||
AGID=564
|
||||
PW=/usr/sbin/pw
|
||||
|
||||
if ${PW} group show "${RGROUP}" 2>/dev/null; then
|
||||
echo "You already have a group \"${RGROUP}\", so I will use it."
|
||||
else
|
||||
if ${PW} groupadd ${RGROUP} -g ${RGID}; then
|
||||
echo "Added group \"${RGROUP}\"."
|
||||
else
|
||||
echo "Adding group \"${RGROUP}\" failed..."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if ${PW} group show "${SGROUP}" 2>/dev/null; then
|
||||
echo "You already have a group \"${SGROUP}\", so I will use it."
|
||||
else
|
||||
if ${PW} groupadd ${SGROUP} -g ${SGID}; then
|
||||
echo "Added group \"${SGROUP}\"."
|
||||
else
|
||||
echo "Adding group \"${SGROUP}\" failed..."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if ${PW} group show "${AGROUP}" 2>/dev/null; then
|
||||
echo "You already have a group \"${AGROUP}\", so I will use it."
|
||||
else
|
||||
if ${PW} groupadd ${AGROUP} -g ${AGID}; then
|
||||
echo "Added group \"${AGROUP}\"."
|
||||
else
|
||||
echo "Adding group \"${AGROUP}\" failed..."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if ${PW} user show "${SUSER}" 2>/dev/null; then
|
||||
echo "You already have a user \"${SUSER}\", so I will use it."
|
||||
else
|
||||
if ${PW} useradd ${SUSER} -u ${SUID} -g ${SGROUP} -h - \
|
||||
-d "/nonexistent" -s /sbin/nologin -c "PulseAudio System User"
|
||||
then
|
||||
echo "Added user \"${SUSER}\"."
|
||||
else
|
||||
echo "Adding user \"${SUSER}\" failed..."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
echo ""
|
||||
exit 0
|
||||
;;
|
||||
esac
|
@ -7,7 +7,7 @@
|
||||
|
||||
PORTNAME= dbus
|
||||
PORTVERSION?= 1.2.4.6
|
||||
PORTREVISION?= 0
|
||||
PORTREVISION?= 1
|
||||
CATEGORIES= devel gnome
|
||||
MASTER_SITES= http://dbus.freedesktop.org/releases/dbus/
|
||||
DISTNAME= dbus-${PORTVERSION}permissive
|
||||
@ -36,6 +36,9 @@ CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" \
|
||||
USE_RC_SUBR= dbus
|
||||
USE_GNOME_SUBR= yes
|
||||
|
||||
USERS= messagebus
|
||||
GROUPS= messagebus
|
||||
|
||||
PLIST_SUB= VERSION="1.0"
|
||||
|
||||
MAN1= dbus-cleanup-sockets.1 dbus-daemon.1 dbus-launch.1 \
|
||||
|
@ -4,33 +4,6 @@ case $2 in
|
||||
POST-INSTALL)
|
||||
USER=messagebus
|
||||
GROUP=${USER}
|
||||
UID=556
|
||||
GID=${UID}
|
||||
PW=/usr/sbin/pw
|
||||
|
||||
if ${PW} group show "${GROUP}" 2>/dev/null; then
|
||||
echo "You already have a group \"${GROUP}\", so I will use it."
|
||||
else
|
||||
if ${PW} groupadd ${GROUP} -g ${GID}; then
|
||||
echo "Added group \"${GROUP}\"."
|
||||
else
|
||||
echo "Adding group \"${GROUP}\" failed..."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if ${PW} user show "${USER}" 2>/dev/null; then
|
||||
echo "You already have a user \"${USER}\", so I will use it."
|
||||
else
|
||||
if ${PW} useradd ${USER} -u ${UID} -g ${GROUP} -h - \
|
||||
-d "/nonexistent" -s /sbin/nologin -c "D-BUS Daemon User"
|
||||
then
|
||||
echo "Added user \"${USER}\"."
|
||||
else
|
||||
echo "Adding user \"${USER}\" failed..."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
/usr/bin/install -d -o ${USER} -g ${GROUP} /var/run/dbus
|
||||
/usr/bin/install -d -o ${USER} -g ${GROUP} /var/db/dbus
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
PORTNAME= hal
|
||||
DISTVERSION= 0.5.11
|
||||
PORTREVISION= 25
|
||||
PORTREVISION= 26
|
||||
CATEGORIES= sysutils
|
||||
MASTER_SITES= http://hal.freedesktop.org/releases/
|
||||
|
||||
@ -50,6 +50,9 @@ CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include -DHAVE_CK_0_3" \
|
||||
#HALVERSION= 0.5.10
|
||||
#SNAPVERSION= 20080218
|
||||
|
||||
USERS= haldaemon
|
||||
GROUPS= haldaemon
|
||||
|
||||
USE_RC_SUBR= hald
|
||||
USE_GNOME_SUBR= yes
|
||||
DOCSDIR= ${PREFIX}/share/doc/${PORTNAME}-${DISTVERSION}
|
||||
|
@ -4,33 +4,6 @@ case $2 in
|
||||
POST-INSTALL)
|
||||
USER=haldaemon
|
||||
GROUP=${USER}
|
||||
UID=560
|
||||
GID=${UID}
|
||||
PW=/usr/sbin/pw
|
||||
|
||||
if ${PW} group show "${GROUP}" 2>/dev/null; then
|
||||
echo "You already have a group \"${GROUP}\", so I will use it."
|
||||
else
|
||||
if ${PW} groupadd ${GROUP} -g ${GID}; then
|
||||
echo "Added group \"${GROUP}\"."
|
||||
else
|
||||
echo "Adding group \"${GROUP}\" failed..."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if ${PW} user show "${USER}" 2>/dev/null; then
|
||||
echo "You already have a user \"${USER}\", so I will use it."
|
||||
else
|
||||
if ${PW} useradd ${USER} -u ${UID} -g ${GROUP} -h - \
|
||||
-d "/nonexistent" -s /sbin/nologin -c "HAL Daemon User"
|
||||
then
|
||||
echo "Added user \"${USER}\"."
|
||||
else
|
||||
echo "Adding user \"${USER}\" failed..."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
/usr/bin/install -d -o ${USER} -g ${GROUP} /var/run/hald
|
||||
/usr/bin/install -d -o ${USER} -g ${GROUP} /var/cache/hald
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
PORTNAME= policykit
|
||||
PORTVERSION= 0.9
|
||||
PORTREVISION= 4
|
||||
PORTREVISION= 5
|
||||
CATEGORIES= sysutils gnome
|
||||
MASTER_SITES= http://hal.freedesktop.org/releases/
|
||||
DISTNAME= PolicyKit-${PORTVERSION}
|
||||
@ -19,6 +19,9 @@ COMMENT= Framework for controlling access to system-wide components
|
||||
LIB_DEPENDS= dbus-glib-1.2:${PORTSDIR}/devel/dbus-glib \
|
||||
expat.6:${PORTSDIR}/textproc/expat2
|
||||
|
||||
USERS= polkit
|
||||
GROUPS= polkit
|
||||
|
||||
USE_GNOME= gnomehack glib20 intlhack
|
||||
USE_GMAKE= yes
|
||||
GNU_CONFIGURE= yes
|
||||
|
@ -4,33 +4,6 @@ case $2 in
|
||||
POST-INSTALL)
|
||||
USER=polkit
|
||||
GROUP=${USER}
|
||||
UID=562
|
||||
GID=${UID}
|
||||
PW=/usr/sbin/pw
|
||||
|
||||
if ${PW} group show "${GROUP}" 2>/dev/null; then
|
||||
echo "You already have a group \"${GROUP}\", so I will use it."
|
||||
else
|
||||
if ${PW} groupadd ${GROUP} -g ${GID}; then
|
||||
echo "Added group \"${GROUP}\"."
|
||||
else
|
||||
echo "Adding group \"${GROUP}\" failed..."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if ${PW} user show "${USER}" 2>/dev/null; then
|
||||
echo "You already have a user \"${USER}\", so I will use it."
|
||||
else
|
||||
if ${PW} useradd ${USER} -u ${UID} -g ${GROUP} -h - \
|
||||
-d "/nonexistent" -s /sbin/nologin -c "PolicyKit Daemon User"
|
||||
then
|
||||
echo "Added user \"${USER}\"."
|
||||
else
|
||||
echo "Adding user \"${USER}\" failed..."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
/usr/bin/install -d -o root -m 0770 -g ${GROUP} /var/run/PolicyKit
|
||||
/usr/bin/install -d -o root -m 0770 -g ${GROUP} /var/lib/PolicyKit
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
PORTNAME= gdm
|
||||
PORTVERSION= 2.26.1
|
||||
PORTREVISION= 6
|
||||
PORTREVISION= 7
|
||||
CATEGORIES= x11 gnome
|
||||
MASTER_SITES= GNOME
|
||||
DIST_SUBDIR= gnome2
|
||||
@ -24,6 +24,9 @@ RUN_DEPENDS= zenity:${PORTSDIR}/x11/zenity \
|
||||
${LOCALBASE}/libexec/gnome-settings-daemon:${PORTSDIR}/sysutils/gnome-settings-daemon \
|
||||
gnome-session:${PORTSDIR}/x11/gnome-session
|
||||
|
||||
USERS= gdm
|
||||
GROUPS= gdm
|
||||
|
||||
USE_BZIP2= yes
|
||||
USE_GETTEXT= yes
|
||||
USE_LDCONFIG= yes
|
||||
|
@ -4,40 +4,10 @@ case $2 in
|
||||
POST-INSTALL)
|
||||
USER=gdm
|
||||
GROUP=${USER}
|
||||
UID=92
|
||||
GID=${UID}
|
||||
PW=/usr/sbin/pw
|
||||
CHMOD=/bin/chmod
|
||||
CHOWN=/usr/sbin/chown
|
||||
MKDIR=/bin/mkdir
|
||||
|
||||
if ${PW} group show "${GROUP}" 2>/dev/null; then
|
||||
echo "You already have a group \"${GROUP}\", so I will use it."
|
||||
else
|
||||
if ${PW} groupadd ${GROUP} -g ${GID}; then
|
||||
echo "Added group \"${GROUP}\"."
|
||||
else
|
||||
echo "Adding group \"${GROUP}\" failed..."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if ${PW} user show "${USER}" 2>/dev/null; then
|
||||
echo "You already have a user \"${USER}\", so I will use it."
|
||||
uhome=`${PW} user show ${USER} | awk -F: '{print $9}'`
|
||||
if [ x"${uhome}" = x"/nonexistent" -o x"${uhome}" = x"/var/gdm" ]; then
|
||||
${PW} usermod ${USER} -d "${PKG_PREFIX}/etc/gdm/home"
|
||||
fi
|
||||
else
|
||||
if ${PW} useradd ${USER} -u ${UID} -g ${GROUP} -h - \
|
||||
-d "${PKG_PREFIX}/etc/gdm/home" -s /sbin/nologin -c "GNOME Display Manager"
|
||||
then
|
||||
echo "Added user \"${USER}\"."
|
||||
else
|
||||
echo "Adding user \"${USER}\" failed..."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
${MKDIR} -p /var/gdm
|
||||
${MKDIR} -p /var/log/gdm
|
||||
${CHMOD} 0755 /var/log/gdm
|
||||
|
Loading…
Reference in New Issue
Block a user