Posted on 2012-05-30 15:32
Milo的海域 阅读(408)
评论(0) 编辑 收藏 所属分类:
MySQL 、
Linux 、
Skills
In many cases, binaries can no longer dump core after calling setuid().
Under Linux it is possible to re-enable this with a system call.
e.g.
+#ifdef __linux__
+#include <sys/prctl.h>
+#endif
+
#ifdef HAVE_purify
#define IF_PURIFY(A,B) (A)
#else
@@ -1362,6 +1366,10 @@
sql_perror("setuid");
unireg_abort(1);
}
+#ifdef __linux__
+ /* inform kernel that process is dumpable */
+ prctl(PR_SET_DUMPABLE,1,0,0,0);
+#endif /* __linux__ */
#endif
Manual of prctl
PR_SET_DUMPABLE
(Since Linux 2.4) Set the state of the flag determining whether core dumps are produced for this process upon delivery of a
signal whose default behaviour is to produce a core dump. (Normally this flag is set for a process by default, but it is
cleared when a set-user-ID or set-group-ID program is executed and also by various system calls that manipulate process UIDs
and GIDs). In kernels up to and including 2.6.12, arg2 must be either 0 (process is not dumpable) or 1 (process is dumpable).
Since kernel 2.6.13, the value 2 is also permitted; this causes any binary which normally would not be dumped to be dumped
readable by root only. (See also the description of /proc/sys/fs/suid_dumpable in proc(5).)
Ref: http://bugs.mysql.com/bug.php?id=21723
Some files about linux core dump:
/proc/sys/fs/suid_dumpable
/etc/profile
/etc/security/limits.conf
/proc/sys/kernel/core_pattern