+ added unit security (header translation of X11/extensions/security.h)

This commit is contained in:
Nikolay Nikolov 2021-08-06 02:56:40 +03:00
parent d33e6d639b
commit 650d2fcaa9
5 changed files with 297 additions and 0 deletions

View File

@ -202,6 +202,14 @@ begin
AddUnit('x');
AddUnit('xlib');
end;
T:=P.Targets.AddUnit('security.pp');
with T.Dependencies do
begin
AddInclude('secur.inc');
AddInclude('xauth.inc');
AddUnit('x');
AddUnit('xlib');
end;
{$ifndef ALLPACKAGES}
Run;

View File

@ -0,0 +1,57 @@
(*
Copyright 1996, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*)
const
SECURITY_EXTENSION_NAME = 'SECURITY';
SECURITY_MAJOR_VERSION = 1;
SECURITY_MINOR_VERSION = 0;
XSecurityNumberEvents = 1;
XSecurityNumberErrors = 2;
XSecurityBadAuthorization = 0;
XSecurityBadAuthorizationProtocol = 1;
{ trust levels }
XSecurityClientTrusted = 0;
XSecurityClientUntrusted = 1;
{ authorization attribute masks }
XSecurityTimeout = 1 shl 0;
XSecurityTrustLevel = 1 shl 1;
XSecurityGroup = 1 shl 2;
XSecurityEventMask = 1 shl 3;
XSecurityAllAuthorizationAttributes =
XSecurityTimeout or XSecurityTrustLevel or XSecurityGroup or XSecurityEventMask;
{ event masks }
XSecurityAuthorizationRevokedMask = 1 shl 0;
XSecurityAllEventMasks = XSecurityAuthorizationRevokedMask;
{ event offsets }
XSecurityAuthorizationRevoked = 0;
XSecurityAuthorizationName = 'XC-QUERY-SECURITY-1';
XSecurityAuthorizationNameLen = 19;

View File

@ -0,0 +1,87 @@
(*
Copyright 1996, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization
from The Open Group.
*)
unit security;
{$PACKRECORDS c}
interface
uses
ctypes, x, xlib;
const
libXext = 'Xext';
{$define _XAUTH_STRUCT_ONLY}
{$I xauth.inc}
{$I secur.inc}
type
{ type for returned auth ids }
PXSecurityAuthorization = ^TXSecurityAuthorization;
TXSecurityAuthorization = culong;
PXSecurityAuthorizationAttributes = ^TXSecurityAuthorizationAttributes;
TXSecurityAuthorizationAttributes = record
timeout: cuint;
trust_level: cuint;
group: TXID;
event_mask: clong;
end;
PXSecurityAuthorizationRevokedEvent = ^TXSecurityAuthorizationRevokedEvent;
TXSecurityAuthorizationRevokedEvent = record
_type: cint; { event base + XSecurityAuthorizationRevoked }
serial: culong; { # of last request processed by server }
send_event: TBool; { true if this came from a SendEvent request }
display: PDisplay; { Display the event was read from }
auth_id: TXSecurityAuthorization; { revoked authorization id }
end;
function XSecurityQueryExtension (
dpy: PDisplay;
major_version_return,
minor_version_return: Pcint): TStatus; cdecl; external libXext;
function XSecurityAllocXauth: PXauth; cdecl; external libXext;
procedure XSecurityFreeXauth(auth: PXauth); cdecl; external libXext;
function XSecurityGenerateAuthorization(
dpy: PDisplay;
auth_in: PXauth;
valuemask: culong;
attributes: PXSecurityAuthorizationAttributes;
auth_id_return: PXSecurityAuthorization): PXauth; cdecl; external libXext;
function XSecurityRevokeAuthorization(
dpy: PDisplay;
auth_id: TXSecurityAuthorization): TStatus; cdecl; external libXext;
implementation
end.

134
packages/x11/src/xauth.inc Normal file
View File

@ -0,0 +1,134 @@
(*
Copyright 1988, 1998 The Open Group
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting
documentation.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*)
type
PXauth = ^TXauth;
TXauth = record
family: cushort;
address_length: cushort;
address: Pchar;
number_length: cushort;
number: Pchar;
name_length: cushort;
name: PChar;
data_length: cushort;
data: PChar;
end;
{$ifndef _XAUTH_STRUCT_ONLY}
# include <X11/Xfuncproto.h>
# include <X11/Xfuncs.h>
# include <stdio.h>
# define FamilyLocal (256) /* not part of X standard (i.e. X.h) */
# define FamilyWild (65535)
# define FamilyNetname (254) /* not part of X standard */
# define FamilyKrb5Principal (253) /* Kerberos 5 principal name */
# define FamilyLocalHost (252) /* for local non-net authentication */
_XFUNCPROTOBEGIN
char *XauFileName(void);
Xauth *XauReadAuth(
FILE* /* auth_file */
);
int XauLockAuth(
_Xconst char* /* file_name */,
int /* retries */,
int /* timeout */,
long /* dead */
);
int XauUnlockAuth(
_Xconst char* /* file_name */
);
int XauWriteAuth(
FILE* /* auth_file */,
Xauth* /* auth */
);
Xauth *XauGetAuthByAddr(
#if NeedWidePrototypes
unsigned int /* family */,
unsigned int /* address_length */,
#else
unsigned short /* family */,
unsigned short /* address_length */,
#endif
_Xconst char* /* address */,
#if NeedWidePrototypes
unsigned int /* number_length */,
#else
unsigned short /* number_length */,
#endif
_Xconst char* /* number */,
#if NeedWidePrototypes
unsigned int /* name_length */,
#else
unsigned short /* name_length */,
#endif
_Xconst char* /* name */
);
Xauth *XauGetBestAuthByAddr(
#if NeedWidePrototypes
unsigned int /* family */,
unsigned int /* address_length */,
#else
unsigned short /* family */,
unsigned short /* address_length */,
#endif
_Xconst char* /* address */,
#if NeedWidePrototypes
unsigned int /* number_length */,
#else
unsigned short /* number_length */,
#endif
_Xconst char* /* number */,
int /* types_length */,
char** /* type_names */,
_Xconst int* /* type_lengths */
);
void XauDisposeAuth(
Xauth* /* auth */
);
_XFUNCPROTOEND
/* Return values from XauLockAuth */
# define LOCK_SUCCESS 0 /* lock succeeded */
# define LOCK_ERROR 1 /* lock unexpectely failed, check errno */
# define LOCK_TIMEOUT 2 /* lock failed, timeouts expired */
{$endif _XAUTH_STRUCT_ONLY}

View File

@ -0,0 +1,11 @@
program security_linktest;
uses
security;
begin
halt(0);
XSecurityQueryExtension(nil,nil,nil);
XSecurityAllocXauth;
XSecurityFreeXauth(nil);
XSecurityGenerateAuthorization(nil,nil,0,nil,nil);
XSecurityRevokeAuthorization(nil,0);
end.