Skip to content

Commit

Permalink
Merge pull request ceph#55218 from tchaikov/debian/postinst
Browse files Browse the repository at this point in the history
debian/*.postinst: add adduser as a dependency and specify --home when adduser 

Reviewed-by: Laura Flores <[email protected]>
Reviewed-by: Adam King [email protected]
  • Loading branch information
yuriw authored Feb 20, 2024
2 parents b9f000f + e74ec0b commit d74e98d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
10 changes: 7 additions & 3 deletions debian/ceph-common.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,20 @@ case "$1" in
--system \
--no-create-home \
--disabled-password \
--home $SERVER_HOME \
--uid $SERVER_UID \
--gid $SERVER_GID \
$SERVER_USER 2>/dev/null || true
echo "..done"
fi
# 3. adjust passwd entry
# NOTE: we should use "adduser --comment" if we don't need to
# support adduser <3.136. "adduser --gecos" is deprecated,
# and will be removed, so we don't use it. the first distro
# using --comment is debian/trixie or ubuntu/mantic.
echo -n "Setting system user $SERVER_USER properties.."
usermod -c "$SERVER_NAME" \
-d $SERVER_HOME \
-g $SERVER_GROUP \
usermod --comment "$SERVER_NAME" \
--gid $SERVER_GROUP \
$SERVER_USER
# Unlock $SERVER_USER in case it is locked from an uninstall
if [ -f /etc/shadow ]; then
Expand Down
21 changes: 13 additions & 8 deletions debian/cephadm.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ case "$1" in
# 1. create user if not existing
if ! getent passwd | grep -q "^cephadm:"; then
echo -n "Adding system user cephadm.."
adduser --quiet --system --disabled-password --gecos 'cephadm user for mgr/cephadm' --shell /bin/bash cephadm 2>/dev/null || true
adduser --quiet \
--system \
--disabled-password \
--home /home/cephadm \
--shell /bin/bash cephadm 2>/dev/null || true
usermod --comment "cephadm user for mgr/cephadm" cephadm
echo "..done"
fi

Expand All @@ -38,19 +43,19 @@ case "$1" in

# set up (initially empty) .ssh/authorized_keys file
if ! test -d /home/cephadm/.ssh; then
mkdir /home/cephadm/.ssh
chown --reference /home/cephadm /home/cephadm/.ssh
chmod 0700 /home/cephadm/.ssh
mkdir /home/cephadm/.ssh
chown --reference /home/cephadm /home/cephadm/.ssh
chmod 0700 /home/cephadm/.ssh
fi
if ! test -e /home/cephadm/.ssh/authorized_keys; then
touch /home/cephadm/.ssh/authorized_keys
chown --reference /home/cephadm /home/cephadm/.ssh/authorized_keys
chmod 0600 /home/cephadm/.ssh/authorized_keys
touch /home/cephadm/.ssh/authorized_keys
chown --reference /home/cephadm /home/cephadm/.ssh/authorized_keys
chmod 0600 /home/cephadm/.ssh/authorized_keys
fi

;;
abort-upgrade|abort-remove|abort-deconfigure)
:
:
;;

*)
Expand Down
6 changes: 4 additions & 2 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ Description: debugging symbols for ceph-base
Package: cephadm
Architecture: linux-any
Recommends: podman (>= 2.0.2) | docker.io | docker-ce
Depends: lvm2,
Depends: adduser (>= 3.11),
lvm2,
python3,
${python3:Depends},
Description: cephadm utility to bootstrap ceph daemons with systemd and containers
Expand Down Expand Up @@ -612,7 +613,8 @@ Description: debugging symbols for rbd-nbd

Package: ceph-common
Architecture: linux-any
Depends: librbd1 (= ${binary:Version}),
Depends: adduser (>= 3.11),
librbd1 (= ${binary:Version}),
python3-cephfs (= ${binary:Version}),
python3-ceph-argparse (= ${binary:Version}),
python3-ceph-common (= ${binary:Version}),
Expand Down

0 comments on commit d74e98d

Please sign in to comment.