diff --git a/adcli.spec b/adcli.spec index d714fc0..cf6f7de 100644 --- a/adcli.spec +++ b/adcli.spec @@ -1,6 +1,6 @@ Name: adcli Version: 0.9.0 -Release: 2 +Release: 3 Summary: A helper library and tools for Active Directory client operations Group: Development/Libraries License: LGPLv2+ @@ -15,6 +15,7 @@ Patch4: 0005-add-option-use-ldaps.patch Patch5: 0006-discovery-fix.patch Patch6: 0007-delete-do-not-exit-if-keytab-cannot-be-read.patch Patch7: 0008-tools-disable-SSSD-s-locator-plugin.patch +Patch8: backport-tools-replace-getpass.patch BuildRequires: gcc intltool pkgconfig libtool gettext-devel krb5-devel BuildRequires: openldap-devel libxslt xmlto git @@ -76,6 +77,9 @@ rm -rf %{buildroot} %doc %{_mandir}/man8/* %changelog +* Fri Dec 6 2024 yixiangzhike - 0.9.0-3 +- backport upsteam patch to enable ctrl+c for the password prompt + * Mon Oct 17 2022 yixiangzhike - 0.9.0-2 - continue to build when test-case(test-adenroll) failed diff --git a/backport-tools-replace-getpass.patch b/backport-tools-replace-getpass.patch new file mode 100644 index 0000000..2b29875 --- /dev/null +++ b/backport-tools-replace-getpass.patch @@ -0,0 +1,91 @@ +From 054b24d5837cb32f94b6b659620caca2b567e4f6 Mon Sep 17 00:00:00 2001 +From: Sumit Bose +Date: Thu, 15 Sep 2022 18:19:19 +0200 +Subject: [PATCH] tools: replace getpass() + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2124030 +Resolves: https://gitlab.freedesktop.org/realmd/adcli/-/issues/10 +--- + tools/tools.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- + 1 file changed, 44 insertions(+), 1 deletion(-) + +diff --git a/tools/tools.c b/tools/tools.c +index c78548b..7e382ae 100644 +--- a/tools/tools.c ++++ b/tools/tools.c +@@ -36,6 +36,7 @@ + #include + #include + #include ++#include + + + static char *adcli_temp_directory = NULL; +@@ -208,6 +209,47 @@ command_usage (void) + printf ("\nSee 'adcli --help' for more information\n"); + } + ++static char *get_password (const char *prompt) ++{ ++ int ret; ++ struct termios termios; ++ struct termios orig_termios; ++ char *buf = NULL; ++ size_t buf_len = 0; ++ ++ ret = tcgetattr (fileno (stdin), &termios); ++ if (ret != 0 ) { ++ return NULL; ++ } ++ ++ orig_termios = termios; ++ termios.c_lflag &= ~ECHO; ++ ++ ret = tcsetattr (fileno (stdin), TCSAFLUSH, &termios); ++ if (ret != 0) { ++ return NULL; ++ } ++ ++ fprintf (stdout, "%s", prompt); ++ fflush (stdout); ++ ++ ret = getline (&buf, &buf_len, stdin); ++ tcsetattr (fileno (stdin), TCSAFLUSH, &orig_termios); ++ if (ret <= 0) { ++ free (buf); ++ return NULL; ++ } ++ ++ if (buf[ret - 1] == '\n') { ++ /* remove new-line character from the end of the buffer and ++ * echo it to stdout */ ++ buf[ret - 1] = '\0'; ++ fprintf (stdout, "\n"); ++ } ++ ++ return buf; ++} ++ + char * + adcli_prompt_password_func (adcli_login_type login_type, + const char *name, +@@ -221,7 +263,7 @@ adcli_prompt_password_func (adcli_login_type login_type, + if (asprintf (&prompt, "Password for %s: ", name) < 0) + return_val_if_reached (NULL); + +- password = getpass (prompt); ++ password = get_password (prompt); + free (prompt); + + if (password == NULL) +@@ -229,6 +271,7 @@ adcli_prompt_password_func (adcli_login_type login_type, + + result = strdup (password); + adcli_mem_clear (password, strlen (password)); ++ free (password); + + return result; + } +-- +2.33.0 +