On Mon, 2020-03-09 at 14:00 +0300, Dmitry V. Levin wrote:
I think this approach is OK. Please commit the patch.
The alternative is of course argument reordering in translated
format strings, but
- most of translators are not aware of this POSIX feature, and
- our translation platform treats it as a C format string error, see
e.g.
https://translate.fedoraproject.org/translate/linux-pam/master/ga/?q=chec...
On Thu, Mar 05, 2020 at 11:26:56PM +0300, Dmitry V. Levin wrote:
> Change formatting of default prompts, making them translatable
> to those languages that use a different word order.
> From non-i18n perspective this change is essentially a no-op.
>
> * libpam/pam_get_authtok.c (PROMPTCURRENT): Replace with
> PROMPT_CURRENT_ARG and PROMPT_CURRENT_NOARG.
> (PROMPT1): Replace with PROMPT_NEW_ARG and PROMPT_NEW_NOARG.
> (PROMPT2): Replace with PROMPT_RETYPE_ARG and PROMPT_RETYPE_NOARG.
> (pam_get_authtok_internal, pam_get_authtok_verify): Use new macros.
> * po/Linux-PAM.pot: Regenerated.
>
> Resolves:
https://github.com/linux-pam/linux-pam/issues/29
> ---
> libpam/pam_get_authtok.c | 54 +++++++++++++++++++++++++-----------
> ----
> po/Linux-PAM.pot | 28 +++++++++++++++------
> 2 files changed, 54 insertions(+), 28 deletions(-)
>
> diff --git a/libpam/pam_get_authtok.c b/libpam/pam_get_authtok.c
> index 99eb25f2..3fa7f7df 100644
> --- a/libpam/pam_get_authtok.c
> +++ b/libpam/pam_get_authtok.c
> @@ -37,12 +37,15 @@
> #include <security/pam_ext.h>
>
> #define PROMPT _("Password: ")
> -/* For Translators: "%s%s" could be replaced with "<service>
" or
> "". */
> -#define PROMPTCURRENT _("Current %s%spassword: ")
> -/* For Translators: "%s%s" could be replaced with "<service>
" or
> "". */
> -#define PROMPT1 _("New %s%spassword: ")
> -/* For Translators: "%s%s" could be replaced with "<service>
" or
> "". */
> -#define PROMPT2 _("Retype new %s%spassword: ")
> +/* For Translators: "%s" is replaced with "<service>".
*/
> +#define PROMPT_CURRENT_ARG _("Current %s password: ")
> +#define PROMPT_CURRENT_NOARG _("Current password: ")
> +/* For Translators: "%s" is replaced with "<service>".
*/
> +#define PROMPT_NEW_ARG _("New %s password: ")
> +#define PROMPT_NEW_NOARG _("New password: ")
> +/* For Translators: "%s" is replaced with "<service>".
*/
> +#define PROMPT_RETYPE_ARG _("Retype new %s password: ")
> +#define PROMPT_RETYPE_NOARG _("Retype new password: ")
> #define MISTYPED_PASS _("Sorry, passwords do not match.")
>
> #define PAM_GETAUTHTOK_NOVERIFY 1
> @@ -142,21 +145,30 @@ pam_get_authtok_internal (pam_handle_t *pamh,
> int item,
> {
> pamh->authtok_verified = 0;
>
> - retval = pam_prompt (pamh, PAM_PROMPT_ECHO_OFF, &resp[0],
> - PROMPT1, authtok_type,
> - strlen (authtok_type) > 0?" ":"");
> + retval = *authtok_type ?
> + pam_prompt (pamh, PAM_PROMPT_ECHO_OFF, &resp[0],
> + PROMPT_NEW_ARG, authtok_type) :
> + pam_prompt (pamh, PAM_PROMPT_ECHO_OFF, &resp[0],
> + "%s", PROMPT_NEW_NOARG);
> if (retval == PAM_SUCCESS && chpass > 1 && resp[0] !=
NULL)
> - retval = pam_prompt (pamh, PAM_PROMPT_ECHO_OFF, &resp[1],
> - PROMPT2, authtok_type,
> - strlen (authtok_type) > 0?" ":"");
> + {
> + retval = *authtok_type ?
> + pam_prompt (pamh, PAM_PROMPT_ECHO_OFF, &resp[1],
> + PROMPT_RETYPE_ARG, authtok_type) :
> + pam_prompt (pamh, PAM_PROMPT_ECHO_OFF, &resp[1],
> + "%s", PROMPT_RETYPE_NOARG);
> + }
> }
> else if (item == PAM_OLDAUTHTOK)
> - retval = pam_prompt (pamh, PAM_PROMPT_ECHO_OFF, &resp[0],
> - PROMPTCURRENT, authtok_type,
> - strlen (authtok_type) > 0?" ":"");
> + {
> + retval = *authtok_type ?
> + pam_prompt (pamh, PAM_PROMPT_ECHO_OFF, &resp[0],
> + PROMPT_CURRENT_ARG, authtok_type) :
> + pam_prompt (pamh, PAM_PROMPT_ECHO_OFF, &resp[0],
> + "%s", PROMPT_CURRENT_NOARG);
> + }
> else
> - retval = pam_prompt (pamh, PAM_PROMPT_ECHO_OFF, &resp[0],
> "%s",
> - PROMPT);
> + retval = pam_prompt (pamh, PAM_PROMPT_ECHO_OFF, &resp[0],
> "%s", PROMPT);
>
> if (retval != PAM_SUCCESS || resp[0] == NULL ||
> (chpass > 1 && resp[1] == NULL))
> @@ -232,9 +244,11 @@ pam_get_authtok_verify (pam_handle_t *pamh,
> const char **authtok,
> retval = pam_get_item (pamh, PAM_AUTHTOK_TYPE, (const void
> **)&authtok_type);
> if (retval != PAM_SUCCESS || authtok_type == NULL)
> authtok_type = "";
> - retval = pam_prompt (pamh, PAM_PROMPT_ECHO_OFF, &resp,
> - PROMPT2, authtok_type,
> - strlen (authtok_type) > 0?" ":"");
> + retval = *authtok_type ?
> + pam_prompt (pamh, PAM_PROMPT_ECHO_OFF, &resp,
> + PROMPT_RETYPE_ARG, authtok_type) :
> + pam_prompt (pamh, PAM_PROMPT_ECHO_OFF, &resp,
> + "%s", PROMPT_RETYPE_NOARG);
> }
>
> if (retval != PAM_SUCCESS || resp == NULL)
> diff --git a/po/Linux-PAM.pot b/po/Linux-PAM.pot
> index 914a679c..b40adea8 100644
> --- a/po/Linux-PAM.pot
> +++ b/po/Linux-PAM.pot
> @@ -8,7 +8,7 @@ msgid ""
> msgstr ""
> "Project-Id-Version: Linux-PAM 1.4.0\n"
> "Report-Msgid-Bugs-To:
http://sourceforge.net/projects/pam\n"
> -"POT-Creation-Date: 2020-03-03 10:51+0100\n"
> +"POT-Creation-Date: 2020-03-05 20:00+0000\n"
> "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
> "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
> "Language-Team: LANGUAGE <LL(a)li.org>\n"
> @@ -38,29 +38,41 @@ msgstr ""
>
> #: libpam/pam_get_authtok.c:41
> #, c-format
> -msgid "Current %s%spassword: "
> +msgid "Current %s password: "
> msgstr ""
>
> -#: libpam/pam_get_authtok.c:43
> +#: libpam/pam_get_authtok.c:42
> +msgid "Current password: "
> +msgstr ""
> +
> +#: libpam/pam_get_authtok.c:44
> #, c-format
> -msgid "New %s%spassword: "
> +msgid "New %s password: "
> msgstr ""
>
> #: libpam/pam_get_authtok.c:45
> +msgid "New password: "
> +msgstr ""
> +
> +#: libpam/pam_get_authtok.c:47
> #, c-format
> -msgid "Retype new %s%spassword: "
> +msgid "Retype new %s password: "
> +msgstr ""
> +
> +#: libpam/pam_get_authtok.c:48
> +msgid "Retype new password: "
> msgstr ""
>
> -#: libpam/pam_get_authtok.c:46
> +#: libpam/pam_get_authtok.c:49
> msgid "Sorry, passwords do not match."
> msgstr ""
>
> -#: libpam/pam_get_authtok.c:139 libpam/pam_get_authtok.c:228
> +#: libpam/pam_get_authtok.c:142 libpam/pam_get_authtok.c:240
> #, c-format
> msgid "Retype %s"
> msgstr ""
>
> -#: libpam/pam_get_authtok.c:166 libpam/pam_get_authtok.c:244
> +#: libpam/pam_get_authtok.c:178 libpam/pam_get_authtok.c:258
> msgid "Password change has been aborted."
> msgstr ""
>
> --
> ldv
_______________________________________________
Pam-developers mailing list -- pam-developers(a)lists.fedorahosted.org
To unsubscribe send an email to
pam-developers-leave(a)lists.fedorahosted.org
Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives:
https://lists.fedorahosted.org/archives/list/pam-developers@lists.fedorah...
--
Tomáš Mráz
No matter how far down the wrong road you've gone, turn back.
Turkish proverb
[You'll know whether the road is wrong if you carefully listen to your
conscience.]