Skip to content

Commit

Permalink
Escape also double quotation marks
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikBengtsson committed Oct 10, 2023
1 parent 271f07b commit 0fad9c6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
10 changes: 5 additions & 5 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

* Authentication methods `--auto=auth-via-su` (default) and
`--auto=auth-via-ssh` did not handle passwords starting with a
hyphen (`-`) or that contained one or more dollar signs (`$`), if
and only if, the `expect` command was installed on the system. A
user who entered such as password in the 'Sign in to RStudio' panel
would always get an `Invalid authentication (incorrect password)`
error.
hyphen (`-`), or that contained one or more dollar signs (`$`) or
double quotation marks (`"`), if and only if, the `expect` command
was installed on the system. A user who entered such as password
in the 'Sign in to RStudio' panel would always get an `Invalid
authentication (incorrect password)` error.


## Version 0.13.9 [2023-10-09]
Expand Down
3 changes: 3 additions & 0 deletions bin/utils/auth-via-ssh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ IFS='' read -r password
# Escape all dollar symbols ('$')
password="${password//\$/\\$}"

# Escape double quotation marks ('"')
password="${password//\"/\\\"}"

command expect <<EOF
eval spawn ssh -o PreferredAuthentications=password -o NumberOfPasswordPrompts=1 -l "$USER" "${RSC_AUTH_SSH_HOST}" "echo true"
expect "password"
Expand Down
3 changes: 3 additions & 0 deletions bin/utils/auth-via-su
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ if command -v expect &> /dev/null; then

# Escape all dollar symbols ('$')
password="${password//\$/\\$}"

# Escape double quotation marks ('"')
password="${password//\"/\\\"}"

## WORKAROUND: Not all 'su' versions support being called
## from within a script. Because of this, we use expect'
Expand Down

0 comments on commit 0fad9c6

Please sign in to comment.