mosquitto icon indicating copy to clipboard operation
mosquitto copied to clipboard

log: show process user in console

Open atifali opened this issue 7 months ago • 3 comments

Thank you for contributing your time to the Mosquitto project!

Before you go any further, please note that we cannot accept contributions if you haven't signed the Eclipse Contributor Agreement. If you aren't able to do that, or just don't want to, please describe your bug fix/feature change in an issue. For simple bug fixes it is can be just as easy for us to be told about the problem and then go fix it directly.

Then please check the following list of things we ask for in your pull request:

  • [x] Have you signed the Eclipse Contributor Agreement, using the same email address as you used in your commits?
  • [x] Do each of your commits have a "Signed-off-by" line, with the correct email address? Use "git commit -s" to generate this line for you.
  • [x] If you are contributing a new feature, is your work based off the develop branch?
  • [x] If you are contributing a bugfix, is your work based off the fixes branch?
  • [x] Have you added an explanation of what your changes do and why you'd like us to include them?
  • [x] Have you successfully run make test with your changes locally?

This is a simple addition to the mosquitto binary to be able to show the user that the process is being run under since there are places where the user privileges are being changed depending on what the mosquitto process is ran under. This makes debugging easier by showing the current process user name in the log. If its an unknown user the program aborts.

atifali avatar Jun 07 '25 05:06 atifali

why would having an unknown uid -> username be a fatal error? can't it just print the id instead?

Daedaluz avatar Jun 07 '25 05:06 Daedaluz

@Daedaluz doesn't a username of unknown mean something is not quite right with the configuration of the user? In which case we would want that fixed before that config is used to run mosquitto. I could be wrong here though! @ralight thoughts on this?

atifali avatar Jun 07 '25 18:06 atifali

perhaps the usecase is narrow, but I think there are some cases where the user / group / privileges are set before the software starts in some container environment configs.

to clarify what i meant; it doesn't have to only print the id, it could fall back to just print the id if the user isn't found.

Daedaluz avatar Jun 08 '25 04:06 Daedaluz

@atifall I think this is a good idea to include, thank you. I do agree with @Daedaluz though, there isn't a hard requirement for there to be a username mapped to a uid. In that case it would be fine to print the uid instead.

ralight avatar Jul 08 '25 08:07 ralight

@ralight I believe this should be good to merge now. Let me know if there are any other changes needed here.

atifali avatar Jul 13 '25 03:07 atifali

Codecov Report

:x: Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/mosquitto.c 75.00% 2 Missing :warning:
Files with missing lines Coverage Δ
src/mosquitto.c 50.60% <75.00%> (+0.81%) :arrow_up:
:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Aug 04 '25 18:08 codecov[bot]

Thank you. It still required a fix for Windows, but I've done that. I've merged it in https://github.com/eclipse-mosquitto/mosquitto/commit/9f1e876d0eaa2d209ae7092d7822c3f36c1dc528, but github hasn't picked it up here for some reason. I'll have to close it manually. Thanks again!

ralight avatar Aug 07 '25 16:08 ralight