diff options
author | Damien Miller <djm@mindrot.org> | 1999-11-22 16:11:05 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 1999-11-22 16:11:05 +1100 |
commit | d770252d3a6dfe5e97d1a6846e2e5bfde92accc2 (patch) | |
tree | ae06bf36e1be1928026832da49c366a8b2d310ce | |
parent | d71b12ee5b6b0283ce41ff2d9c8864c6aadc6bbe (diff) |
- Added a setenv replacement for systems which lack it
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | helper.c | 21 | ||||
-rw-r--r-- | helper.h | 4 |
4 files changed, 27 insertions, 1 deletions
@@ -13,6 +13,7 @@ | |||
13 | - Fix EGD problems (Thanks to Ben Taylor <bent@clark.net>) | 13 | - Fix EGD problems (Thanks to Ben Taylor <bent@clark.net>) |
14 | - Retry /dev/urandom reads interrupted by signal (report from | 14 | - Retry /dev/urandom reads interrupted by signal (report from |
15 | Robert Hardy <rhardy@webcon.net>) | 15 | Robert Hardy <rhardy@webcon.net>) |
16 | - Added a setenv replacement for systems which lack it | ||
16 | 17 | ||
17 | 19991121 | 18 | 19991121 |
18 | - OpenBSD CVS Changes: | 19 | - OpenBSD CVS Changes: |
diff --git a/configure.in b/configure.in index 0678fa4c8..a831b9210 100644 --- a/configure.in +++ b/configure.in | |||
@@ -58,7 +58,7 @@ dnl Checks for header files. | |||
58 | AC_CHECK_HEADERS(pty.h endian.h paths.h lastlog.h shadow.h netgroup.h maillock.h sys/select.h sys/time.h) | 58 | AC_CHECK_HEADERS(pty.h endian.h paths.h lastlog.h shadow.h netgroup.h maillock.h sys/select.h sys/time.h) |
59 | 59 | ||
60 | dnl Checks for library functions. | 60 | dnl Checks for library functions. |
61 | AC_CHECK_FUNCS(openpty strlcpy strlcat mkdtemp arc4random setproctitle setlogin) | 61 | AC_CHECK_FUNCS(openpty strlcpy strlcat mkdtemp arc4random setproctitle setlogin setenv) |
62 | 62 | ||
63 | AC_CHECK_FUNC(login, | 63 | AC_CHECK_FUNC(login, |
64 | [AC_DEFINE(HAVE_LOGIN)], | 64 | [AC_DEFINE(HAVE_LOGIN)], |
@@ -149,3 +149,24 @@ void setproctitle(const char *fmt, ...) | |||
149 | /* FIXME */ | 149 | /* FIXME */ |
150 | } | 150 | } |
151 | #endif /* !HAVE_SETPROCTITLE */ | 151 | #endif /* !HAVE_SETPROCTITLE */ |
152 | |||
153 | #ifndef HAVE_SETENV | ||
154 | int setenv(const char *name, const char *value, int overwrite) | ||
155 | { | ||
156 | char *env_string; | ||
157 | int result; | ||
158 | |||
159 | /* Don't overwrite existing env. var if overwrite is 0 */ | ||
160 | if (!overwrite && (getenv(name) != NULL)) | ||
161 | return(0); | ||
162 | |||
163 | env_string = xmalloc(strlen(name) + strlen(value) + 2); | ||
164 | sprintf(env_string, "%s=%s", name, value); | ||
165 | |||
166 | result = putenv(env_string); | ||
167 | |||
168 | xfree(env_string); | ||
169 | |||
170 | return(result); | ||
171 | } | ||
172 | #endif /* !HAVE_SETENV */ | ||
@@ -47,4 +47,8 @@ void arc4random_stir(void); | |||
47 | void setproctitle(const char *fmt, ...); | 47 | void setproctitle(const char *fmt, ...); |
48 | #endif /* !HAVE_SETPROCTITLE */ | 48 | #endif /* !HAVE_SETPROCTITLE */ |
49 | 49 | ||
50 | #ifndef HAVE_SETENV | ||
51 | int setenv(const char *name, const char *value, int overwrite); | ||
52 | #endif /* !HAVE_SETENV */ | ||
53 | |||
50 | #endif /* _HELPER_H */ | 54 | #endif /* _HELPER_H */ |