]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
debian/ceph-common.postinst: set user directory using adduser
authorKefu Chai <tchaikov@gmail.com>
Wed, 17 Jan 2024 15:36:12 +0000 (23:36 +0800)
committerMatthew Vernon <mvernon@wikimedia.org>
Thu, 22 Feb 2024 10:06:29 +0000 (10:06 +0000)
now that adduser allows us to set its home directory, we can do
this using adduser instead of using usermod. this change also
silences the warning from lintian
"maintainer-script-lacks-home-in-adduser". lintian complains if
`adduser --system` is called without passing `--home` option.

also, take this opportunity to s/-c/--comment/ in the command line
of `usermod`, for better readability.

Fixes: https://tracker.ceph.com/issues/64069
Signed-off-by: Kefu Chai <tchaikov@gmail.com>
(cherry picked from commit a1a857698cad4f2feeea0b56fd781350e44078b7)

debian/ceph-common.postinst

index d147de5386b2dbff0d2ace1500b61815f8ace9c6..e058d096ee1a100810059fddd8d955fdd95d7c1f 100644 (file)
@@ -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