ksh builtin getconf is missing some parameters
To construct its built-in
getconf command, the ksh93 configuration system extracts information from the system getconf binary and from several headers.
Unfortunately, the script that does this expects GNU sed and in particular tries to use sed to substitute newlines for spaces. This does not work and as a result several parameters are not exposed in the built-in.
This was discovered when richlowe generated the ksh93 feature files on a system which had GNU sed earlier in the path than /usr/bin; there's a secondary problem that the user's path can affect the feature generation.
Note that this is not part of a standard build, it's a manual process to re-generate the feature files that ksh93 needs to build.
Updated by Andy Fiddaman 4 months ago
The root cause of this problem was discovered to be a
sed expression in libast's
conf.sh which tries to separate a list of space-separated words across multiple lines into a file containing one word per line. The list of words is extracted from header files and this is part of the process for populating the
getconf translation tables.
The original code here looked like:
sed \ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789]/ /g' \ -e 's/[ ][ ]*/\n/g'
and the problem is that the illumos
sed command does not support escapes such as the
\n there; rather it treats it as a literal
n. This was resulting in the loss of several tokens from the output (unfortunately not all of them or testing would have shown up the problem!)
The new version (see the associated gerrit review):
sed \ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789]/ /g' \ -e 's/[ ][ ]*/%/g' | tr '%' '\n'
which replaces space sequences with % then uses
tr to swap these for a newline. It's safe to use
% since any existing
% characters would have been replaced with a space in the previous expression.
In addition to this change, I've also updated the paths in the various
.iffe make files so that it is explicit and therefore consistent between systems that may run this feature target in the future.
Updated by Andy Fiddaman 4 months ago
Tested by comparing the output of ksh's built-in
getconf before and after this change.
Some adhoc testing shows that keys that were previously unavailable are now present:
af@bloody:~/getconf/old$ getconf UID_MAX 60002 af@bloody:~/getconf/old$ getconf UADDR_MAX getconf: Invalid argument (UADDR_MAX) af@bloody:~/getconf/old$ getconf ADDRESS_WIDTH getconf: Invalid argument (ADDRESS_WIDTH) af@bloody:~/getconf$ getconf ISALIST getconf: Invalid argument (ISALIST)
af@bloody:~/getconf/new$ getconf UID_MAX 60002 af@bloody:~/getconf/new$ getconf UADDR_MAX undefined af@bloody:~/getconf/new$ getconf ADDRESS_WIDTH 64 af@bloody:~/getconf/new$ getconf ISALIST amd64 pentium_pro+mmx pentium_pro pentium+mmx pentium i486 i386 i86
and other comparisons show more attributes being provided than before:
--- old/all 2021-09-02 00:03:54.152609154 +0000 +++ new/all 2021-09-02 00:47:03.500851286 +0000 @@ -1,6 +1,9 @@ _POSIX_ABI_AIO_XFER_MAX=undefined _POSIX_ABI_ASYNCHRONOUS_IO=undefined _POSIX_ABI_ASYNC_IO=undefined +_POSIX_ACCESS_FILTERING=1 +_POSIX_ACL_ENABLED=2 +ADDRESS_WIDTH=64 _POSIX_ADVISORY_INFO=200112 AIO_LISTIO_MAX=4096 _POSIX_AIO_LISTIO_MAX=4096 @@ -10,6 +13,10 @@ _POSIX_AIO_PRIO_DELTA_MAX=0 ALLOC_SIZE_MIN=131072 ARCHITECTURE=i386 +ARCHITECTURE_32=i386 +ARCHITECTURE_64=amd64 +ARCHITECTURE_K=amd64 +ARCHITECTURE_NATIVE=amd64 ARG_MAX=2096640 ... -_POSIX_VERSION=undefined +_POSIX_VERSION=200112 _POSIX_VERSION_88=undefined _POSIX_VERSION_90=undefined _POSIX_VERSION_93=undefined +_POSIX_XATTR_ENABLED=1 +_POSIX_XATTR_EXISTS=0 ...
Updated by Electric Monk 4 months ago
- % Done changed from 0 to 100
- Status changed from In Progress to Closed
commit 78f5fe539528ce4afb4d8137ae7f8ff44765b467 Author: Andy Fiddaman <firstname.lastname@example.org> Date: 2021-09-15T08:14:24.000Z 14044 ksh builtin getconf is missing some parameters Reviewed by: Toomas Soome <email@example.com> Reviewed by: Rich Lowe <firstname.lastname@example.org> Approved by: Gordon Ross <email@example.com>