Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYaakov Selkowitz <yselkowi@redhat.com>2019-02-19 08:06:11 +0300
committerYaakov Selkowitz <yselkowi@redhat.com>2019-02-19 22:01:50 +0300
commit850705f92e3371bc0c56cee270327add84cd441a (patch)
treed6434ae5da8c354df7b4118579282e171d7f5e1d
parentdd415f1a8c0480303a38f8f4612430c201e967cc (diff)
Cygwin: add secure_getenv
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
-rw-r--r--newlib/libc/include/stdlib.h3
-rw-r--r--winsup/cygwin/common.din1
-rw-r--r--winsup/cygwin/environ.cc10
-rw-r--r--winsup/cygwin/include/cygwin/version.h3
-rw-r--r--winsup/doc/posix.xml1
5 files changed, 17 insertions, 1 deletions
diff --git a/newlib/libc/include/stdlib.h b/newlib/libc/include/stdlib.h
index 9773d3672..933d181e1 100644
--- a/newlib/libc/include/stdlib.h
+++ b/newlib/libc/include/stdlib.h
@@ -94,6 +94,9 @@ void exit (int __status) _ATTRIBUTE ((__noreturn__));
void free (void *) _NOTHROW;
char * getenv (const char *__string);
char * _getenv_r (struct _reent *, const char *__string);
+#if __GNU_VISIBLE
+char * secure_getenv (const char *__string);
+#endif
char * _findenv (const char *, int *);
char * _findenv_r (struct _reent *, const char *, int *);
#if __POSIX_VISIBLE >= 200809
diff --git a/winsup/cygwin/common.din b/winsup/cygwin/common.din
index f620d8183..68b95d470 100644
--- a/winsup/cygwin/common.din
+++ b/winsup/cygwin/common.din
@@ -1255,6 +1255,7 @@ sched_rr_get_interval SIGFE
sched_setparam SIGFE
sched_setscheduler SIGFE
sched_yield SIGFE
+secure_getenv NOSIGFE
seed48 NOSIGFE
seekdir SIGFE
select = cygwin_select SIGFE
diff --git a/winsup/cygwin/environ.cc b/winsup/cygwin/environ.cc
index 495c340a4..21f13734c 100644
--- a/winsup/cygwin/environ.cc
+++ b/winsup/cygwin/environ.cc
@@ -549,6 +549,16 @@ _getenv_r (struct _reent *, const char *name)
return findenv_func (name, &offset);
}
+/* Like getenv, but returns NULL if effective and real UID/GIDs do not match */
+extern "C" char *
+secure_getenv (const char *name)
+{
+ int offset;
+ if (cygheap->user.issetuid ())
+ return NULL;
+ return findenv_func (name, &offset);
+}
+
/* Return number of environment entries, including terminating NULL. */
static int __stdcall
envsize (const char * const *in_envp)
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index 2c55f4b79..d865f299d 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -508,12 +508,13 @@ details. */
335: Change size of utsname, change uname output.
336: New Cygwin PID algorithm (yeah, not really an API change)
337: MOUNT_BINARY -> MOUNT_TEXT
+ 338: Export secure_getenv.
Note that we forgot to bump the api for ualarm, strtoll, strtoull,
sigaltstack, sethostname. */
#define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 337
+#define CYGWIN_VERSION_API_MINOR 338
/* There is also a compatibity version number associated with the shared memory
regions. It is incremented when incompatible changes are made to the shared
diff --git a/winsup/doc/posix.xml b/winsup/doc/posix.xml
index 8e9b1a511..0755beda0 100644
--- a/winsup/doc/posix.xml
+++ b/winsup/doc/posix.xml
@@ -1377,6 +1377,7 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008).</para>
removexattr
scandirat
sched_getcpu
+ secure_getenv
setxattr
signalfd
sincos