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]: passing a password with a "&" break --unattended install #4787

Closed
1 of 4 tasks
JJKW1984 opened this issue May 7, 2024 · 4 comments
Closed
1 of 4 tasks

[BUG]: passing a password with a "&" break --unattended install #4787

JJKW1984 opened this issue May 7, 2024 · 4 comments

Comments

@JJKW1984
Copy link

JJKW1984 commented May 7, 2024

What happened?

When creating a unattended install script we are unable to pass any password with a "&" starting it.

.\config.cmd --unattended --agent 'agent1' --pool 'build pool' --url 'https://dev.azure.com/testorg' --auth 'PAT' --token 'token' --runAsService --windowsLogonAccount 'US\ADO' --windowsLogonPassword '$password'

We have tried escaping the password and passing it in as a variable but the command misinterpreted as two commands.

ErrorWithPassword

Versions

Windows 2022 / 3.328.0

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

No response

Version controll system

No response

Relevant log output

[2024-05-07 16:10:30Z INFO AgentProcess] Agent package win-x64.
[2024-05-07 16:10:30Z INFO AgentProcess] Running on Windows (X64).
[2024-05-07 16:10:30Z INFO AgentProcess] RuntimeInformation: Microsoft Windows 10.0.19045.
[2024-05-07 16:10:30Z INFO AgentProcess] Version: 3.238.0
[2024-05-07 16:10:30Z INFO AgentProcess] Commit: da4a9e997b7f4c8939ef934a21070524b5ec664c
[2024-05-07 16:10:30Z INFO AgentProcess] Culture: en-US
[2024-05-07 16:10:30Z INFO AgentProcess] UI Culture: en-US
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Bin': 'C:\agent\bin'
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Root': 'C:\agent'
[2024-05-07 16:10:30Z INFO AgentProcess] Validating directory permissions for: 'C:\agent'
[2024-05-07 16:10:30Z INFO PowerShellExeUtil] Generation: '1'
[2024-05-07 16:10:30Z INFO PowerShellExeUtil] Key name 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine', value name 'PowerShellVersion' is null.
[2024-05-07 16:10:30Z INFO PowerShellExeUtil] Unable to determine the Powershell engine version.  Possibly Powershell is not installed.
[2024-05-07 16:10:30Z INFO PowerShellExeUtil] Generation: '3'
[2024-05-07 16:10:30Z INFO PowerShellExeUtil] Key name 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine', value name 'PowerShellVersion': '5.1.19041.1'
[2024-05-07 16:10:30Z INFO PowerShellExeUtil] Key name 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine', value name 'ApplicationBase': 'C:\Windows\System32\WindowsPowerShell\v1.0'
[2024-05-07 16:10:30Z INFO AgentProcess] Key name 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework', value name 'InstallRoot': 'C:\Windows\Microsoft.NET\Framework64\'
[2024-05-07 16:10:30Z INFO AgentProcess] Key name 'SOFTWARE\Microsoft\NET Framework Setup\NDP' contains sub keys:
[2024-05-07 16:10:30Z INFO AgentProcess]  'CDF'
[2024-05-07 16:10:30Z INFO AgentProcess]  'v4'
[2024-05-07 16:10:30Z INFO AgentProcess]  'v4.0'
[2024-05-07 16:10:30Z INFO AgentProcess] Key name 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4', value name 'Version' is null.
[2024-05-07 16:10:30Z INFO AgentProcess] Key name 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4', value name '' is null.
[2024-05-07 16:10:30Z INFO AgentProcess] Key name 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4' contains sub keys:
[2024-05-07 16:10:30Z INFO AgentProcess]  'Client'
[2024-05-07 16:10:30Z INFO AgentProcess]  'Full'
[2024-05-07 16:10:30Z INFO AgentProcess] Key name 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client', value name 'Version': '4.8.04084'
[2024-05-07 16:10:30Z INFO AgentProcess] Key name 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client', value name 'Install': '1'
[2024-05-07 16:10:30Z INFO AgentProcess] Key name 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client', value name 'InstallPath': 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\'
[2024-05-07 16:10:30Z INFO AgentProcess] Key name 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Client', value name 'Release': '528372'
[2024-05-07 16:10:30Z INFO AgentProcess] Type is System.Int32
[2024-05-07 16:10:30Z INFO AgentProcess] Interpreted version: 4.7.0
[2024-05-07 16:10:30Z INFO AgentProcess] Key name 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', value name 'Version': '4.8.04084'
[2024-05-07 16:10:30Z INFO AgentProcess] Key name 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', value name 'Install': '1'
[2024-05-07 16:10:30Z INFO AgentProcess] Key name 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', value name 'InstallPath': 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\'
[2024-05-07 16:10:30Z INFO AgentProcess] Key name 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full', value name 'Release': '528372'
[2024-05-07 16:10:30Z INFO AgentProcess] Type is System.Int32
[2024-05-07 16:10:30Z INFO AgentProcess] Interpreted version: 4.7.0
[2024-05-07 16:10:30Z INFO AgentProcess] Key name 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4.0', value name 'Version' is null.
[2024-05-07 16:10:30Z INFO AgentProcess] Key name 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4.0', value name '': 'deprecated'
[2024-05-07 16:10:30Z INFO AgentProcess] Found 2 versions:
[2024-05-07 16:10:30Z INFO AgentProcess]  4.7.0
[2024-05-07 16:10:30Z INFO AgentProcess]  4.7.0
[2024-05-07 16:10:30Z INFO AgentProcess] Testing for min NET Framework version: '4.5'
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Bin': 'C:\agent\bin'
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Root': 'C:\agent'
[2024-05-07 16:10:30Z INFO AgentProcess] Arguments parsed
[2024-05-07 16:10:30Z ERR  Terminal] WRITE ERROR: An error occurred: MissingValueOptionError
[2024-05-07 16:10:30Z ERR  Terminal] WRITE ERROR: Unrecognized command-line input arguments: ''. For usage refer to: .\config.cmd --help or ./config.sh --help
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Bin': 'C:\agent\bin'
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Root': 'C:\agent'
[2024-05-07 16:10:30Z INFO HostContext] Well known config file 'Proxy': 'C:\agent\.proxy'
[2024-05-07 16:10:30Z INFO VstsAgentWebProxy] No proxy setting found.
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Bin': 'C:\agent\bin'
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Root': 'C:\agent'
[2024-05-07 16:10:30Z INFO HostContext] Well known config file 'Certificates': 'C:\agent\.certificates'
[2024-05-07 16:10:30Z INFO AgentCertificateManager] No certificate setting found.
[2024-05-07 16:10:30Z INFO Agent] ExecuteCommand
[2024-05-07 16:10:30Z INFO ConfigurationStore] currentAssemblyLocation: C:\agent\bin\Agent.Listener.dll
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Bin': 'C:\agent\bin'
[2024-05-07 16:10:30Z INFO ConfigurationStore] binPath: C:\agent\bin
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Bin': 'C:\agent\bin'
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Root': 'C:\agent'
[2024-05-07 16:10:30Z INFO ConfigurationStore] RootFolder: C:\agent
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Bin': 'C:\agent\bin'
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Root': 'C:\agent'
[2024-05-07 16:10:30Z INFO HostContext] Well known config file 'Agent': 'C:\agent\.agent'
[2024-05-07 16:10:30Z INFO ConfigurationStore] ConfigFilePath: C:\agent\.agent
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Bin': 'C:\agent\bin'
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Root': 'C:\agent'
[2024-05-07 16:10:30Z INFO HostContext] Well known config file 'Credentials': 'C:\agent\.credentials'
[2024-05-07 16:10:30Z INFO ConfigurationStore] CredFilePath: C:\agent\.credentials
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Bin': 'C:\agent\bin'
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Root': 'C:\agent'
[2024-05-07 16:10:30Z INFO HostContext] Well known config file 'Service': 'C:\agent\.service'
[2024-05-07 16:10:30Z INFO ConfigurationStore] ServiceConfigFilePath: C:\agent\.service
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Bin': 'C:\agent\bin'
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Root': 'C:\agent'
[2024-05-07 16:10:30Z INFO HostContext] Well known config file 'Autologon': 'C:\agent\.autologon'
[2024-05-07 16:10:30Z INFO ConfigurationStore] AutoLogonSettingsFilePath: C:\agent\.autologon
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Bin': 'C:\agent\bin'
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Root': 'C:\agent'
[2024-05-07 16:10:30Z INFO HostContext] Well known config file 'Options': 'C:\agent\.options'
[2024-05-07 16:10:30Z INFO ConfigurationStore] RuntimeOptionsFilePath: C:\agent\.options
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Bin': 'C:\agent\bin'
[2024-05-07 16:10:30Z INFO HostContext] Well known directory 'Root': 'C:\agent'
[2024-05-07 16:10:30Z INFO HostContext] Well known config file 'SetupInfo': 'C:\agent\.setup_info'
[2024-05-07 16:10:30Z INFO ConfigurationStore] SetupInfoFilePath: C:\agent\.setup_info
[2024-05-07 16:10:30Z INFO ConfigurationManager] LoadSettings
[2024-05-07 16:10:30Z INFO ConfigurationStore] IsConfigured()
[2024-05-07 16:10:30Z INFO ConfigurationStore] IsConfigured: False
[2024-05-07 16:10:30Z INFO ConfigurationManager] Is configured: False
[2024-05-07 16:10:30Z ERR  Terminal] WRITE ERROR: An error occurred: Not configured
[2024-05-07 16:10:30Z ERR  AgentProcess] System.InvalidOperationException: Not configured
   at Microsoft.VisualStudio.Services.Agent.Listener.Configuration.ConfigurationManager.LoadSettings() in D:\a\_work\1\s\src\Agent.Listener\Configuration\ConfigurationManager.cs:line 68
   at Microsoft.VisualStudio.Services.Agent.Listener.Agent.ExecuteCommand(CommandSettings command) in D:\a\_work\1\s\src\Agent.Listener\Agent.cs:line 175
   at Microsoft.VisualStudio.Services.Agent.Listener.Program.MainAsync(IHostContext context, String[] args) in D:\a\_work\1\s\src\Agent.Listener\Program.cs:line 163
