[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r5818 - in GNUnet: contrib src/include src/transports
From: |
gnunet |
Subject: |
[GNUnet-SVN] r5818 - in GNUnet: contrib src/include src/transports |
Date: |
Thu, 6 Dec 2007 20:49:15 -0700 (MST) |
Author: grothoff
Date: 2007-12-06 20:49:14 -0700 (Thu, 06 Dec 2007)
New Revision: 5818
Modified:
GNUnet/contrib/config-daemon.scm
GNUnet/contrib/dot-procmailrc
GNUnet/src/include/gnunet_transport.h
GNUnet/src/transports/smtp.c
Log:
making SMTP transport work again and fixing mantis 1142
Modified: GNUnet/contrib/config-daemon.scm
===================================================================
--- GNUnet/contrib/config-daemon.scm 2007-12-07 01:06:48 UTC (rev 5817)
+++ GNUnet/contrib/config-daemon.scm 2007-12-07 03:49:14 UTC (rev 5818)
@@ -203,6 +203,20 @@
'advanced) )
+(define (general-hosts builder)
+ (builder
+ "GNUNETD"
+ "HOSTS"
+ (_ "Name of the directory where gnunetd should store contact information
about peers")
+ (_
+"Unless you want to share the directory directly using a webserver, the
default is most likely just fine." )
+ '()
+ #t
+ "/var/lib/gnunet/data/hosts/"
+ '()
+ 'rare) )
+
+
;; logging options
(define (log-level description option builder)
@@ -255,6 +269,18 @@
'()
'rare) )
+(define (log-devel builder)
+ (builder
+ "LOGGING"
+ "DEVELOPER"
+ (_ "Enable for extra-verbose logging.")
+ (nohelp)
+ '()
+ #f
+ #f
+ #f
+ 'rare) )
+
(define (logging builder)
(builder
"LOGGING"
@@ -264,6 +290,7 @@
(list
(log-keeplog builder)
(log-logfile builder)
+ (log-devel builder)
(log-level (_ "Logging of events for users") "USER-LEVEL" builder)
(log-level (_ "Logging of events for the system administrator")
"ADMIN-LEVEL" builder)
)
@@ -325,8 +352,8 @@
Loading the 'nat' and 'tcp' modules is required for peers behind NAT boxes
that cannot directly be reached from the outside. Peers that are NOT behind a
NAT box and that want to *allow* peers that ARE behind a NAT box to connect
must ALSO load the 'nat' module. Note that the actual transfer will always be
via tcp initiated by the peer behind the NAT box. The nat transport requires
the use of tcp, http, smtp and/or tcp6 in addition to nat itself.")
'()
#t
- "udp tcp nat"
- (list "MC" "udp" "udp6" "tcp" "tcp6" "nat")
+ "udp tcp http nat"
+ (list "MC" "udp" "udp6" "tcp" "tcp6" "nat" "http" "smtp")
'always) )
@@ -514,6 +541,7 @@
(network-port builder)
(network-trusted builder)
(general-hostlisturl builder)
+ (general-hosts builder)
(general-http-proxy builder)
(f2f builder)
(fs-path builder)
@@ -855,6 +883,18 @@
(cons 0 65535)
'nat-unlimited))
+(define (http-upnp builder)
+ (builder
+ "HTTP"
+ "UPNP"
+ (_ "Should we try to determine our external IP using UPnP?")
+ (_ "You can use 'make check' in src/transports/upnp/ to find out if your NAT
supports UPnP. You should disable this option if you are sure that you are not
behind a NAT. If your NAT box does not support UPnP, having this on will not
do much harm (only cost a small amount of resources).")
+ '()
+ #t
+ #t
+ #f
+ 'http-port-nz))
+
(define (http-advertised-port builder)
(builder
"HTTP"
@@ -875,6 +915,8 @@
(nohelp)
(list
(http-port builder)
+ (http-advertised-port builder)
+ (http-upnp builder)
)
#t
#f
@@ -882,6 +924,90 @@
'http-loaded) )
+
+
+(define (smtp-mtu builder)
+ (builder
+ "SMTP"
+ "MTU"
+ (_ "What is the maximum transfer unit for SMTP?")
+ (nohelp)
+ '()
+ #t
+ 65528
+ (cons 1200 65528)
+ 'smtp-loaded))
+
+(define (smtp-email builder)
+ (builder
+ "SMTP"
+ "EMAIL"
+ (_ "Which e-mail address should be used to send e-mail to this peer?")
+ (_ "You must make sure that e-mail received at this address is forwarded to
the PIPE which is read by gnunetd. Use the FILTER option to filter e-mail with
procmail and the PIPE option to set the name of the pipe.")
+ '()
+ #t
+ "address@hidden"
+ '()
+ 'smtp-loaded))
+
+(define (smtp-filter builder)
+ (builder
+ "SMTP"
+ "FILTER"
+ (_ "Which header line should other peers include in e-mails to enable
filtering?")
+ (_ "You can specify a header line here which can then be used by procmail to
filter GNUnet e-mail from your inbox and forward it to gnunetd.")
+ '()
+ #t
+ "X-mailer: GNUnet"
+ '()
+ 'smtp-loaded))
+
+(define (smtp-pipe builder)
+ (builder
+ "SMTP"
+ "PIPE"
+ (_ "What is the filename of the pipe where gnunetd can read its e-mail?")
+ (_ "Have a look at contrib/dot-procmailrc for an example .procmailrc file.")
+ '()
+ #t
+ "/var/lib/gnunet/smtp-pipe"
+ '()
+ 'smtp-loaded))
+
+(define (smtp-server builder)
+ (builder
+ "SMTP"
+ "PIPE"
+ (_ "What is the name and port of the server for outgoing e-mail?")
+ (_ "The basic format is HOSTNAME:PORT.")
+ '()
+ #t
+ "localhost:25"
+ '()
+ 'smtp-loaded))
+
+(define (smtp builder)
+ (builder
+ "SMTP"
+ ""
+ (_ "SMTP transport")
+ (nohelp)
+ (list
+ (smtp-email builder)
+ (smtp-filter builder)
+ (smtp-pipe builder)
+ (smtp-server builder)
+ (smtp-mtu builder)
+ )
+ #t
+ #f
+ #f
+ 'smtp-loaded) )
+
+
+
+
+
(define (udp-port builder)
(builder
"UDP"
@@ -1131,6 +1257,7 @@
(udp builder)
(udp6 builder)
(http builder)
+ (smtp builder)
)
#t
#f
@@ -1328,6 +1455,7 @@
(f2f (string= (get-option ctx "MODULES" "topology") "topology_f2f") )
(tcp-port-nz (eq? (get-option ctx "TCP" "PORT") 0) )
(udp-port-nz (eq? (get-option ctx "UDP" "PORT") 0) )
+ (http-port-nz (eq? (get-option ctx "HTTP" "PORT") 0) )
(mysql (string= (get-option ctx "MODULES" "sqstore") "sqstore_mysql") )
(fs-loaded (list? (member "fs" (string-split (get-option ctx "GNUNETD"
"APPLICATIONS") #\ ) ) ) )
(nat-loaded (list? (member "nat" (string-split (get-option ctx "GNUNETD"
"TRANSPORTS") #\ ) ) ) )
@@ -1338,6 +1466,7 @@
(tcp6-loaded (list? (member "tcp6" (string-split (get-option ctx
"GNUNETD" "TRANSPORTS") #\ ) ) ) )
(udp6-loaded (list? (member "udp6" (string-split (get-option ctx
"GNUNETD" "TRANSPORTS") #\ ) ) ) )
(http-loaded (list? (member "http" (string-split (get-option ctx
"GNUNETD" "TRANSPORTS") #\ ) ) ) )
+ (smtp-loaded (list? (member "smtp" (string-split (get-option ctx
"GNUNETD" "TRANSPORTS") #\ ) ) ) )
)
(begin
(if (and nat-loaded nat-limited tcp-loaded)
Modified: GNUnet/contrib/dot-procmailrc
===================================================================
--- GNUnet/contrib/dot-procmailrc 2007-12-07 01:06:48 UTC (rev 5817)
+++ GNUnet/contrib/dot-procmailrc 2007-12-07 03:49:14 UTC (rev 5818)
@@ -2,18 +2,18 @@
# if you want to receive messages from the SMTP transport.
#
# If you want logging...
-# LOGFILE=/tmp/procmail-log
+LOGFILE=/tmp/procmail-log
# Set to yes when debugging
-VERBOSE=no
+VERBOSE=yes
# set to "all" if you want lots of output
-LOGABSTRACT=no
+LOGABSTRACT=all
-# replace "X-mailer: 590N" with the appropriate filter string from your
gnunet.conf file
+# replace "X-mailer: GNUnet" with the appropriate filter string from your
gnunet.conf file
:0:
-* ^X-mailer: 590N
-/tmp/gnunet.smtp
+* ^X-mailer: GNUnet
+/var/lib/gnunet/smtp-pipe
# where do you want your other e-mail delivered to
# (default: /var/spool/mail/$USER)
Modified: GNUnet/src/include/gnunet_transport.h
===================================================================
--- GNUnet/src/include/gnunet_transport.h 2007-12-07 01:06:48 UTC (rev
5817)
+++ GNUnet/src/include/gnunet_transport.h 2007-12-07 03:49:14 UTC (rev
5818)
@@ -373,7 +373,7 @@
* The type of inittransport_XXX is GNUNET_TransportMainMethod.
*/
typedef GNUNET_TransportAPI
- *(*GNUNET_TransportMainMethod) (GNUNET_CoreAPIForTransport *);
+ * (*GNUNET_TransportMainMethod) (GNUNET_CoreAPIForTransport *);
#if 0 /* keep Emacsens' auto-indent happy */
{
Modified: GNUnet/src/transports/smtp.c
===================================================================
--- GNUnet/src/transports/smtp.c 2007-12-07 01:06:48 UTC (rev 5817)
+++ GNUnet/src/transports/smtp.c 2007-12-07 03:49:14 UTC (rev 5818)
@@ -44,10 +44,6 @@
#define FILTER_STRING_SIZE 64
-#define CONTENT_TYPE_MULTIPART "Content-Type: Multipart/Mixed;"
-
-#define BOUNDARY_SPECIFIER "-EL-GNUNET-"
-
/* how long can a line in base64 encoded
mime text be? (in characters, excluding "\n") */
#define MAX_CHAR_PER_LINE 76
@@ -115,6 +111,8 @@
*/
static char *smtp_server_name;
+static char *pipename;
+
/**
* Lock for uses of libesmtp (not thread-safe).
*/
@@ -125,6 +123,8 @@
*/
static struct sigaction old_handler;
+static char *email;
+
static GNUNET_TransportAPI smtpAPI;
static GNUNET_Stats_ServiceAPI *stats;
@@ -158,6 +158,7 @@
unsigned int i;
char c;
unsigned int ret;
+ char *opt;
/* (*output)[ret++] = '\r'; \*/
#define CHECKLINE \
@@ -165,45 +166,50 @@
(*output)[ret++] = '\n'; \
}
ret = 0;
- *output = GNUNET_malloc ((((len * 4 / 3) + 8) * (MAX_CHAR_PER_LINE + 2)) /
- MAX_CHAR_PER_LINE);
+ opt = GNUNET_malloc (2 + (((len * 4 / 3) + 8) * (MAX_CHAR_PER_LINE + 2)) /
+ MAX_CHAR_PER_LINE);
+ /* message must start with \r\n for libesmtp */
+ *output = opt;
+ opt[0] = '\r';
+ opt[1] = '\n';
+ ret += 2;
for (i = 0; i < len; ++i)
{
c = (data[i] >> 2) & 0x3f;
- (*output)[ret++] = cvt[(int) c];
+ opt[ret++] = cvt[(int) c];
CHECKLINE;
c = (data[i] << 4) & 0x3f;
if (++i < len)
c |= (data[i] >> 4) & 0x0f;
- (*output)[ret++] = cvt[(int) c];
+ opt[ret++] = cvt[(int) c];
CHECKLINE;
if (i < len)
{
c = (data[i] << 2) & 0x3f;
if (++i < len)
c |= (data[i] >> 6) & 0x03;
- (*output)[ret++] = cvt[(int) c];
+ opt[ret++] = cvt[(int) c];
CHECKLINE;
}
else
{
++i;
- (*output)[ret++] = FILLCHAR;
+ opt[ret++] = FILLCHAR;
CHECKLINE;
}
if (i < len)
{
c = data[i] & 0x3f;
- (*output)[ret++] = cvt[(int) c];
+ opt[ret++] = cvt[(int) c];
CHECKLINE;
}
else
{
- (*output)[ret++] = FILLCHAR;
+ opt[ret++] = FILLCHAR;
CHECKLINE;
}
}
- (*output)[ret++] = FILLCHAR;
+ opt[ret++] = FILLCHAR;
return ret;
}
@@ -287,43 +293,33 @@
static void *
listenAndDistribute (void *unused)
{
- char *pipename;
char *line;
unsigned int linesize;
SMTPMessage *mp;
FILE *fdes;
char *retl;
- char *boundary;
char *out;
unsigned int size;
GNUNET_TransportPacket *coreMP;
int fd;
+ unsigned int pos;
- GNUNET_GC_get_configuration_value_filename (coreAPI->cfg,
- "SMTP",
- "PIPE",
-
GNUNET_DEFAULT_DAEMON_VAR_DIRECTORY
- "/smtp-pipe", &pipename);
- UNLINK (pipename);
- if (0 != mkfifo (pipename, S_IWUSR | S_IRUSR))
- GNUNET_GE_DIE_STRERROR (ectx,
- GNUNET_GE_ADMIN | GNUNET_GE_BULK |
- GNUNET_GE_FATAL, "mkfifo");
- linesize = ((smtpAPI.mtu * 4 / 3) + 8) * (MAX_CHAR_PER_LINE + 2) /
MAX_CHAR_PER_LINE; /* maximum size of a line supported */
+ linesize = ((GNUNET_MAX_BUFFER_SIZE * 4 / 3) + 8) * (MAX_CHAR_PER_LINE + 2)
/ MAX_CHAR_PER_LINE; /* maximum size of a line supported */
line = GNUNET_malloc (linesize + 2); /* 2 bytes for off-by-one errors, just
to be safe... */
#define READLINE(l,limit) \
- do { retl = fgets(l, limit, fdes); \
+ do { retl = fgets(l, (limit), fdes); \
if ( (retl == NULL) || (smtp_shutdown == GNUNET_YES)) {\
- goto END; \
+ goto END; \
}\
- GNUNET_network_monitor_notify_transmission(coreAPI->load_monitor,
GNUNET_ND_DOWNLOAD, strlen(retl)); \
+ if (coreAPI->load_monitor != NULL) \
+ GNUNET_network_monitor_notify_transmission(coreAPI->load_monitor,
GNUNET_ND_DOWNLOAD, strlen(retl)); \
} while (0)
while (smtp_shutdown == GNUNET_NO)
{
- fd = GNUNET_disk_file_open (ectx, pipename, O_RDONLY);
+ fd = OPEN (pipename, O_RDONLY | O_ASYNC);
if (fd == -1)
{
if (smtp_shutdown == GNUNET_NO)
@@ -333,42 +329,22 @@
fdes = fdopen (fd, "r");
while (smtp_shutdown == GNUNET_NO)
{
+ /* skip until end of header */
do
{
READLINE (line, linesize);
}
- while (0 != strAUTOncmp (line, CONTENT_TYPE_MULTIPART));
- READLINE (line, linesize);
- if (strlen (line) < strlen (" boundary=\""))
+ while ((line[0] != '\r') && (line[0] != '\n')); /* expect
newline */
+ READLINE (line, linesize); /* read base64 encoded message;
decode, process */
+ pos = 0;
+ while (1)
{
- goto END;
+ pos = strlen (line) - 1; /* ignore new line */
+ READLINE (&line[pos], linesize - pos); /* read base64 encoded
message; decode, process */
+ if ((line[pos] == '\r') || (line[pos] == '\n'))
+ break; /* empty line => end of message! */
}
- boundary = GNUNET_strdup (&line[strlen (" boundary=\"") - 2]);
- if (boundary[strlen (boundary) - 2] != '\"')
- {
- GNUNET_free (boundary);
- goto END; /* format error */
- }
- else
- {
- boundary[strlen (boundary) - 2] = '\0';
- boundary[0] = boundary[1] = '-';
- }
- do
- {
- READLINE (line, linesize);
- }
- while (0 != strAUTOncmp (line, boundary));
- do
- {
- READLINE (line, linesize); /* content type, etc. */
- }
- while (0 != strAUTOncmp (line, ""));
- READLINE (line, linesize); /* read base64 encoded message;
decode, process */
- while ((line[strlen (line) - 2] != FILLCHAR) &&
- (strlen (line) < linesize))
- READLINE (&line[strlen (line) - 1], linesize - strlen (line));
- size = base64_decode (line, strlen (line) - 1, &out);
+ size = base64_decode (line, pos, &out);
if (size < sizeof (SMTPMessage))
{
GNUNET_GE_BREAK (ectx, 0);
@@ -394,9 +370,9 @@
GNUNET_free (out);
goto END;
}
- if (stats != NULL)
- stats->change (stat_bytesReceived, size);
- coreMP = GNUNET_malloc (sizeof (GNUNET_TransportPacket));
+ if (stats != NULL)
+ stats->change (stat_bytesReceived, size);
+ coreMP = GNUNET_malloc (sizeof (GNUNET_TransportPacket));
coreMP->msg = out;
coreMP->size = size - sizeof (SMTPMessage);
coreMP->tsession = NULL;
@@ -408,7 +384,6 @@
#endif
coreAPI->receive (coreMP);
- READLINE (line, linesize); /* new line at the end */
}
END:
#if DEBUG_SMTP
@@ -419,9 +394,7 @@
if (fdes != NULL)
fclose (fdes);
}
- UNLINK (pipename);
- GNUNET_free (pipename);
-
+ GNUNET_free (line);
return NULL;
}
@@ -451,6 +424,8 @@
GNUNET_GE_BREAK (ectx, 0);
return GNUNET_SYSERR; /* obviously invalid */
}
+ if (NULL == strstr (maddr->filter, ": "))
+ return GNUNET_SYSERR;
return GNUNET_OK;
}
@@ -465,40 +440,22 @@
api_create_hello ()
{
GNUNET_MessageHello *msg;
- char *email;
char *filter;
EmailAddress *haddr;
int i;
- if (!GNUNET_GC_have_configuration_value (coreAPI->cfg, "SMTP", "EMAIL"))
+ GNUNET_GC_get_configuration_value_string (coreAPI->cfg,
+ "SMTP", "FILTER",
+ "X-mailer: GNUnet", &filter);
+ if (NULL == strstr (filter, ": "))
{
- static int once;
- if (once == 0)
- {
- GNUNET_GE_LOG (ectx,
- GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
- "No email-address specified, cannot create SMTP
advertisement.\n");
- once = 1;
- }
+ GNUNET_GE_LOG (ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_BULK | GNUNET_GE_USER,
+ _("SMTP filter string to invalid, lacks ': '\n"));
+ GNUNET_free (filter);
return NULL;
}
- if (!GNUNET_GC_have_configuration_value (coreAPI->cfg, "SMTP", "FILTER"))
- {
- static int once;
- if (once == 0)
- {
- GNUNET_GE_LOG (ectx,
- GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER,
- _
- ("No filter for E-mail specified, cannot create SMTP
advertisement.\n"));
- once = 1;
- }
- return NULL;
- }
- GNUNET_GC_get_configuration_value_string (coreAPI->cfg,
- "SMTP", "EMAIL", NULL, &email);
- GNUNET_GC_get_configuration_value_string (coreAPI->cfg,
- "SMTP", "FILTER", NULL, &filter);
+
if (strlen (filter) > FILTER_STRING_SIZE)
{
filter[FILTER_STRING_SIZE] = '\0';
@@ -519,9 +476,9 @@
msg->protocol = htons (GNUNET_TRANSPORT_PROTOCOL_NUMBER_SMTP);
msg->MTU = htonl (smtpAPI.mtu);
msg->header.size = htons (GNUNET_sizeof_hello (msg));
- GNUNET_free (email);
if (api_verify_hello (msg) == GNUNET_SYSERR)
GNUNET_GE_ASSERT (ectx, 0);
+ GNUNET_free (filter);
return msg;
}
@@ -565,6 +522,8 @@
const GNUNET_MessageHello *hello;
const EmailAddress *haddr;
char *m;
+ char *filter;
+ char *fvalue;
SMTPMessage *mp;
struct GetMessageClosure gm_cls;
smtp_session_t session;
@@ -608,6 +567,7 @@
GNUNET_mutex_unlock (lock);
return GNUNET_SYSERR;
}
+ haddr = (const EmailAddress *) &hello[1];
message = smtp_add_message (session);
if (message == NULL)
{
@@ -621,32 +581,28 @@
GNUNET_mutex_unlock (lock);
return GNUNET_SYSERR;
}
- haddr = (const EmailAddress *) &hello[1];
- recipient = smtp_add_recipient (message, haddr->senderAddress);
- if (recipient == NULL)
+ smtp_set_header (message, "To", NULL, haddr->senderAddress);
+ smtp_set_header (message, "From", NULL, email);
+
+ filter = GNUNET_strdup (haddr->filter);
+ fvalue = strstr (filter, ": ");
+ GNUNET_GE_ASSERT (NULL, NULL != fvalue);
+ fvalue[0] = '\0';
+ fvalue += 2;
+ if (0 == smtp_set_header (message, filter, fvalue))
{
GNUNET_GE_LOG (ectx,
GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
GNUNET_GE_BULK,
_("SMTP: `%s' failed: %s.\n"),
- "smtp_add_recipient",
- smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
- smtp_destroy_session (session);
- GNUNET_mutex_unlock (lock);
- return GNUNET_SYSERR;
- }
- if (0 == smtp_set_header (message, haddr->filter))
- {
- GNUNET_GE_LOG (ectx,
- GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
- GNUNET_GE_BULK,
- _("SMTP: `%s' failed: %s.\n"),
"smtp_set_header",
smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
smtp_destroy_session (session);
GNUNET_mutex_unlock (lock);
+ GNUNET_free (filter);
return GNUNET_SYSERR;
}
+ GNUNET_free (filter);
m = GNUNET_malloc (size + sizeof (SMTPMessage));
memcpy (m, msg, size);
mp = (SMTPMessage *) & m[size];
@@ -680,6 +636,21 @@
GNUNET_free (gm_cls.ebody);
return GNUNET_SYSERR;
}
+ recipient = smtp_add_recipient (message, haddr->senderAddress);
+ if (recipient == NULL)
+ {
+ GNUNET_GE_LOG (ectx,
+ GNUNET_GE_WARNING | GNUNET_GE_ADMIN | GNUNET_GE_USER |
+ GNUNET_GE_BULK,
+ _("SMTP: `%s' failed: %s.\n"),
+ "smtp_add_recipient",
+ smtp_strerror (smtp_errno (), ebuf, EBUF_LEN));
+ smtp_destroy_session (session);
+ GNUNET_mutex_unlock (lock);
+ return GNUNET_SYSERR;
+ }
+ /* smtp_set_resent_headers(message, 0); */
+ smtp_dsn_set_notify (recipient, Notify_NEVER);
if (0 == smtp_start_session (session))
{
GNUNET_GE_LOG (ectx,
@@ -694,9 +665,11 @@
return GNUNET_SYSERR;
}
if (stats != NULL)
- stats->change (stat_bytesSent, size);
- GNUNET_network_monitor_notify_transmission (coreAPI->load_monitor,
- GNUNET_ND_UPLOAD, gm_cls.esize);
+ stats->change (stat_bytesSent, size);
+ if (coreAPI->load_monitor != NULL)
+ GNUNET_network_monitor_notify_transmission (coreAPI->load_monitor,
+ GNUNET_ND_UPLOAD,
+ gm_cls.esize);
smtp_destroy_session (session);
GNUNET_mutex_unlock (lock);
GNUNET_free (gm_cls.ebody);
@@ -822,6 +795,14 @@
coreAPI = core;
ectx = core->ectx;
+ if (!GNUNET_GC_have_configuration_value (coreAPI->cfg, "SMTP", "EMAIL"))
+ {
+ GNUNET_GE_LOG (ectx,
+ GNUNET_GE_ERROR | GNUNET_GE_BULK | GNUNET_GE_USER,
+ _
+ ("No email-address specified, can not start SMTP
transport.\n"));
+ return NULL;
+ }
GNUNET_GC_get_configuration_value_number (coreAPI->cfg,
"SMTP",
"MTU",
@@ -837,6 +818,30 @@
stat_bytesDropped
= stats->create (gettext_noop ("# bytes dropped by SMTP (outgoing)"));
}
+ GNUNET_GC_get_configuration_value_filename (coreAPI->cfg,
+ "SMTP",
+ "PIPE",
+
GNUNET_DEFAULT_DAEMON_VAR_DIRECTORY
+ "/smtp-pipe", &pipename);
+ UNLINK (pipename);
+ if (0 != mkfifo (pipename, S_IWUSR | S_IRUSR | S_IWGRP | S_IWOTH))
+ {
+ GNUNET_GE_LOG_STRERROR (ectx,
+ GNUNET_GE_ADMIN | GNUNET_GE_BULK |
+ GNUNET_GE_FATAL, "mkfifo");
+ GNUNET_free (pipename);
+ coreAPI->releaseService (stats);
+ stats = NULL;
+ return NULL;
+ }
+ /* we need to allow the mailer program to send us messages;
+ easiest done by giving it write permissions (see Mantis #1142) */
+ if (0 != chmod (pipename, S_IWUSR | S_IRUSR | S_IWGRP | S_IWOTH))
+ GNUNET_GE_LOG_STRERROR (ectx,
+ GNUNET_GE_ADMIN | GNUNET_GE_BULK |
+ GNUNET_GE_WARNING, "chmod");
+ GNUNET_GC_get_configuration_value_string (coreAPI->cfg,
+ "SMTP", "EMAIL", NULL, &email);
lock = GNUNET_mutex_create (GNUNET_NO);
GNUNET_GC_get_configuration_value_string (coreAPI->cfg,
"SMTP",
@@ -847,6 +852,7 @@
sigemptyset (&sa.sa_mask);
sa.sa_flags = 0;
sigaction (SIGPIPE, &sa, &old_handler);
+
smtpAPI.protocolNumber = GNUNET_TRANSPORT_PROTOCOL_NUMBER_SMTP;
smtpAPI.mtu = mtu - sizeof (SMTPMessage);
smtpAPI.cost = 50;
@@ -875,6 +881,11 @@
}
GNUNET_mutex_destroy (lock);
lock = NULL;
+ UNLINK (pipename);
+ GNUNET_free (pipename);
+ pipename = NULL;
+ GNUNET_free (email);
+ email = NULL;
}
/* end of smtp.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r5818 - in GNUnet: contrib src/include src/transports,
gnunet <=