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

-f does not work with process substitution #123

Open
codigoergosum opened this issue Oct 20, 2022 · 1 comment
Open

-f does not work with process substitution #123

codigoergosum opened this issue Oct 20, 2022 · 1 comment

Comments

@codigoergosum
Copy link

codigoergosum commented Oct 20, 2022

$ bash -x ssl-cert-check -f <(echo -e 'example.com 443')

fails because /dev/fd/63 does not satisfy the test:

elif [ -f "${SERVERFILE}" ]; then

which looks for an extant regular file. However, a regular file should not be required, just a readable one. In bash, I'd suggest the -r test instead--I can't speak to other shells.

@pillilz
Copy link

pillilz commented Apr 2, 2023

Similarly the following does not work due to [ -f "${SERVERFILE}" ]:

$ echo example.com 443 | ssl-cert-check -f /dev/stdin

Another disadvantage is the race condition between the test and grep actually opening the file. Not a big issue, but not ideal either.
I propose to change the code like this:

elif [ -n "${SERVERFILE}" ]; then
    print_heading

    grep -E -v '(^#|^$)' "${SERVERFILE}" | while read HOST PORT
    do
        if [ "$PORT" = "FILE" ]; then
            check_file_status "${HOST}" "FILE" "${HOST}"
        else
            check_server_status "${HOST}" "${PORT}"
        fi
    done
    if [ ${PIPESTATUS[0]} != 0 ]
    then
	echo "Error opening ${SERVERFILE}"
    else
        print_summary
    fi

Happy to raise a pull request if desired.

hgraeber added a commit to hgraeber/ssl-cert-check that referenced this issue Jun 1, 2024
So ssl-cert-check will be in '-s' mode independent from wheter the file
exists or what type of file it is. Fixes Matty9191#123
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

No branches or pull requests

2 participants