@ivanduplenskikh
Copy link
Contributor

Hi @JJKW1984 thanks for reporting! We are working on more prioritized issues at the moment, but will get back to this one soon.

@itsme112358
Copy link

This is not just & character, this happens with lots of special characters. The way config.cmd passes the password is "not very good".
The only safe characters we found so far are _ and -.
Now there seems to be another issue with passing parameters in general, we also pass tags. The following example results

.\config.cmd --unattended --url https://dev.azure.com/AareonRelionGmbH --auth pat --token xxx --projectName "xxx" --agent "xxx" --windowsLog
onAccount "xxx" --windowsLogonPassword 'xxx' --runAsService --deploymentGroup --deploymentGroupName "xxx" --addDeploymentGroupTags --deploymentGroupTags 'Serverinstance, Secondary, Production, Host'

Results in a registered Agent (in Azure DevOps) with only one tag 'Serverinstance - mind the leading tick. The remaining tags are ignored.
I'm disappointed that basic stuff like passing parameters isn't handled correctly - that's really, really, really stuff you should know how to do as a developer.
And now using the same script which was working ~4 weeks ago, the agent service cannot be registered with the error Invalid windows credentials entered..
So at the very least please stop breaking stuff and/or document how we are supposed to pass params correctly.

@ChristopherHX
Copy link

ChristopherHX commented May 31, 2024

the config.cmd is pretty old https://github.com/microsoft/azure-pipelines-agent/blob/master/src/Misc/layoutroot/config.cmd (ca. 5 years not touched)
I don't think someone here broke any stuff here that worked 1 year ago, maybe your script parameter did change and you run into this or the account has password has changed

I usually call the exe directly .\bin\Agent.Listener.exe configure instead of .\config.cmd that could save headache trying to deal with the wrapper script as someone not involved into this application

Copy link

This issue has had no activity in 180 days. Please comment if it is not actually stale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants