예제 #1
0
	def init_curl(self, config=None):
		if config == None:
			config = getconfig()
		if not self.cookie_file:
			self.cookie_file = tempfile.NamedTemporaryFile()
			self.cookie_jar = self.cookie_file.name
		self.curl = pycurl.Curl()
		self.curl.setopt(pycurl.FOLLOWLOCATION, 1)
		self.curl.setopt(pycurl.MAXREDIRS, 5)
		self.curl.unsetopt(pycurl.CAPATH)
		self.curl.setopt(pycurl.CAINFO, '/etc/pki/tls/certs/ca-bundle.crt')
		pycurl_httpauth = pycurl.HTTPAUTH_GSSNEGOTIATE
		self.curl.setopt(pycurl.USERPWD, ":")
		self.curl.setopt(pycurl.HTTPAUTH, pycurl_httpauth)
		self.curl.setopt(pycurl.COOKIEJAR, self.cookie_jar)
		self.curl.setopt(pycurl.COOKIEFILE, self.cookie_jar)
		self.curl.setopt(pycurl.SSL_VERIFYPEER, config.get('webservice', 'ssl_verify_peer') != 'False')
		self.curl.setopt(pycurl.SSL_VERIFYHOST, config.get('webservice', 'ssl_verify_host') != 'False')

		return self.curl
예제 #2
0
from mod_python import apache
from mod_python import Cookie
from myemsl.service.admin import switchuser

from myemsl.getconfig import getconfig
config = getconfig()


def handler(req):
    req.content_type = "text/json"
    all_cookies = Cookie.get_cookies(req)
    session_id = all_cookies.get(config.get('session', 'cookie_name'), None)
    if req.method != "POST":
        return 400
    if session_id == None:
        return apache.HTTP_UNAUTHORIZED
    try:
        url = req.path_info.split('/', 2)[2]
    except:
        return 400
    res = switchuser.switch_user(session_id.value, url, req)
    if res == 200:
        return apache.OK
    return res
예제 #3
0
def get_unix_user():
	config = getconfig()
	return config.get('unix', 'user')
예제 #4
0
# Author: Brock Erwin
# Description: Apache python module that handles notification requests
#              from a client.  To be more specific, there are two modes
#              of operation.
#              GET: Server will return a list of proposals and their
#                   respective notification preferences per proposal
#              POST: Client can set per proposal notification prefe-
#                    rences.
from mod_python import apache
from cgi import parse_qs, escape
import sys,traceback
from myemsl.getconfig import getconfig
config = getconfig()
from myemsl.service import notification
from myemsl.logging import getLogger
logger = getLogger(__name__)

def handler(req):
#	req.write('user is: %s \n' % req.user)
	# Generic try-catch block to prevent server from crashing
	try:
		logger.debug( 'handler:notification' )
		if req.method == "GET":
			notification.getnotifications(req.user, req)
		elif req.method == "POST":
				notification.setnotifications(req.user, parse_qs(req.read()))
		else:
			return apache.HTTP_NOT_IMPLEMENTED
		return apache.OK
	except Exception, e:
		req.write(str(e))
예제 #5
0
def get_unix_user():
    config = getconfig()
    return config.get('unix', 'user')