summaryrefslogtreecommitdiffstats
path: root/lib/libc_r/uthread
diff options
context:
space:
mode:
authorkris <kris@FreeBSD.org>2002-10-13 11:23:31 +0000
committerkris <kris@FreeBSD.org>2002-10-13 11:23:31 +0000
commit12bba2e84c7f57d8cb64605026fd5a0e02b20332 (patch)
tree6db4f639bd8d6515e69da1eec36d8f68f1436eba /lib/libc_r/uthread
parent71c7a4a40e1ec3a79c70d9b7c71180fadc2ed309 (diff)
downloadFreeBSD-src-12bba2e84c7f57d8cb64605026fd5a0e02b20332.zip
FreeBSD-src-12bba2e84c7f57d8cb64605026fd5a0e02b20332.tar.gz
Dump in $TMPDIR if !setugid, and use mode 0644 instead of 0666.
MFC after: 2 weeks
Diffstat (limited to 'lib/libc_r/uthread')
-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 305a2b9..0193e04 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;
OpenPOWER on IntegriCloud