From 277b0c36c173c727ad49f154a661a51051a3e259 Mon Sep 17 00:00:00 2001 From: Ben Kibbey Date: Tue, 24 Feb 2009 19:42:15 -0500 Subject: [PATCH] Added PWMD_OPTION_PINENTRY_LC_CTYPE and PWMD_OPTION_PINENTRY_LC_MESSAGES. --- libpwmd.3.in | 16 +++++++++++++--- libpwmd.c | 46 ++++++++++++++++++++++++++++++++++++++-------- libpwmd.h.in | 5 +++++ types.h | 2 ++ 4 files changed, 58 insertions(+), 11 deletions(-) diff --git a/libpwmd.3.in b/libpwmd.3.in index 305da73a..48b0cd2e 100644 --- a/libpwmd.3.in +++ b/libpwmd.3.in @@ -15,7 +15,7 @@ \\$2 \(laURL: \\$1 \(ra\\$3 .. .if \n[.g] .mso www.tmac -.TH LIBPWMD 3 "23 Feb 2009" "Password Manager Daemon Library" "Password Manager Daemon Library" +.TH LIBPWMD 3 "24 Feb 2009" "Password Manager Daemon Library" "Password Manager Daemon Library" .SH NAME libpwmd \- pwmd client interface library @@ -132,6 +132,17 @@ The full path to the pinentry binary. Only useful when \fBpwmd_open_nb\fP() or \fBpwmd_save_nb\fP() are used. The next argument should be of type \fIchar *\fP. The default is \fI@pinentry@\fP. .TP +.B PWMD_OPTION_PINENTRY_LC_CTYPE +The value of this option is passed to the +.BR pinentry (1) +command line. The next argument should be of type \fIchar *\fP. + +.TP +.B PWMD_OPTION_PINENTRY_LC_MESSAGES +The value of this option is passed to the +.BR pinentry (1) +command line. The next argument should be of type \fIchar *\fP. +.TP .B PWMD_OPTION_PINENTRY Whether to use .BR pinentry (1) @@ -239,8 +250,7 @@ that utilize a server INQUIRE response (i.e., "STORE"), you must use \fBpwmd_inquire\fP() and not this function. .P .TP -.BI "gpg_error_t pwmd_command_ap(pwm_t *" pwm ", char **" result ", const char -*" fmt ", va_list " ap ");" +.BI "gpg_error_t pwmd_command_ap(pwm_t *" pwm ", char **" result ", const char *" fmt ", va_list " ap ");" Like \fBpwmd_command\fP() but takes a formatted argument list. .P .TP diff --git a/libpwmd.c b/libpwmd.c index 70bb963c..e0ca604e 100644 --- a/libpwmd.c +++ b/libpwmd.c @@ -198,6 +198,12 @@ void pwmd_close(pwm_t *pwm) if (pwm->pinentry_term) xfree(pwm->pinentry_term); + if (pwm->lcctype) + xfree(pwm->lcctype); + + if (pwm->lcmessages) + xfree(pwm->lcmessages); + if (pwm->filename) xfree(pwm->filename); @@ -577,7 +583,8 @@ static gpg_error_t launch_pinentry(pwm_t *pwm) assuan_context_t ctx; int child_list[] = {-1}; char *display = getenv("DISPLAY"); - const char *argv[6]; + const char *argv[10]; + const char **p = argv; int have_display = 0; char *tty = NULL; @@ -595,15 +602,26 @@ static gpg_error_t launch_pinentry(pwm_t *pwm) if (!have_display && !tty) return GPG_ERR_ENOTTY; - argv[0] = "pinentry"; - argv[1] = have_display ? "--display" : "--ttyname"; - argv[2] = have_display ? pwm->pinentry_display ? pwm->pinentry_display : display : tty; - argv[3] = NULL; + *p++ = "pinentry"; + *p++ = have_display ? "--display" : "--ttyname"; + *p++ = have_display ? pwm->pinentry_display ? pwm->pinentry_display : display : tty; + + if (pwm->lcctype) { + *p++ = "--lc-ctype"; + *p++ = pwm->lcctype; + } + + if (pwm->lcmessages) { + *p++ = "--lc-messages"; + *p++ = pwm->lcmessages; + } + + *p = NULL; if (!have_display) { - argv[3] = "--ttytype"; - argv[4] = pwm->pinentry_term ? pwm->pinentry_term : getenv("TERM"); - argv[5] = NULL; + *p++ = "--ttytype"; + *p++ = pwm->pinentry_term ? pwm->pinentry_term : getenv("TERM"); + *p = NULL; } rc = assuan_pipe_connect(&ctx, pwm->pinentry_path ? pwm->pinentry_path : PINENTRY_PATH, argv, child_list); @@ -1370,6 +1388,16 @@ gpg_error_t pwmd_setopt(pwm_t *pwm, pwmd_option_t opt, ...) xfree(pwm->desc); pwm->desc = percent_escape(va_arg(ap, char *)); break; + case PWMD_OPTION_PINENTRY_LC_CTYPE: + if (pwm->lcctype) + xfree(pwm->lcctype); + pwm->lcctype = xstrdup(va_arg(ap, char *)); + break; + case PWMD_OPTION_PINENTRY_LC_MESSAGES: + if (pwm->lcmessages) + xfree(pwm->lcmessages); + pwm->lcmessages = xstrdup(va_arg(ap, char *)); + break; #else case PWMD_OPTION_PINENTRY: case PWMD_OPTION_PINENTRY_TRIES: @@ -1380,6 +1408,8 @@ gpg_error_t pwmd_setopt(pwm_t *pwm, pwmd_option_t opt, ...) case PWMD_OPTION_PINENTRY_TITLE: case PWMD_OPTION_PINENTRY_PROMPT: case PWMD_OPTION_PINENTRY_DESC: + case PWMD_OPTION_PINENTRY_LC_CTYPE: + case PWMD_OPTION_PINENTRY_LC_MESSAGES: error = GPG_ERR_NOT_IMPLEMENTED; break; #endif diff --git a/libpwmd.h.in b/libpwmd.h.in index 7216f4d3..b4d5b598 100644 --- a/libpwmd.h.in +++ b/libpwmd.h.in @@ -192,6 +192,11 @@ typedef enum { PWMD_OPTION_PINENTRY_PROMPT, PWMD_OPTION_PINENTRY_DESC, + /* Internationalization: --lc-ctype and --lc-messages options to + * pinentry. */ + PWMD_OPTION_PINENTRY_LC_CTYPE, + PWMD_OPTION_PINENTRY_LC_MESSAGES, + /* * PWMD_OPTION_STATUS_FUNC * diff --git a/types.h b/types.h index f4cc3a8b..4ca1762f 100644 --- a/types.h +++ b/types.h @@ -38,6 +38,8 @@ struct pwm_s { char *pinentry_tty; char *pinentry_term; char *pinentry_display; + char *lcctype; + char *lcmessages; char *title; char *prompt; char *desc; -- 2.11.4.GIT