summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/smtp.c
AgeCommit message (Collapse)Author
2010-04-21Runner process is just a helper for queue, so tear down its imsgJacek Masiulaniec
channels to parent, mda, mta, lka, smtp, and control. This leaves just the channel to queue, which forwards imsgs on runner's behalf and redirects any replies back to it. OK gilles@
2010-04-21Remove unusable ifdef DEBUG code.Jacek Masiulaniec
2010-04-20Kill *2400* lines of code by abstracting common bits of the imsg handlers.Jacek Masiulaniec
2010-01-03Implement "log verbose" and "log brief" to enable or disable verbose debugCharles Longeau
logging on runtime. Based on claudio@'s work on ripd, ospfd, ospf6d, dvmrpd, ldpd, bgpd. With help/ideas/testing from gilles@ jacekm@ todd@ ok jacekm@
2009-12-14Set initial session limit so that IMSG_SMTP_ENQUEUE can be satisfied evenJacek Masiulaniec
in absence of all other real listening sockets. Spotted by todd@
2009-12-13Use safe fd limits in smtp, lka, queue, and control. Removes aJacek Masiulaniec
possibility for fd-starvation fatal when under heavy load.
2009-11-08- make aliases expansion use a rb tree instead of a tail queue, the codeGilles Chehade
doesn't take advantage of the new structure yet, but this was a needed change for upcoming improvements. - introduce aliasestree_{lookup,insert,remove} to the aliases api - rename queue_generate_id() to generate_uid() and move it to utils.c as it is used all over the place and not only in queue tree idea discussed with jacekm@, if you update rebuild aliases db, make clean and flush queue
2009-10-25tag should also be copied from listener to message when the message isGilles Chehade
enqueued through smtpctl
2009-09-18Remove useless Received line added at the /usr/sbin/sendmail stage, itJacek Masiulaniec
was not correctly formatted anyway. Recording of sender uid has been moved to the server process (getpeereid), which means it is not subject to forgery. Based on problem report by Michael Lechtermann <michael@lechtermann.net>
2009-09-03imsg_get sets errno so use fatal instead of fatalx.Jacek Masiulaniec
2009-08-06- change all occurences of T_DAEMON_BATCH,MESSAGE to T_BOUNCE_BATCH/MESSAGEGilles Chehade
- make sure T_BOUNCE_MESSAGE is no longer OR-ed to T_MDA/MTA_MESSAGE - define F_MESSAGE_BOUNCE flag and make sure bounce sessions set it - teach smtpctl show queue how to recognize a bounce message
2009-08-06This commit reworks the entire mailer daemon support to actually make itGilles Chehade
work for real. As an added bonus, it simplifies it, makes it follow the same code path as regular messages and kills quite some code from mta, mda and store. There's still some work needed but the most painful part is behind us now ;) ok jacekm@
2009-06-07Change the way fds passed over a socket are retreived on the receiving side.Eric Faurot
Currently the receiver fetches an imsg via imsg_get() and if he expects an fd, he then calls imsg_get_fd() to fetch the next fd queued on the imsgbuf from which the imsg came. This changes hides the fd queueing mechanism to the API user. When closing an imsg with an fd, the message is flagged so that the receiving end knows it must dequeue the fd in imsg_get() and return it with the imsg structure. This way there is no (less) possible screw up from imsg_get_fd() not being called directly after imsg_get() by the user. The retreived imsg is self-contained. ok pyr@, "I like that" henning@
2009-06-06Sync with relayd:Pierre-Yves Ritschard
Stop pushing event handling in the imsg framework. Instead, provide a small glue layer on top of both imsg and libevent. This finally clearly separates event handling and imsg construction. Sidetrack bonus: remove the mega-ugly hack of having a dummy imsg_event_add stub in smtpctl. ok jaceckm@
2009-06-05make smtpd's imsg lib ready, just like relayd and ospfd.Pierre-Yves Ritschard
ok gilles@, jacekm@
2009-06-02make env->sc_listeners and env->sc_ssl pointers, one step further towardGilles Chehade
configuration reloading without killing active sessions; ok jacekm@
2009-06-01Don't destroy listening socket when pause/resume request is received,Jacek Masiulaniec
use event_del/event_add instead; ok gilles@
2009-06-01Fix EV_READ/EV_WRITE testing inside IMSG handlers. Based on similar changeJacek Masiulaniec
to the routing daemons by claudio@; ok gilles@
2009-05-25merge smtp_listener_setup into its only caller; ok gilles@Jacek Masiulaniec
2009-05-24Parent process shouldn't be base64-decoding untrusted strings, moveJacek Masiulaniec
this code to privsep smtp process; ok gilles@
2009-05-24Parent process forks 3 types of processes, track them all in a single treeJacek Masiulaniec
using newly introduced child struct. Manage process titles centrally in struct smtpd. ok gilles@
2009-05-24Instead of keeping stats private to each process, and querying everyJacek Masiulaniec
process individually whenever stats need to be fetched, keep stats in MAP_ANON shared memory allocated by parent. This means control has direct access to stats and can respond very quickly without troubling any other daemon processes. ok gilles@
2009-05-20first step towards configuration reload in smtpd, smtpctl reload will parseGilles Chehade
the configuration file again and replace current configuration with new one in all processes. what we don't support yet is graceful restart, clients in sessions at the moment of the reload will have a temp failure thrown at 'em which is ok RFC-wise but which we will try to improve anyway. tested with various setups, "diff reads good" jacekm@
2009-05-19Verify the amount of IMSG payload is exactly as expected; ok gilles@Jacek Masiulaniec
2009-05-18Complete rework of bufferevent event masking allowing for moreJacek Masiulaniec
strictness: - Drop clients attempting command pipelining; protects the daemon from all kinds of abuse. - Replace F_EVLOCKED flag with F_WRITEONLY which has cleaner sematics: when up, session must not be destroyed nor read from, but may be written to. - Write callback becomes a central place for enabling EV_READ. - Delay bufferevent creation until after ssl handshake is completed. A bunch of session error stats were added to smtpctl's "show stats". These could help spotting event masking errors in the future. ok gilles@
2009-05-14use the nitems() macro where appropriateEric Faurot
ok gilles@, jacekm@
2009-05-10assert copyright; ok gilles@Jacek Masiulaniec
2009-05-09fix function names in log_debugJacek Masiulaniec
2009-05-09- New API to handle all DNS query types (A, MX, PTR) asynchronously.Jacek Masiulaniec
- Improve RFC compliance: CNAMEs are resolved, equal preference MXs are randomized, relaying via MX that has equal/lower preference than local server is prevented, decision on when to treat domain name as implicit MX is better. ok gilles@
2009-04-28fix a bug where client with unresolvable revdns is never greeted; ok gilles@Jacek Masiulaniec
2009-04-28make S_DATAREQUEST state similar to S_{MAIL,RCPT}REQUEST; ok gilles@Jacek Masiulaniec
2009-04-27fix unlikely fd leak; ok gilles@Jacek Masiulaniec
2009-04-24Enclose common imsg handling code in a function, which additionallyJacek Masiulaniec
does some sanity checking. Fix a bug that could lead to fatal under rare circumstances, exposed by this newly added check; ok gilles@
2009-04-24use same timeout at each session state, and make use ofJacek Masiulaniec
bufferevent_settimeout instead of rolling our own; ok gilles@
2009-04-21correct some fatal(x) calls and error stringsEric Faurot
ok gilles@ jacekm@
2009-04-20Rewrite smtp session timeouts; use evtimer_* from event(3) insteadJacek Masiulaniec
of regularly walking session tree in search of idle clients. Gives the smtp process a chance to become idle. As a bonus, add smtp.sessions.timeout counter to "smtpctl show stats". ok gilles@
2009-04-16Total rewrite of the sendmail interface. Adds support for -t, -v,Jacek Masiulaniec
and -F cmdline args. Also, date and Message-Id headers are added when missing. The main trouble with the current enqueue code is that it requires dealing with problems in the control process that are already solved in the smtp process, ie. duplicating a lot of code which interacts with untrusted clients. This diff solves this by making sendmail obtain a SMTP socket from smtp via smtpd.sock, and using that socket to deliver the message. For smtpd it looks as if connection was made from the network, only difference being the F_MESSAGE_ENQUEUED message flag, handy when differentation between local and remote deliveries is wanted. Most of the features come from the femail program, created by henning@. Additional testing by Nigel J. Taylor. ok gilles@, henning@ happy with smtpd using femail code
2009-04-09change syntax of the "listen on" and "relay via" directives:Jacek Masiulaniec
1) kill the ssmtp keyword in "ssmtp listen on ..."; 2) kill the use keyword in "... use certificate foo"; 3) tls no longer implicit, user must explicitely use the tls or smtps option. 4) for "relay via", move the tls/smtps options to right after the port specification; makes it similar to "listen on". These directives: ssmtp listen on fxp0 use ceritifate "foo" accept for all relay via tls "mx.bar.com" now become: listen on fxp0 smtps certificate "foo" accept for all relay via "mx.bar.com" tls ok gilles@
2009-03-29turn some log_debugs into log_warns or even fatals; "looks ok" gilles@Jacek Masiulaniec
2009-03-15since we are going to share code in smtp sessions and mta sessions, we needGilles Chehade
to also share the statistics structure, still being worked on
2009-03-15save 4 bytes per message by moving the datafp field of struct message toGilles Chehade
struct session where it really belongs.
2009-02-23add missing headers needed by time()Charles Longeau
ok jacekm@ gilles@
2009-02-22add missing headersCharles Longeau
ok gilles@
2009-02-22replace MAX* constants by sizeof where possibleOleg Safiullin
ok jacekm@
2009-02-18previous commit was incomplete, this fixes ssmtpGilles Chehade
2009-02-18smtp_accept() now requests from lka that it performs the hostname lookupGilles Chehade
and inserts the session into the session tree. session_init() is called only when we receive the resolution answer. this fixes a race condition that would sometimes cause the hostname to appear as "<unknown>" in headers just because dns was lagging, and it unbreaks ssmtp support which suffered from th very same race condition.
2009-02-17after a message has been commited to queue, do not incondtionnally clearGilles Chehade
the message id and uid immediately. only do it if session has been flagged with F_QUIT, otherwise session_pickup() will do it when in state S_DONE. this fixes a bug reported by pea@ where the message id was not displayed in the "message accepted for delivery" line.
2009-02-15New config.c that allows for process cloning. Done by pyr@ forJacek Masiulaniec
relayd at n2k9, and adapted to smtpd; ok gilles@
2009-01-30improve statistics for smtp process. not only collect the current sessionsGilles Chehade
count, but also the total sessions count, ssmtp sessions (both current and total) and starttls sessions (both current and total) # ./smtpctl/smtpctl show stats|grep smtp.sessions smtp.sessions = 0 smtp.sessions.active = 0 smtp.sessions.ssmtp = 0 smtp.sessions.ssmtp.active = 0 smtp.sessions.starttls = 0 smtp.sessions.starttls.active = 0 #
2009-01-30clear the F_EVLOCK flag earlier to prevent the error event handler fromGilles Chehade
being called again with F_EVLOCK set. this fixes a bug where disconnect after smtpd sends greeting and before entering any command failed to go into session_destroy(). while at it, rename the "smtp.clients" statistic to "smtp.sessions" and add counters to struct s_smtp so that I can add ssmtp and starttls with my next commit ;)