Skip to content

Fixes support for syslog when salt is running as non-root user - #68890

Open
shadow38 wants to merge 5 commits into
saltstack:3008.xfrom
shadow38:syslog-support-3006
Open

shadow38 wants to merge 5 commits into
saltstack:3008.xfrom
shadow38:syslog-support-3006

Conversation

@shadow38

@shadow38 shadow38 commented Apr 3, 2026

Copy link
Copy Markdown

What does this PR do?

Adds support for file:// scheme in syslog handler configuration.

What issues does this PR fix or reference?

Closes #68801 (previous PR targeting master, reopened for 3006.x as requested by @dwoz)

Previous Commits

Cherry-picked from previous PR #68801 and rebased onto 3006.x

@shadow38
shadow38 requested a review from a team as a code owner April 3, 2026 12:39
@welcome

welcome Bot commented Apr 3, 2026

Copy link
Copy Markdown

Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here's some information that may help as you continue your Salt journey.
Please be sure to review our Code of Conduct. Also, check out some of our community resources including:

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at [email protected]. We're glad you've joined our community and look forward to doing awesome things with you!

@dwoz

dwoz commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

@shadow38 please open an issue. Add a changelog for it and make sure we have test coverage.


parsed_log_path = urlparse(path)

if parsed_log_path.scheme in ("tcp", "udp", "file"):

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.

Should unix:// also be supported?

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.

I see that this is probably based on the documentation at https://docs.saltproject.io/en/latest/ref/configuration/logging/index.html#std-conf_log-log_file which does not include unix://. It seems like unix should also be supported but probably out of scope of this if it doesn't just work by adding it here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The is_syslog_path function is an extract of the syslog path parser from saltstack core source code. If is massively based on the setup_logfile_handler function. I didn't revalidate the whole parsing assuming that the parsing was already correct.

Comment thread salt/utils/parsers.py
)

if not is_writeable(logfile, check_parent=True):
if not is_syslog_path(logfile) and not is_writeable(logfile, check_parent=True):

@bdrx312 bdrx312 Apr 8, 2026 •

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.

The docstring of is_syslog_path says log-facility is optional but returns False if the prefix is tcp:///udp:// and the log-facility is not provided. In general I don't think we care that the file is specifically a "syslog" path. It seems like we should allow writing to any log specified with file://,tcp://,udp:// which would be more robust.

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.

According the last example in the documentation at https://docs.saltproject.io/en/latest/ref/configuration/logging/index.html#std-conf_log-log_file log_file: udp://loghost:10514 should also be supported and work.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The docstring of is_syslog_path says log-facility is optional but returns False if the prefix is tcp:///udp:// and the log-facility is not provided. In general I don't think we care that the file is specifically a "syslog" path. It seems like we should allow writing to any log specified with file://,tcp://,udp:// which would be more robust.

If you think that checking that path starts with file, tcp or udp is correct, I can change my PR. Your proposal is the same as the initial PR related to this bug : https://github.com/saltstack/salt/pull/62263/changes . I just thought that parsing the syslog path was a "cleaner" way to manage this bug.

@shadow38 shadow38 Apr 14, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

According the last example in the documentation at https://docs.saltproject.io/en/latest/ref/configuration/logging/index.html#std-conf_log-log_file log_file: udp://loghost:10514 should also be supported and work.

I just performed some tests and udp://loghost:10514 is correctly parsed as a valid syslog path in the is_syslog_path function. I'll try to add some pytest in this PR

@jendyai

jendyai commented Sep 15, 2026

Copy link
Copy Markdown

This PR also needs to cover salt-api and explicitly configured api_logfile.

salt.config.api_config() currently passes api_logfile and the copied log_file directly to prepend_root_dir():
prepend_root_dir(opts, ["api_pidfile", "api_logfile", "log_file", "pidfile"])

Consequently:
file:///var/run/log/LOG_LOCAL6

becomes:
/file:/var/run/log/LOG_LOCAL6

before LogLevelMixIn.__setup_logfile_logger_config() is called.

This was reproduced on FreeBSD with salt-api. The malformed value is then passed to verify_log_files(), which attempts to create /file: and fails on a read-only root filesystem.

I suggest:

  1. Use the existing should_prepend_root_dir() helper for api_logfile and the corresponding log_file in api_config().
  2. Skip verify_log_files() when is_syslog_path(logfile) is true.
  3. Add an api_config() regression test asserting that file://, udp://, and tcp:// values remain unchanged.

The later is_writeable() guard added by this PR is still necessary, but on its own it does not cover the salt-api path.

@twangboy

twangboy commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

We are no longer accepting bug fixes on the 3006.x branch. Please rebase against the 3008.x branch.

@dwoz
dwoz changed the base branch from 3006.x to 3008.x October 22, 2026 00:14
@dwoz
dwoz force-pushed the syslog-support-3006 branch from 485d14a to d89b39a Compare October 22, 2026 00:15
@twangboy twangboy modified the milestones: Argon v3008.5, Argon v3008.7 Oct 30, 2026

This branch was previously deployed

1 inactive deployment
ci — d89b39ad Deployed Oct 31, 2026 by dwoz via Build Onedir Packages / DEB (arm64) #27723
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants