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

Undeclared dependency on GNU awk asort() in vdev_id #239

Open
OsmiumBalloon opened this issue Jun 23, 2024 · 0 comments
Open

Undeclared dependency on GNU awk asort() in vdev_id #239

OsmiumBalloon opened this issue Jun 23, 2024 · 0 comments

Comments

@OsmiumBalloon
Copy link

Summary

The /lib/udev/vdev_id script included with the zfsutils package on Debian makes use of feature(s) specific to GNU awk (gawk), but the script only specifies awk generically, and the package control file does not specify awk at all. Debian defaults to nawk, which does not provide the feature(s) in question, leading to script aborts.

Environment

  • Debian 12.5 "bookworm"
  • Kernel 6.1.0-21-amd64 / 6.1.90-1 (2024-05-03)
  • zfsutils 2.1.11-1
  • mawk 1.3.4.20200120-3.1
  • gawk 5.2.1-2

Description

In file/lib/udev/vdev_id, in function sas_handler(), on line 321, the code invokes the asort function to sort the array a. The asort() function is a GNU extension; it is not part of the standard awk. See Gawk: Effective AWK Programming, Section 12.3.2. When this code is encountered, the awk interpreter aborts with an error, "function asort never defined".

For example, an extract from syslog, with udev_log set to debug in
/etc/udev/udev.conf:

Jun 12 10:37:19 penguin (udev-worker)[3212]: dm-0: '/lib/udev/vdev_id -d dm-0'(err) 'awk: line 7: function asort never defined'

This was with the default Debian awk, mawk, installed. Installing gawk (which automatically makes it the preferred alternative) resolved this error.

The vdev_id code in question is only invoked for multipath SAS storage. Many other packages (or people) want gawk installed anyway. So one needs the particular combination of SAS + multipath + minimalist-install to encounter the bug.

Resolution

In researching this error, I found that another "assuming gawk" bug has been encountered previously. See "vdev_id.conf slot mapping fails on Debian 7", Issue #136, from 2014.

Perhaps the best thing to do here is to simply declare a dependency on gawk and move on with your lives. In 2024 it is not that heavy a requirement, especially in the land of Linux where the userland is usually heavily GNU-based.

Alternatively, if there is a strong desire to avoid GNU-isms for whatever reason, it is possible to find sort routines implemented in pure standard POSIX awk code. See https://unix.stackexchange.com/questions/609866/ for example.

@OsmiumBalloon OsmiumBalloon changed the title Undeclared dependency on GNU awk in vdev_id Undeclared dependency on GNU awk asort() in vdev_id Jul 4, 2024
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

1 participant