diff options
-rw-r--r-- | source3/include/includes.h | 4 | ||||
-rw-r--r-- | source3/lib/replace.c | 18 | ||||
-rw-r--r-- | source3/nsswitch/winbindd.h | 14 | ||||
-rw-r--r-- | source3/nsswitch/winbindd_ads.c | 4 |
4 files changed, 23 insertions, 17 deletions
diff --git a/source3/include/includes.h b/source3/include/includes.h index bb78ae0780..731d94996c 100644 --- a/source3/include/includes.h +++ b/source3/include/includes.h @@ -966,6 +966,10 @@ size_t strnlen(const char *s, size_t n); unsigned long strtoul(const char *nptr, char **endptr, int base); #endif +#ifndef HAVE_SETENV +int setenv(const char *name, const char *value, int overwrite); +#endif + #if (defined(USE_SETRESUID) && !defined(HAVE_SETRESUID_DECL)) /* stupid glibc */ int setresuid(uid_t ruid, uid_t euid, uid_t suid); diff --git a/source3/lib/replace.c b/source3/lib/replace.c index cd48b8d160..0c62ec9bfa 100644 --- a/source3/lib/replace.c +++ b/source3/lib/replace.c @@ -447,3 +447,21 @@ char *rep_inet_ntoa(struct in_addr ip) return t; } #endif + +#ifndef HAVE_SETENV + int setenv(const char *name, const char *value, int overwrite) +{ + char *p = NULL; + int ret = -1; + + asprintf(&p, "%s=%s", name, value); + + if (overwrite || getenv(name)) { + if (p) ret = putenv(p); + } else { + ret = 0; + } + + return ret; +} +#endif diff --git a/source3/nsswitch/winbindd.h b/source3/nsswitch/winbindd.h index e8bcf76bd3..164b7ffda7 100644 --- a/source3/nsswitch/winbindd.h +++ b/source3/nsswitch/winbindd.h @@ -205,18 +205,4 @@ typedef struct { #define DOM_SEQUENCE_NONE ((uint32)-1) -/* SETENV */ -#if HAVE_SETENV -#define SETENV(name, value, overwrite) setenv(name,value,overwrite) -#elif HAVE_PUTENV -#define SETENV(name, value, overwrite) \ -{ \ - fstring envvar; \ - slprintf(envvar, sizeof(fstring), "%s=%s", name, value); \ - putenv(envvar); \ -} -#else -#define SETENV(name, value, overwrite) ; -#endif - #endif /* _WINBINDD_H */ diff --git a/source3/nsswitch/winbindd_ads.c b/source3/nsswitch/winbindd_ads.c index 7cea4aa716..be4ed1c667 100644 --- a/source3/nsswitch/winbindd_ads.c +++ b/source3/nsswitch/winbindd_ads.c @@ -46,9 +46,7 @@ static ADS_STRUCT *ads_cached_connection(struct winbindd_domain *domain) } /* we don't want this to affect the users ccache */ - ccache = lock_path("winbindd_ccache"); - SETENV("KRB5CCNAME", ccache, 1); - unlink(ccache); + setenv("KRB5CCNAME", "MEMORY:winbind_ccache", 1); ads = ads_init(domain->alt_name, domain->name, NULL); if (!ads) { |