aboutsummaryrefslogtreecommitdiff
path: root/modules/pam_mkhomedir/mkhomedir_helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'modules/pam_mkhomedir/mkhomedir_helper.c')
-rw-r--r--modules/pam_mkhomedir/mkhomedir_helper.c47
1 files changed, 8 insertions, 39 deletions
diff --git a/modules/pam_mkhomedir/mkhomedir_helper.c b/modules/pam_mkhomedir/mkhomedir_helper.c
index eefb5999..3b8ea454 100644
--- a/modules/pam_mkhomedir/mkhomedir_helper.c
+++ b/modules/pam_mkhomedir/mkhomedir_helper.c
@@ -9,6 +9,7 @@
*/
#include "config.h"
+#include "pam_inline.h"
#include <stdarg.h>
#include <sys/types.h>
@@ -121,38 +122,11 @@ copy_entry(struct dir_spec *parent, const struct passwd *pwd, mode_t dir_mode,
/* If it's a symlink, create a new link. */
if (S_ISLNK(st.st_mode))
{
- int pointedlen = 0;
-#ifndef PATH_MAX
- char *pointed = NULL;
- {
- int size = 100;
-
- while (1)
- {
- pointed = malloc(size);
- if (pointed == NULL)
- {
- retval = PAM_BUF_ERR;
- goto go_out;
- }
- pointedlen = readlink(newsource, pointed, size);
- if (pointedlen < 0) break;
- if (pointedlen < size) break;
- free(pointed);
- size *= 2;
- }
- }
- if (pointedlen < 0)
- free(pointed);
- else
- pointed[pointedlen] = 0;
-#else
- char pointed[PATH_MAX] = {};
+ char *pointed;
- pointedlen = readlink(newsource, pointed, sizeof(pointed) - 1);
-#endif
+ pointed = xreadlink(newsource);
- if (pointedlen >= 0)
+ if (pointed)
{
if (symlinkat(pointed, parent->fd, dent->d_name) != 0)
{
@@ -161,9 +135,8 @@ copy_entry(struct dir_spec *parent, const struct passwd *pwd, mode_t dir_mode,
if (retval != PAM_SUCCESS)
pam_syslog(NULL, LOG_DEBUG, "unable to create link %s/%s: %m",
parent->path, dent->d_name);
-#ifndef PATH_MAX
- free(pointed);
-#endif
+
+ free(pointed);
goto go_out;
}
@@ -173,15 +146,11 @@ copy_entry(struct dir_spec *parent, const struct passwd *pwd, mode_t dir_mode,
pam_syslog(NULL, LOG_DEBUG,
"unable to change perms on link %s/%s: %m",
parent->path, dent->d_name);
-#ifndef PATH_MAX
- free(pointed);
-#endif
retval = PAM_PERM_DENIED;
+ free(pointed);
goto go_out;
}
-#ifndef PATH_MAX
- free(pointed);
-#endif
+ free(pointed);
}
retval = PAM_SUCCESS;
goto go_out;