commit-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Mailutils branch, master, updated. release-2.2-118-g271d62e


From: Sergey Poznyakoff
Subject: [SCM] GNU Mailutils branch, master, updated. release-2.2-118-g271d62e
Date: Mon, 04 Oct 2010 11:49:31 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Mailutils".

http://git.savannah.gnu.org/cgit/mailutils.git/commit/?id=271d62e93d6dc12f80d785d680df34cc35fddd90

The branch, master has been updated
       via  271d62e93d6dc12f80d785d680df34cc35fddd90 (commit)
      from  96e44735dce29f8cdf0f8512bd3bfccc4b350055 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 271d62e93d6dc12f80d785d680df34cc35fddd90
Author: Sergey Poznyakoff <address@hidden>
Date:   Mon Oct 4 14:08:51 2010 +0300

    New mu submode: acl.  Supersedes examples/aclck.c
    
    * mu/acl.c: New file.
    * mu/Makefile.am: Add acl.c
    * po/POTFILES.in: Add acl.c
    * mu/mu.c (mutool_action_tab): Add acl mode.
    * mu/mu.h (mutool_acl): New proto.
    * mu/flt2047.c: Fix docstrings.
    * mu/pop.c: Likewise.

-----------------------------------------------------------------------

Summary of changes:
 mu/Makefile.am |    1 +
 mu/acl.c       |  193 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 mu/flt2047.c   |    2 +-
 mu/mu.c        |    2 +
 mu/mu.h        |    1 +
 mu/pop.c       |    2 +-
 po/POTFILES.in |    1 +
 7 files changed, 200 insertions(+), 2 deletions(-)
 create mode 100644 mu/acl.c

diff --git a/mu/Makefile.am b/mu/Makefile.am
index 0a3c50e..c9b5e39 100644
--- a/mu/Makefile.am
+++ b/mu/Makefile.am
@@ -17,6 +17,7 @@
 
 bin_PROGRAMS = mu
 mu_SOURCES = \
+ acl.c\
  info.c\
  mu.h\
  mu.c\
diff --git a/mu/acl.c b/mu/acl.c
new file mode 100644
index 0000000..0c9cc21
--- /dev/null
+++ b/mu/acl.c
@@ -0,0 +1,193 @@
+/* GNU Mailutils -- a suite of utilities for electronic mail
+   Copyright (C) 2010 Free Software Foundation, Inc.
+
+   GNU Mailutils is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   GNU Mailutils is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GNU Mailutils.  If not, see <http://www.gnu.org/licenses/>. */
+
+#if defined(HAVE_CONFIG_H)
+# include <config.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <sys/un.h>
+#include <arpa/inet.h>
+#include <mailutils/mailutils.h>
+#include <mailutils/libcfg.h>
+#include "argp.h"
+#include "mu.h"
+#include "xalloc.h"
+
+static char acl_doc[] = N_("mu acl - test access control lists.");
+static char acl_args_doc[] = N_("ADDRESS [ADDRESS...]");
+
+static struct argp_option acl_options[] = {
+  { "file", 'f', N_("FILE"), 0, N_("read ACLs from FILE") },
+  { "path", 'p', N_("PATH"), 0,
+    N_("path to the ACL in the configuration tree") },
+  { NULL }
+};
+
+static char *input_file_name;
+static struct sockaddr *target_sa;
+static socklen_t target_salen;
+static mu_acl_t acl;
+static const char *path = "acl";
+
+static struct sockaddr *
+parse_address (socklen_t *psalen, const char *str)
+{
+  struct sockaddr_in in;
+  struct sockaddr *sa;
+  
+  in.sin_family = AF_INET;
+  if (inet_aton (str, &in.sin_addr) == 0)
+    {
+      mu_error ("Invalid IPv4: %s", str);
+      exit (1);
+    }
+  in.sin_port = 0;
+  *psalen = sizeof (in);
+  sa = malloc (*psalen);
+  if (!sa)
+    {
+      mu_error ("%s", mu_strerror (errno));
+      exit (1);
+    }
+  
+  memcpy (sa, &in, sizeof (in));
+  return sa;
+}
+
+static error_t
+acl_parse_opt (int key, char *arg, struct argp_state *state)
+{
+  switch (key)
+    {
+    case 'f':
+      input_file_name = arg;
+      break;
+
+    case 'p':
+      path = arg;
+      break;
+      
+    default:
+      return ARGP_ERR_UNKNOWN;
+    }
+  return 0;
+}
+
+static struct argp acl_argp = {
+  acl_options,
+  acl_parse_opt,
+  acl_args_doc,
+  acl_doc,
+  NULL,
+  NULL,
+  NULL
+};
+
+
+static struct mu_cfg_param acl_cfg_param[] = {
+  { "acl", mu_cfg_section, &acl, 0, NULL, "access control list" },
+  { NULL }
+};
+
+int
+mutool_acl (int argc, char **argv)
+{
+  int rc, index;
+  mu_acl_result_t result;
+  mu_cfg_tree_t *tree = NULL, *temp_tree = NULL;
+  mu_cfg_node_t *node;
+  int flags = 0;
+  
+  if (argp_parse (&acl_argp, argc, argv, ARGP_IN_ORDER, &index, NULL))
+    return 1;
+
+  argc -= index;
+  argv += index;
+
+  if (argc == 0)
+    {
+      mu_error (_("not enough arguments"));
+      return 1;
+    }
+
+  if (input_file_name)
+    {
+      mu_load_site_rcfile = 0;
+      mu_load_user_rcfile = 0;
+      mu_load_rcfile = input_file_name;
+    }
+
+  mu_acl_cfg_init ();
+  if (mu_libcfg_parse_config (&tree))
+    return 1;
+  if (!tree)
+    return 0;
+  
+  if (mu_cfg_find_node (tree, path, &node))
+    {
+      mu_error (_("cannot find node: %s"), path);
+      return 1;
+    }
+
+  mu_cfg_tree_create (&temp_tree);
+  mu_cfg_tree_add_node (temp_tree, node);
+  rc = mu_cfg_tree_reduce (temp_tree, mu_program_name, acl_cfg_param,
+                          flags, NULL);
+  if (rc)
+    return 1;
+  if (!acl)
+    {
+      mu_error (_("No ACL found in config"));
+      return 1;
+    }
+  
+  while (argc--)
+    {
+      const char *ap = *argv++;
+
+      target_sa = parse_address (&target_salen, ap);
+      printf ("Testing %s:\n", ap);
+      rc = mu_acl_check_sockaddr (acl, target_sa, target_salen, &result);
+      if (rc)
+       {
+         mu_error ("mu_acl_check_sockaddr failed: %s", mu_strerror (rc));
+         return 1;
+       }
+
+      switch (result)
+       {
+       case mu_acl_result_undefined:
+         printf ("%s: undefined\n", ap);
+         break;
+      
+       case mu_acl_result_accept:
+         printf ("%s: accept\n", ap);
+         break;
+
+       case mu_acl_result_deny:
+         printf ("%s: deny\n", ap);
+         break;
+       }
+    }
+
+  mu_cfg_destroy_tree (&tree);
+  mu_cfg_destroy_tree (&temp_tree);
+
+  return 0;
+}
diff --git a/mu/flt2047.c b/mu/flt2047.c
index 75d3b37..7c6c9d6 100644
--- a/mu/flt2047.c
+++ b/mu/flt2047.c
@@ -23,7 +23,7 @@
 #include "argp.h"
 #include "mu.h"
 
