Ejemplo n.º 1
0
    has_code = form.has_key(evcommon.POST_PERSONAL_CODE)
    has_vote = form.has_key(evcommon.POST_EVOTE)
    has_sess = form.has_key(evcommon.POST_SESS_ID)

    if (not has_sha1):
        bad_input()

    val_sha = form.getvalue(evcommon.POST_VOTERS_FILES_SHA1)

    if (not has_code) and (not has_vote):
        msg = htsalldisp.consistency(val_sha)
        protocol.http_response(msg)
        cgi.sys.exit(0)

    if (has_sess):
        sessionid.setsid(form.getvalue(evcommon.POST_SESS_ID))

    if has_code and has_vote:
        if (has_sess):
            val_code = form.getvalue(evcommon.POST_PERSONAL_CODE)
            val_vote = form.getvalue(evcommon.POST_EVOTE)
            msg = htsalldisp.store_vote(val_sha, val_code, val_vote)
            protocol.http_response(msg)
            cgi.sys.exit(0)
        else:
            bad_input()

    if has_code and (not has_vote):
        if (has_sess):
            val_code = form.getvalue(evcommon.POST_PERSONAL_CODE)
            msg = htsalldisp.check_repeat(val_sha, val_code)
Ejemplo n.º 2
0
import election
import os

if not evcommon.testrun():
    os.umask(007)
    form = cgi.FieldStorage()
    result = protocol.msg_error_technical()
    mid = middisp.MIDDispatcher()
    evlog.AppLog().set_app('MID')

    try:
        has_sess = form.has_key(evcommon.POST_SESS_ID)
        has_poll = form.has_key(evcommon.POST_MID_POLL)
        if has_sess:
            if cgivalidator.validate_sessionid(form):
                sessionid.setsid(form.getvalue(evcommon.POST_SESS_ID))
            if has_poll:
                req_params = [evcommon.POST_MID_POLL, evcommon.POST_SESS_ID]
                res, logline = cgivalidator.validate_form(form, req_params)
                if res:
                    result = mid.poll()
                else:
                    evlog.log_error(logline)
            else:
                req_params = [evcommon.POST_EVOTE, evcommon.POST_SESS_ID]
                res, logline = cgivalidator.validate_form(form, req_params)
                if res:
                    cgilog.do_log("vote/auth")
                    result = mid.init_sign(form)
                else:
                    cgilog.do_log_error('vote/auth/err')