aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2013-04-26 20:22:01 +0000
committerRob Austein <sra@hactrn.net>2013-04-26 20:22:01 +0000
commit0e071680dd9340d6c043ae08c974ba319dbd0e52 (patch)
treec9a269e51d571bc88a05df8c36a83e23c05df6de
parent63778293fffbaa50f175da2d652d85a8ff3da832 (diff)
Loading setproctitle dumps core when running under WSGI and Apache, so
don't try. Closes #520. svn path=/trunk/; revision=5310
-rw-r--r--rpkid/portal-gui/rpki.wsgi7
-rw-r--r--rpkid/rpki/log.py8
2 files changed, 12 insertions, 3 deletions
diff --git a/rpkid/portal-gui/rpki.wsgi b/rpkid/portal-gui/rpki.wsgi
index 37bed594..a01bf8f7 100644
--- a/rpkid/portal-gui/rpki.wsgi
+++ b/rpkid/portal-gui/rpki.wsgi
@@ -25,6 +25,13 @@ os.environ['DJANGO_SETTINGS_MODULE'] = 'rpki.gui.default_settings'
# needed for local_settings.py
sys.path.insert(1, rpki.autoconf.sysconfdir + '/rpki')
+# Kludge to disable use of setproctitle in rpki.log. For reasons
+# unknown, at least on Ubuntu 12.04 LTS, we dump core with a segment
+# violation if we try to load that module in this process, even though
+# it works fine in other processes on the same system. Not yet sure
+# what this is about, just disable setproctitle in WSGI case for now.
+os.environ['DISABLE_SETPROCTITLE'] = 'yes'
+
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
diff --git a/rpkid/rpki/log.py b/rpkid/rpki/log.py
index 558d3c68..cc2babcc 100644
--- a/rpkid/rpki/log.py
+++ b/rpkid/rpki/log.py
@@ -39,10 +39,12 @@ import time
import traceback as tb
try:
- import setproctitle
- have_setproctitle = True
-except ImportError:
have_setproctitle = False
+ if os.getenv("DISABLE_SETPROCTITLE") is None:
+ import setproctitle
+ have_setproctitle = True
+except ImportError:
+ pass
## @var enable_trace
# Whether call tracing is enabled.
t .nt { color: #B06; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #369 } /* Name.Variable */ .highlight .ow { color: #080 } /* Operator.Word */ .highlight .w { color: #BBB } /* Text.Whitespace */ .highlight .mb { color: #00D; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #00D; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #00D; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #00D; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #00D; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #D20; background-color: #FFF0F0 } /* Literal.String.Affix */ .highlight .sb { color: #D20; background-color: #FFF0F0 } /* Literal.String.Backtick */ .highlight .sc { color: #D20; background-color: #FFF0F0 } /* Literal.String.Char */ .highlight .dl { color: #D20; background-color: #FFF0F0 } /* Literal.String.Delimiter */ .highlight .sd { color: #D20; background-color: #FFF0F0 } /* Literal.String.Doc */ .highlight .s2 { color: #D20; background-color: #FFF0F0 } /* Literal.String.Double */ .highlight .se { color: #04D; background-color: #FFF0F0 } /* Literal.String.Escape */ .highlight .sh { color: #D20; background-color: #FFF0F0 } /* Literal.String.Heredoc */ .highlight .si { color: #33B; background-color: #FFF0F0 } /* Literal.String.Interpol */ .highlight .sx { color: #2B2; background-color: #F0FFF0 } /* Literal.String.Other */ .highlight .sr { color: #080; background-color: #FFF0FF } /* Literal.String.Regex */ .highlight .s1 { color: #D20; background-color: #FFF0F0 } /* Literal.String.Single */ .highlight .ss { color: #A60; background-color: #FFF0F0 } /* Literal.String.Symbol */ .highlight .bp { color: #038 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #06B; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #369 } /* Name.Variable.Class */ .highlight .vg { color: #D70 } /* Name.Variable.Global */ .highlight .vi { color: #33B } /* Name.Variable.Instance */ .highlight .vm { color: #369 } /* Name.Variable.Magic */ .highlight .il { color: #00D; font-weight: bold } /* Literal.Number.Integer.Long */
from django.views.generic.create_update import create_object, update_object, \
						delete_object
from django.views.generic.list_detail import object_detail
from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404, render_to_response
import models
import forms


# For each type of object, we have a detail view, a create view and
# an update view.  We heavily leverage the generic views, only
# adding our own idea of authorization.

def handle( request ):
    '''If the session has a handle, return the config.  If the user only has
    one config that he can access, return that one; else return None.'''
    if 'handle' in request.session:
	return Conf.objects.get( handle=request.session[ 'handle' ] )
    conf = Conf.objects.all().filter( owner__in=request.user.groups )
    if conf.count() == 1:
	return conf[ 0 ]
    return None

def choose_handle( request ):
    '''The logged-in user can access multiple (or no) handles.
    Ask them to pick which one(s) they want to access.'''
    raise NotImplementedError

@login_required
def dashboard( request ):
    '''The user's dashboard.  If the handle is not specified,
    see what the user has access to based on his groups.  If
    multiple, give him a selector and store the result in the
    session.'''
    handle = handle( request )
    if handle is None:
	return choose_handle( request )
    # ... pick out data for the dashboard and return it
    return render_to_response( 'myrpki/dashboard.html', context={ 'conf': handle } )

@login_required
def cert_add( request ):
    # todo: enforce that the saved form points to this conf
    return create_object( request, form_class=forms.CertForm )

@login_required
def cert_view( request, id ):
    handle = handle( request )
    queryset = Cert.objects.filter( conf=handle )
    return object_detail( queryset=queryset, object_id=id )

@login_required
def cert_edit( request, id ):
    cert = get_object_or_404( models.Cert, pk=id )
    # make sure it is owned by the current handle
    return update_object( request, form_class=forms.CertForm, object_id=id )

@login_required
def cert_delete( request, id ):
    cert = get_object_or_404( models.Cert, pk=id )
    # make sure it is owned by the current handle
    return delete_object( request, model=models.Cert, object_id=id,
			  post_delete_redirect='/dashboard/' )