Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-23589

portability: use `uname -n` instead of `hostname`

Details

    Description

      Scripts included with mariadb use `hostname` to query the hostname, used to create logfiles, pidfiles, etc. However this command is not defined by POSIX and thus not guaranteed to work.

      Better use portable `uname -n` instead.

      See attached patch.

      Attachments

        Issue Links

          Activity

            Hi ghen thanks for the patch.
            I suggest you to raise an PR https://github.com/MariaDB/server/pulls so your patch could be more visible and more developers could look into.

            anel Anel Husakovic added a comment - Hi ghen thanks for the patch. I suggest you to raise an PR https://github.com/MariaDB/server/pulls so your patch could be more visible and more developers could look into.

            Where does hostname not exist? We'd need at least one platform where your patch makes a difference, for testing.

            serg Sergei Golubchik added a comment - Where does hostname not exist? We'd need at least one platform where your patch makes a difference, for testing.

            Arch Linux default install (without inetutils pkg, no longer part of base OS. uname is part of coreutils)

            ghen Geert Hendrickx added a comment - Arch Linux default install (without inetutils pkg, no longer part of base OS. uname is part of coreutils)

            Indeed and not only on arch, see bellow:

            for os in debian ubuntu archlinux fedora centos ; do echo $os: && docker run -it ${os}:latest /bin/bash -c "uname -n; hostname"; done
            debian:
            a22a4f5dd91b
            a22a4f5dd91b
            ubuntu:
            37ecd90c8a07
            37ecd90c8a07
            archlinux:
            95435e433627
            /bin/bash: hostname: command not found
            fedora:
            9bccea21bb4f
            /bin/bash: hostname: command not found
            centos:
            4a9a34aab63e
            4a9a34aab63e
            

            So `uname -n` seems to be a good alternative for very basic and clean OS installations (and docker).

            faust Faustin Lammler added a comment - Indeed and not only on arch, see bellow: ❯ for os in debian ubuntu archlinux fedora centos ; do echo $os: && docker run -it ${os}:latest /bin/bash -c "uname -n; hostname" ; done debian: a22a4f5dd91b a22a4f5dd91b ubuntu: 37ecd90c8a07 37ecd90c8a07 archlinux: 95435e433627 /bin/bash : hostname : command not found fedora: 9bccea21bb4f /bin/bash : hostname : command not found centos: 4a9a34aab63e 4a9a34aab63e So `uname -n` seems to be a good alternative for very basic and clean OS installations (and docker).
            ghen Geert Hendrickx added a comment - - edited anel PR is here: https://github.com/MariaDB/server/pull/1663

            ghen great thanks for raising the patch. We will take a look.
            danblack what should be the fix version for this?

            anel Anel Husakovic added a comment - ghen great thanks for raising the patch. We will take a look. danblack what should be the fix version for this?
            danblack Daniel Black added a comment - - edited

            Thanks faust that clearly shows what's in the minimal install and the two gaps.

            https://www.archlinux.org/packages/extra/x86_64/mariadb/ (10.5) has the inetutils dependency I assume solely for this. eworm I assuming this is safe and drops a dependency for archlinux so is a gain?

            Fedora, https://src.fedoraproject.org/rpms/mariadb, no dependency listed (in any branch aka release) on hostname package (that contains hostname).
            https://bugzilla.redhat.com/show_bug.cgi?id=1317907 old closed bug that is related to hostname in fedora scripts that like this bugs replaces it with uname (https://src.fedoraproject.org/rpms/mariadb/c/f61d6f22879ff7825cd656dda4859c6357280762) rather than add a dependency. There are no outstanding distro bugs about this and `hostnames` minimal use in mysql_install_db/mysqld_safe means no-one noticed or cared.

            Fedora 31 (has 10.3) will EOL about the same time as MariaDB's release so no-one will care.
            Fedora 32 (has 10.4) will EOL mid next year. fc33/fc34 also have 10.4
            FYI mschorm

            So target 10.4 unless serg has a different option.

            danblack Daniel Black added a comment - - edited Thanks faust that clearly shows what's in the minimal install and the two gaps. https://www.archlinux.org/packages/extra/x86_64/mariadb/ (10.5) has the inetutils dependency I assume solely for this. eworm I assuming this is safe and drops a dependency for archlinux so is a gain? Fedora, https://src.fedoraproject.org/rpms/mariadb , no dependency listed (in any branch aka release) on hostname package (that contains hostname). https://bugzilla.redhat.com/show_bug.cgi?id=1317907 old closed bug that is related to hostname in fedora scripts that like this bugs replaces it with uname ( https://src.fedoraproject.org/rpms/mariadb/c/f61d6f22879ff7825cd656dda4859c6357280762 ) rather than add a dependency. There are no outstanding distro bugs about this and `hostnames` minimal use in mysql_install_db/mysqld_safe means no-one noticed or cared. Fedora 31 (has 10.3) will EOL about the same time as MariaDB's release so no-one will care. Fedora 32 (has 10.4) will EOL mid next year. fc33/fc34 also have 10.4 FYI mschorm So target 10.4 unless serg has a different option.

            I will happily drop the dependency, especially as it's old inetutils.
            Thanks!

            eworm Christian Hesse added a comment - I will happily drop the dependency, especially as it's old inetutils. Thanks!
            danblack Daniel Black added a comment -

            scripts/wsrep_sst_mysqldump.sh

                [ "$1" = "$(hostname -s)" ] && return 0
                [ "$1" = "$(hostname -f)" ] && return 0
                [ "$1" = "$(hostname -d)" ] && return 0
            

            Is the donor name passed though wsrep.

            https://galeracluster.com/library/documentation/scriptable-sst.html its specified as an IP.

            danblack Daniel Black added a comment - scripts/wsrep_sst_mysqldump.sh [ "$1" = "$(hostname -s)" ] && return 0 [ "$1" = "$(hostname -f)" ] && return 0 [ "$1" = "$(hostname -d)" ] && return 0 Is the donor name passed though wsrep. https://galeracluster.com/library/documentation/scriptable-sst.html its specified as an IP.

            I didn't verify that particular functionality, just added another item to that list of "anything that could match the local host". It's equivalent to the hostname -f that was already there, regardless of whether an FQDN would be valid input or not.

            ghen Geert Hendrickx added a comment - I didn't verify that particular functionality, just added another item to that list of "anything that could match the local host". It's equivalent to the hostname -f that was already there, regardless of whether an FQDN would be valid input or not.

            jplindst can you please take a look in wsrep change?

            anel Anel Husakovic added a comment - jplindst can you please take a look in wsrep change?

            Pushed with 1bb3ad6dfc885112d to 10.4.
            Note: wsrep change not pushed yet.

            anel Anel Husakovic added a comment - Pushed with 1bb3ad6dfc885112d to 10.4 . Note: wsrep change not pushed yet.

            People

              anel Anel Husakovic
              ghen Geert Hendrickx
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.