]> granicus.if.org Git - linux-pam/blobdiff - libpam_misc/help_env.c
Relevant BUGIDs:
[linux-pam] / libpam_misc / help_env.c
index 9f66156ed9ede446adce18801e46b3ef0b52b4ac..601c5f41c4af5461d496942a7349586a147e97b6 100644 (file)
@@ -5,28 +5,13 @@
  *
  */
 
+#include "config.h"
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <security/pam_misc.h>
 
-/*
- * This is a useful function for dumping the Linux-PAM environment
- * into some local memory, prior to it all getting lost when pam_end()
- * is called.
- *
- * Initially it was assumed that libpam did not do this part correctly
- * (based on a loose email definition).  The X/Open XSSO spec makes it
- * clear that this function is a duplicate of the one already in
- * libpam and therefore unnecessary.  IT WILL BE COMPLETELY REMOVED
- * IN libpam_misc 1.0 */
-
-char **pam_misc_copy_env(pam_handle_t *pamh);
-char **pam_misc_copy_env(pam_handle_t *pamh)
-{
-    return pam_getenvlist(pamh);
-}
-
 /*
  * This function should be used to carefully dispose of the copied
  * environment.
@@ -89,9 +74,7 @@ int pam_misc_setenv(pam_handle_t *pamh, const char *name
            return PAM_PERM_DENIED;          /* not allowed to overwrite */
        }
     }
-    tmp = malloc(2+strlen(name)+strlen(value));
-    if (tmp != NULL) {
-       sprintf(tmp,"%s=%s",name,value);
+    if (asprintf(&tmp, "%s=%s", name, value) >= 0) {
        D(("pam_putt()ing: %s", tmp));
        retval = pam_putenv(pamh, tmp);
        _pam_overwrite(tmp);                 /* purge */