aboutsummaryrefslogtreecommitdiff
path: root/lib/libc_r
diff options
context:
space:
mode:
authorKris Kennaway <kris@FreeBSD.org>2002-10-13 11:23:31 +0000
committerKris Kennaway <kris@FreeBSD.org>2002-10-13 11:23:31 +0000
commit56373a5196b5b5da3caeb22b1147f0c933785dcd (patch)
tree6db4f639bd8d6515e69da1eec36d8f68f1436eba /lib/libc_r
parent61bdf123c30ff94346dc23eb6bc241997efc21d6 (diff)
downloadsrc-56373a5196b5b5da3caeb22b1147f0c933785dcd.tar.gz
src-56373a5196b5b5da3caeb22b1147f0c933785dcd.zip
Dump in $TMPDIR if !setugid, and use mode 0644 instead of 0666.
MFC after: 2 weeks
Notes
Notes: svn path=/head/; revision=105038
Diffstat (limited to 'lib/libc_r')
-rw-r--r--lib/libc_r/uthread/uthread_info.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/libc_r/uthread/uthread_info.c b/lib/libc_r/uthread/uthread_info.c
index 305a2b980ece..0193e049c06b 100644
--- a/lib/libc_r/uthread/uthread_info.c
+++ b/lib/libc_r/uthread/uthread_info.c
@@ -31,13 +31,14 @@
*
* $FreeBSD$
*/
+#include <errno.h>
+#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
-#include <fcntl.h>
#include <string.h>
-#include <unistd.h>
+#include <paths.h>
#include <pthread.h>
-#include <errno.h>
+#include <unistd.h>
#include "pthread_private.h"
#ifndef NELEMENTS
@@ -85,15 +86,18 @@ _thread_dump_info(void)
int fd;
int i;
pthread_t pthread;
- char tmpfile[128];
+ char *tmpdir;
+ char tmpfile[PATH_MAX];
pq_list_t *pq_list;
+ if (issetugid() != 0 || (tmpdir = getenv("TMPDIR")) == NULL)
+ tmpdir = _PATH_TMP;
for (i = 0; i < 100000; i++) {
- snprintf(tmpfile, sizeof(tmpfile), "/tmp/uthread.dump.%u.%i",
- getpid(), i);
+ snprintf(tmpfile, sizeof(tmpfile), "%s/uthread.dump.%u.%i",
+ tmpdir, getpid(), i);
/* Open the dump file for append and create it if necessary: */
if ((fd = __sys_open(tmpfile, O_RDWR | O_CREAT | O_EXCL,
- 0666)) < 0) {
+ 0644)) < 0) {
/* Can't open the dump file. */
if (errno == EEXIST)
continue;