deliver.c (77349) | deliver.c (80785) |
---|---|
1/* 2 * Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers. 3 * All rights reserved. 4 * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. 5 * Copyright (c) 1988, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * By using this file, you agree to the terms and conditions set 9 * forth in the LICENSE file which can be found at the top level of 10 * the sendmail distribution. 11 * 12 */ 13 14#ifndef lint | 1/* 2 * Copyright (c) 1998-2001 Sendmail, Inc. and its suppliers. 3 * All rights reserved. 4 * Copyright (c) 1983, 1995-1997 Eric P. Allman. All rights reserved. 5 * Copyright (c) 1988, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * By using this file, you agree to the terms and conditions set 9 * forth in the LICENSE file which can be found at the top level of 10 * the sendmail distribution. 11 * 12 */ 13 14#ifndef lint |
15static char id[] = "@(#)$Id: deliver.c,v 8.600.2.1.2.81 2001/05/23 02:15:42 ca Exp $"; | 15static char id[] = "@(#)$Id: deliver.c,v 8.600.2.1.2.86 2001/07/20 21:52:55 gshapiro Exp $"; |
16#endif /* ! lint */ 17 18#include <sendmail.h> 19 20 21#if HASSETUSERCONTEXT 22# include <login_cap.h> 23#endif /* HASSETUSERCONTEXT */ --- 1898 unchanged lines hidden (view full) --- 1922 int i; 1923 int save_errno; 1924 int new_euid = NO_UID; 1925 int new_ruid = NO_UID; 1926 int new_gid = NO_GID; 1927 struct stat stb; 1928 extern int DtableSize; 1929 | 16#endif /* ! lint */ 17 18#include <sendmail.h> 19 20 21#if HASSETUSERCONTEXT 22# include <login_cap.h> 23#endif /* HASSETUSERCONTEXT */ --- 1898 unchanged lines hidden (view full) --- 1922 int i; 1923 int save_errno; 1924 int new_euid = NO_UID; 1925 int new_ruid = NO_UID; 1926 int new_gid = NO_GID; 1927 struct stat stb; 1928 extern int DtableSize; 1929 |
1930 /* clear the events to turn off SIGALRMs */ 1931 clear_events(); 1932 |
|
1930 /* Reset global flags */ 1931 RestartRequest = NULL; 1932 ShutdownRequest = NULL; 1933 PendingSignal = 0; 1934 1935 if (e->e_lockfp != NULL) 1936 (void) close(fileno(e->e_lockfp)); 1937 1938 /* child -- set up input & exec mailer */ | 1933 /* Reset global flags */ 1934 RestartRequest = NULL; 1935 ShutdownRequest = NULL; 1936 PendingSignal = 0; 1937 1938 if (e->e_lockfp != NULL) 1939 (void) close(fileno(e->e_lockfp)); 1940 1941 /* child -- set up input & exec mailer */ |
1939 (void) setsignal(SIGINT, SIG_IGN); | 1942 (void) setsignal(SIGALRM, sm_signal_noop); 1943 (void) setsignal(SIGCHLD, SIG_DFL); |
1940 (void) setsignal(SIGHUP, SIG_IGN); | 1944 (void) setsignal(SIGHUP, SIG_IGN); |
1945 (void) setsignal(SIGINT, SIG_IGN); |
|
1941 (void) setsignal(SIGTERM, SIG_DFL); | 1946 (void) setsignal(SIGTERM, SIG_DFL); |
1947# ifdef SIGUSR1 1948 (void) setsignal(SIGUSR1, sm_signal_noop); 1949# endif /* SIGUSR1 */ |
|
1942 1943 if (m != FileMailer || stat(tochain->q_user, &stb) < 0) 1944 stb.st_mode = 0; 1945 1946# if HASSETUSERCONTEXT 1947 /* 1948 ** Set user resources. 1949 */ --- 116 unchanged lines hidden (view full) --- 2066 syserr("openmailer: cannot chdir(/)"); 2067 exit(EX_TEMPFAIL); 2068 } 2069 } 2070 2071 /* reset user id */ 2072 endpwent(); 2073 if (bitnset(M_SPECIFIC_UID, m->m_flags)) | 1950 1951 if (m != FileMailer || stat(tochain->q_user, &stb) < 0) 1952 stb.st_mode = 0; 1953 1954# if HASSETUSERCONTEXT 1955 /* 1956 ** Set user resources. 1957 */ --- 116 unchanged lines hidden (view full) --- 2074 syserr("openmailer: cannot chdir(/)"); 2075 exit(EX_TEMPFAIL); 2076 } 2077 } 2078 2079 /* reset user id */ 2080 endpwent(); 2081 if (bitnset(M_SPECIFIC_UID, m->m_flags)) |
2082 { |
|
2074 new_euid = m->m_uid; | 2083 new_euid = m->m_uid; |
2084 2085 /* 2086 ** Undo the effects of the uid change in main 2087 ** for signal handling. The real uid may 2088 ** be used by mailer in adding a "From " 2089 ** line. 2090 */ 2091 2092 if (RealUid != 0 && RealUid != getuid()) 2093 new_ruid = RealUid; 2094 } |
|
2075 else if (bitset(S_ISUID, stb.st_mode)) 2076 new_ruid = stb.st_uid; 2077 else if (ctladdr != NULL && ctladdr->q_uid != 0) 2078 new_ruid = ctladdr->q_uid; 2079 else if (m->m_uid != 0) 2080 new_ruid = m->m_uid; 2081 else 2082 new_ruid = DefUid; 2083 if (new_euid != NO_UID) 2084 { 2085 if (RunAsUid != 0 && new_euid != RunAsUid) 2086 { 2087 /* Only root can change the uid */ 2088 syserr("openmailer: insufficient privileges to change uid"); 2089 exit(EX_TEMPFAIL); 2090 } 2091 2092 vendor_set_uid(new_euid); 2093# if MAILER_SETUID_METHOD == USE_SETEUID | 2095 else if (bitset(S_ISUID, stb.st_mode)) 2096 new_ruid = stb.st_uid; 2097 else if (ctladdr != NULL && ctladdr->q_uid != 0) 2098 new_ruid = ctladdr->q_uid; 2099 else if (m->m_uid != 0) 2100 new_ruid = m->m_uid; 2101 else 2102 new_ruid = DefUid; 2103 if (new_euid != NO_UID) 2104 { 2105 if (RunAsUid != 0 && new_euid != RunAsUid) 2106 { 2107 /* Only root can change the uid */ 2108 syserr("openmailer: insufficient privileges to change uid"); 2109 exit(EX_TEMPFAIL); 2110 } 2111 2112 vendor_set_uid(new_euid); 2113# if MAILER_SETUID_METHOD == USE_SETEUID |
2114# if HASSETREUID 2115 /* 2116 ** Undo the effects of the uid change in main 2117 ** for signal handling. The real uid may 2118 ** be used by mailer in adding a "From " 2119 ** line. 2120 */ 2121 2122 if (new_ruid != NO_UID && 2123 setreuid(RealUid, geteuid()) < 0) 2124 { 2125 syserr("openmailer: setreuid(%d, %d) failed", 2126 (int) new_ruid, (int) geteuid()); 2127 exit(EX_OSERR); 2128 } 2129# endif /* HASSETREUID */ |
|
2094 if (seteuid(new_euid) < 0 && suidwarn) 2095 { 2096 syserr("openmailer: seteuid(%ld) failed", 2097 (long) new_euid); 2098 exit(EX_TEMPFAIL); 2099 } 2100# endif /* MAILER_SETUID_METHOD == USE_SETEUID */ 2101# if MAILER_SETUID_METHOD == USE_SETREUID --- 938 unchanged lines hidden (view full) --- 3040** ENDMAILER -- Wait for mailer to terminate. 3041** 3042** We should never get fatal errors (e.g., segmentation 3043** violation), so we report those specially. For other 3044** errors, we choose a status message (into statmsg), 3045** and if it represents an error, we print it. 3046** 3047** Parameters: | 2130 if (seteuid(new_euid) < 0 && suidwarn) 2131 { 2132 syserr("openmailer: seteuid(%ld) failed", 2133 (long) new_euid); 2134 exit(EX_TEMPFAIL); 2135 } 2136# endif /* MAILER_SETUID_METHOD == USE_SETEUID */ 2137# if MAILER_SETUID_METHOD == USE_SETREUID --- 938 unchanged lines hidden (view full) --- 3076** ENDMAILER -- Wait for mailer to terminate. 3077** 3078** We should never get fatal errors (e.g., segmentation 3079** violation), so we report those specially. For other 3080** errors, we choose a status message (into statmsg), 3081** and if it represents an error, we print it. 3082** 3083** Parameters: |
3048** pid -- pid of mailer. | 3084** mci -- the mailer connection info. |
3049** e -- the current envelope. 3050** pv -- the parameter vector that invoked the mailer 3051** (for error messages). 3052** 3053** Returns: 3054** exit code of mailer. 3055** 3056** Side Effects: --- 1863 unchanged lines hidden (view full) --- 4920 } 4921 else 4922 { 4923 auto int rcode; 4924 4925 nmx = getmxrr(hp, mxhosts, mxprefs, TRUE, &rcode); 4926 if (nmx <= 0) 4927 { | 3085** e -- the current envelope. 3086** pv -- the parameter vector that invoked the mailer 3087** (for error messages). 3088** 3089** Returns: 3090** exit code of mailer. 3091** 3092** Side Effects: --- 1863 unchanged lines hidden (view full) --- 4956 } 4957 else 4958 { 4959 auto int rcode; 4960 4961 nmx = getmxrr(hp, mxhosts, mxprefs, TRUE, &rcode); 4962 if (nmx <= 0) 4963 { |
4964 int save_errno; |
|
4928 register MCI *mci; 4929 4930 /* update the connection info for this host */ | 4965 register MCI *mci; 4966 4967 /* update the connection info for this host */ |
4968 save_errno = errno; |
|
4931 mci = mci_get(hp, m); | 4969 mci = mci_get(hp, m); |
4932 mci->mci_errno = errno; | 4970 mci->mci_errno = save_errno; |
4933 mci->mci_herrno = h_errno; 4934 mci->mci_lastuse = now; 4935 if (rcode == EX_NOHOST) 4936 mci_setstat(mci, rcode, "5.1.2", 4937 "550 Host unknown"); 4938 else 4939 mci_setstat(mci, rcode, NULL, NULL); 4940 --- 396 unchanged lines hidden --- | 4971 mci->mci_herrno = h_errno; 4972 mci->mci_lastuse = now; 4973 if (rcode == EX_NOHOST) 4974 mci_setstat(mci, rcode, "5.1.2", 4975 "550 Host unknown"); 4976 else 4977 mci_setstat(mci, rcode, NULL, NULL); 4978 --- 396 unchanged lines hidden --- |