Project

General

Profile

Actions

Bug #14044

closed

ksh builtin getconf is missing some parameters

Added by Andy Fiddaman 25 days ago. Updated 11 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
cmd - userland programs
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Bite-size
Tags:
Gerrit CR:

Description

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.

Actions #1

Updated by Andy Fiddaman 25 days ago

  • Description updated (diff)
Actions #2

Updated by Andy Fiddaman 20 days ago

  • Gerrit CR set to 1688
Actions #3

Updated by Andy Fiddaman 16 days 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.

Actions #4

Updated by Andy Fiddaman 12 days 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:

Old:

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)

New:

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
...
Actions #5

Updated by Electric Monk 11 days ago

  • % Done changed from 0 to 100
  • Status changed from In Progress to Closed

git commit 78f5fe539528ce4afb4d8137ae7f8ff44765b467

commit  78f5fe539528ce4afb4d8137ae7f8ff44765b467
Author: Andy Fiddaman <omnios@citrus-it.co.uk>
Date:   2021-09-15T08:14:24.000Z

    14044 ksh builtin getconf is missing some parameters
    Reviewed by: Toomas Soome <tsoome@me.com>
    Reviewed by: Rich Lowe <richlowe@richlowe.net>
    Approved by: Gordon Ross <gordon.w.ross@gmail.com>

Actions

Also available in: Atom PDF