* [Buildroot] [pull request] Pull request for branch yem-package-create-user
@ 2012-12-30 23:26 Yann E. MORIN
2012-12-30 23:26 ` [Buildroot] [PATCH 1/3] system/skeleton: add the shadow-group file Yann E. MORIN
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Yann E. MORIN @ 2012-12-30 23:26 UTC (permalink / raw)
To: buildroot
Hello All!
Here is a series that allows packages to create users.
Packages that install daemons may well want to run those daemons as
non-root users to avoid security issues. Currently, there are two users
of choice to run 'generic' daemons: root or daemon (although there are
a few dedicated users to run a few services: mail, sshd, ftp...).
This series builds upon both the package infrastrucutre to define the
user(s) a package may want to create, and the filesystem infrastructure
to actually generate these users, and chown their ${HOME}s.
Documentation is updated accordingly.
Note: for now, users' passwords are md5-encrypted. Once the pending
change to introduce alternative password-encryption schemes is applied,
we can use that to encode users' passwords, too.
As a proof of concept, the package tvheadend has been updated to use
a dedicated user to run its daemon as (call me stubborn! ;-] ).
The following changes since commit f1d44593a04ff3be981c8a3b01a502f0b18193ee:
docs/manual: small fixes and enhancements to adding generic packages (2012-12-30 22:39:13 +0100)
are available in the git repository at:
git://gitorious.org/buildroot/buildroot.git yem-package-create-user
Yann E. MORIN (3):
system/skeleton: add the shadow-group file
packages: add ability for packages to create users
package/tvheadend: use a non-root user to run the daemon
docs/manual/adding-packages-generic.txt | 16 ++-
docs/manual/makedev-syntax.txt | 65 ++++++
fs/common.mk | 5 +-
package/pkg-generic.mk | 1 +
package/tvheadend/etc.default.tvheadend | 5 +-
package/tvheadend/tvheadend.mk | 10 +-
support/scripts/mkusers | 341 +++++++++++++++++++++++++++++++
system/skeleton/etc/gshadow | 21 ++
8 files changed, 456 insertions(+), 8 deletions(-)
create mode 100755 support/scripts/mkusers
create mode 100644 system/skeleton/etc/gshadow
Regards,
Yann E. MORIN
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Buildroot] [PATCH 1/3] system/skeleton: add the shadow-group file
2012-12-30 23:26 [Buildroot] [pull request] Pull request for branch yem-package-create-user Yann E. MORIN
@ 2012-12-30 23:26 ` Yann E. MORIN
2012-12-31 17:18 ` Thomas Petazzoni
2012-12-30 23:26 ` [Buildroot] [PATCH 2/3] packages: add ability for packages to create users Yann E. MORIN
2012-12-30 23:26 ` [Buildroot] [PATCH 3/3] package/tvheadend: use a non-root user to run the daemon Yann E. MORIN
2 siblings, 1 reply; 9+ messages in thread
From: Yann E. MORIN @ 2012-12-30 23:26 UTC (permalink / raw)
To: buildroot
/etc/gshadow is to /etc/group what /etc/shadow is to /etc/passwd.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
system/skeleton/etc/gshadow | 21 +++++++++++++++++++++
1 files changed, 21 insertions(+), 0 deletions(-)
create mode 100644 system/skeleton/etc/gshadow
diff --git a/system/skeleton/etc/gshadow b/system/skeleton/etc/gshadow
new file mode 100644
index 0000000..0af6dad
--- /dev/null
+++ b/system/skeleton/etc/gshadow
@@ -0,0 +1,21 @@
+root:*::
+daemon:*::
+bin:*::
+sys:*::
+adm:*::
+tty:*::
+disk:*::
+wheel:*::
+audio:*::
+www-data:*::
+utmp:*::
+staff:*::
+lock:*::
+haldaemon:*::
+dbus:*::
+netdev:*::
+ftp:*::
+nobody:*::
+nogroup:*::
+users:*::
+default:*::
--
1.7.2.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Buildroot] [PATCH 2/3] packages: add ability for packages to create users
2012-12-30 23:26 [Buildroot] [pull request] Pull request for branch yem-package-create-user Yann E. MORIN
2012-12-30 23:26 ` [Buildroot] [PATCH 1/3] system/skeleton: add the shadow-group file Yann E. MORIN
@ 2012-12-30 23:26 ` Yann E. MORIN
2012-12-30 23:26 ` [Buildroot] [PATCH 3/3] package/tvheadend: use a non-root user to run the daemon Yann E. MORIN
2 siblings, 0 replies; 9+ messages in thread
From: Yann E. MORIN @ 2012-12-30 23:26 UTC (permalink / raw)
To: buildroot
Packages that install daemons may need those daemons to run as a non-root,
or an otherwise non-system (eg. 'daemon'), user.
Add infrastructure for packages to create users, by declaring the
FOO_USERS variable that conatin a makedev-syntax-like description
of the user(s) to add.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
docs/manual/adding-packages-generic.txt | 16 ++-
docs/manual/makedev-syntax.txt | 65 ++++++
fs/common.mk | 5 +-
package/pkg-generic.mk | 1 +
support/scripts/mkusers | 341 +++++++++++++++++++++++++++++++
5 files changed, 425 insertions(+), 3 deletions(-)
create mode 100755 support/scripts/mkusers
diff --git a/docs/manual/adding-packages-generic.txt b/docs/manual/adding-packages-generic.txt
index 0759d4f..1adf424 100644
--- a/docs/manual/adding-packages-generic.txt
+++ b/docs/manual/adding-packages-generic.txt
@@ -50,7 +50,11 @@ system is based on hand-written Makefiles or shell scripts.
34: /bin/foo f 4755 0 0 - - - - -
35: endef
36:
-37: $(eval $(generic-package))
+37: define LIBFOO_USERS
+38: foo -1 libfoo -1 * - - - LibFoo daemon
+39: endef
+40
+41: $(eval $(generic-package))
--------------------------------
The Makefile begins on line 6 to 10 with metadata information: the
@@ -95,7 +99,10 @@ On line 29..31, we define a device-node file used by this package
On line 33..35, we define the permissions to set to specific files
installed by this package (+LIBFOO_PERMISSIONS+).
-Finally, on line 37, we call the +generic-package+ function, which
+On lines 37..39, we define a user that is used by this package (eg.
+to run a daemon as non-root).
+
+Finally, on line 41, we call the +generic-package+ function, which
generates, according to the variables defined previously, all the
Makefile code necessary to make your package working.
@@ -252,6 +259,11 @@ information is (assuming the package name is +libfoo+) :
You can find some documentation for this syntax in the xref:makedev-syntax[].
This variable is optional.
+* +LIBFOO_USERS+ lists the users to create for this package, if it installs
+ a daemon you want to run with a specific user. The syntax is similar in
+ spirit to the makedevs one, and is described in the xref:makeuser-syntax[].
+ This variable is optional.
+
* +LIBFOO_LICENSE+ defines the license (or licenses) under which the package
is released.
This name will appear in the manifest file produced by +make legal-info+.
diff --git a/docs/manual/makedev-syntax.txt b/docs/manual/makedev-syntax.txt
index 27517b3..fffdac9 100644
--- a/docs/manual/makedev-syntax.txt
+++ b/docs/manual/makedev-syntax.txt
@@ -54,3 +54,68 @@ and then for device files corresponding to the partitions of
/dev/hda b 640 0 0 3 1 1 1 15
-------------------------------------------------------------------
+
+[[makeuser-syntax]]
+Makeuser syntax documentation
+-----------------------------
+
+The syntax to create users is inspired by the makedev syntax, above, but
+is psecific to buildroot.
+
+The syntax for adding a user is a space-separated list of fields, one
+user per-line; the fields are:
+
+|=================================================================
+|username |uid |group |gid |password |home |shell |groups |comment
+|=================================================================
+
+Where:
+
+- +username+ is the desired user name (aka login name) for the user.
+ It must be unique.
+- +uid+ is the desired UID for the user. It must be unique, and not
+ +0+. If set to +-1+, then a unique UID will be computed by buildroot.
+- +group+ is the desired name for the user's main group.
+- +gid+ is the desired GID for the user's main group. It must be unique,
+ and not +0+. If set to +-1+, then a unique GID will be computed by
+ buildroot.
+- +password+ is the crypt(3)-encrypted password. If prefixed with +=+,
+ then it is interpreted as clear-text, and will be cypt-encoded. If
+ prefixed with +!+, then login is disabled. If set to +*+, then login
+ is not allowed.
+- +home+ is the desired home directory for the user. If set to '-', no
+ home directory will be created, and the user's home will be +/+.
+ Explicitly setting +home+ to +/+ is not allowed.
+- +shell+ is the desired shell for the user. If set to +-+, then
+ +/bin/false+ is set as the user's shell.
+- +groups+ is the comma-separated list of additional groups the user
+ should be part of. If set to +-+, then the user will be a member of
+ no additional group.
+- +comment+ is an almost-free-form text.
+
+There are a few restrictions on the content of each field:
+
+* except for +comment+, all fields are mandatory.
+* except for +comment+, fields may not contain spaces.
+* no field may contain a column (+:+).
+
+If +home+ is not +-+, then the home directory, and all files below,
+will belong to the user and its main group.
+
+Example:
+
+----
+foo -1 bar -1 !=blabla /home/foo /bin/sh alpha,bravo Foo user
+----
+
+This will create this user:
+
+- +username+ (aka login name) is: +foo+
+- +uid+ is computed by buildroot
+- main +group+ is: +bar+
+- main group +gid+ is computed by buildroot
+- clear-text +password+ is: +blabla+, will be crypt(3)-encrypted, but login is disabled.
+- +home+ is: +/home/foo+
+- +shell+ is: +/bin/sh+
+- +foo+ is also a member of +groups+: +alpha+ and +bravo+
+- +comment+ is: +Foo user+
diff --git a/fs/common.mk b/fs/common.mk
index b1512dd..b5a7950 100644
--- a/fs/common.mk
+++ b/fs/common.mk
@@ -35,6 +35,7 @@ FAKEROOT_SCRIPT = $(BUILD_DIR)/_fakeroot.fs
FULL_DEVICE_TABLE = $(BUILD_DIR)/_device_table.txt
ROOTFS_DEVICE_TABLES = $(call qstrip,$(BR2_ROOTFS_DEVICE_TABLE)) \
$(call qstrip,$(BR2_ROOTFS_STATIC_DEVICE_TABLE))
+USERS_TABLE = $(BUILD_DIR)/_users_table.txt
define ROOTFS_TARGET_INTERNAL
@@ -55,11 +56,13 @@ endif
printf '$(subst $(sep),\n,$(PACKAGES_PERMISSIONS_TABLE))' >> $(FULL_DEVICE_TABLE)
echo "$(HOST_DIR)/usr/bin/makedevs -d $(FULL_DEVICE_TABLE) $(TARGET_DIR)" >> $(FAKEROOT_SCRIPT)
endif
+ printf '$(subst $(sep),\n,$(PACKAGES_USERS))' > $(USERS_TABLE)
+ $(TOPDIR)/support/scripts/mkusers $(USERS_TABLE) $(TARGET_DIR) >> $(FAKEROOT_SCRIPT)
echo "$(ROOTFS_$(2)_CMD)" >> $(FAKEROOT_SCRIPT)
chmod a+x $(FAKEROOT_SCRIPT)
$(HOST_DIR)/usr/bin/fakeroot -- $(FAKEROOT_SCRIPT)
cp support/misc/target-dir-warning.txt $(TARGET_DIR_WARNING_FILE)
- - at rm -f $(FAKEROOT_SCRIPT) $(FULL_DEVICE_TABLE)
+ - at rm -f $(FAKEROOT_SCRIPT) $(FULL_DEVICE_TABLE) $(USERS_TABLE)
$(foreach hook,$(ROOTFS_$(2)_POST_GEN_HOOKS),$(call $(hook))$(sep))
ifeq ($$(BR2_TARGET_ROOTFS_$(2)_GZIP),y)
gzip -9 -c $$@ > $$@.gz
diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index a570ad7..871544c 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -510,6 +510,7 @@ ifeq ($$($$($(2)_KCONFIG_VAR)),y)
TARGETS += $(1)
PACKAGES_PERMISSIONS_TABLE += $$($(2)_PERMISSIONS)$$(sep)
PACKAGES_DEVICES_TABLE += $$($(2)_DEVICES)$$(sep)
+PACKAGES_USERS += $$($(2)_USERS)$$(sep)
ifeq ($$($(2)_SITE_METHOD),svn)
DL_TOOLS_DEPENDENCIES += svn
diff --git a/support/scripts/mkusers b/support/scripts/mkusers
new file mode 100755
index 0000000..ee922cd
--- /dev/null
+++ b/support/scripts/mkusers
@@ -0,0 +1,341 @@
+#!/bin/bash
+set -e
+myname="${0##*/}"
+
+#----------------------------------------------------------------------------
+# Configurable items
+MIN_UID=1000
+MAX_UID=1999
+MIN_GID=1000
+MAX_GID=1999
+# No more is configurable below this point
+#----------------------------------------------------------------------------
+
+#----------------------------------------------------------------------------
+USERS_TABLE="${1}"
+TARGET_DIR="${2}"
+shift 2
+PASSWD="${TARGET_DIR}/etc/passwd"
+SHADOW="${TARGET_DIR}/etc/shadow"
+GROUP="${TARGET_DIR}/etc/group"
+GSHADOW="${TARGET_DIR}/etc/gshadow"
+
+#----------------------------------------------------------------------------
+error() {
+ local fmt="${1}"
+ shift
+
+ printf "%s: " "${myname}" >&2
+ printf "${fmt}" "${@}" >&2
+}
+fail() {
+ error "$@"
+ exit 1
+}
+
+#----------------------------------------------------------------------------
+get_uid() {
+ local username="${1}"
+
+ grep -r -E "${username}:" "${PASSWD}" |cut -d: -f3
+}
+
+#----------------------------------------------------------------------------
+get_ugid() {
+ local username="${1}"
+
+ grep -r -E "${username}:" "${PASSWD}" |cut -d: -f4
+}
+
+#----------------------------------------------------------------------------
+get_gid() {
+ local group="${1}"
+
+ grep -r -E "${group}:" "${GROUP}" |cut -d: -f3
+}
+
+#----------------------------------------------------------------------------
+get_username() {
+ local uid="${1}"
+
+ sed -r -e '/^([^:]+):[^:]+:'"${uid}"':.*/!d; s//\1/;' "${PASSWD}"
+}
+
+#----------------------------------------------------------------------------
+get_group() {
+ local gid="${1}"
+
+ sed -r -e '/^([^:]+):[^:]+:'"${gid}"':/!d; s//\1/;' "${GROUP}"
+}
+
+#----------------------------------------------------------------------------
+get_ugroup() {
+ local username="${1}"
+ local ugid
+
+ ugid="$( get_ugid "${username}" )"
+ if [ -n "${ugid}" ]; then
+ get_group "${ugid}"
+ fi
+}
+
+#----------------------------------------------------------------------------
+# Sanity-check the new user/group:
+# - check the gid is not already used for another group
+# - check the group does not already exist with another gid
+# - check the user does not already exist with another gid
+# - check the uid is not already used for another user
+# - check the user does not already exist with another uid
+# - check the user does not already exist in another group
+check_user_validity() {
+ local username="${1}"
+ local uid="${2}"
+ local group="${3}"
+ local gid="${4}"
+ local _uid _ugid _gid _username _group _ugroup
+
+ _group="$( get_group "${gid}" )"
+ _gid="$( get_gid "${group}" )"
+ _ugid="$( get_ugid "${username}" )"
+ _username="$( get_username "${uid}" )"
+ _uid="$( get_uid "${username}" )"
+ _ugroup="$( get_ugroup "${username}" )"
+
+ if [ ${gid} -ge 0 ]; then
+ # check the gid is not already used for another group
+ if [ -n "${_group}" -a "${_group}" != "${group}" ]; then
+ fail "gid is already used by group '${_group}'\n"
+ fi
+
+ # check the group does not already exists with another gid
+ if [ -n "${_gid}" -a ${_gid} -ne ${gid} ]; then
+ fail "group already exists with gid '${_gid}'\n"
+ fi
+
+ # check the user does not already exists with another gid
+ if [ -n "${_ugid}" -a ${_ugid} -ne ${gid} ]; then
+ fail "user already exists with gid '${_ugid}'\n"
+ fi
+ fi
+
+ if [ ${uid} -ge 0 ]; then
+ # check the uid is not already used for another user
+ if [ -n "${_username}" -a "${_username}" != "${username}" ]; then
+ fail "uid is already used by user '${_username}'\n"
+ fi
+
+ # check the user does not already exists with another uid
+ if [ -n "${_uid}" -a ${_uid} -ne ${uid} ]; then
+ fail "user already exists with uid '${_uid}'\n"
+ fi
+ fi
+
+ # check the user does not already exist in another group
+ if [ -n "${_ugroup}" -a "${_ugroup}" != "${group}" ]; then
+ fail "user already exists with group '${_ugroup}'\n"
+ fi
+
+ return 0
+}
+
+#----------------------------------------------------------------------------
+# Generate a unique GID for given group. If the group already exists,
+# then simply report its current GID. Otherwise, generate the lowest GID
+# that is:
+# - not 0
+# - comprised in [MIN_GID..MAX_GID]
+# - not already used by a group
+generate_gid() {
+ local group="${1}"
+ local gid
+
+ gid="$( get_gid "${group}" )"
+ if [ -z "${gid}" ]; then
+ for(( gid=MIN_GID; gid<=MAX_GID; gid++ )); do
+ if [ -z "$( get_group "${gid}" )" ]; then
+ break
+ fi
+ done
+ if [ ${gid} -gt ${MAX_GID} ]; then
+ fail "can not allocate a GID for group '%s'\n" "${group}"
+ fi
+ fi
+ printf "%d\n" "${gid}"
+}
+
+#----------------------------------------------------------------------------
+# Add a group; if it does already exist, remove it first
+add_one_group() {
+ local group="${1}"
+ local gid="${2}"
+ local _f
+
+ # Generate a new GID if needed
+ if [ ${gid} -eq -1 ]; then
+ gid="$( generate_gid "${group}" )"
+ fi
+
+ # Remove any previous instance of this group
+ for _f in "${GROUP}" "${GSHADOW}"; do
+ sed -r -i -e '/^'"${group}"':.*/d;' "${_f}"
+ done
+
+ printf "%s:x:%d:\n" "${group}" "${gid}" >>"${GROUP}"
+ printf "%s:*::\n" "${group}" >>"${GSHADOW}"
+}
+
+#----------------------------------------------------------------------------
+# Generate a unique UID for given username. If the username already exists,
+# then simply report its current UID. Otherwise, generate the lowest UID
+# that is:
+# - not 0
+# - comprised in [MIN_UID..MAX_UID]
+# - not already used by a user
+generate_uid() {
+ local username="${1}"
+ local uid
+
+ uid="$( get_uid "${username}" )"
+ if [ -z "${uid}" ]; then
+ for(( uid=MIN_UID; uid<=MAX_UID; uid++ )); do
+ if [ -z "$( get_username "${uid}" )" ]; then
+ break
+ fi
+ done
+ if [ ${uid} -gt ${MAX_UID} ]; then
+ fail "can not allocate a UID for user '%s'\n" "${username}"
+ fi
+ fi
+ printf "%d\n" "${uid}"
+}
+
+#----------------------------------------------------------------------------
+# Add given user to given group, if not already the case
+add_user_to_group() {
+ local username="${1}"
+ local group="${2}"
+ local _f
+
+ for _f in "${GROUP}" "${GSHADOW}"; do
+ sed -r -i -e 's/^('"${group}"':.*:)(([^:]+,)?)'"${username}"'(,[^:]+*)?$/\1\2\4/;' \
+ -e 's/^('"${group}"':.*)$/\1,'"${username}"'/;' \
+ -e 's/,+/,/' \
+ -e 's/:,/:/' \
+ "${_f}"
+ done
+}
+
+#----------------------------------------------------------------------------
+# Add a user; if it does already exist, remove it first
+add_one_user() {
+ local username="${1}"
+ local uid="${2}"
+ local group="${3}"
+ local gid="${4}"
+ local passwd="${5}"
+ local home="${6}"
+ local shell="${7}"
+ local groups="${8}"
+ local comment="${9}"
+ local nb_days="$((($(date +%s)+(24*60*60-1))/(24*60*60)))"
+ local _f _group _home _shell _gid _passwd
+
+ # First, sanity-check the user
+ check_user_validity "${username}" "${uid}" "${group}" "${gid}"
+
+ # Generate a new UID if needed
+ if [ ${uid} -eq -1 ]; then
+ uid="$( generate_uid "${username}" )"
+ fi
+
+ # Remove any previous instance of this user
+ for _f in "${PASSWD}" "${SHADOW}"; do
+ sed -r -i -e '/^'"${username}"':.*/d;' "${_f}"
+ done
+
+ _gid="$( get_gid "${group}" )"
+ _shell="${shell}"
+ if [ "${shell}" = "-" ]; then
+ _shell="/bin/false"
+ fi
+ case "${home}" in
+ -) _home="/";;
+ /) fail "home can not be explicitly '/'\n";;
+ /*) _home="${home}";;
+ *) fail "home must be an absolute path";;
+ esac
+ case "${passwd}" in
+ =!*|!=*)
+ _passwd='!'"$( mkpasswd -m md5 "${passwd#??}" )"
+ ;;
+ =*)
+ _passwd="$( mkpasswd -m md5 "${passwd#?}" )"
+ ;;
+ *)
+ _passwd="${passwd}"
+ ;;
+ esac
+
+ printf "%s:x:%d:%d:%s:%s:%s\n" \
+ "${username}" "${uid}" "${_gid}" \
+ "${comment}" "${_home}" "${_shell}" \
+ >>"${PASSWD}"
+ printf "%s:%s:%d:0:99999:7:::\n" \
+ "${username}" "${_passwd}" "${nb_days}" \
+ >>"${SHADOW}"
+
+ # Add the user to its additional groups
+ if [ "${groups}" != "-" ]; then
+ for _group in ${groups//,/ }; do
+ add_user_to_group "${username}" "${_group}"
+ done
+ fi
+
+ # If the user has a home, chown it
+ # (Note: stdout goes to the fakeroot-script)
+ if [ "${home}" != "-" ]; then
+ mkdir -p "${TARGET_DIR}/${home}"
+ printf "chown -R %d:%d '%s'\n" "${uid}" "${_gid}" "${TARGET_DIR}/${home}"
+ fi
+}
+
+#----------------------------------------------------------------------------
+main() {
+ local username uid group gid passwd home shell groups comment
+
+ # Some sanity checks
+ if [ ${MIN_UID} -le 0 ]; then
+ fail "MIN_UID must be >0 (currently %d)\n" ${MIN_UID}
+ fi
+ if [ ${MIN_GID} -le 0 ]; then
+ fail "MIN_GID must be >0 (currently %d)\n" ${MIN_GID}
+ fi
+
+ # First, create all the main groups
+ while read username uid group gid passwd home shell groups comment; do
+ [ -n "${username}" ] || continue # Package with no user
+ add_one_group "${group}" "${gid}"
+ done <"${USERS_TABLE}"
+
+ # Then, create all the additional groups
+ # If any additional group is already a main group, we should use
+ # the gid of that main group; otherwise, we can use any gid
+ while read username uid group gid passwd home shell groups comment; do
+ [ -n "${username}" ] || continue # Package with no user
+ if [ "${groups}" != "-" ]; then
+ for g in ${groups//,/ }; do
+ add_one_group "${g}" -1
+ done
+ fi
+ done <"${USERS_TABLE}"
+
+ # Finally, add users
+ while read username uid group gid passwd home shell groups comment; do
+ [ -n "${username}" ] || continue # Package with no user
+ add_one_user "${username}" "${uid}" "${group}" "${gid}" "${passwd}" \
+ "${home}" "${shell}" "${groups}" "${comment}"
+ done <"${USERS_TABLE}"
+}
+
+#----------------------------------------------------------------------------
+main "${@}"
--
1.7.2.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Buildroot] [PATCH 3/3] package/tvheadend: use a non-root user to run the daemon
2012-12-30 23:26 [Buildroot] [pull request] Pull request for branch yem-package-create-user Yann E. MORIN
2012-12-30 23:26 ` [Buildroot] [PATCH 1/3] system/skeleton: add the shadow-group file Yann E. MORIN
2012-12-30 23:26 ` [Buildroot] [PATCH 2/3] packages: add ability for packages to create users Yann E. MORIN
@ 2012-12-30 23:26 ` Yann E. MORIN
2 siblings, 0 replies; 9+ messages in thread
From: Yann E. MORIN @ 2012-12-30 23:26 UTC (permalink / raw)
To: buildroot
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
package/tvheadend/etc.default.tvheadend | 5 ++---
package/tvheadend/tvheadend.mk | 10 ++++++++--
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/package/tvheadend/etc.default.tvheadend b/package/tvheadend/etc.default.tvheadend
index c769055..253f832 100644
--- a/package/tvheadend/etc.default.tvheadend
+++ b/package/tvheadend/etc.default.tvheadend
@@ -1,6 +1,5 @@
-# Once we have a real user, we'll use it
-TVH_USER=root
-TVH_GROUP=root
+TVH_USER=tvheadend
+TVH_GROUP=tvheadend
#TVH_ADAPTERS=
#TVH_HTTP_PORT=9981
#TVH_HTSP_PORT=9982
diff --git a/package/tvheadend/tvheadend.mk b/package/tvheadend/tvheadend.mk
index 5100781..f63b433 100644
--- a/package/tvheadend/tvheadend.mk
+++ b/package/tvheadend/tvheadend.mk
@@ -26,9 +26,11 @@ TVHEADEND_DEPENDENCIES += dvb-apps
# To run tvheadend, we need:
# - a startup script, and its config file
# - a default DB with a tvheadend admin
+# - a non-root user to run as
define TVHEADEND_INSTALL_DB
- $(INSTALL) -D package/tvheadend/accesscontrol.1 \
- $(TARGET_DIR)/root/.hts/tvheadend/accesscontrol/1
+ $(INSTALL) -D -m 0600 package/tvheadend/accesscontrol.1 \
+ $(TARGET_DIR)/home/tvheadend/.hts/tvheadend/accesscontrol/1
+ chmod -R go-rwx $(TARGET_DIR)/home/tvheadend
endef
TVHEADEND_POST_INSTALL_TARGET_HOOKS = TVHEADEND_INSTALL_DB
@@ -37,6 +39,10 @@ define TVHEADEND_INSTALL_INIT_SYSV
$(INSTALL) -D package/tvheadend/S99tvheadend $(TARGET_DIR)/etc/init.d/S99tvheadend
endef
+define TVHEADEND_USERS
+tvheadend -1 tvheadend -1 * /home/tvheadend - - TVHeadend daemon
+endef
+
#----------------------------------------------------------------------------
# tvheadend is not an autotools-based package, but it is possible to
# call its ./configure script as if it were an autotools one.
--
1.7.2.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [Buildroot] [PATCH 1/3] system/skeleton: add the shadow-group file
2012-12-30 23:26 ` [Buildroot] [PATCH 1/3] system/skeleton: add the shadow-group file Yann E. MORIN
@ 2012-12-31 17:18 ` Thomas Petazzoni
2012-12-31 18:18 ` Yann E. MORIN
0 siblings, 1 reply; 9+ messages in thread
From: Thomas Petazzoni @ 2012-12-31 17:18 UTC (permalink / raw)
To: buildroot
Dear Yann E. MORIN,
On Mon, 31 Dec 2012 00:26:02 +0100, Yann E. MORIN wrote:
> /etc/gshadow is to /etc/group what /etc/shadow is to /etc/passwd.
Could you give some more details? I understand /etc/shadow as opposed
to /etc/passwd, but I don't see the point of /etc/gshadow since groups
don't have passwords.
Thomas
--
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Buildroot] [PATCH 1/3] system/skeleton: add the shadow-group file
2012-12-31 17:18 ` Thomas Petazzoni
@ 2012-12-31 18:18 ` Yann E. MORIN
2013-01-01 9:26 ` Thomas Petazzoni
0 siblings, 1 reply; 9+ messages in thread
From: Yann E. MORIN @ 2012-12-31 18:18 UTC (permalink / raw)
To: buildroot
Thomas, All,
On Monday 31 December 2012 Thomas Petazzoni wrote:
> On Mon, 31 Dec 2012 00:26:02 +0100, Yann E. MORIN wrote:
> > /etc/gshadow is to /etc/group what /etc/shadow is to /etc/passwd.
>
> Could you give some more details? I understand /etc/shadow as opposed
> to /etc/passwd, but I don't see the point of /etc/gshadow since groups
> don't have passwords.
Wrong. Groups can have passwords. And users can change-group with:
$ newgrp [-] groupname
If the user is a member of that group, or the group is paswrod-less, then
no password is asked for, and the current group-id has changed (it is a bit
like 'su', but to just change group)
If the user is not a member that group, and the group is not restricted (eg.
password is not '*' and does not start with '!', then the user is asked to
enter the group password.
See:
group(5) gshadow(5) newgrp(1)
I hope that was enough to explain addition of gshadow. ;-)
Happy New Year!
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Buildroot] [PATCH 1/3] system/skeleton: add the shadow-group file
2012-12-31 18:18 ` Yann E. MORIN
@ 2013-01-01 9:26 ` Thomas Petazzoni
2013-01-01 15:36 ` Yann E. MORIN
0 siblings, 1 reply; 9+ messages in thread
From: Thomas Petazzoni @ 2013-01-01 9:26 UTC (permalink / raw)
To: buildroot
Dear Yann E. MORIN,
Happy New Year!
On Mon, 31 Dec 2012 19:18:08 +0100, Yann E. MORIN wrote:
> Wrong. Groups can have passwords. And users can change-group with:
>
> $ newgrp [-] groupname
>
> If the user is a member of that group, or the group is paswrod-less, then
> no password is asked for, and the current group-id has changed (it is a bit
> like 'su', but to just change group)
>
> If the user is not a member that group, and the group is not restricted (eg.
> password is not '*' and does not start with '!', then the user is asked to
> enter the group password.
>
> See:
> group(5) gshadow(5) newgrp(1)
>
> I hope that was enough to explain addition of gshadow. ;-)
Interesting, I didn't know about this.
The next question that comes up is: do we really need to support this
in Buildroot?
Thomas
--
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Buildroot] [PATCH 1/3] system/skeleton: add the shadow-group file
2013-01-01 9:26 ` Thomas Petazzoni
@ 2013-01-01 15:36 ` Yann E. MORIN
2013-01-01 21:08 ` Peter Korsgaard
0 siblings, 1 reply; 9+ messages in thread
From: Yann E. MORIN @ 2013-01-01 15:36 UTC (permalink / raw)
To: buildroot
Thomas, All,
On Tuesday 01 January 2013 Thomas Petazzoni wrote:
> On Mon, 31 Dec 2012 19:18:08 +0100, Yann E. MORIN wrote:
> > Wrong. Groups can have passwords. And users can change-group with:
[--SNIP--]
> The next question that comes up is: do we really need to support this
> in Buildroot?
Well, I interpreted the abscence of that file as an oversight, that's why
I thought of adding it.
Right, we probably do not need the change-group feature in buildroot.
However, for the sake of consistency, I think it is good to have gshadow.
But I can very well live without it, sure.
Anyway... Happy New Year to all! :-)
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Buildroot] [PATCH 1/3] system/skeleton: add the shadow-group file
2013-01-01 15:36 ` Yann E. MORIN
@ 2013-01-01 21:08 ` Peter Korsgaard
0 siblings, 0 replies; 9+ messages in thread
From: Peter Korsgaard @ 2013-01-01 21:08 UTC (permalink / raw)
To: buildroot
>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:
Hi,
>> The next question that comes up is: do we really need to support this
>> in Buildroot?
Yann> Well, I interpreted the abscence of that file as an oversight,
Yann> that's why I thought of adding it.
Yann> Right, we probably do not need the change-group feature in
Yann> buildroot. However, for the sake of consistency, I think it is
Yann> good to have gshadow.
Yann> But I can very well live without it, sure.
Well, the fact that nobody has ever asked for it in the 11 years
buildroot has existed and that Thomas (and me) didn't know about the
file, makes me think that perhaps it isn't too important to support it
in the default skeleton (you can certainly manually add it).
Yann> Anyway... Happy New Year to all! :-)
Thanks, same to you!
--
Bye, Peter Korsgaard
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2013-01-01 21:08 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-30 23:26 [Buildroot] [pull request] Pull request for branch yem-package-create-user Yann E. MORIN
2012-12-30 23:26 ` [Buildroot] [PATCH 1/3] system/skeleton: add the shadow-group file Yann E. MORIN
2012-12-31 17:18 ` Thomas Petazzoni
2012-12-31 18:18 ` Yann E. MORIN
2013-01-01 9:26 ` Thomas Petazzoni
2013-01-01 15:36 ` Yann E. MORIN
2013-01-01 21:08 ` Peter Korsgaard
2012-12-30 23:26 ` [Buildroot] [PATCH 2/3] packages: add ability for packages to create users Yann E. MORIN
2012-12-30 23:26 ` [Buildroot] [PATCH 3/3] package/tvheadend: use a non-root user to run the daemon Yann E. MORIN
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox