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

Exec[update_pgpass] failed #830

Closed
src386 opened this issue Aug 3, 2022 · 1 comment · Fixed by #904
Closed

Exec[update_pgpass] failed #830

src386 opened this issue Aug 3, 2022 · 1 comment · Fixed by #904

Comments

@src386
Copy link

src386 commented Aug 3, 2022

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 6.27.1-1focal
  • Ruby: 2.5.9p229
  • Distribution: Ubuntu 20.04
  • Module version: master (currently v9.2.0)

How to reproduce (e.g Puppet code you use)

Use Postgresql and set a custom password with special characters such as &.

class { 'apache':
    mpm_module => 'prefork',
  }
  class { 'apache::mod::php': }
  class { 'postgresql::server': }
  class { 'zabbix':
    zabbix_url        => 'zabbix.example.com',
    database_password => 'secret&password',
  }

What are you seeing

Error: sh: 1: password: not found
localhost:5432:zabbix_server:zabbix_server:secret

Error: /Stage[main]/Zabbix::Database::Postgresql/Exec[update_pgpass]/returns: change from 'notrun' to ['0'] failed: sh: 1: password: not found
localhost:5432:zabbix_server:zabbix_server:secret

What behaviour did you expect instead

Notice: /Stage[main]/Zabbix::Database::Postgresql/Exec[update_pgpass]/returns: executed successfully

Output log

Any additional information you'd like to impart

The Exec[update_pgpass] is defined here: https://github.com/voxpupuli/puppet-zabbix/blob/master/manifests/database/postgresql.pp#L67

command => "echo ${database_host}:5432:${database_name}:${database_user}:${database_password} >> /root/.pgpass",

As we can see, the echoed string is not protected/escaped, resulting in some characters breaking the command.

Workaround:

command => "echo \"${database_host}:5432:${database_name}:${database_user}:${database_password}\" >> /root/.pgpass",

It is interesting to note that the unless => argument was already protected/escaped.

@src386
Copy link
Author

src386 commented Aug 3, 2022

#831

@ekohl ekohl linked a pull request Nov 7, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant