2 # This patch is the ProFTPD part of CR 28398194. The mod_solaris_priv.c
3 # makes the FTP session process privilege aware. As soon as
4 # solaris_priv_post_pass() calls setreuid() to make a process privilege
5 # aware, it sets 'session.disable_id_switching' to TRUE. Unfortunately
6 # it's not enough, because mod_auth_pam.c overrides .disable_id_switching to
7 # tell src/privs.c to operate as root. This is of course futile on Oracle
8 # Solaris and makes src/privs.c complain loudly. All details were submitted
10 # https://github.com/proftpd/proftpd/pull/732
12 # The other part of the fix updates mod_solaris_priv.c to set
13 # he priv_aware flag as soon as a session process is privilege aware.
15 # If the pull request is accepted, we can kill this patch
16 # as soon as we get fixed proftpd from upstream. There is no ETA.
18 --- a/include/proftpd.h
19 +++ b/include/proftpd.h
20 @@ -97,6 +97,9 @@ typedef struct {
23 int disable_id_switching; /* Disable UID/GID switching */
25 + int priv_aware; /* process posses all privs it needs */
26 +#endif /* SOLARIS2 */
27 uid_t uid, ouid; /* Current and original UIDs */
28 gid_t gid; /* Current GID */
30 diff --git a/src/privs.c b/src/privs.c
31 index 8a86947d8..7f18af07b 100644
34 @@ -185,7 +185,11 @@ int pr_privs_root(const char *file, int lineno) {
39 + if (!session.disable_id_switching && !session.priv_aware) {
41 if (!session.disable_id_switching) {
44 #if defined(HAVE_SETEUID)
45 if (seteuid(PR_ROOT_UID) < 0) {
46 @@ -247,7 +251,12 @@ int pr_privs_user(const char *file, int lineno) {
51 + if (!session.disable_id_switching && !session.priv_aware) {
53 if (!session.disable_id_switching) {
56 #if defined(HAVE_SETEUID)
57 if (seteuid(PR_ROOT_UID) < 0) {
58 int priority = (errno == EPERM ? PR_LOG_NOTICE : PR_LOG_ERR);
59 @@ -335,7 +344,12 @@ int pr_privs_relinquish(const char *file, int lineno) {
64 + if (!session.disable_id_switching && !session.priv_aware) {
66 if (!session.disable_id_switching) {
69 #if defined(HAVE_SETEUID)
70 if (geteuid() != PR_ROOT_UID) {
71 if (seteuid(PR_ROOT_UID) < 0) {