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

win_service quotes in path to handle spaces #32368

Closed
valerius257 opened this issue Oct 31, 2017 · 7 comments · Fixed by #32469
Closed

win_service quotes in path to handle spaces #32368

valerius257 opened this issue Oct 31, 2017 · 7 comments · Fixed by #32469
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team. windows Windows community

Comments

@valerius257
Copy link

ISSUE TYPE
  • Bug Report
COMPONENT NAME

win_service

ANSIBLE VERSION
ansible 2.4.0.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /bin/ansible
  python version = 2.7.5 (default, Aug  4 2017, 00:39:18) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
CONFIGURATION
DEFAULT_ROLES_PATH(/etc/ansible/ansible.cfg) = [u'/etc/ansible/roles', u'/usr/share/ansible/roles']
PERSISTENT_CONNECT_TIMEOUT(/etc/ansible/ansible.cfg) = 30
OS / ENVIRONMENT

Ansible Host: CentOS 7
Managing: Windows 2012 R2

SUMMARY

win_service fails to create service when quoted path which is needed to handle spaces in path.

STEPS TO REPRODUCE
- name: create jenkins slave service
  win_service:
   name: jenkins-slave
   display_name: Jenkins Slave
   start_mode: auto
   path: '"C:\Jenkins Slave\jenkins-slave.exe"'
EXPECTED RESULTS

windows service created with path being in quotes

ACTUAL RESULTS

win_service failed to create service

fatal: [host]: FAILED! => {
    "changed": false,
    "failed": true,
    "msg": "Get-AnsibleParam: Parameter 'path' has an invalid path '\"C:\\Jenkins Slave\\jenkins-slave.exe\"' specified."
}
@ansibot
Copy link
Contributor

ansibot commented Oct 31, 2017

@ansibot ansibot added affects_2.4 This issue/PR affects Ansible v2.4 bug_report module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. windows Windows community labels Oct 31, 2017
@jborean93
Copy link
Contributor

Do you need to quote the path? I've got plenty of local services where the Path to executable is in C:\Program Files\* and they are not quoted.

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Oct 31, 2017
@valerius257
Copy link
Author

In this particular case quotes are not needed but this may be needed when additional parameters are passed to the service or parameters itself should be in quotes.
For example Microsoft Policy Platform Local Authority service have the following path "C:\Program Files\Microsoft Policy Platform\policyHost.exe" /service

@dssdss
Copy link

dssdss commented Oct 31, 2017

I have the same issue when I try to deploy Zabbix Agent service with the command line: "C:\Program Files\zabbix\zabbix_agentd.exe" --config "C:\Program Files\zabbix\zabbix_agentd.conf".

It is standard for Windows to use quotas, while using long folder of filenames in the path.

For example path to executable for the regular Microsoft service - MSSQLSERVER:
"E:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Binn\sqlservr.exe" -sMSSQLSERVER

Its a bug with quotes in win_service, please fix it!!!

@jborean93
Copy link
Contributor

Thanks for the info @valerius257 and @dssdss. I suppose it is also a security risk as someone could create a malicious exe at C:\Program.exe and Windows will execute that per their process argument rules.

I've raised a PR to fix this here #32469 so if you can check it out we can merge it in hopefully before 2.4.2 is out.

The issue is from a change in 2.4 where parameters with a type of path were actually validated as a valid path which when quotes are used makes it invalid. I've fixed it up and added integration tests so it should be working.

@jborean93 jborean93 added this to Nice to have in 2.4.x Blocker List Nov 1, 2017
@dssdss
Copy link

dssdss commented Nov 2, 2017

Now, it works! Thank you very much.

@jborean93
Copy link
Contributor

Fixed has been merged to devel and cherry-picked to stable-2.4 with e771b64. Will be released under 2.4.2 beta 3

@jborean93 jborean93 moved this from Nice to have to Done in 2.4.2 in 2.4.x Blocker List Nov 3, 2017
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.4 This issue/PR affects Ansible v2.4 bug This issue/PR relates to a bug. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team. windows Windows community
Projects
No open projects
2.4.x Blocker List
Done in 2.4.2
Development

Successfully merging a pull request may close this issue.

4 participants