Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] mount.fstab_present state should escape spaces and tabs #66907

Open
scy opened this issue Sep 19, 2024 · 3 comments
Open

[BUG] mount.fstab_present state should escape spaces and tabs #66907

scy opened this issue Sep 19, 2024 · 3 comments
Labels
Bug broken, incorrect, or confusing behavior needs-triage

Comments

@scy
Copy link

scy commented Sep 19, 2024

Description
If the source (name) or destination (fs_file) of an fstab entry generated by mount.fstab_present contains spaces or tabs, these need to be replaced by \040 and \011, respectively, when writing to /etc/fstab, else the line cannot be parsed. I think the same applies to mount options (fs_mntops) as well.

Setup

  • on-prem machine (my laptop)
  • onedir packaging
  • masterless
  • installed from https://repo.saltproject.io/salt/py3/debian/12/amd64/latest

Steps to Reproduce the behavior

example:
  mount.fstab_present:
    - name: /dev/sda1
    - fs_file: /tmp/some directory with spaces
    - 
    - mount: true

Expected behavior
The fstab entry should start like this:

/dev/sda1    /tmp/some\040directory\040with\040spaces    …

Actual behavior
Salt places the spaces verbatim in the file.

It is possible to manually use the correct escapes in the YAML, but then mount: true won't work either, because it tries to find a mount point with the escape codes: Error while mounting /tmp/some\040directory\040with\040spaces: can't find in /etc/fstab.

Versions Report

salt-call --versions-report
Salt Version:
          Salt: 3007.1
 
Python Version:
        Python: 3.10.14 (main, Apr  3 2024, 21:30:09) [GCC 11.2.0]
 
Dependency Versions:
          cffi: 1.16.0
      cherrypy: 18.8.0
      dateutil: 2.8.2
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.4
       libgit2: Not Installed
  looseversion: 1.3.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.7
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 23.1
     pycparser: 2.21
      pycrypto: Not Installed
  pycryptodome: 3.19.1
        pygit2: Not Installed
  python-gnupg: 0.5.2
        PyYAML: 6.0.1
         PyZMQ: 25.1.2
        relenv: 0.16.0
         smmap: Not Installed
       timelib: 0.3.0
       Tornado: 6.3.3
           ZMQ: 4.3.4
 
Salt Package Information:
  Package Type: onedir
 
System Versions:
          dist: debian 12.7 bookworm
        locale: utf-8
       machine: x86_64
       release: 6.1.0-25-amd64
        system: Linux
       version: Debian GNU/Linux 12.7 bookworm
@scy scy added Bug broken, incorrect, or confusing behavior needs-triage labels Sep 19, 2024
Copy link

welcome bot commented Sep 19, 2024

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!

@bdrx312
Copy link
Contributor

bdrx312 commented Sep 20, 2024

Backslashes and newlines should also be escaped.

@OrangeDog
Copy link
Contributor

Backslashes and newlines should also be escaped.

Unfortunately, that makes it a breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior needs-triage
Projects
None yet
Development

No branches or pull requests

3 participants