/usr/lib/python3/dist-packages/Xlib/ext/security.py is in python3-xlib 0.20-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | # Xlib.ext.security -- SECURITY extension module
#
# Copyright (C) 2010-2013 Outpost Embedded, LLC
# Forest Bond <forest.bond@rapidrollout.com>
#
# 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.,
# 59 Temple Place,
# Suite 330,
# Boston, MA 02111-1307 USA
'''
A partial implementation of the SECURITY extension. Support for the
SecurityAuthorizationRevoked event is not implemented.
'''
from Xlib.protocol import rq
extname = 'SECURITY'
SecurityClientTrusted = 0
SecurityClientUntrusted = 1
SecurityAuthorizationRevokedMask = 1
AUTHID = rq.Card32
class QueryVersion(rq.ReplyRequest):
_request = rq.Struct(rq.Card8('opcode'),
rq.Opcode(0),
rq.RequestLength(),
rq.Card16('major_version'),
rq.Card16('minor_version')
)
_reply = rq.Struct(rq.ReplyCode(),
rq.Pad(1),
rq.Card16('sequence_number'),
rq.ReplyLength(),
rq.Card16('major_version'),
rq.Card16('minor_version'),
rq.Pad(20)
)
def query_version(self):
return QueryVersion(display=self.display,
opcode=self.display.get_extension_major(extname),
major_version=1,
minor_version=0)
class SecurityGenerateAuthorization(rq.ReplyRequest):
# The order of fields here does not match the specifications I've seen
# online, but it *does* match with the X.org implementation. I guess the
# spec is out-of-date.
_request = rq.Struct(rq.Card8('opcode'),
rq.Opcode(1),
rq.RequestLength(),
rq.LengthOf('auth_proto', 2),
rq.LengthOf('auth_data', 2),
rq.Card32('value_mask'),
rq.String8('auth_proto'),
rq.Binary('auth_data'),
rq.List('values', rq.Card32Obj)
)
_reply = rq.Struct(rq.ReplyCode(),
rq.Pad(1),
rq.Card16('sequence_number'),
rq.ReplyLength(),
AUTHID('authid'),
rq.LengthOf('auth_data_return', 2),
rq.Pad(18),
rq.Binary('auth_data_return')
)
def generate_authorization(self, auth_proto, auth_data=b'', timeout=None,
trust_level=None, group=None, event_mask=None):
value_mask = 0
values = []
if timeout is not None:
value_mask |= 1
values.append(timeout)
if trust_level is not None:
value_mask |= 2
values.append(trust_level)
if group is not None:
value_mask |= 4
values.append(group)
if event_mask is not None:
value_mask |= 8
values.append(event_mask)
return SecurityGenerateAuthorization(display=self.display,
opcode=self.display.get_extension_major(extname),
value_mask=value_mask,
auth_proto=auth_proto,
auth_data=auth_data,
values=values)
class SecurityRevokeAuthorization(rq.Request):
_request = rq.Struct(rq.Card8('opcode'),
rq.Opcode(2),
rq.RequestLength(),
AUTHID('authid')
)
def revoke_authorization(self, authid):
return SecurityRevokeAuthorization(display=self.display,
opcode=self.display.get_extension_major(extname),
authid=authid)
def init(disp, info):
disp.extension_add_method('display',
'security_query_version',
query_version)
disp.extension_add_method('display',
'security_generate_authorization',
generate_authorization)
disp.extension_add_method('display',
'security_revoke_authorization',
revoke_authorization)
|