Skip to content

debian/*.postinst: add adduser as a dependency and specify --home when adduser - #55218

Merged
yuriw merged 6 commits into
ceph:mainfrom
tchaikov:debian/postinst
Feb 20, 2024
Merged

yuriw merged 6 commits into
ceph:mainfrom
tchaikov:debian/postinst

Conversation

@tchaikov

@tchaikov tchaikov commented Jan 17, 2024 •

Copy link
Copy Markdown
Contributor

in this changeset, we

  • add adduser as the runtime dependency of ceph-common and cephadm
  • pass --home to adduser in the postinst script to accommodate the recent change in this tool

Fixes: https://tracker.ceph.com/issues/64069

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows
  • jenkins test rook e2e

@mcv21

mcv21 commented Jan 17, 2024

Copy link
Copy Markdown
Contributor

I'm slightly confused by the whitespace changes, but the substantive changes here look right to me. Thanks for getting to this more quickly than I did! :)

@tchaikov

tchaikov commented Jan 18, 2024 •

Copy link
Copy Markdown
Contributor Author

I'm slightly confused by the whitespace changes, but the substantive changes here look right to me. Thanks for getting to this more quickly than I did! :)

@mcv21 hi Matthew, thank you for your review. regarding the "the white space changes", please check its commit message. my editor does not use 8 spaces when rendering tab by default, hence i noticed this inconsistency. and since i was editing that file, i fixed it as well.

@tchaikov

tchaikov commented Jan 18, 2024 •

Copy link
Copy Markdown
Contributor Author
  • note to myself, please reference the tracker ticket.

@tchaikov tchaikov self-assigned this Jan 18, 2024
@tchaikov

Copy link
Copy Markdown
Contributor Author

@tchaikov tchaikov removed their assignment Jan 18, 2024
@mcv21

mcv21 commented Jan 18, 2024

Copy link
Copy Markdown
Contributor

build-tested at https://shaman.ceph.com/builds/ceph/kefu-debian-postinst-1/6b6e81398c4958477fd92cba5671c217b70a0a08/

At the risk of opening a can of worms, would it be possible to build-test on Debian too?

@tchaikov

Copy link
Copy Markdown
Contributor Author

build-tested at https://shaman.ceph.com/builds/ceph/kefu-debian-postinst-1/6b6e81398c4958477fd92cba5671c217b70a0a08/

At the risk of opening a can of worms, would it be possible to build-test on Debian too?

@mcv21 i am building the debian packages using a sid pbuilder env, is this good enough? or you prefer building it in a bookworm pbuilder env?

@mcv21

mcv21 commented Jan 18, 2024

Copy link
Copy Markdown
Contributor

sid is probably OK, though I think bookworm is better given that's the release we're targetting; I'd just not seen any Debian in the shaman output you linked.

@tchaikov

Copy link
Copy Markdown
Contributor Author
[ 13%] Building CXX object src/msg/CMakeFiles/common-msg-objs.dir/async/Stack.cc.o
cd /var/ssd/ceph/obj-x86_64-linux-gnu/src/msg && /usr/bin/c++ -DBOOST_ASIO_DISABLE_THREAD_KEYWORD_EXTENSION -DBOOST_ASIO_HAS_IO_URING -DBOOST_ASIO_NO_TS_EXECUTORS -DHAVE_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE -D__CEPH__ -D__STDC_FORMAT_MACROS -D__linux__ -I/var/ssd/ceph/obj-x86_64-linux-gnu/src/include -I/var/ssd/ceph/src -isystem /var/ssd/ceph/obj-x86_64-linux-gnu/boost/include -isystem /var/ssd/ceph/obj-x86_64-linux-gnu/include -isystem /var/ssd/ceph/src/xxHash -isystem /var/ssd/ceph/src/fmt/include -g -O2 -ffile-prefix-map=/var/ssd/ceph=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2 -std=c++20 -fPIC   -U_FORTIFY_SOURCE -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free -DBOOST_PHOENIX_STL_TUPLE_H_ -Wall -fno-strict-aliasing -fsigned-char -Wtype-limits -Wignored-qualifiers -Wpointer-arith -Werror=format-security -Winit-self -Wno-unknown-pragmas -Wnon-virtual-dtor -Wno-ignored-qualifiers -ftemplate-depth-1024 -Wpessimizing-move -Wredundant-move -Wstrict-null-sentinel -Woverloaded-virtual -fstack-protector-strong -fdiagnostics-color=auto -MD -MT src/msg/CMakeFiles/common-msg-objs.dir/async/Stack.cc.o -MF CMakeFiles/common-msg-objs.dir/async/Stack.cc.o.d -o CMakeFiles/common-msg-objs.dir/async/Stack.cc.o -c /var/ssd/ceph/src/msg/async/Stack.cc
In file included from /var/ssd/ceph/src/spawn/include/spawn/detail/net.hpp:16,
                 from /var/ssd/ceph/src/spawn/include/spawn/spawn.hpp:21,
                 from /var/ssd/ceph/src/common/async/yield_context.h:23,
                 from /var/ssd/ceph/src/crypto/openssl/openssl_crypto_accel.h:19,
                 from /var/ssd/ceph/src/crypto/openssl/openssl_crypto_plugin.h:19,
                 from /var/ssd/ceph/src/crypto/openssl/openssl_crypto_plugin.cc:16:
/var/ssd/ceph/obj-x86_64-linux-gnu/boost/include/boost/asio/bind_executor.hpp: In instantiation of ‘class boost::asio::detail::executor_binder_base<void (*)(), boost::asio::executor, false>’:
/var/ssd/ceph/obj-x86_64-linux-gnu/boost/include/boost/asio/bind_executor.hpp:209:7:   required from ‘class boost::asio::executor_binder<void (*)(), boost::asio::executor>’
/var/ssd/ceph/src/spawn/include/spawn/spawn.hpp:114:11:   required from ‘class spawn::basic_yield_context<boost::asio::executor_binder<void (*)(), boost::asio::executor> >’
/var/ssd/ceph/src/common/async/yield_context.h:36:17:   required from here
/var/ssd/ceph/obj-x86_64-linux-gnu/boost/include/boost/asio/bind_executor.hpp:185:12: error: ‘boost::asio::detail::executor_binder_base<T, Executor, false>::executor_’ has incomplete type
  185 |   Executor executor_;
      |            ^~~~~~~~~
In file included from /var/ssd/ceph/obj-x86_64-linux-gnu/boost/include/boost/asio/detail/completion_handler.hpp:21,
                 from /var/ssd/ceph/obj-x86_64-linux-gnu/boost/include/boost/asio/impl/io_context.hpp:18,
                 from /var/ssd/ceph/obj-x86_64-linux-gnu/boost/include/boost/asio/io_context.hpp:1523,
                 from /var/ssd/ceph/src/crypto/crypto_plugin.h:23,
                 from /var/ssd/ceph/src/crypto/openssl/openssl_crypto_plugin.h:18:
/var/ssd/ceph/obj-x86_64-linux-gnu/boost/include/boost/asio/detail/handler_work.hpp:39:7: note: forward declaration of ‘class boost::asio::executor’
   39 | class executor;
      |       ^~~~~~~~
make[3]: *** [src/crypto/openssl/CMakeFiles/ceph_crypto_openssl.dir/build.make:93: src/crypto/openssl/CMakeFiles/ceph_crypto_openssl.dir/openssl_crypto_plugin.cc.o] Error 1

FWIW, the latest tree fails to build on sid. i don't think it's related to the change in this PR though.

@tchaikov

Copy link
Copy Markdown
Contributor Author

jenkins test api

@tchaikov

Copy link
Copy Markdown
Contributor Author

@mcv21 i am afraid that i don't have enough bandwidth chasing the FTBFS issue. do you think it's a blocker? since ubuntu focal was released back in 2020-04, while bookworm 2023-06, the dependency changes should be safe. what do you think?

@tchaikov
tchaikov requested a review from a team January 23, 2024 16:33
@tchaikov

Copy link
Copy Markdown
Contributor Author

@ljflores hi Laura, could you please help review this change? i am not sure whom i should ping for review, if you are not, would you mind pinging the reviewer(s) who can help on this?

@ljflores

Copy link
Copy Markdown
Member

@tchaikov Sure, will take a look

@ljflores ljflores added the core label Jan 23, 2024
@ljflores
ljflores requested review from a team and adk3798 January 23, 2024 16:44
@ljflores

Copy link
Copy Markdown
Member

Since this is an update to a cephadm package, one of the orch members (or @adk3798) would probably be best to review this.

@adk3798 adk3798 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just reviewing from orch side. Don't know the build stuff very well, especially debian specific build stuff, but seems good to me.

@ljflores ljflores left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the core side of things, I would definitely like to have this go through integration testing. Logistically it makes sense, but I'm wondering if there is there anything specific that was done (or that can be done) to verify this change?

Comment thread debian/cephadm.postinst Resolved
@tchaikov

Copy link
Copy Markdown
Contributor Author

@tchaikov Sure, will take a look

thank you for your review and approval.

@mcv21

mcv21 commented Jan 24, 2024

Copy link
Copy Markdown
Contributor

@mcv21 i am afraid that i don't have enough bandwidth chasing the FTBFS issue. do you think it's a blocker? since ubuntu focal was released back in 2020-04, while bookworm 2023-06, the dependency changes should be safe. what do you think?

It'll presumably need fixing at some point, but I can't see that it's related to this change (so I don't think it should block it).

Comment thread debian/cephadm.postinst Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, I am new to ceph, I was trying to install cephamd on Debian bookworm and ran into the problem this PR solves.

I was going through the Debian docs and found that they are going to remove --gecos option in the next release. Instead, --comment should be used. I see that for the other postinst script --comment is already used.

Does it make sense to use the new option for this script too as a part of this PR or should it be solved in a different ticket?

@tchaikov tchaikov Jan 30, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sitiritis hi Tymur, thank you for the reminder. since this change is being tested in lab, and i hope that this fix can be backported sooner. also, --gecos has not been deprecated, so guess we can live with it a little bit longer. but once this change lands, i will create another PR to s/--gecos/--comment/ to be more future-proof. so, "in a different ticket" or pull request. in general, we file a ticket so that it can be tracked and the corresponding fixes can be backported. if the --gecos does not cause any real-world issues yet, we could dispense a ticket on tracker.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sitiritis since our CI is still using ubuntu:jammy, and the adduser shipped along with it does not support --comment yet, i am not using --comment and since --gecos is going to be removed after bookworm, as you point out. i am adding a commit to use usermod directly. once we have the luxury of dropping the support of release before debian/trixie or ubuntu/mantic. we can start using adduser --comment. to be more future-proof, i will add a commit in this PR to switch to usermod.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you :)
I just got access to ceph's redmine to create a ticket for this change, but it seems I don't need to do this anymore.

in `debian/ceph-common.postinst` and `debian/cephadm.postinst`, we
use `adduser --system` to create the system user when configuring
the corresponding package.

before this change, the dependency is not listed in the runtime
`Depends` section of ceph-common and cephadm.

in this change, the dependency is added. this is also suggested
by Securing Debian Manual, see
https://www.debian.org/doc/manuals/securing-debian-manual/bpp-lower-privs.en.html

Signed-off-by: Kefu Chai <[email protected]>
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 <[email protected]>
quote from adduser/NEWS.Debian.gz:

>  System user home defaults to /nonexistent if --home is not specified.
>  Packages that call adduser to create system accounts should explicitly
>  specify a location for /home (see Lintian check
>  maintainer-script-lacks-home-in-adduser).

so let's follow this change in adduser. otherwise "cephadm"
would have a $HOME at `/nonexistent`.

Fixes: https://tracker.ceph.com/issues/64069
Signed-off-by: Kefu Chai <[email protected]>
for better readability, and to be more consistent with the rest
of this file, and other .postinst scripts of this project.

Signed-off-by: Kefu Chai <[email protected]>
--gecos option of adduser is deprecated in debian/bookworm, and
will be removed in debian/trixie,
see https://manpages.debian.org/bookworm/adduser/adduser.8.en.html.
so to be future-proof, let's switch to `usermod --comment`. please
note, since we still need to support ubuntu/jammy which is used in
our CI, and `adduser` shipped by ubuntu/jammy does not support
`--comment` yet, so we cannot use this option.

Signed-off-by: Kefu Chai <[email protected]>
@tchaikov

tchaikov commented Feb 4, 2024 •

Copy link
Copy Markdown
Contributor Author

@yuriw
yuriw merged commit d74e98d into ceph:main Feb 20, 2024
@mcv21

mcv21 commented Feb 20, 2024

Copy link
Copy Markdown
Contributor

@tchaikov thanks for working on this; are you OK to backport it to reef, please? :)
[I mean if not I can probably open a MR myself, but...]

@tchaikov

tchaikov commented Feb 20, 2024 •

Copy link
Copy Markdown
Contributor Author

@tchaikov thanks for working on this; are you OK to backport it to reef, please? :) [I mean if not I can probably open a MR myself, but...]

@mcv21 Hi Mathew, would be great if you could help on this. i am tied up with my daytime job recently.

@tchaikov
tchaikov deleted the debian/postinst branch February 20, 2024 16:43
@mcv21

mcv21 commented Feb 20, 2024

Copy link
Copy Markdown
Contributor

@tchaikov thanks for working on this; are you OK to backport it to reef, please? :) [I mean if not I can probably open a MR myself, but...]

@mcv21 Hi Mathew, would be great if you could help on this. i am tied up with my daytime job recently.

I will endeavour to, but can you set the tracker task to state: pending backport please? the ceph-backport.sh script won't run at the moment because the tracker task isn't in that state (and I don't have enough redmine permissions to do it myself).

@tchaikov

Copy link
Copy Markdown
Contributor Author

@mcv21 changed. thanks in advance!

@mcv21

mcv21 commented Feb 20, 2024

Copy link
Copy Markdown
Contributor

@tchaikov sorry, the backport tasks are assigned to you, so ceph-backport.sh won't continue. Can you assign them to me (or maybe just unassigning them to yourself is sufficient)?

@jhrcz-ls

Copy link
Copy Markdown
Contributor

i would like to warn before using hardcoded /home/cephadm as home for cephadm user... because in debian distro package ceph (a way to get 16.2 on debian bookworm) uses /var/lib/cephadm and when upgrading from debian package to ceph-io package this causes problems. (good thing is that other issue, the different behaviour of adduser on deb bookworm is fixed with this PR). i'm not sure that clean transition from debians package to ceph-io package is something to expect.

i filled issue in tracker (https://tracker.ceph.com/issues/64488) but later found issue related to this PR (https://tracker.ceph.com/issues/64069)

@mcv21

mcv21 commented Feb 22, 2024

Copy link
Copy Markdown
Contributor

I'd like to bring the Debian packaging in ceph-upstream and ceph-Debian (if you see what I mean) closer together; but I think fixing this bug is not the place to change where ceph-upstream sets the cephadm user's $HOME to be.

@mcv21

mcv21 commented Feb 22, 2024

Copy link
Copy Markdown
Contributor

@tchaikov sorry, the backport tasks are assigned to you, so ceph-backport.sh won't continue. Can you assign them to me (or maybe just unassigning them to yourself is sufficient)?

NVM, I found the --force option :)

@tchaikov

Copy link
Copy Markdown
Contributor Author

i would like to warn before using hardcoded /home/cephadm as home for cephadm user... because in debian distro package ceph (a way to get 16.2 on debian bookworm) uses /var/lib/cephadm and when upgrading from debian package to ceph-io package this causes problems. (good thing is that other issue, the different behaviour of adduser on deb bookworm is fixed with this PR). i'm not sure that clean transition from debians package to ceph-io package is something to expect.

i filled issue in tracker (https://tracker.ceph.com/issues/64488) but later found issue related to this PR (https://tracker.ceph.com/issues/64069)

@jhrcz-ls hi Jan, thanks for filing this issue. i think we'd need a separate PR to address it.

@cbodley

cbodley commented Jul 10, 2025

Copy link
Copy Markdown
Contributor

@tchaikov @adk3798 sorry to revive an old pr, but i think this is related to a failure i'm seeing trying to install ceph packages on ubuntu 24.04 in teuthology:

Adding system user cephadm....done
usermod: unlocking the user's password would result in a passwordless account.
You should set a password with usermod -p to unlock this user's password.
mkdir: cannot create directory '/nonexistent/.ssh': No such file or directory
dpkg: error processing package cephadm (--configure):
 installed cephadm package post-installation script subprocess returned error exit status 1

any idea why it's trying to mkdir /nonexistent/.ssh? tracking in https://tracker.ceph.com/issues/72083

@mcv21

mcv21 commented Jul 11, 2025

Copy link
Copy Markdown
Contributor

@cbodley I'm pleased to see Debian-based distros making their way into teuthology :)

I think we might want to make the different postinsts easier to tell apart (e.g. that "Adding system user cephadm....done" could come from either), but my best theory here is that it's running ceph-common.postinst not cephadm.postinst (which is wrong for the cephadm package), because the ceph-common postinst sets home to $SERVER_HOME (which I'm guessing ends up being /nonexistent/) and then something is trying to write to ~.

Can you get a shell on the failing system? I think you could then inspect /var/lib/dpkg/info/cephadm.postinst and also how the cephadm user has been set up...

@cbodley

cbodley commented Jul 11, 2025

Copy link
Copy Markdown
Contributor

thanks @mcv21,

I'm pleased to see Debian-based distros making their way into teuthology :)

we've always tested against ubuntu there. we're just very late in adopting 24.04

Can you get a shell on the failing system? I think you could then inspect /var/lib/dpkg/info/cephadm.postinst and also how the cephadm user has been set up...

possible but tricky to keep the machine around after failure. after a test job, they get reimaged for the next one. i'm guessing it will be easier to test the package installation manually using the same repo?

https://4.chacra.ceph.com/r/ceph/wip-72020/fd5963bfafc2d7f3637520a540509de807dc4450/ubuntu/noble/flavors/default/

@cbodley

cbodley commented Jul 11, 2025 •

Copy link
Copy Markdown
Contributor

Can you get a shell on the failing system? I think you could then inspect /var/lib/dpkg/info/cephadm.postinst and also how the cephadm user has been set up...

i guess /nonexistent is coming from /etc/passwd:

cephadm:x:122:65534:cephadm user for mgr/cephadm:/nonexistent:/bin/bash

on ubuntu 22, it looks like this:

cephadm:x:130:65534:cephadm user for mgr/cephadm:/home/cephadm:/bin/bash

@cbodley

cbodley commented Jul 11, 2025

Copy link
Copy Markdown
Contributor

comparing jammy's https://manpages.ubuntu.com/manpages/jammy/man8/adduser.8.html with noble's https://manpages.ubuntu.com/manpages/noble/man8/adduser.8.html, i see that a new paragraph was added under "Add a system user":

If no home directory is specified, the default home directory for a new system user is /nonexistent. This directory should never exist on any Debian system, and adduser will never create it automatically.

@cbodley

cbodley commented Jul 11, 2025

Copy link
Copy Markdown
Contributor

testing #64459 to fix

@tchaikov

tchaikov commented Jul 11, 2025 •

Copy link
Copy Markdown
Contributor Author

@cbodley Thanks for pinging me. I'll take a look at this issue over the weekend if no one else picks it up before then.

EDIT. seems you beat me to it =)

@cbodley

cbodley commented Jul 11, 2025

Copy link
Copy Markdown
Contributor

i see that this pr did correctly add --home /home/cephadm, but a later pr #62507 removed it

@mcv21

mcv21 commented Jul 11, 2025

Copy link
Copy Markdown
Contributor

i see that this pr did correctly add --home /home/cephadm, but a later pr #62507 removed it

Ah, yes, that would explain it :-/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants