HEX
Server: Apache
System: Linux vpshost0650.publiccloud.com.br 4.4.79-grsec-1.lc.x86_64 #1 SMP Wed Aug 2 14:18:21 -03 2017 x86_64
User: bandeirantesbomb3 (10068)
PHP: 8.0.7
Disabled: apache_child_terminate,dl,escapeshellarg,escapeshellcmd,exec,link,mail,openlog,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,php_check_syntax,php_strip_whitespace,popen,proc_close,proc_open,shell_exec,symlink,system
Upload Files
File: //proc/thread-self/root/usr/share/doc/m2crypto-0.21.1/demo/Zope/utilities/x509_user.py
#!/usr/bin/python

"""
This is a very simple program to manage the access_x509 database. The 
overriding goal is program portability, hence its use of 'anydbm'.

Invoke it thusly:

    x509_user.py 
        -u <username> 
        [ -x <X.509 subject DN> ]
        [ -f <database> ] 

<username> is the Zope username; it must be present.

<X.509 subject DN> is the X.509 certificate's subject distinguished name
to associate with the user. If it is present, the association is created 
or updated. If it is absent, the association is removed.

<database> defaults to 'access_x509'.

(I told you this is a dumb program.)


To read the subject distinguished name from the certificate 'client.pem', 
invoke 'openssl' thusly:

    openssl x509 -subject -noout -in client.pem

This produces the output:

    subject=/C=SG/O=M2Crypto Client/CN=M2Crypto Client/Email=ngps@post1.com


Next, invoke this tool:

    x509_user.py -u superuser \\
        -f "/C=SG/O=M2Crypto Client/CN=M2Crypto Client/Email=ngps@post1.com"

This associates the user who owns client.pem to the Zope "superuser".


Copyright (c) 2000 Ng Pheng Siong. This program is released under the ZPL.
"""

import anydbm, getopt, sys

x509_db = 'access_x509'
username = subject_dn = None

argerr='Usage'

optlist, optarg=getopt.getopt(sys.argv[1:], 'f:u:x:')   # ;-)
for opt in optlist:
    if '-f' in opt:
        x509_db = opt[1]
    elif '-u' in opt:
        username = opt[1]
    elif '-x' in opt:
        subject_dn = opt[1]

if username is None:
    raise argerr, '\n' + __doc__

db = anydbm.open(x509_db, 'cw')
if subject_dn is None:
    # Remove the association...
    try:
        subject_dn = db[username]
        del db[subject_dn]
        del db[username]
    except:
        pass
else:
    # Create/update the association.
    db[subject_dn] = username
    db[username] = subject_dn
db.close()