svn commit: samba r21793 - in
branches/SAMBA_4_0/source/lib/replace: .
metze at samba.org
metze at samba.org
Mon Mar 12 09:59:06 GMT 2007
Author: metze
Date: 2007-03-12 09:59:06 +0000 (Mon, 12 Mar 2007)
New Revision: 21793
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=21793
Log:
add replacement for unsetenv()
metze
Modified:
branches/SAMBA_4_0/source/lib/replace/README
branches/SAMBA_4_0/source/lib/replace/libreplace.m4
branches/SAMBA_4_0/source/lib/replace/replace.c
branches/SAMBA_4_0/source/lib/replace/replace.h
Changeset:
Modified: branches/SAMBA_4_0/source/lib/replace/README
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/README 2007-03-12 05:54:14 UTC (rev 21792)
+++ branches/SAMBA_4_0/source/lib/replace/README 2007-03-12 09:59:06 UTC (rev 21793)
@@ -21,6 +21,7 @@
vsyslog
timegm
setenv
+unsetenv
strndup
strnlen
waitpid
Modified: branches/SAMBA_4_0/source/lib/replace/libreplace.m4
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/libreplace.m4 2007-03-12 05:54:14 UTC (rev 21792)
+++ branches/SAMBA_4_0/source/lib/replace/libreplace.m4 2007-03-12 09:59:06 UTC (rev 21793)
@@ -263,7 +263,8 @@
AC_CHECK_TYPE(comparison_fn_t,
[AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])])
-AC_CHECK_FUNCS(strnlen setenv)
+AC_CHECK_FUNCS(setenv unsetenv)
+AC_CHECK_FUNCS(strnlen)
AC_CHECK_FUNCS(strtoull __strtoull strtouq strtoll __strtoll strtoq)
# this test disabled as we don't actually need __VA_ARGS__ yet
Modified: branches/SAMBA_4_0/source/lib/replace/replace.c
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/replace.c 2007-03-12 05:54:14 UTC (rev 21792)
+++ branches/SAMBA_4_0/source/lib/replace/replace.c 2007-03-12 09:59:06 UTC (rev 21793)
@@ -590,6 +590,40 @@
}
#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])
{
Modified: branches/SAMBA_4_0/source/lib/replace/replace.h
===================================================================
--- branches/SAMBA_4_0/source/lib/replace/replace.h 2007-03-12 05:54:14 UTC (rev 21792)
+++ branches/SAMBA_4_0/source/lib/replace/replace.h 2007-03-12 09:59:06 UTC (rev 21793)
@@ -140,6 +140,11 @@
int rep_setenv(const char *name, const char *value, int overwrite);
#endif
+#ifndef HAVE_UNSETENV
+#define unsetenv rep_unsetenv
+int rep_unsetenv(const char *name, const char *value, int overwrite);
+#endif
+
#ifndef HAVE_SETEUID
#define seteuid rep_seteuid
int rep_seteuid(uid_t);
More information about the samba-cvs
mailing list