author | xiao qing lu - Sun Microsystems - Beijing China <xiaoqing.lu@oracle.com> |
Tue, 12 Jul 2016 19:50:03 -0700 | |
changeset 6403 | 9d25dbe7eb71 |
parent 6156 | 693241cfaaaf |
permissions | -rw-r--r-- |
6156
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
1 |
# |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
2 |
# This patch is to make ssh-agent and sftp-server untraceable on Solaris |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
3 |
# without using the sgid bit. The OpenSSH upstream contains code for |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
4 |
# Linux to disable ptrace on these two programs. This patch provides the |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
5 |
# equivalent Solaris implementation. |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
6 |
# |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
7 |
# This Solaris-specific patch has been contributed back to OpenSSH upstream. |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
8 |
# For more information, see https://bugzilla.mindrot.org/show_bug.cgi?id=2584. |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
9 |
# In the future, if this is accepted by the upsteam in a later release, we will |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
10 |
# remove this patch when we upgrade to that release. |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
11 |
# |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
12 |
--- orig/config.h.in Mon Jun 6 19:22:23 2016 |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
13 |
+++ new/config.h.in Mon Jun 6 19:25:05 2016 |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
14 |
@@ -962,6 +962,9 @@ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
15 |
/* Define to 1 if you have the `setpcred' function. */ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
16 |
#undef HAVE_SETPCRED |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
17 |
|
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
18 |
+/* Define to 1 if you have the `setpflags' function. */ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
19 |
+#undef HAVE_SETPFLAGS |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
20 |
+ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
21 |
/* Define to 1 if you have the `setppriv' function. */ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
22 |
#undef HAVE_SETPPRIV |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
23 |
|
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
24 |
--- orig/configure.ac Mon Jun 6 16:03:27 2016 |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
25 |
+++ new/configure.ac Mon Jun 6 19:17:06 2016 |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
26 |
@@ -899,6 +899,8 @@ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
27 |
else |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
28 |
AC_MSG_RESULT([no]) |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
29 |
fi |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
30 |
+ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
31 |
+ AC_CHECK_FUNCS([setpflags]) |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
32 |
AC_CHECK_FUNCS([setppriv]) |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
33 |
AC_CHECK_FUNCS([priv_basicset]) |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
34 |
AC_CHECK_HEADERS([priv.h]) |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
35 |
--- orig/sftp-server.c Tue Jun 7 11:16:34 2016 |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
36 |
+++ new/sftp-server.c Tue Jun 7 16:48:09 2016 |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
37 |
@@ -32,6 +32,9 @@ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
38 |
#ifdef HAVE_SYS_PRCTL_H |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
39 |
#include <sys/prctl.h> |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
40 |
#endif |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
41 |
+#ifdef HAVE_PRIV_H |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
42 |
+#include <priv.h> /* For setpflags() and __PROC_PROTECT */ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
43 |
+#endif |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
44 |
|
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
45 |
#include <dirent.h> |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
46 |
#include <errno.h> |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
47 |
@@ -1588,6 +1591,11 @@ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
48 |
|
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
49 |
log_init(__progname, log_level, log_facility, log_stderr); |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
50 |
|
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
51 |
+#if defined(HAVE_SETPFLAGS) && defined(__PROC_PROTECT) |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
52 |
+ /* On Solaris, we should make this process untraceable */ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
53 |
+ if (setpflags(__PROC_PROTECT, 1) != 0) |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
54 |
+ fatal("unable to make the process untraceable"); |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
55 |
+#else |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
56 |
#if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE) |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
57 |
/* |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
58 |
* On Linux, we should try to avoid making /proc/self/{mem,maps} |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
59 |
@@ -1598,6 +1606,7 @@ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
60 |
if (prctl(PR_SET_DUMPABLE, 0) != 0) |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
61 |
fatal("unable to make the process undumpable"); |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
62 |
#endif /* defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE) */ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
63 |
+#endif |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
64 |
|
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
65 |
/* Drop any fine-grained privileges we don't need */ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
66 |
platform_pledge_sftp_server(); |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
67 |
--- orig/ssh-agent.c Mon Jun 6 19:04:38 2016 |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
68 |
+++ new/ssh-agent.c Tue Jun 7 12:18:11 2016 |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
69 |
@@ -92,6 +92,10 @@ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
70 |
#include <sys/prctl.h> /* For prctl() and PR_SET_DUMPABLE */ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
71 |
#endif |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
72 |
|
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
73 |
+#if defined(HAVE_PRIV_H) |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
74 |
+#include <priv.h> /* For setpflags() and __PROC_PROTECT */ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
75 |
+#endif |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
76 |
+ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
77 |
typedef enum { |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
78 |
AUTH_UNUSED, |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
79 |
AUTH_SOCKET, |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
80 |
@@ -1209,10 +1213,16 @@ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
81 |
setegid(getgid()); |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
82 |
setgid(getgid()); |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
83 |
|
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
84 |
+#if defined(HAVE_SETPFLAGS) && defined(__PROC_PROTECT) |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
85 |
+ /* make it untraceable on Solaris */ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
86 |
+ (void) setpflags(__PROC_PROTECT, 1); |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
87 |
+ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
88 |
+#else |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
89 |
#if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE) |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
90 |
/* Disable ptrace on Linux without sgid bit */ |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
91 |
prctl(PR_SET_DUMPABLE, 0); |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
92 |
#endif |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
93 |
+#endif |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
94 |
|
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
95 |
#ifdef ENABLE_OPENSSL_FIPS |
693241cfaaaf
23535037 ssh-agent should mark itself untraceable
Huie-Ying Lee <huieying.lee@oracle.com>
parents:
diff
changeset
|
96 |
fips_err = ssh_FIPS_mode_set_if_capable(); |