[Pkg-mongodb-maintainers] [pkg-mongodb] 372/394: postinst: refactor user creation
Apollon Oikonomopoulos
apoikos at moszumanska.debian.org
Wed Sep 21 14:00:35 UTC 2016
This is an automated email from the git hooks/post-receive script.
apoikos pushed a commit to branch master
in repository pkg-mongodb.
commit 6c7aa275338568e5dc2698225d1d781ab4b7bac8
Author: Apollon Oikonomopoulos <apoikos at debian.org>
Date: Thu Feb 11 00:09:55 2016 +0200
postinst: refactor user creation
The current user creation logic has a couple of drawbacks:
- It uses a loose match against /etc/passwd. The grep call will match
anything with the "mongodb" word in it, and it also assumes that
/etc/passwd is the only NSS source on the system.
- The mongodb user has nogroup as its primary group
- The mongodb user has a valid shell
Replace the user creation with a single, unconditional call to adduser
which will succeed if the mongodb system user exists (even if previously
created with `nogroup' as the primary group).
---
debian/mongodb-server.postinst | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/debian/mongodb-server.postinst b/debian/mongodb-server.postinst
index 9d084de..22b3006 100644
--- a/debian/mongodb-server.postinst
+++ b/debian/mongodb-server.postinst
@@ -21,11 +21,9 @@ set -e
case "$1" in
configure)
# create a mongodb group and user
- if ! grep -q mongodb /etc/passwd; then
- adduser --system --home /var/lib/mongodb --no-create-home mongodb
- addgroup --system mongodb
- adduser mongodb mongodb
- fi
+ adduser --system --disabled-password --disabled-login \
+ --home /var/lib/mongodb --no-create-home \
+ --quiet --group mongodb
# create db -- note: this should agree with dbpath in mongodb.conf
mkdir -p /var/lib/mongodb
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mongodb/pkg-mongodb.git
More information about the Pkg-mongodb-maintainers
mailing list