示例#1
0
if not evcommon.testrun():
    os.umask(007)
    form = cgi.FieldStorage()

    has_sha1 = form.has_key(evcommon.POST_VOTERS_FILES_SHA1)
    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()
示例#2
0
if not evcommon.testrun():
    os.umask(007)
    form = cgi.FieldStorage()

    has_sha256 = form.has_key(evcommon.POST_VOTERS_FILES_SHA256)
    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_sha256):
        bad_input()

    val_sha = form.getvalue(evcommon.POST_VOTERS_FILES_SHA256)

    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()
示例#3
0
                or evcommon.POST_PERSONAL_CODE in form):
            # Check for repeat voting
            req_params = [evcommon.POST_VOTERS_FILES_SHA256,
                          evcommon.POST_SESS_ID,
                          evcommon.POST_PERSONAL_CODE]
            res, logline = cgivalidator.validate_form(form, req_params)
            if res:
                sha = form.getvalue(evcommon.POST_VOTERS_FILES_SHA256)
                code = form.getvalue(evcommon.POST_PERSONAL_CODE)
                result = htsalldisp.check_repeat(sha, code)
            else:
                evlog.log_error("repeat/err, " + logline)

        else:
            # Check consistency
            req_params = [evcommon.POST_VOTERS_FILES_SHA256]
            res, logline = cgivalidator.validate_form(form, req_params)
            if res:
                sha = form.getvalue(evcommon.POST_VOTERS_FILES_SHA256)
                result = htsalldisp.consistency(sha)
            else:
                evlog.log_error("consistency/err, " + logline)
    except:
        evlog.log_exception()
        result = protocol.msg_error_technical()

    protocol.http_response(result)
    cgi.sys.exit(0)

# vim:set ts=4 sw=4 et fileencoding=utf8:
示例#4
0
            # Check for repeat voting
            req_params = [
                evcommon.POST_VOTERS_FILES_SHA256, evcommon.POST_SESS_ID,
                evcommon.POST_PERSONAL_CODE
            ]
            res, logline = cgivalidator.validate_form(form, req_params)
            if res:
                sha = form.getvalue(evcommon.POST_VOTERS_FILES_SHA256)
                code = form.getvalue(evcommon.POST_PERSONAL_CODE)
                result = htsalldisp.check_repeat(sha, code)
            else:
                evlog.log_error("repeat/err, " + logline)

        else:
            # Check consistency
            req_params = [evcommon.POST_VOTERS_FILES_SHA256]
            res, logline = cgivalidator.validate_form(form, req_params)
            if res:
                sha = form.getvalue(evcommon.POST_VOTERS_FILES_SHA256)
                result = htsalldisp.consistency(sha)
            else:
                evlog.log_error("consistency/err, " + logline)
    except:
        evlog.log_exception()
        result = protocol.msg_error_technical()

    protocol.http_response(result)
    cgi.sys.exit(0)

# vim:set ts=4 sw=4 et fileencoding=utf8: