summaryrefslogtreecommitdiff
path: root/source4/lib/replace/replace.c
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2007-03-12 09:59:06 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:49:27 -0500
commit544a2d30e01b5f4f9849c9aa631e0525062c2707 (patch)
treebad5bc3e6465af5b78a22cf382388b4420b04fc9 /source4/lib/replace/replace.c
parent9b921af12e6e26f0b0f4fa0341acfcddf68221e1 (diff)
downloadsamba-544a2d30e01b5f4f9849c9aa631e0525062c2707.tar.gz
samba-544a2d30e01b5f4f9849c9aa631e0525062c2707.tar.bz2
samba-544a2d30e01b5f4f9849c9aa631e0525062c2707.zip
r21793: add replacement for unsetenv()
metze (This used to be commit d6de7f2cda70cfd55f0f7fbb9f3b93a5a58c6f51)
Diffstat (limited to 'source4/lib/replace/replace.c')
-rw-r--r--source4/lib/replace/replace.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/source4/lib/replace/replace.c b/source4/lib/replace/replace.c
index 9e6c75bd35..486c1c5e13 100644
--- a/source4/lib/replace/replace.c
+++ b/source4/lib/replace/replace.c
@@ -590,6 +590,40 @@ int rep_setenv(const char *name, const char *value, int overwrite)
}
#endif
+#ifndef HAVE_UNSETENV
+int rep_unsetenv(const char *name)
+{
+ char *p;
+ size_t l1;
+ int ret;
+
+ if (!getenv(name)) {
+ return 0;
+ }
+
+ l1 = strlen(name);
+
+ p = malloc(l1+1);
+ if (p == NULL) {
+ return -1;
+ }
+ memcpy(p, name, l1);
+ p[l1] = 0;
+
+ /*
+ * use using "name" here unsets the var
+ *
+ * "name=" would set it to an empty string..
+ */
+ ret = putenv(p);
+ if (ret != 0) {
+ free(p);
+ }
+
+ return ret;
+}
+#endif
+
#ifndef HAVE_SOCKETPAIR
int rep_socketpair(int d, int type, int protocol, int sv[2])
{