From d4bfb01416cd7954db52acc41d764847364b97f9 Mon Sep 17 00:00:00 2001
From: Lev Kujawski <int21h@mailbox.org>
Date: Wed, 6 Jan 2021 12:26:40 -0700
Subject: [PATCH 5/7] Disable binding a privileged client port with rresvport()
 on Linux systems using the musl C library, where that function is
 unsupported. If there is a need for XPrint support, a BSD-licensed
 implementation of rresvport() is available in the portable edition of
 OpenSSH.

---
 cde/programs/dtprintinfo/objects/PrintObj/ParseJobs.C | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/cde/programs/dtprintinfo/objects/PrintObj/ParseJobs.C b/cde/programs/dtprintinfo/objects/PrintObj/ParseJobs.C
index b970d7eb..2c532c8a 100644
--- a/cde/programs/dtprintinfo/objects/PrintObj/ParseJobs.C
+++ b/cde/programs/dtprintinfo/objects/PrintObj/ParseJobs.C
@@ -195,8 +195,16 @@ int ConnectToPrintServer(const char *rhost, int timeout)
    // run as user's UID, but with privileges from root
    SETEUID(0);
 
-   // Try connecting to the server.
+   // Try connecting to the server from a privileged port.
+   /* FIXME: Test for the presence of rresvport and provide a substitute
+    *        if necessary. Linux C library support:
+    * dietlibc: no rresvport, defines __dietlibc__
+    * musl: no rresvport
+    * uclibc: rresvport, defines __GLIBC__
+    */
+#if !defined(__linux__) || defined(__GLIBC__)
    s = rresvport(&lport);
+#endif
 
    signal(SIGALRM, connect_timeout);
    if (timeout > 0)
-- 
2.30.0