-static char flt2047_doc[] = N_("mu 2047 - decode/encode message headers");
+static char flt2047_doc[] = N_("mu 2047 - decode/encode message headers.");
 static char flt2047_args_doc[] = N_("[text]");
 
 static struct argp_option flt2047_options[] = {
diff --git a/mu/mu.c b/mu/mu.c
index 9af9e0a..784698c 100644
--- a/mu/mu.c
+++ b/mu/mu.c
@@ -32,6 +32,7 @@ Commands are:\n\
     mu pop    - POP3 client program\n\
     mu filter - filter program\n\
     mu 2047   - decode/encode message headers as per RFC 2047\n\
+    mu acl    - test access control lists\n\
 \n\
 Try `mu COMMAND --help' to get help on a particular COMMAND.\n\
 \n\
@@ -92,6 +93,7 @@ struct mutool_action_tab mutool_action_tab[] = {
   { "filter", mutool_filter },
   { "2047", mutool_flt2047 },
   { "query", mutool_query },
+  { "acl", mutool_acl },
   { NULL }
 };
 
diff --git a/mu/mu.h b/mu/mu.h
index 5fe3097..a251d7d 100644
--- a/mu/mu.h
+++ b/mu/mu.h
@@ -33,6 +33,7 @@ int mutool_filter (int argc, char **argv);
 int mutool_flt2047 (int argc, char **argv);
 int mutool_info (int argc, char **argv);
 int mutool_query (int argc, char **argv);
+int mutool_acl (int argc, char **argv);
 
 extern char *mutool_shell_prompt;
 extern mu_vartab_t mutool_prompt_vartab;
diff --git a/mu/pop.c b/mu/pop.c
index 8375776..e4b9a25 100644
--- a/mu/pop.c
+++ b/mu/pop.c
@@ -27,7 +27,7 @@
 #include "argp.h"
 #include "xalloc.h"
 
-static char pop_doc[] = N_("mu pop - POP3 client shell");
+static char pop_doc[] = N_("mu pop - POP3 client shell.");
 static char pop_args_doc[] = "";
 
 static struct argp_option pop_options[] = {
diff --git a/po/POTFILES.in b/po/POTFILES.in
index a00a3c2..386fe5b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -197,6 +197,7 @@ sieve/sieve.c
 
 sql/mysql.c
 
+mu/acl.c
 mu/filter.c
 mu/flt2047.c
 mu/info.c


hooks/post-receive
-- 
GNU Mailutils



reply via email to

[Prev in Thread] Current Thread [Next in Thread]