* Local functions...
*/
-static int cups_rresvport(int *port, int family);
+static int cups_rresvport(int *port, int min, int family);
static int lpd_command(int lpd_fd, char *format, ...)
# ifdef __GNUC__
__attribute__ ((__format__ (__printf__, 2, 3)))
static int /* O - Socket or -1 on error */
cups_rresvport(int *port, /* IO - Port number to bind to */
+ int min, /* I - Minimim port number use */
int family) /* I - Address family */
{
http_addr_t addr; /* Socket address */
* Try to bind the socket to a reserved port...
*/
- while (*port > 511)
+ while (*port >= min)
{
/*
* Set the port number...
else
{
/*
- * We're running as root and want to comply with RFC 1179. Reserve a
- * privileged lport between 721 and 731...
+ * We're running as root and want to either:
+ * a) comply with RFC 1179 and reserve a lport between 721 and 731
+ * b) just reserve a privileged port between 512 and 1023
*/
- if ((fd = cups_rresvport(&lport, addr->addr.addr.sa_family)) < 0)
+ if ((fd = cups_rresvport(&lport,
+ reserve == RESERVE_RFC1179 ? 721 : 512,
+ addr->addr.addr.sa_family)) < 0)
{
perror("DEBUG: Unable to reserve port");
sleep(1);