summaryrefslogtreecommitdiffstats
path: root/imap/pop3dcapa.c
diff options
context:
space:
mode:
authorSam Varshavchik2013-08-19 16:39:41 -0400
committerSam Varshavchik2013-08-25 14:43:51 -0400
commit9c45d9ad13fdf439d44d7443ae75da15ea0223ed (patch)
tree7a81a04cb51efb078ee350859a64be2ebc6b8813 /imap/pop3dcapa.c
parenta9520698b770168d1f33d6301463bb70a19655ec (diff)
downloadcourier-libs-9c45d9ad13fdf439d44d7443ae75da15ea0223ed.tar.bz2
Initial checkin
Imported from subversion report, converted to git. Updated all paths in scripts and makefiles, reflecting the new directory hierarchy.
Diffstat (limited to 'imap/pop3dcapa.c')
-rw-r--r--imap/pop3dcapa.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/imap/pop3dcapa.c b/imap/pop3dcapa.c
new file mode 100644
index 0000000..5d0eef4
--- /dev/null
+++ b/imap/pop3dcapa.c
@@ -0,0 +1,87 @@
+/*
+** Copyright 1998 - 2008 Double Precision, Inc.
+** See COPYING for distribution information.
+*/
+
+#if HAVE_CONFIG_H
+#undef PACKAGE
+#undef VERSION
+#include "config.h"
+#endif
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <ctype.h>
+#include <fcntl.h>
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+
+extern const char *externalauth();
+
+int have_starttls()
+{
+ const char *p;
+
+ if ((p=getenv("POP3_STARTTLS")) == 0) return (0);
+ if (*p != 'y' && *p != 'Y') return (0);
+
+ p=getenv("COURIERTLS");
+ if (!p || !*p) return (0);
+ if (access(p, X_OK)) return (0);
+ return (1);
+}
+
+
+int tls_required()
+{
+ const char *p=getenv("POP3_TLS_REQUIRED");
+
+ if (p && atoi(p)) return (1);
+ return (0);
+}
+
+const char *pop3_externalauth()
+{
+ const char *external=NULL;
+ const char *p;
+
+ if ((p=getenv("POP3_TLS")) != 0 && atoi(p))
+ external=externalauth();
+
+ return external;
+}
+
+void pop3dcapa()
+{
+ const char *p;
+ const char *external=pop3_externalauth();
+
+ printf("+OK Here's what I can do:\r\n");
+
+ if ((p=getenv("POP3_TLS")) != 0 && atoi(p) &&
+ (p=getenv("POP3AUTH_TLS")) != 0 && *p)
+ ;
+ else
+ p=getenv("POP3AUTH");
+
+ if ((p && *p) || external)
+ {
+ if (!p)
+ p="";
+
+ if (!external)
+ external="";
+
+ printf("SASL %s%s%s\r\n", p, *p && *external ? " ":"",
+ *external ? "EXTERNAL":"");
+ }
+
+ if (have_starttls())
+ printf("STLS\r\n");
+
+ printf("TOP\r\nUSER\r\nLOGIN-DELAY 10\r\nPIPELINING\r\nUIDL\r\nIMPLEMENTATION Courier Mail Server\r\n.\r\n");
+ fflush(stdout);
+}