diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2024-02-01 18:14:56 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2024-02-01 18:32:43 -0800 |
commit | 3672840c24e0826b7305d5143c95b2d070c57366 (patch) | |
tree | 7e4f3a135e337af951e70a5ba516993accb72769 | |
parent | bccb77746528134aa2e865ca4f44fd9424738b3f (diff) |
greeter: Handle const qualification differences between Solaris & Linux PAM
Solaris does not specify "const" on the first argument to PAM conversation
functions, nor the third argument to pam_get_item(). Linux PAM does both.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | greeter/greet.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/greeter/greet.c b/greeter/greet.c index bd1ed2b..36a9510 100644 --- a/greeter/greet.c +++ b/greeter/greet.c @@ -153,11 +153,16 @@ static XtAppContext context; static XtIntervalId pingTimeout; #ifdef USE_PAM -static int pamconv(int num_msg, -# ifndef sun - const -# endif - struct pam_message **msg, + +#ifdef __sun +/* Solaris does not const qualify arguments to pam_get_item() or the + PAM conversation function that Linux-PAM and others do. */ +# define XDM_PAM_QUAL /**/ +#else +# define XDM_PAM_QUAL const +#endif + +static int pamconv(int num_msg, XDM_PAM_QUAL struct pam_message **msg, struct pam_response **response, void *appdata_ptr); # define PAM_ERROR_PRINT(pamfunc, pamh) \ @@ -583,7 +588,8 @@ greet_user_rtn GreetUser( char *username = NULL; RUN_AND_CHECK_PAM_ERROR(pam_get_item, - (*pamhp, PAM_USER, (void *) &username)); + (*pamhp, PAM_USER, + (XDM_PAM_QUAL void **) &username)); if (username != NULL) { Debug("PAM_USER: %s\n", username); greet->name = username; @@ -603,12 +609,12 @@ greet_user_rtn GreetUser( break; } else { /* Try to fill in username for failed login error log */ - char *username = greet->name; + XDM_PAM_QUAL char *username = greet->name; if (username == NULL) { RUN_AND_CHECK_PAM_ERROR(pam_get_item, (*pamhp, PAM_USER, - (void *) &username)); + (XDM_PAM_QUAL void **) &username)); } FailedLogin (d, username); RUN_AND_CHECK_PAM_ERROR(pam_end, @@ -695,11 +701,7 @@ greet_user_rtn GreetUser( #ifdef USE_PAM -static int pamconv(int num_msg, -# ifndef sun - const -# endif - struct pam_message **msg, +static int pamconv(int num_msg, XDM_PAM_QUAL struct pam_message **msg, struct pam_response **response, void *appdata_ptr) { int i; @@ -730,12 +732,12 @@ static int pamconv(int num_msg, } for (i = 0; i < num_msg; i++ , m++ , r++) { - char *username; + XDM_PAM_QUAL char *username; int promptId = 0; loginPromptState pStyle = LOGIN_PROMPT_ECHO_OFF; - if ((pam_get_item(*pamhp, PAM_USER, (void *) &username) == PAM_SUCCESS) - && (username != NULL) && (*username != '\0')) { + if ((pam_get_item(*pamhp, PAM_USER, (XDM_PAM_QUAL void **) &username) + == PAM_SUCCESS) && (username != NULL) && (*username != '\0')) { SetPrompt(login, LOGIN_PROMPT_USERNAME, NULL, LOGIN_TEXT_INFO, False); SetValue(login, LOGIN_PROMPT_USERNAME, username); |