aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/lib/X11
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2016-07-01 15:48:55 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2016-07-01 15:48:55 +0200
commit2f19f2f66d7cc3d844e8f1eb58d65c4fa6b867d1 (patch)
treeba1bf29ee69e8ae391b0773161ff3baf58707761 /nx-X11/lib/X11
parenta3a295288189d1312f5abef0e7b4cc57b948e7d3 (diff)
parent20454528656dbe98a538de7c67ce89e50841bd5f (diff)
downloadnx-libs-2f19f2f66d7cc3d844e8f1eb58d65c4fa6b867d1.tar.gz
nx-libs-2f19f2f66d7cc3d844e8f1eb58d65c4fa6b867d1.tar.bz2
nx-libs-2f19f2f66d7cc3d844e8f1eb58d65c4fa6b867d1.zip
Merge branch 'sunweaver-pr/libXau-cleanup' into 3.6.x
Attributes GH PR #152: https://github.com/ArcticaProject/nx-libs/pull/152 Reviewed by: Vadim Troshchinskiy <vadim@qindel.com> -- Fri, 01 Jul 2016 14:55:00 +0200
Diffstat (limited to 'nx-X11/lib/X11')
-rw-r--r--nx-X11/lib/X11/AuDispose.c51
-rw-r--r--nx-X11/lib/X11/AuFileName.c75
-rw-r--r--nx-X11/lib/X11/AuGetBest.c173
-rw-r--r--nx-X11/lib/X11/AuRead.c137
-rw-r--r--nx-X11/lib/X11/Imakefile18
5 files changed, 436 insertions, 18 deletions
diff --git a/nx-X11/lib/X11/AuDispose.c b/nx-X11/lib/X11/AuDispose.c
new file mode 100644
index 000000000..dc2080f40
--- /dev/null
+++ b/nx-X11/lib/X11/AuDispose.c
@@ -0,0 +1,51 @@
+/* $Xorg: AuDispose.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xau/AuDispose.c,v 1.4 2001/07/25 15:04:48 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <nx-X11/Xauth.h>
+#include <stdlib.h>
+
+void
+XauDisposeAuth (auth)
+Xauth *auth;
+{
+ if (auth) {
+ if (auth->address) (void) free (auth->address);
+ if (auth->number) (void) free (auth->number);
+ if (auth->name) (void) free (auth->name);
+ if (auth->data) {
+ (void) bzero (auth->data, auth->data_length);
+ (void) free (auth->data);
+ }
+ free ((char *) auth);
+ }
+ return;
+}
diff --git a/nx-X11/lib/X11/AuFileName.c b/nx-X11/lib/X11/AuFileName.c
new file mode 100644
index 000000000..6ab0138b8
--- /dev/null
+++ b/nx-X11/lib/X11/AuFileName.c
@@ -0,0 +1,75 @@
+/* $Xorg: AuFileName.c,v 1.5 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xau/AuFileName.c,v 3.6 2001/07/25 15:04:48 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <nx-X11/Xauth.h>
+#include <nx-X11/Xos.h>
+#include <stdlib.h>
+
+char *
+XauFileName ()
+{
+ char *slashDotXauthority = "/.Xauthority";
+ char *name;
+ static char *buf;
+ static int bsize;
+#ifdef WIN32
+ char dir[128];
+#endif
+ int size;
+
+ if ((name = getenv ("XAUTHORITY")))
+ return name;
+ name = getenv ("HOME");
+ if (!name) {
+#ifdef WIN32
+ (void) strcpy (dir, "/users/");
+ if ((name = getenv("USERNAME"))) {
+ (void) strcat (dir, name);
+ name = dir;
+ }
+ if (!name)
+#endif
+ return 0;
+ }
+ size = strlen (name) + strlen(&slashDotXauthority[1]) + 2;
+ if (size > bsize) {
+ if (buf)
+ free (buf);
+ buf = malloc ((unsigned) size);
+ if (!buf)
+ return 0;
+ bsize = size;
+ }
+ strcpy (buf, name);
+ strcat (buf, slashDotXauthority + (name[1] == '\0' ? 1 : 0));
+ return buf;
+}
diff --git a/nx-X11/lib/X11/AuGetBest.c b/nx-X11/lib/X11/AuGetBest.c
new file mode 100644
index 000000000..03d49ac80
--- /dev/null
+++ b/nx-X11/lib/X11/AuGetBest.c
@@ -0,0 +1,173 @@
+/* $Xorg: AuGetBest.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xau/AuGetBest.c,v 1.7 2001/12/14 19:54:36 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <nx-X11/Xauth.h>
+#include <nx-X11/Xos.h>
+#ifdef XTHREADS
+#include <nx-X11/Xthreads.h>
+#endif
+#ifdef hpux
+#define X_INCLUDE_NETDB_H
+#define XOS_USE_NO_LOCKING
+#include <nx-X11/Xos_r.h>
+#endif
+
+static int
+binaryEqual (_Xconst char *a, _Xconst char *b, int len)
+{
+ while (len--)
+ if (*a++ != *b++)
+ return 0;
+ return 1;
+}
+
+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** types,
+ _Xconst int* type_lengths)
+{
+ FILE *auth_file;
+ char *auth_name;
+ Xauth *entry;
+ Xauth *best;
+ int best_type;
+ int type;
+#ifdef hpux
+ char *fully_qual_address;
+ unsigned short fully_qual_address_length;
+#endif
+
+ auth_name = XauFileName ();
+ if (!auth_name)
+ return 0;
+ if (access (auth_name, R_OK) != 0) /* checks REAL id */
+ return 0;
+ auth_file = fopen (auth_name, "rb");
+ if (!auth_file)
+ return 0;
+
+#ifdef hpux
+ if (family == FamilyLocal) {
+#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
+ _Xgethostbynameparams hparams;
+#endif
+ struct hostent *hostp;
+
+ /* make sure we try fully-qualified hostname */
+ if ((hostp = _XGethostbyname(address,hparams)) != NULL) {
+ fully_qual_address = hostp->h_name;
+ fully_qual_address_length = strlen(fully_qual_address);
+ }
+ else
+ {
+ fully_qual_address = NULL;
+ fully_qual_address_length = 0;
+ }
+ }
+#endif /* hpux */
+
+ best = 0;
+ best_type = types_length;
+ for (;;) {
+ entry = XauReadAuth (auth_file);
+ if (!entry)
+ break;
+ /*
+ * Match when:
+ * either family or entry->family are FamilyWild or
+ * family and entry->family are the same and
+ * address and entry->address are the same
+ * and
+ * either number or entry->number are empty or
+ * number and entry->number are the same
+ * and
+ * either name or entry->name are empty or
+ * name and entry->name are the same
+ */
+
+ if ((family == FamilyWild || entry->family == FamilyWild ||
+ (entry->family == family &&
+ ((address_length == entry->address_length &&
+ binaryEqual (entry->address, address, (int)address_length))
+#ifdef hpux
+ || (family == FamilyLocal &&
+ fully_qual_address_length == entry->address_length &&
+ binaryEqual (entry->address, fully_qual_address,
+ (int) fully_qual_address_length))
+#endif
+ ))) &&
+ (number_length == 0 || entry->number_length == 0 ||
+ (number_length == entry->number_length &&
+ binaryEqual (entry->number, number, (int)number_length))))
+ {
+ if (best_type == 0)
+ {
+ best = entry;
+ break;
+ }
+ for (type = 0; type < best_type; type++)
+ if (type_lengths[type] == entry->name_length &&
+ !(strncmp (types[type], entry->name, entry->name_length)))
+ {
+ break;
+ }
+ if (type < best_type)
+ {
+ if (best)
+ XauDisposeAuth (best);
+ best = entry;
+ best_type = type;
+ if (type == 0)
+ break;
+ continue;
+ }
+ }
+ XauDisposeAuth (entry);
+ }
+ (void) fclose (auth_file);
+ return best;
+}
diff --git a/nx-X11/lib/X11/AuRead.c b/nx-X11/lib/X11/AuRead.c
new file mode 100644
index 000000000..2e2509633
--- /dev/null
+++ b/nx-X11/lib/X11/AuRead.c
@@ -0,0 +1,137 @@
+/* $Xorg: AuRead.c,v 1.4 2001/02/09 02:03:42 xorgcvs Exp $ */
+
+/*
+
+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.
+
+*/
+/* $XFree86: xc/lib/Xau/AuRead.c,v 1.5 2001/07/25 15:04:48 dawes Exp $ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <nx-X11/Xauth.h>
+#include <stdlib.h>
+#include <errno.h>
+
+static int
+read_short (unsigned short *shortp, FILE *file)
+{
+ unsigned char file_short[2];
+
+ /*
+ * Added a check on EINTR to prevent the fread() call to be
+ * interrupted by any signal not blocked by OsBlockSignals().
+ */
+
+ for (;;) {
+ if (fread ((char *) file_short, (int) sizeof (file_short), 1, file) != 1) {
+ if (errno == EINTR && ferror (file)) {
+ perror ("Reading from auth file");
+ clearerr (file);
+ continue;
+ }
+ return 0;
+ }
+ break;
+ }
+ *shortp = file_short[0] * 256 + file_short[1];
+ return 1;
+}
+
+static int
+read_counted_string (unsigned short *countp, char **stringp, FILE *file)
+{
+ unsigned short len;
+ char *data;
+
+ if (read_short (&len, file) == 0)
+ return 0;
+ if (len == 0) {
+ data = 0;
+ } else {
+ data = malloc ((unsigned) len);
+ if (!data)
+ return 0;
+ for (;;)
+ {
+ if (fread (data, (int) sizeof (char), (int) len, file) != len)
+ {
+ if (errno == EINTR && ferror (file))
+ {
+ perror ("Reading from auth file");
+ clearerr (file);
+ continue;
+ }
+ bzero (data, len);
+ free (data);
+ return 0;
+ }
+ break;
+ }
+ }
+ *stringp = data;
+ *countp = len;
+ return 1;
+}
+
+Xauth *
+XauReadAuth (auth_file)
+FILE *auth_file;
+{
+ Xauth local;
+ Xauth *ret;
+
+ if (read_short (&local.family, auth_file) == 0)
+ return 0;
+ if (read_counted_string (&local.address_length, &local.address, auth_file) == 0)
+ return 0;
+ if (read_counted_string (&local.number_length, &local.number, auth_file) == 0) {
+ if (local.address) free (local.address);
+ return 0;
+ }
+ if (read_counted_string (&local.name_length, &local.name, auth_file) == 0) {
+ if (local.address) free (local.address);
+ if (local.number) free (local.number);
+ return 0;
+ }
+ if (read_counted_string (&local.data_length, &local.data, auth_file) == 0) {
+ if (local.address) free (local.address);
+ if (local.number) free (local.number);
+ if (local.name) free (local.name);
+ return 0;
+ }
+ ret = (Xauth *) malloc (sizeof (Xauth));
+ if (!ret) {
+ if (local.address) free (local.address);
+ if (local.number) free (local.number);
+ if (local.name) free (local.name);
+ if (local.data) {
+ bzero (local.data, local.data_length);
+ free (local.data);
+ }
+ return 0;
+ }
+ *ret = local;
+ return ret;
+}
diff --git a/nx-X11/lib/X11/Imakefile b/nx-X11/lib/X11/Imakefile
index 1ba1e4818..cc87d6e7b 100644
--- a/nx-X11/lib/X11/Imakefile
+++ b/nx-X11/lib/X11/Imakefile
@@ -172,12 +172,6 @@ EXTRA_LIBRARIES = /**/
SETID_DEFINES = -DHASGETRESUID
#endif
XLC_DEFINES = -DXLOCALEDIR=\"$(XLOCALEDIR)\"
-#if HasKrb5
- K5OBJS = k5encode.o
- K5SRCS = k5encode.c
- K5INCL = Krb5Includes
- K5DEFS = Krb5Defines
-#endif
#if (defined(FreeBSDArchitecture) && OSRelVersion < 500016) || \
defined(OpenBSDArchitecture)
THRSTUBSRCS = UIThrStubs.c
@@ -1082,9 +1076,6 @@ SpecialCLibObjectRule(KeyBind,$(ICONFIGFILES),$(XKB_DEFINES))
SpecialCLibObjectRule(XKBBind,$(ICONFIGFILES),$(XKB_DEFINES))
SpecialCLibObjectRule(imConv,$(ICONFIGFILES),$(XKB_DEFINES))
#endif
-#if HasKrb5
-SpecialCLibObjectRule(k5encode,$(_NOOP_),$(K5INCL))
-#endif
#if BuildLoadableXlibI18n
SpecialCLibObjectRuleSeparateOpts(lcInit,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES))
SpecialCLibObjectRuleSeparateOpts(lcGeneric,$(ICONFIGFILES),$(_NOOP_),$(LC_DYNDEFINES))
@@ -1104,15 +1095,6 @@ InstallNonExecFile(XErrorDB,$(LIBDIR))
InstallNonExecFile(XKeysymDB,$(LIBDIR))
InstallLintLibrary(X11,$(LINTLIBDIR))
-
-LinkSourceFile(AuDispose.c,$(XAUTHSRC))
-LinkSourceFile(AuGetBest.c,$(XAUTHSRC))
-LinkSourceFile(AuFileName.c,$(XAUTHSRC))
-LinkSourceFile(AuRead.c,$(XAUTHSRC))
-#if HasKrb5
-LinkSourceFile(k5encode.c,$(XAUTHSRC))
-#endif
-
#ifdef QNX4Architecture
LOCAL_LDFLAGS=-F
#endif