Allow sysadmin to set the default policy.
[cascardo/rnetproxy.git] / popproxy.c
index f5f88bd..c69b455 100644 (file)
@@ -32,6 +32,8 @@
 #include "hcconn_ssl.h"
 #include "tcp_connect.h"
 
+#include "usermap.h"
+
 #define CONFFILE SYSCONFDIR "/popproxy.conf"
 
 struct pop_address
@@ -187,6 +189,7 @@ int main (int argc, char **argv)
   int server_ssl;
   gchar *certfile;
   gchar *ssl_keyfile;
+  gchar *policy;
   struct pop_address pop_address;
 
   gnutls_global_init ();
@@ -277,6 +280,19 @@ int main (int argc, char **argv)
       g_error_free (error);
     }
 
+  error = NULL;
+  policy = g_key_file_get_string (keyfile, "global", "policy",
+                                  &error);
+  if (policy == NULL && error != NULL)
+    {
+      policy = g_strdup ("deny");
+      g_error_free (error);
+    }
+
+  if (!strcmp (policy, "allow"))
+    ACCESS_DEFAULT = ACCESS_ALLOW;
+  g_free (policy);
+
 
   pop_address.server = server_address;
   pop_address.port = server_port;
@@ -293,6 +309,8 @@ int main (int argc, char **argv)
   pop_log_init ();
 
   g_message ("Listening at %s:%s.", conf_address, port);
+  if (ACCESS_DEFAULT == ACCESS_ALLOW)
+    g_message ("Authorizing users by default.");
 
   if (!foreground)
     daemon (0, 0);