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

zed_guid_to_pool() broken on hosts with dash as /bin/sh #11954

Closed
ZNikke opened this issue Apr 27, 2021 · 1 comment
Closed

zed_guid_to_pool() broken on hosts with dash as /bin/sh #11954

ZNikke opened this issue Apr 27, 2021 · 1 comment
Labels
Status: Triage Needed New issue which needs to be triaged Type: Defect Incorrect behavior (e.g. crash, hang)

Comments

@ZNikke
Copy link

ZNikke commented Apr 27, 2021

System information

Type Version/Name
Distribution Name Ubuntu
Distribution Version 20.04.2 LTS
Linux Kernel 5.4.0-72-generic
Architecture x86_64
ZFS Version 2.1.0-rc4
SPL Version 2.1.0-rc4

Describe the problem you're observing

On hosts with dash as /bin/sh the zed_guid_to_pool() helper function in zed.d/zed-functions.sh doesn't work due to using the dash-internal printf with a format it doesn't understand.

Suggested workaround is to either use the binary printf, ie /usr/bin/printf although /bin/printf works on newer Linux distros, or to simply declare the zed.d scripts to be bash scripts with #!/bin/bash.

The latter would likely be more honest with regards to how much is actually tested with other shells, and make it easier for developers with nice features like local variables in functions etc. There's nothing wrong with stating that a script is a bash-script, it's just being honest with the dependency. But saying that a script is an sh-script opens up cans of worms since then you must really really be sh, which I know openzfs knows and tries hard to be but yet cases like this are missed despite shellcheck etc.

Describe how to reproduce the problem

# /bin/dash
# . /etc/zfs/zed.d/zed-functions.sh
# zed_guid_to_pool $(zpool list -Ho guid | head -n 1)
/bin/dash: 514: printf: %l: invalid directive

Include any warning/errors/backtraces from the system logs

@ZNikke ZNikke added Status: Triage Needed New issue which needs to be triaged Type: Defect Incorrect behavior (e.g. crash, hang) labels Apr 27, 2021
nabijaczleweli added a commit to nabijaczleweli/zfs that referenced this issue Apr 27, 2021
nabijaczleweli added a commit to nabijaczleweli/zfs that referenced this issue Apr 27, 2021
@nabijaczleweli
Copy link
Contributor

Added this to #11935

nabijaczleweli added a commit to nabijaczleweli/zfs that referenced this issue Apr 27, 2021
nabijaczleweli added a commit to nabijaczleweli/zfs that referenced this issue Apr 29, 2021
nabijaczleweli added a commit to nabijaczleweli/zfs that referenced this issue Apr 29, 2021
nabijaczleweli added a commit to nabijaczleweli/zfs that referenced this issue Apr 29, 2021
nabijaczleweli added a commit to nabijaczleweli/zfs that referenced this issue Apr 29, 2021
nabijaczleweli added a commit to nabijaczleweli/zfs that referenced this issue Apr 29, 2021
nabijaczleweli added a commit to nabijaczleweli/zfs that referenced this issue Apr 29, 2021
nabijaczleweli added a commit to nabijaczleweli/zfs that referenced this issue Apr 29, 2021
behlendorf pushed a commit to behlendorf/zfs that referenced this issue May 10, 2021
Reviewed-by: Tony Hutter <[email protected]>
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
Closes openzfs#11935
Closes openzfs#11954
sempervictus pushed a commit to sempervictus/zfs that referenced this issue May 31, 2021
Reviewed-by: Tony Hutter <[email protected]>
Signed-off-by: Ahelenia Ziemiańska <[email protected]>
Closes openzfs#11935
Closes openzfs#11954
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needed New issue which needs to be triaged Type: Defect Incorrect behavior (e.g. crash, hang)
Projects
None yet
Development

No branches or pull requests

2 participants