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

easyrsa: 319: set: Illegal option -o echo #308

Closed
HarmtH opened this issue May 10, 2019 · 19 comments · Fixed by #315
Closed

easyrsa: 319: set: Illegal option -o echo #308

HarmtH opened this issue May 10, 2019 · 19 comments · Fixed by #315

Comments

@HarmtH
Copy link

HarmtH commented May 10, 2019

I'm running easy-rsa without a terminal and therefore the stty calls in the script fail.

As fallback set +o echo and set -e echo are used, but these settings don't seem to exist, at least not in zsh, bash or dash.

@TinCanTech
Copy link
Collaborator

How do you run easyrsa3 without a terminal ?

@HarmtH
Copy link
Author

HarmtH commented May 13, 2019

ssh -T or cronjobs for example.

@ecrist
Copy link
Member

ecrist commented May 13, 2019

This is a pretty easy fix. I'll work on getting it in over the next couple days.

Just need to wrap hide_read_pass with test -t I think. Need to do some testing.

@merlin-tc
Copy link

merlin-tc commented May 16, 2019

I think I am hitting the same bug. I am using easyrsa in combination with an ansible playbook.
I just commented the offending part of line 320 for now.

(stty echo 2>/dev/null) # || set -o echo

@ecrist
Copy link
Member

ecrist commented May 17, 2019

Can @HarmtH or @merlin-tc try this in your use cases?

Replace/modify the hide_read_pass() function to look like the following:

hide_read_pass()
{
        # if we're not a tty, these will fail
        if [ -t 1 ];
        then
                (stty -echo 2>/dev/null) || set +o echo
                read -r "$@"
                (stty echo 2>/dev/null) || set -o echo
        else
                read -r "$@"
        fi
} # => hide_read_pass()

@HarmtH
Copy link
Author

HarmtH commented May 17, 2019

I've actually hit this https://github.com/OpenVPN/easy-rsa/blob/master/easyrsa3/easyrsa#L320 instance of set -o echo. Can you update it there as well?

I think this fix will work, but this will only fix the problem when stty fails due to no terminal, set -o echo will still be executed when stty fails for other reasons.

@ecrist
Copy link
Member

ecrist commented May 17, 2019 via email

@HarmtH
Copy link
Author

HarmtH commented May 17, 2019

Yes I know. The annoying thing is that an illegal set option is treated as a syntax error and thus aborts the script in every shell I've tried (dash, zsh, ksh..) except bash. And there is no satisfactory way to get the available set options. set -o gives you the available options and their current settings, but in an unspecified layout, according to the POSIX docs.

@HarmtH
Copy link
Author

HarmtH commented May 17, 2019

Come to think of it, perhaps we can try setting the option in a subshell, and then set it for real if that succeeds:

(stty -echo 2>/dev/null) || { (set +o echo 2>/dev/null) && set +o echo; }

No unexpected aborts possible this way.

@merlin-tc
Copy link

@HarmtH your command works when called via ansible or a non interactive shell.

@luizluca
Copy link
Contributor

luizluca commented Jun 4, 2019

(OpenWrt) ash does not have "set -o echo".

root@OpenWrt:~# set -o echo
-ash: set: illegal option -o echo

But it does not have stty as well.

The only viable option here is "read -s". I'll PR something...

@TinCanTech
Copy link
Collaborator

It seems that set -o option will be supported in future.
See entry 0000537 (and the related 0000052) in the Austin Group Issue Tracker.
https://www.in-ulm.de/~mascheck/various/set-e/

@HarmtH
Copy link
Author

HarmtH commented Jun 4, 2019

The only viable option here is "read -s". I'll PR something...

$ read -s foo
dash: 1: read: Illegal option -s

read -s is a (bash?) extension. And probably just does the equivalent of stty -echo

@luizluca
Copy link
Contributor

luizluca commented Jun 4, 2019

read -s is a (bash?) extension. And probably just does the equivalent of stty -echo

It is.. when available. There is no stty by default in OpenWrt. 'read -s' also works in ash while it does not accept 'set -o echo'.

@TinCanTech
Copy link
Collaborator

Can we please keep separate issues in separate tickets.

@luizluca
Copy link
Contributor

luizluca commented Jun 5, 2019

Can we please keep separate issues in separate tickets.

@TinCanTech , my fault. I got here because the same "set -o echo" abort issue got me. However, it was not because it's not a terminal but because there is no 'set -o echo' in ash.

Part of my PR #315 is just like @HarmtH suggested: using a subshell in order to silently test for 'set -o echo' support and avoid shell to abort when it got the illegal option. This discussion might be more "on topic" there.

@devZer0
Copy link

devZer0 commented Apr 5, 2021

i'm getting this error during pivpn installation

An updated CRL has been created.
CRL file: /etc/openvpn/easy-rsa/pki/crl.pem

./easyrsa: 341: set: Illegal option -o echo
Adding system user `openvpn' (UID 106) ...
Adding new group `openvpn' (GID 112) ...

@TinCanTech
Copy link
Collaborator

@devZer0 This would probably be something to report to pivpn

@MichaIng
Copy link

MichaIng commented Oct 11, 2021

This would probably be something to report to pivpn

No, this is called within the easyrsa script, and it is illegal on all shells tested and reported above. I'm not sure what this aims to do, but if it is valid on any shell, then probably easyrsa should check whether it's sh invocation is actually that shell before trying to set this otherwise illegal option.

EDIT: Ah I see now the actual fix: #315
It looks like this is part of v3.0.7 already which is used by PiVPN as well. The subshell redirects for the test look actually fine and work well here when testing isolated, so not sure how this error can still show up.

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

Successfully merging a pull request may close this issue.

7 participants