Rip dosetenv()
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 3 Jun 2008 10:39:07 +0000 (13:39 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 3 Jun 2008 10:39:07 +0000 (13:39 +0300)
- just use regular setenv() instead
- we already carry setenv() in misc/ for platforms that don't have it

lib/misc.c
lib/misc.h
lib/signature.c

index 15d5a9d..d8e9679 100644 (file)
@@ -44,15 +44,3 @@ int doputenv(const char *str)
     return putenv(a);
 }
 
-int dosetenv(const char * name, const char * value, int overwrite)
-{
-    char * a;
-
-    if (!overwrite && getenv(name)) return 0;
-
-    /* FIXME: this leaks memory! */
-    a = xmalloc(strlen(name) + strlen(value) + sizeof("="));
-    (void) stpcpy( stpcpy( stpcpy( a, name), "="), value);
-    return putenv(a);
-}
-
index 049b2ca..574c468 100644 (file)
@@ -24,15 +24,6 @@ rpmRC rpmMkdirPath (const char * dpath, const char * dname);
 
 /**
  * Like the libc function, but malloc()'s the space needed.
- * @param name         variable name
- * @param value                variable value
- * @param overwrite    should an existing variable be changed?
- * @return             0 on success
- */
-int dosetenv(const char * name, const char * value, int overwrite);
-
-/**
- * Like the libc function, but malloc()'s the space needed.
  * @param str          "name=value" string
  * @return             0 on success
  */
index b3e7f42..c507b7c 100644 (file)
@@ -16,7 +16,6 @@
 #include <rpm/rpmts.h>
 
 #include "rpmio/digest.h"
-#include "lib/misc.h"  /* XXX for dosetenv() */
 #include "lib/rpmlead.h"
 #include "lib/signature.h"
 #include "lib/header_internal.h"
@@ -384,11 +383,11 @@ static int makePGPSignature(const char * file, rpmSigTag * sigTagp,
        (void) dup2(inpipe[0], 3);
        (void) close(inpipe[1]);
 
-       (void) dosetenv("PGPPASSFD", "3", 1);
+       (void) setenv("PGPPASSFD", "3", 1);
        if (pgp_path && *pgp_path != '\0')
-           (void) dosetenv("PGPPATH", pgp_path, 1);
+           (void) setenv("PGPPATH", pgp_path, 1);
 
-       /* dosetenv("PGPPASS", passPhrase, 1); */
+       /* setenv("PGPPASS", passPhrase, 1); */
 
        unsetenv("MALLOC_CHECK_");
        if ((path = rpmDetectPGPVersion(&pgpVer)) != NULL) {
@@ -520,8 +519,8 @@ static int makeGPGSignature(const char * file, rpmSigTag * sigTagp,
        (void) close(inpipe[1]);
 
        if (gpg_path && *gpg_path != '\0')
-           (void) dosetenv("GNUPGHOME", gpg_path, 1);
-       (void) dosetenv("LC_ALL", "C", 1);
+           (void) setenv("GNUPGHOME", gpg_path, 1);
+       (void) setenv("LC_ALL", "C", 1);
 
        unsetenv("MALLOC_CHECK_");
        cmd = rpmExpand("%{?__gpg_sign_cmd}", NULL);
@@ -845,7 +844,7 @@ static int checkPassPhrase(const char * passPhrase, const rpmSigTag sigTag)
        {   const char *gpg_path = rpmExpand("%{?_gpg_path}", NULL);
 
            if (gpg_path && *gpg_path != '\0')
-               (void) dosetenv("GNUPGHOME", gpg_path, 1);
+               (void) setenv("GNUPGHOME", gpg_path, 1);
 
            cmd = rpmExpand("%{?__gpg_check_password_cmd}", NULL);
            rc = poptParseArgvString(cmd, NULL, (const char ***)&av);
@@ -862,9 +861,9 @@ static int checkPassPhrase(const char * passPhrase, const rpmSigTag sigTag)
            const char *path;
            pgpVersion pgpVer;
 
-           (void) dosetenv("PGPPASSFD", "3", 1);
+           (void) setenv("PGPPASSFD", "3", 1);
            if (pgp_path && *pgp_path != '\0')
-               xx = dosetenv("PGPPATH", pgp_path, 1);
+               xx = setenv("PGPPATH", pgp_path, 1);
 
            if ((path = rpmDetectPGPVersion(&pgpVer)) != NULL) {
                switch(pgpVer) {