diff options
Diffstat (limited to 'modules/pam_echo')
-rw-r--r-- | modules/pam_echo/pam_echo.c | 14 | ||||
-rw-r--r-- | modules/pam_echo/tst-pam_echo-retval.c | 8 |
2 files changed, 11 insertions, 11 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; } diff --git a/modules/pam_echo/tst-pam_echo-retval.c b/modules/pam_echo/tst-pam_echo-retval.c index 8264cb0e..31432dc6 100644 --- a/modules/pam_echo/tst-pam_echo-retval.c +++ b/modules/pam_echo/tst-pam_echo-retval.c @@ -5,6 +5,7 @@ */ #include "test_assert.h" +#include "pam_inline.h" #include <limits.h> #include <stdio.h> @@ -24,9 +25,10 @@ main(void) { pam_handle_t *pamh = NULL; FILE *fp; - char cwd[PATH_MAX]; + char *cwd; - ASSERT_NE(NULL, getcwd(cwd, sizeof(cwd))); + cwd = xgetcwd(); + ASSERT_NE(NULL, cwd); /* PAM_SUCCESS -> PAM_SUCCESS, PAM_IGNORE -> PAM_PERM_DENIED */ ASSERT_NE(NULL, fp = fopen(service_file, "w")); @@ -97,5 +99,7 @@ main(void) ASSERT_EQ(0, unlink(service_file)); + free(cwd); + return 0; } |