summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-06-17 08:04:28 -0700
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-06-17 08:04:28 -0700
commit4535f5a5ddfe6993ac4d3e7e4ecd63b216649dad (patch)
tree886d4d1e5e06c0b2281b4347b1b5f0f0a46aef27
parent3182474429ae251603e46f6ac32e46cde87e92ac (diff)
parent6ce11c9e50cba0303aea06672388d3af452fa468 (diff)
downloadbcfg2-4535f5a5ddfe6993ac4d3e7e4ecd63b216649dad.tar.gz
bcfg2-4535f5a5ddfe6993ac4d3e7e4ecd63b216649dad.tar.bz2
bcfg2-4535f5a5ddfe6993ac4d3e7e4ecd63b216649dad.zip
Merge pull request #96 from kincl/jasons-hacking
Svn: Adding config options for specifying a user and password for subversion and to trust server SSL certificates
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Probes.py3
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Svn.py39
2 files changed, 41 insertions, 1 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Probes.py b/src/lib/Bcfg2/Server/Plugins/Probes.py
index 8937e4740..0974184b4 100644
--- a/src/lib/Bcfg2/Server/Plugins/Probes.py
+++ b/src/lib/Bcfg2/Server/Plugins/Probes.py
@@ -12,6 +12,7 @@ import Bcfg2.Server.Plugin
try:
from django.db import models
+ from django.core.exceptions import MultipleObjectsReturned
HAS_DJANGO = True
class ProbesDataModel(models.Model,
@@ -255,7 +256,7 @@ class Probes(Bcfg2.Server.Plugin.Probing,
ProbesGroupsModel.objects.get_or_create(
hostname=client.hostname,
group=group)
- except ProbesGroupsModel.MultipleObjectsReturned:
+ except MultipleObjectsReturned:
ProbesGroupsModel.objects.filter(hostname=client.hostname,
group=group).delete()
ProbesGroupsModel.objects.get_or_create(
diff --git a/src/lib/Bcfg2/Server/Plugins/Svn.py b/src/lib/Bcfg2/Server/Plugins/Svn.py
index 51f44c52d..240fd7f89 100644
--- a/src/lib/Bcfg2/Server/Plugins/Svn.py
+++ b/src/lib/Bcfg2/Server/Plugins/Svn.py
@@ -59,9 +59,48 @@ class Svn(Bcfg2.Server.Plugin.Version):
self.client.callback_conflict_resolver = \
self.get_conflict_resolver(choice)
+ try:
+ if self.core.setup.cfp.get(
+ "svn",
+ "always_trust").lower() == "true":
+ self.client.callback_ssl_server_trust_prompt = \
+ self.ssl_server_trust_prompt
+ except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
+ self.logger.debug("Svn: Using subversion cache for SSL "
+ "certificate trust")
+
+ try:
+ if (self.core.setup.cfp.get("svn", "user") and
+ self.core.setup.cfp.get("svn", "password")):
+ self.client.callback_get_login = \
+ self.get_login
+ except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
+ self.logger.info("Svn: Using subversion cache for "
+ "password-based authetication")
+
self.logger.debug("Svn: Initialized svn plugin with SVN directory %s" %
self.vcs_path)
+ # pylint: disable=W0613
+ def get_login(self, realm, username, may_save):
+ """ PySvn callback to get credentials for HTTP basic authentication """
+ self.logger.debug("Svn: Logging in with username: %s" %
+ self.core.setup.cfp.get("svn", "user"))
+ return True, \
+ self.core.setup.cfp.get("svn", "user"), \
+ self.core.setup.cfp.get("svn", "password"), \
+ False
+ # pylint: enable=W0613
+
+ def ssl_server_trust_prompt(self, trust_dict):
+ """ PySvn callback to always trust SSL certificates from SVN server """
+ self.logger.debug("Svn: Trusting SSL certificate from %s, "
+ "issued by %s for realm %s" %
+ (trust_dict['hostname'],
+ trust_dict['issuer_dname'],
+ trust_dict['realm']))
+ return True, trust_dict['failures'], False
+
def get_conflict_resolver(self, choice):
""" Get a PySvn conflict resolution callback """
def callback(conflict_description):