diff options
Diffstat (limited to 'modules/pam_echo/pam_echo.c')
-rw-r--r-- | modules/pam_echo/pam_echo.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/modules/pam_echo/pam_echo.c b/modules/pam_echo/pam_echo.c index 5a882028..d58f0ac6 100644 --- a/modules/pam_echo/pam_echo.c +++ b/modules/pam_echo/pam_echo.c @@ -47,10 +47,6 @@ #include <sys/types.h> #include <sys/stat.h> -#ifndef HOST_NAME_MAX -#define HOST_NAME_MAX 255 -#endif - #include <security/pam_modules.h> #include <security/pam_modutil.h> #include <security/_pam_macros.h> @@ -62,7 +58,7 @@ replace_and_print (pam_handle_t *pamh, const char *mesg) { char *output; size_t length = strlen (mesg) + PAM_MAX_MSG_SIZE; - char myhostname[HOST_NAME_MAX+1]; + char *myhostname = NULL; const void *str = NULL; const char *p, *q; int item; @@ -108,10 +104,8 @@ replace_and_print (pam_handle_t *pamh, const char *mesg) } if (item == -2) { - if (gethostname (myhostname, sizeof (myhostname)) == -1) - str = NULL; - else - str = &myhostname; + myhostname = xgethostname(); + str = myhostname; } else { @@ -128,6 +122,8 @@ replace_and_print (pam_handle_t *pamh, const char *mesg) pam_info (pamh, "%s", output); free (output); + if (myhostname) { free(myhostname); } + return PAM_SUCCESS; } |