summaryrefslogtreecommitdiffstats
path: root/ctdb/lib/replace/replace.c
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2007-05-02 07:32:04 +1000
committerAndrew Tridgell <tridge@samba.org>2007-05-02 07:32:04 +1000
commit169f12940462da90d6cdbbd1c8f170fa978d959a (patch)
treebb9a82c2e458f6149939720e9291f9e2b05985bd /ctdb/lib/replace/replace.c
parent3a05ad1402c20df868abb2aeb56a6d9e3be1f884 (diff)
downloadsamba-169f12940462da90d6cdbbd1c8f170fa978d959a.tar.gz
samba-169f12940462da90d6cdbbd1c8f170fa978d959a.tar.xz
samba-169f12940462da90d6cdbbd1c8f170fa978d959a.zip
merge latest versions of lib/replace, lib/talloc, lib/tdb and lib/events into ctdb bzr tree
(This used to be ctdb commit eaea8a9fa8d2f5e08f3af619fa1008a663f39053)
Diffstat (limited to 'ctdb/lib/replace/replace.c')
-rw-r--r--ctdb/lib/replace/replace.c53
1 files changed, 26 insertions, 27 deletions
diff --git a/ctdb/lib/replace/replace.c b/ctdb/lib/replace/replace.c
index 9e6c75bd358..db299130e51 100644
--- a/ctdb/lib/replace/replace.c
+++ b/ctdb/lib/replace/replace.c
@@ -154,33 +154,6 @@ time_t rep_mktime(struct tm *t)
#endif /* !HAVE_MKTIME */
-#ifndef HAVE_INNETGR
-#if defined(HAVE_SETNETGRENT) && defined(HAVE_GETNETGRENT) && defined(HAVE_ENDNETGRENT)
-/*
- * Search for a match in a netgroup. This replaces it on broken systems.
- */
-int rep_innetgr(const char *group, const char *host, const char *user,
- const char *dom)
-{
- char *hst, *usr, *dm;
-
- setnetgrent(group);
- while (getnetgrent(&hst, &usr, &dm)) {
- if (((host == 0) || (hst == 0) || !strcmp(host, hst)) &&
- ((user == 0) || (usr == 0) || !strcmp(user, usr)) &&
- ((dom == 0) || (dm == 0) || !strcmp(dom, dm))) {
- endnetgrent();
- return (1);
- }
- }
- endnetgrent();
- return (0);
-}
-#endif /* HAVE_SETNETGRENT HAVE_GETNETGRENT HAVE_ENDNETGRENT */
-#endif /* HAVE_INNETGR */
-
-
-
#ifndef HAVE_INITGROUPS
/****************************************************************************
some systems don't have an initgroups call
@@ -590,6 +563,32 @@ int rep_setenv(const char *name, const char *value, int overwrite)
}
#endif
+#ifndef HAVE_UNSETENV
+int rep_unsetenv(const char *name)
+{
+ extern char **environ;
+ size_t len = strlen(name);
+ size_t i;
+ int found = 0;
+
+ for (i=0; (environ && environ[i]); i++) {
+ if (found) {
+ environ[i-1] = environ[i];
+ continue;
+ }
+
+ if (strncmp(environ[i], name, len) == 0 && environ[i][len] == '=') {
+ free(environ[i]);
+ environ[i] = NULL;
+ found = 1;
+ continue;
+ }
+ }
+
+ return 0;
+}
+#endif
+
#ifndef HAVE_SOCKETPAIR
int rep_socketpair(int d, int type, int protocol, int sv[2])
{