[comp.windows.x] xaccess

Richard.Draves@IUS3.IUS.CS.CMU.EDU (05/31/88)

#
# type    sh /afs/cs.cmu.edu/bsd4.3/source/usr/misc/.X11tra/src/contrib/xaccess/xaccess.shar   to unpack this archive.
#
echo extracting README...
cat >README <<'!E!O!F!'
This is a very simple program for enabling and disabling an X server's use
of the host access control list.  It has a few CMU-CSD/Mach dependencies (use
of boolean_t and quit come to mind) but I thought it might be useful to
others anyway...
!E!O!F!
#
# type    sh /afs/cs.cmu.edu/bsd4.3/source/usr/misc/.X11tra/src/contrib/xaccess/xaccess.shar   to unpack this archive.
#
echo extracting xaccess.man...
cat >xaccess.man <<'!E!O!F!'
.TH XACCESS 1 "29 May 1988" "X Version 11"
.SH NAME
xaccess - enable/disable access control
.SH SYNOPSIS
.B "xaccess"
[-on] [-off]
.SH DESCRIPTION
.PP
The \fIxaccess\fP program allows you to enable or disable your display server's
use of a host access control list.  The server maintains a list of hosts
allowed to open connections to the server.  By default, \fIxaccess\fP will
disable use of this access control list and allow any host to open connections.
.SH OPTIONS
.TP 8
.B \-off
This option (the default) disables use of the access control list.
.TP 8
.B \-on
This option enables use of the access control list.
.SH "SEE ALSO"
X(1), xhost(1)
.SH AUTHOR
Richard Draves
!E!O!F!
#
# type    sh /afs/cs.cmu.edu/bsd4.3/source/usr/misc/.X11tra/src/contrib/xaccess/xaccess.shar   to unpack this archive.
#
echo extracting Imakefile...
cat >Imakefile <<'!E!O!F!'
LOCAL_LIBRARIES = $(XLIB)

SimpleProgramTarget(xaccess)
!E!O!F!
#
# type    sh /afs/cs.cmu.edu/bsd4.3/source/usr/misc/.X11tra/src/contrib/xaccess/xaccess.shar   to unpack this archive.
#
echo extracting xaccess.c...
cat >xaccess.c <<'!E!O!F!'
#include <stdio.h>
#include <strings.h>
#include <X11/Xlib.h>
#define	EXPORT_BOOLEAN
#include <sys/boolean.h>

#define streql(a, b)	(strcmp((a), (b)) == 0)

static char *program;

static void
usage()
{
    quit(1, "%s: usage: %s [-on] [-off]\n", program, program);
}

void
main(argc, argv)
    int argc;
    char *argv[];
{
    Display *d;
    boolean_t Access = FALSE;
    int i;

    if ((program = rindex(argv[0], '/')) != NULL)
	program++;
    else
	program = argv[0];

    for (i = 1; i < argc; i++)
	if (streql(argv[i], "-on"))
	    Access = TRUE;
	else if (streql(argv[i], "-off"))
	    Access = FALSE;
	else if (streql(argv[i], "--"))
	    break;
	else if (argv[i][0] == '-')
	    usage();
	else
	    break;

    if (i < argc)
	usage();

    d = XOpenDisplay((char *) NULL);
    if (d == NULL)
	quit(1, "%s: could not open display\n", program);

    if (Access)
	XEnableAccessControl(d);
    else
	XDisableAccessControl(d);
    XSync(d);

    exit(0);
}
!E!O!F!