initial import.
authorPierre Habouzit <madcoder@debian.org>
Sun, 7 Jan 2007 23:34:43 +0000 (00:34 +0100)
committerPierre Habouzit <madcoder@debian.org>
Sun, 7 Jan 2007 23:34:43 +0000 (00:34 +0100)
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
.gitignore [new file with mode: 0644]
COPYING [new file with mode: 0644]
Makefile [new file with mode: 0644]
mk/cflags.mk [new file with mode: 0644]
mk/headache.cfg [new file with mode: 0644]
policy.c [new file with mode: 0644]
policy.h [new file with mode: 0644]
postlicyd.c [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..beb847d
--- /dev/null
@@ -0,0 +1,5 @@
+postlicyd
+
+*.o
+.*.d
+.*.swp
diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..a8df9cc
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,28 @@
+        postlicyd: a postfix policy daemon with a lot of features
+        ~~~~~~~~~
+________________________________________________________________________
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+3. The names of its contributors may not be used to endorse or promote
+   products derived from this software without specific prior written
+   permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..bd9fb10
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,72 @@
+##############################################################################
+#          postlicyd: a postfix policy daemon with a lot of features         #
+#          ~~~~~~~~~                                                         #
+#  ________________________________________________________________________  #
+#                                                                            #
+#  Redistribution and use in source and binary forms, with or without        #
+#  modification, are permitted provided that the following conditions        #
+#  are met:                                                                  #
+#                                                                            #
+#  1. Redistributions of source code must retain the above copyright         #
+#     notice, this list of conditions and the following disclaimer.          #
+#  2. Redistributions in binary form must reproduce the above copyright      #
+#     notice, this list of conditions and the following disclaimer in the    #
+#     documentation and/or other materials provided with the distribution.   #
+#  3. The names of its contributors may not be used to endorse or promote    #
+#     products derived from this software without specific prior written     #
+#     permission.                                                            #
+#                                                                            #
+#  THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND   #
+#  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE     #
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR        #
+#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS    #
+#  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR    #
+#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF      #
+#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS  #
+#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN   #
+#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)   #
+#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF    #
+#  THE POSSIBILITY OF SUCH DAMAGE.                                           #
+##############################################################################
+
+include mk/cflags.mk
+
+PROGRAMS = postlicyd
+
+postlicyd_SOURCES = \
+               policy.h        \
+               policy.c        \
+               postlicyd.c
+
+postlicyd_LIBADD = -ludns
+
+# RULES ###################################################################{{{
+
+all: $(PROGRAMS)
+
+clean:
+       $(RM) $(PROGRAMS)
+       $(RM) *.o
+
+distclean: clean
+
+headers: HEADACHEOPTS=-c mk/headache.cfg -h COPYING
+headers:
+       @which headache > /dev/null || \
+               ( echo "package headache not installed" ; exit 1 )
+       @git ls-files | egrep '(\.h|\.c|Makefile|*\.mk)$$' | xargs -t headache $(HEADACHEOPTS)
+
+%.o: %.c Makefile
+       $(CC) $(CFLAGS) -MMD -MT ".$*.d $@" -MF .$*.d -g -c -o $@ $<
+
+%.d: %.c Makefile
+       $(CC) $(CFLAGS) -MM -MT ".$*.d $@" -MF .$*.d $<
+
+.SECONDEXPANSION:
+
+$(PROGRAMS): $$(patsubst %.c,%.o,$$($$@_SOURCES)) Makefile
+       $(CC) -o $@ $(CFLAGS) $(filter %.o,$^) $(LDFLAGS) $($@_LIBADD) $(filter %.a,$^)
+
+-include $(foreach p,$(PROGRAMS),$(patsubst %.c,%.d,$(filter %.c,$p_SOURCES)))
+
+###########################################################################}}}
diff --git a/mk/cflags.mk b/mk/cflags.mk
new file mode 100644 (file)
index 0000000..ac87e55
--- /dev/null
@@ -0,0 +1,85 @@
+##############################################################################
+#          postlicyd: a postfix policy daemon with a lot of features         #
+#          ~~~~~~~~~                                                         #
+#  ________________________________________________________________________  #
+#                                                                            #
+#  Redistribution and use in source and binary forms, with or without        #
+#  modification, are permitted provided that the following conditions        #
+#  are met:                                                                  #
+#                                                                            #
+#  1. Redistributions of source code must retain the above copyright         #
+#     notice, this list of conditions and the following disclaimer.          #
+#  2. Redistributions in binary form must reproduce the above copyright      #
+#     notice, this list of conditions and the following disclaimer in the    #
+#     documentation and/or other materials provided with the distribution.   #
+#  3. The names of its contributors may not be used to endorse or promote    #
+#     products derived from this software without specific prior written     #
+#     permission.                                                            #
+#                                                                            #
+#  THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND   #
+#  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE     #
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR        #
+#  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS    #
+#  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR    #
+#  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF      #
+#  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS  #
+#  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN   #
+#  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)   #
+#  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF    #
+#  THE POSSIBILITY OF SUCH DAMAGE.                                           #
+##############################################################################
+
+GCCVERSION:=$(shell $(CC) -dumpversion)
+GCCMACHINE:=$(shell $(CC) -dumpmachine)
+OBJSUFFIX:=-$(GCCMACHINE:-linux-gnu=)-$(GCCVERSION)
+
+ifneq (,$(filter 4.%,$(GCCVERSION)))
+  GCC4=1
+endif
+
+LDFLAGS += -Wl,--warn-common
+
+# Use pipes and not temp files.
+CFLAGS += -pipe
+# optimize even more
+CFLAGS += -O2
+# let the type char be unsigned by default
+CFLAGS += -funsigned-char
+CFLAGS += -fstrict-aliasing
+# turn on all common warnings
+CFLAGS += -Wall
+# turn on extra warnings
+CFLAGS += $(if $(GCC4),-Wextra,-W)
+# treat warnings as errors
+CFLAGS += -Werror
+CFLAGS += -Wchar-subscripts
+# warn about undefined preprocessor identifiers
+CFLAGS += -Wundef
+# warn about local variable shadowing another local variable
+CFLAGS += -Wshadow
+# warn about casting of pointers to increased alignment requirements
+CFLAGS += -Wcast-align
+# make string constants const
+CFLAGS += -Wwrite-strings
+# warn about implicit conversions with side effects
+# fgets, calloc and friends take an int, not size_t...
+#CFLAGS += -Wconversion
+# warn about comparisons between signed and unsigned values
+CFLAGS += -Wsign-compare
+# warn about unused declared stuff
+CFLAGS += -Wunused
+# don not warn about unused return value
+CFLAGS += -Wno-unused-value
+# warn about variable use before initialization
+CFLAGS += -Wuninitialized
+# warn about pointer arithmetic on void* and function pointers
+CFLAGS += -Wpointer-arith
+# warn about multiple declarations
+CFLAGS += -Wredundant-decls
+# warn if the format string is not a string literal
+CFLAGS += -Wformat-nonliteral
+# do not warn about strftime format with y2k issues
+CFLAGS += -Wno-format-y2k
+# barf if we change constness
+#CFLAGS += -Wcast-qual
+
diff --git a/mk/headache.cfg b/mk/headache.cfg
new file mode 100644 (file)
index 0000000..69fadf0
--- /dev/null
@@ -0,0 +1,5 @@
+# C source
+| ".*\\.[ch]"    -> frame open:"/*" line:"*" close:"*/" width:72
+# Misc
+| ".*Makefile.*" -> frame open:"#"  line:"#" close:"#" width:72
+| ".*\\.mk"      -> frame open:"#"  line:"#" close:"#" width:72
diff --git a/policy.c b/policy.c
new file mode 100644 (file)
index 0000000..d7892d3
--- /dev/null
+++ b/policy.c
@@ -0,0 +1,37 @@
+/******************************************************************************/
+/*          postlicyd: a postfix policy daemon with a lot of features         */
+/*          ~~~~~~~~~                                                         */
+/*  ________________________________________________________________________  */
+/*                                                                            */
+/*  Redistribution and use in source and binary forms, with or without        */
+/*  modification, are permitted provided that the following conditions        */
+/*  are met:                                                                  */
+/*                                                                            */
+/*  1. Redistributions of source code must retain the above copyright         */
+/*     notice, this list of conditions and the following disclaimer.          */
+/*  2. Redistributions in binary form must reproduce the above copyright      */
+/*     notice, this list of conditions and the following disclaimer in the    */
+/*     documentation and/or other materials provided with the distribution.   */
+/*  3. The names of its contributors may not be used to endorse or promote    */
+/*     products derived from this software without specific prior written     */
+/*     permission.                                                            */
+/*                                                                            */
+/*  THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND   */
+/*  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE     */
+/*  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR        */
+/*  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS    */
+/*  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR    */
+/*  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF      */
+/*  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS  */
+/*  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN   */
+/*  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)   */
+/*  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF    */
+/*  THE POSSIBILITY OF SUCH DAMAGE.                                           */
+/******************************************************************************/
+
+/*
+ * Copyright (C) 2006 Pierre Habouzit
+ */
+
+#include "policy.h"
+
diff --git a/policy.h b/policy.h
new file mode 100644 (file)
index 0000000..b655ab3
--- /dev/null
+++ b/policy.h
@@ -0,0 +1,82 @@
+/******************************************************************************/
+/*          postlicyd: a postfix policy daemon with a lot of features         */
+/*          ~~~~~~~~~                                                         */
+/*  ________________________________________________________________________  */
+/*                                                                            */
+/*  Redistribution and use in source and binary forms, with or without        */
+/*  modification, are permitted provided that the following conditions        */
+/*  are met:                                                                  */
+/*                                                                            */
+/*  1. Redistributions of source code must retain the above copyright         */
+/*     notice, this list of conditions and the following disclaimer.          */
+/*  2. Redistributions in binary form must reproduce the above copyright      */
+/*     notice, this list of conditions and the following disclaimer in the    */
+/*     documentation and/or other materials provided with the distribution.   */
+/*  3. The names of its contributors may not be used to endorse or promote    */
+/*     products derived from this software without specific prior written     */
+/*     permission.                                                            */
+/*                                                                            */
+/*  THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND   */
+/*  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE     */
+/*  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR        */
+/*  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS    */
+/*  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR    */
+/*  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF      */
+/*  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS  */
+/*  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN   */
+/*  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)   */
+/*  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF    */
+/*  THE POSSIBILITY OF SUCH DAMAGE.                                           */
+/******************************************************************************/
+
+/*
+ * Copyright (C) 2006 Pierre Habouzit
+ */
+
+#ifndef POSTLICYD_POLICY_H
+#define POSTLICYD_POLICY_H
+
+enum protocol_state {
+    STATE_CONNECT,
+    STATE_HELO, /* or EHLO */
+    STATE_MAIL,
+    STATE_RCPT,
+    STATE_DATE,
+    STATE_EOM,
+    STATE_VRFY,
+    STATE_ETRN,
+};
+
+typedef struct policy_request {
+    unsigned ready : 1;
+    unsigned state : 4;
+    unsigned esmtp : 1;
+
+    const char *helo_name;
+    const char *queue_id;
+    const char *sender;
+    const char *recipient;
+    const char *recipient_count;
+    const char *client_address;
+    const char *client_name;
+    const char *rclient_name;
+    const char *instance;
+
+    /* postfix 2.2+ */
+    const char *sasl_method;
+    const char *sasl_username;
+    const char *sasl_sender;
+    const char *size;
+    const char *ccert_subject;
+    const char *ccert_issuer;
+    const char *ccsert_fingerprint;
+
+    /* postfix 2.3+ */
+    const char *encryption_protocol;
+    const char *encryption_cipher;
+    const char *encryption_keysize;
+    const char *etrn_domain;
+} policy_request;
+
+
+#endif
diff --git a/postlicyd.c b/postlicyd.c
new file mode 100644 (file)
index 0000000..f3fb187
--- /dev/null
@@ -0,0 +1,39 @@
+/******************************************************************************/
+/*          postlicyd: a postfix policy daemon with a lot of features         */
+/*          ~~~~~~~~~                                                         */
+/*  ________________________________________________________________________  */
+/*                                                                            */
+/*  Redistribution and use in source and binary forms, with or without        */
+/*  modification, are permitted provided that the following conditions        */
+/*  are met:                                                                  */
+/*                                                                            */
+/*  1. Redistributions of source code must retain the above copyright         */
+/*     notice, this list of conditions and the following disclaimer.          */
+/*  2. Redistributions in binary form must reproduce the above copyright      */
+/*     notice, this list of conditions and the following disclaimer in the    */
+/*     documentation and/or other materials provided with the distribution.   */
+/*  3. The names of its contributors may not be used to endorse or promote    */
+/*     products derived from this software without specific prior written     */
+/*     permission.                                                            */
+/*                                                                            */
+/*  THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND   */
+/*  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE     */
+/*  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR        */
+/*  PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS    */
+/*  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR    */
+/*  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF      */
+/*  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS  */
+/*  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN   */
+/*  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)   */
+/*  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF    */
+/*  THE POSSIBILITY OF SUCH DAMAGE.                                           */
+/******************************************************************************/
+
+/*
+ * Copyright (C) 2006 Pierre Habouzit
+ */
+
+int main(void)
+{
+    return 0;
+}