bugSTUMP - Bugs: bug #59261, Nonsensical conditional in...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #59261: Nonsensical conditional in hostname.REPLACEMENT

Submitter:  Tristan Miller <psychonaut>
Submitted:  Tue 13 Oct 2020 12:28:22 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Ready For Test
Privacy:  Public Assigned to:  rayner
Open/Closed:  Open Planned Release:  2.6

Thu 13 Oct 2022 11:04:03 PM UTC, comment #3: 

Opted to remove the hostname.REPLACEMENT script altogether, along with the reference to it in modenv.

The rationale for this is:
1. It never worked like it was supposed to.
2. As far as I can see, inews/rnews don't invoke the hostname command anyway. Possibly some very old versions did?
3. It's supposed to be a workaround for a problem on BSD-ish systems, but our STUMP installation on NetBSD has been working for many years without using hostname.REPLACEMENT or encountering the problem it's supposed to fix. And as Mike says, the script just emits the FQDN, which is what modern BSD hostname does by default. This all implies the problem it was meant to solve no longer exists.

Rayner Lucas <rayner>
Group administrator
Fri 07 Oct 2022 12:27:28 AM UTC, comment #2: 

The conditional is backwards anyway, the -f flag should cause the command to print the FQDN.

As far as I can see, the output of 'hostname' is used only twice in STUMP itself. Both times are in the 'pmapp' PGPMoose script, and in each case the FQDN is the expected result.

The comments in the script and in etc/modenv also suggest that it is needed to work around some unspecified incompatibility between inews/rnews and BSD hostname (though it also says you can just ignore any errors). I don't think modern inews/rnews use the hostname command, though, so this may be a workaround for a problem that no longer exists.

This looks like two bugs that partially cancel each other out, and it was never noticed because it accidentally does the required thing in the only places it might ever be used.

I vote for replacing it with "echo $FULL_HOSTNAME" as suggested by Mike, or possibly removing it altogether.

Rayner Lucas <rayner>
Group administrator
Thu 15 Oct 2020 04:30:45 PM UTC, comment #1: 

The:  if [ "x$1" = "-f" ] ; then

Within that script it kind of looks like an attempt at one of the usual workarounds for older Bourne Shell problems where [ "$1" = "-f" ]  would error out if $1 ever turned out to be empty.   They likely intended to have  written [ "x$1" != "x-f" ]

However, this logic flow of not defaulting to "-f" is strange for the hostname command,  and if meant to "replace" hostname it makes more sense to just have an unconditional:   echo $FULL_HOSTNAME


The hostname system utility does not originally have reliable  standardized semantics and has different available command line options and choice of whether you are printing the FQDN or Host portion only by default.. across different operating systems; on some OSes executing "hostname" with no options would print the Fully-Qualified Domain matching POSIX gethostname() or or uname nodename.. on others Hostname  defaults to trimming off the domain portion of the FQDN.

Even on modern FreeBSD, etc, however the -f option is redundant as  "hostname -f"  is currently the default on modern OS, and  "hostname -s" the opposite.




Mike Keith <mysidia>
Tue 13 Oct 2020 12:28:22 PM UTC, original submission:  

The hostname.REPLACEMENT script, which is supposed to be a "drop-in replacement for hostname" on certain BSD-derived systems, consists of the following code:


    HOSTNAME=manifold
    FULL_HOSTNAME=manifold.algebra.com

    if [ "x$1" = "-f" ] ; then
      echo $HOSTNAME
    else
      echo $FULL_HOSTNAME
    fi


However, the comparison in the conditional can never be true.  Quite possibly this is a bug, but without knowing more about the problem with BSD hostname that this script is supposed to work around, I can't be sure.  (Maybe Igor really did want the script to always output $FULL_HOSTNAME, but in that case why have a conditional at all, and why instruct the user to declare both HOSTNAME and FULL_HOSTNAME?)

Tristan Miller <psychonaut>
Group administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rayner (Posted a comment)
  • -email is unavailable- added by mysidia (Posted a comment)
  • -email is unavailable- added by psychonaut (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-06-23 rayner Planned ReleaseNone 2.6
    2022-10-13 rayner StatusNone Ready For Test
        Assigned toNone rayner

    Back to the top

    Powered by Savane 3.13-1277.
    Corresponding source code