Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 317341 | Differences between
and this patch

Collapse All | Expand All

(-)a/configure.ac (-1 / +17 lines)
Lines 74-79 AC_CHECK_HEADERS_ONCE([ \ Link Here
74
	execinfo.h \
74
	execinfo.h \
75
	fcntl.h \
75
	fcntl.h \
76
	grp.h \
76
	grp.h \
77
	kvm.h \
77
	libgen.h \
78
	libgen.h \
78
	limits.h \
79
	limits.h \
79
	memory.h \
80
	memory.h \
Lines 101-110 AC_CHECK_HEADERS_ONCE([ \ Link Here
101
	sys/syscall.h \
102
	sys/syscall.h \
102
	sys/time.h \
103
	sys/time.h \
103
	sys/types.h \
104
	sys/types.h \
105
	sys/sysctl.h \
104
	sys/user.h \
106
	sys/user.h \
105
	sys/wait.h \
107
	sys/wait.h \
106
	asm/ptrace.h \
108
	asm/ptrace.h \
107
	linux/ptrace.h \
109
	linux/ptrace.h \
110
	machine/reg.h \
108
])
111
])
109
112
110
dnl Checks for typedefs, structures, and compiler characteristics.
113
dnl Checks for typedefs, structures, and compiler characteristics.
Lines 119-125 AC_CHECK_TYPES([sighandler_t, sig_t, __sighandler_t],,,[#include <signal.h>]) Link Here
119
122
120
save_CPPFLAGS=$CPPFLAGS
123
save_CPPFLAGS=$CPPFLAGS
121
CPPFLAGS="-I$srcdir $CPPFLAGS"
124
CPPFLAGS="-I$srcdir $CPPFLAGS"
122
AC_CHECK_TYPES([struct user_regs_struct, struct pt_regs],,,[#include "headers.h"])
125
AC_CHECK_TYPES([struct user_regs_struct, struct pt_regs, struct reg],,,[#include "headers.h"])
123
CPPFLAGS=$save_CPPFLAGS
126
CPPFLAGS=$save_CPPFLAGS
124
127
125
dnl Checks for library functions.
128
dnl Checks for library functions.
Lines 180-185 AC_CHECK_LIB([sigsegv], [stackoverflow_install_handler], Link Here
180
	[HAVE_LIBSIGSEGV=false])
183
	[HAVE_LIBSIGSEGV=false])
181
AM_CONDITIONAL(HAVE_LIBSIGSEGV, $HAVE_LIBSIGSEGV)
184
AM_CONDITIONAL(HAVE_LIBSIGSEGV, $HAVE_LIBSIGSEGV)
182
185
186
have_libkvm="no"
187
AC_CHECK_LIB([kvm], [kvm_open],
188
	[have_libkvm="yes"],
189
	[have_libkvm="no"])
190
LIBKVM=""
191
if test "x$have_libkvm" = xyes ; then
192
	AC_DEFINE([HAVE_LIBKVM], [1], [libkvm is available])
193
	LIBKVM=-lkvm
194
else
195
	AC_DEFINE([HAVE_LIBKVM], [0], [libkvm is not available])
196
fi
197
AC_SUBST(LIBKVM)
198
183
dnl Check for gcc atomic primitives
199
dnl Check for gcc atomic primitives
184
AC_MSG_CHECKING([for __sync_lock_test_and_set])
200
AC_MSG_CHECKING([for __sync_lock_test_and_set])
185
sltas=no
201
sltas=no
(-)a/headers.h (+9 lines)
Lines 32-37 Link Here
32
#ifdef HAVE_GRP_H
32
#ifdef HAVE_GRP_H
33
# include <grp.h>
33
# include <grp.h>
34
#endif
34
#endif
35
#ifdef HAVE_KVM_H
36
# include <kvm.h>
37
#endif
35
#ifdef HAVE_LIBGEN_H
38
#ifdef HAVE_LIBGEN_H
36
# include <libgen.h>
39
# include <libgen.h>
37
#endif
40
#endif
Lines 107-112 Link Here
107
#ifdef HAVE_SYS_SYSCALL_H
110
#ifdef HAVE_SYS_SYSCALL_H
108
# include <sys/syscall.h>
111
# include <sys/syscall.h>
109
#endif
112
#endif
113
#ifdef HAVE_SYS_SYSCTL_H
114
# include <sys/sysctl.h>
115
#endif
110
#ifdef HAVE_SYS_TIME_H
116
#ifdef HAVE_SYS_TIME_H
111
# include <sys/time.h>
117
# include <sys/time.h>
112
#endif
118
#endif
Lines 119-124 Link Here
119
#ifdef HAVE_SYS_WAIT_H
125
#ifdef HAVE_SYS_WAIT_H
120
# include <sys/wait.h>
126
# include <sys/wait.h>
121
#endif
127
#endif
128
#ifdef HAVE_MACHINE_REG_H
129
# include <machine/reg.h>
130
#endif
122
131
123
#ifdef __ia64__ /* what a pos */
132
#ifdef __ia64__ /* what a pos */
124
# define ia64_fpreg FU_ia64_fpreg
133
# define ia64_fpreg FU_ia64_fpreg
(-)a/libsandbox/Makefile.am (-1 / +1 lines)
Lines 14-20 libsandbox_la_CFLAGS = $(CFLAG_EXCEPTIONS) Link Here
14
#	$(top_builddir)/libsbutil/libsbutil.la
14
#	$(top_builddir)/libsbutil/libsbutil.la
15
libsandbox_la_LIBSBLIB = $(top_builddir)/libsbutil/.libs/libsbutil.a
15
libsandbox_la_LIBSBLIB = $(top_builddir)/libsbutil/.libs/libsbutil.a
16
libsandbox_la_LIBADD = \
16
libsandbox_la_LIBADD = \
17
	-lc $(LIBDL) \
17
	-lc $(LIBDL) $(LIBKVM) \
18
	$(libsandbox_la_LIBSBLIB)
18
	$(libsandbox_la_LIBSBLIB)
19
# Do not add -nostdlib or -nostartfiles, as then our constructor
19
# Do not add -nostdlib or -nostartfiles, as then our constructor
20
# and destructor will not be executed ...
20
# and destructor will not be executed ...
(-)a/libsandbox/libsandbox.c (+39 lines)
Lines 124-129 static const char *sb_get_fd_dir(void) Link Here
124
#endif
124
#endif
125
}
125
}
126
126
127
#if !HAVE_LIBKVM
127
static const char *sb_get_cmdline(pid_t pid)
128
static const char *sb_get_cmdline(pid_t pid)
128
{
129
{
129
#if !defined(SANDBOX_PROC_1_CMDLINE) && !defined(SANDBOX_PROC_SELF_CMDLINE) && !defined(SANDBOX_PROC_dd_CMDLINE)
130
#if !defined(SANDBOX_PROC_1_CMDLINE) && !defined(SANDBOX_PROC_SELF_CMDLINE) && !defined(SANDBOX_PROC_dd_CMDLINE)
Lines 135-140 static const char *sb_get_cmdline(pid_t pid) Link Here
135
	sprintf(path, "/proc/%i/cmdline", pid);
136
	sprintf(path, "/proc/%i/cmdline", pid);
136
	return path;
137
	return path;
137
}
138
}
139
#else /* !HAVE_LIBKVM */
140
static char **sb_get_kvm_cmdline(pid_t pid)
141
{
142
	int cnt = 0;
143
	char** ret;
144
	kvm_t * kt = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL);
145
	struct kinfo_proc * proc = kvm_getprocs(kt, KERN_PROC_PID | KERN_PROC_ALL, ( pid ? pid : getpid() ), &cnt);
146
	ret = ( cnt > 0 ? kvm_getargv(kt, proc, 0) : NULL);
147
	kvm_close(kt);
148
	return ret;
149
}
150
#endif /* !HAVE_LIBKVM */
138
151
139
int canonicalize(const char *path, char *resolved_path)
152
int canonicalize(const char *path, char *resolved_path)
140
{
153
{
Lines 358-363 char *egetcwd(char *buf, size_t size) Link Here
358
	return tmpbuf;
371
	return tmpbuf;
359
}
372
}
360
373
374
#if !HAVE_LIBKVM
361
static int sb_copy_file_to_fd(const char *file, int ofd)
375
static int sb_copy_file_to_fd(const char *file, int ofd)
362
{
376
{
363
	int ret = -1;
377
	int ret = -1;
Lines 388-393 static int sb_copy_file_to_fd(const char *file, int ofd) Link Here
388
	free(buf);
402
	free(buf);
389
	return ret;
403
	return ret;
390
}
404
}
405
#endif /* !HAVE_LIBKVM */
391
406
392
void sb_dump_backtrace(void)
407
void sb_dump_backtrace(void)
393
{
408
{
Lines 397-406 void sb_dump_backtrace(void) Link Here
397
	num_funcs = backtrace(funcs, ARRAY_SIZE(funcs));
412
	num_funcs = backtrace(funcs, ARRAY_SIZE(funcs));
398
	backtrace_symbols_fd(funcs, num_funcs, STDERR_FILENO);
413
	backtrace_symbols_fd(funcs, num_funcs, STDERR_FILENO);
399
#endif
414
#endif
415
#if !HAVE_LIBKVM
400
	const char *cmdline = sb_get_cmdline(trace_pid);
416
	const char *cmdline = sb_get_cmdline(trace_pid);
401
	sb_printf("%s: ", cmdline);
417
	sb_printf("%s: ", cmdline);
402
	sb_copy_file_to_fd(cmdline, STDERR_FILENO);
418
	sb_copy_file_to_fd(cmdline, STDERR_FILENO);
403
	sb_printf("\n\n");
419
	sb_printf("\n\n");
420
#else  /* !HAVE_LIBKVM */
421
	char **cmdline = sb_get_kvm_cmdline(trace_pid);
422
	if(cmdline) {
423
		int i;
424
		for(i=0;cmdline[i];i++)	sb_printf("%s ", cmdline[i]);
425
		sb_printf("\n\n");
426
	}
427
	else
428
		sb_printf("libkvm: unable to get cmdline\n\n");
429
#endif /* !HAVE_LIBKVM */
404
}
430
}
405
431
406
__attribute__((noreturn))
432
__attribute__((noreturn))
Lines 492-502 static bool write_logfile(const char *logfile, const char *func, const char *pat Link Here
492
	_SB_WRITE_STR(rpath);
518
	_SB_WRITE_STR(rpath);
493
519
494
	_SB_WRITE_STR("\nC: ");
520
	_SB_WRITE_STR("\nC: ");
521
#if !HAVE_LIBKVM
495
	const char *cmdline = sb_get_cmdline(trace_pid);
522
	const char *cmdline = sb_get_cmdline(trace_pid);
496
	if (sb_copy_file_to_fd(cmdline, logfd)) {
523
	if (sb_copy_file_to_fd(cmdline, logfd)) {
497
		_SB_WRITE_STR("unable to read ");
524
		_SB_WRITE_STR("unable to read ");
498
		_SB_WRITE_STR(cmdline);
525
		_SB_WRITE_STR(cmdline);
499
	}
526
	}
527
#else /* !HAVE_LIBKVM */
528
	char **cmdline = sb_get_kvm_cmdline(trace_pid);
529
	if(cmdline) {
530
		int i;
531
		for(i=0;cmdline[i];i++){
532
			_SB_WRITE_STR(cmdline[i]);
533
			_SB_WRITE_STR(" ");
534
		}
535
	}
536
	else
537
		_SB_WRITE_STR("unable to get cmdline from libkvm");
538
#endif /* !HAVE_LIBKVM */
500
	_SB_WRITE_STR("\n");
539
	_SB_WRITE_STR("\n");
501
540
502
	return true;
541
	return true;
(-)a/localdecls.h (-1 / +2 lines)
Lines 67-72 typedef __sighandler_t sighandler_t; Link Here
67
typedef struct pt_regs trace_regs;
67
typedef struct pt_regs trace_regs;
68
#elif defined(HAVE_STRUCT_USER_REGS_STRUCT)
68
#elif defined(HAVE_STRUCT_USER_REGS_STRUCT)
69
typedef struct user_regs_struct trace_regs;
69
typedef struct user_regs_struct trace_regs;
70
#elif defined(HAVE_STRUCT_REG)
71
typedef struct reg trace_regs;
70
#else
72
#else
71
# error "unable to find struct for tracing regs"
73
# error "unable to find struct for tracing regs"
72
#endif
74
#endif
73
- 

Return to bug 317341