Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250709235242.6ab2aaeb@windsurf>
Date: Wed, 9 Jul 2025 23:52:42 +0200
From: Thomas Petazzoni <thomas.petazzoni@...tlin.com>
To: musl@...ts.openwall.com
Subject: getpass() feature test macro

Hello,

I am working on a build failure happening with the gcr package
(https://gitlab.gnome.org/GNOME/gcr/) due to its use of the getpass()
function in:

  https://gitlab.gnome.org/GNOME/gcr/-/blob/main/gcr/console-interaction.c?ref_type=heads

This fails to build with gcc >= 14 musl toolchains because it doesn't
find the prototype for getpass() even though it's defined in <unistd.h>
which is included.

musl provides the getpass() prototype when:

#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)

glibc provides the getpass() prototype when:

#if defined __USE_MISC || (defined __USE_XOPEN && !defined __USE_XOPEN2K)

The gcr code base is built with _XOPEN_SOURCE defined, so the build
works fine with glibc, but not with musl.

According to https://man7.org/linux/man-pages/man3/getpass.3.html the
feature test macro requirements for glibc are:

       getpass():
           Since glibc 2.2.2:
               _XOPEN_SOURCE && ! (_POSIX_C_SOURCE >= 200112L)
                   || /* glibc >= 2.19: */ _DEFAULT_SOURCE
                   || /* glibc <= 2.19: */ _BSD_SOURCE
           Before glibc 2.2.2:
               none

So, now the $100 question is: is it gcr that needs to be fixed to
define another feature macro (and if so, which one), or is it musl's
code that should provide getpass() prototype under different conditions?

Thanks a lot in advance for your feedback!

(Obviously the feedback of "getpass is legacy and sucks" isn't very
useful, as it's not the point of this discussion and this fact is known
and understood.)

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.