|
|
|
|
Index: popper/main.c
|
|
|
|
|
--- popper/main.c.orig 2003-01-02 03:39:02.000000000 +0100
|
|
|
|
|
+++ popper/main.c 2003-09-18 22:04:57.000000000 +0200
|
|
|
|
|
@@ -226,12 +226,6 @@
|
|
|
|
|
err_out = msg_out = fopen ( "/dev/null", "w+" ); /* until we get set up */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
- * Ensure default port & address is in network order
|
|
|
|
|
- */
|
|
|
|
|
- addr = htonl ( addr );
|
|
|
|
|
- port = htons ( port );
|
|
|
|
|
-
|
|
|
|
|
- /*
|
|
|
|
|
* Set defaults for Qargc and Qargv
|
|
|
|
|
*/
|
|
|
|
|
Qargc = argc;
|
|
|
|
|
@@ -256,43 +250,34 @@
|
|
|
|
|
ptr = argv [ 1 ];
|
|
|
|
|
if ( argc >= 2 && ( *ptr == ':' || isdigit ( (int) *ptr ) ) )
|
|
|
|
|
{
|
|
|
|
|
- unsigned long a = addr;
|
|
|
|
|
- unsigned short n = port;
|
|
|
|
|
- char b [ 25 ] = "";
|
|
|
|
|
- char *q = b;
|
|
|
|
|
-
|
|
|
|
|
- /*
|
|
|
|
|
- * We might have an ip address first
|
|
|
|
|
- */
|
|
|
|
|
- if ( strchr ( ptr, '.' ) != NULL )
|
|
|
|
|
- while ( *ptr == '.' || isdigit ( (int) *ptr ) )
|
|
|
|
|
- *q++ = *ptr++;
|
|
|
|
|
-
|
|
|
|
|
- if ( *b != '\0' )
|
|
|
|
|
- {
|
|
|
|
|
- a = inet_addr ( b );
|
|
|
|
|
- ptr = strchr ( ptr, ':' );
|
|
|
|
|
- if ( ptr != NULL )
|
|
|
|
|
- ptr++;
|
|
|
|
|
+ char *cpIp = NULL;
|
|
|
|
|
+ char *cpPort = NULL;
|
|
|
|
|
+ char *cpDup;
|
|
|
|
|
+ char *cp;
|
|
|
|
|
+
|
|
|
|
|
+ if ((cpDup = strdup(ptr)) == NULL)
|
|
|
|
|
+ err_dump ( HERE, "unable to allocate memory to examine first argument" );
|
|
|
|
|
+ if ((cp = strchr(cpDup, ':')) != NULL) {
|
|
|
|
|
+ *cp++ = '\0'; /* a colon means both ip and port are given, split them */
|
|
|
|
|
+ if (*cpDup != '\0') /* do not accept empty strings */
|
|
|
|
|
+ cpIp = cpDup;
|
|
|
|
|
+ if (*cp != '\0') /* do not accept empty strings */
|
|
|
|
|
+ cpPort = cp;
|
|
|
|
|
}
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- ptr = argv [ 1 ];
|
|
|
|
|
- if ( *ptr == ':' )
|
|
|
|
|
- ptr++;
|
|
|
|
|
+ else {
|
|
|
|
|
+ if (strchr (ptr, '.') != NULL)
|
|
|
|
|
+ cpIp = cpDup; /* no colon but a dot means a ip is given */
|
|
|
|
|
+ else
|
|
|
|
|
+ cpPort = cpDup; /* no colon and no dot means a port is given */
|
|
|
|
|
}
|
|
|
|
|
+ if (cpIp != NULL )
|
|
|
|
|
+ addr = inet_addr(cpIp);
|
|
|
|
|
+ if (cpPort != NULL )
|
|
|
|
|
+ port = atoi(cpPort);
|
|
|
|
|
+ free(cpDup);
|
|
|
|
|
|
|
|
|
|
- /*
|
|
|
|
|
- * We might have a port number
|
|
|
|
|
- */
|
|
|
|
|
- if ( ptr != NULL )
|
|
|
|
|
- n = atoi ( ptr );
|
|
|
|
|
-
|
|
|
|
|
- if ( a == BAD_ADDR || n == 0 || n > USHRT_MAX )
|
|
|
|
|
+ if ( addr == BAD_ADDR || port == 0 || port > USHRT_MAX )
|
|
|
|
|
err_dump ( HERE, "invalid address and/or port: \"%s\"", argv[1] );
|
|
|
|
|
-
|
|
|
|
|
- port = htons ( n );
|
|
|
|
|
- addr = a;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Since we consumed the first specified parameter,
|
|
|
|
|
@@ -310,6 +295,8 @@
|
|
|
|
|
Qargv [ rslt - 1 ] = argv [ rslt ];
|
|
|
|
|
Qargc = argc - 1;
|
|
|
|
|
}
|
|
|
|
|
+ /* Ensure address remains and default port becomes network byte order */
|
|
|
|
|
+ port = htons ( port );
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Open the log
|
|
|
|
|
@@ -477,6 +464,22 @@
|
|
|
|
|
|
|
|
|
|
#endif /* not _DEBUG */
|
|
|
|
|
|
|
|
|
|
+#ifdef PIDFILE
|
|
|
|
|
+ /*
|
|
|
|
|
+ * Write PID file. -- RSE
|
|
|
|
|
+ */
|
|
|
|
|
+ {
|
|
|
|
|
+ pid_t pid;
|
|
|
|
|
+ FILE *fp;
|
|
|
|
|
+
|
|
|
|
|
+ pid = getpid();
|
|
|
|
|
+ if ((fp = fopen(PIDFILE, "w")) == NULL)
|
|
|
|
|
+ err_dump(HERE, "Can't write pidfile '%s'", PIDFILE);
|
|
|
|
|
+ fprintf(fp, "%ld\n", (long)pid);
|
|
|
|
|
+ fclose(fp);
|
|
|
|
|
+ }
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
/*
|
|
|
|
|
* Set up the socket on which we listen
|
|
|
|
|
*/
|
|
|
|
|
@@ -510,17 +513,9 @@
|
|
|
|
|
rslt = bind ( sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr) );
|
|
|
|
|
if ( rslt < 0 )
|
|
|
|
|
{
|
|
|
|
|
- if ( errno == EADDRINUSE )
|
|
|
|
|
- {
|
|
|
|
|
- fprintf ( stderr, "%s:%d in use\n",
|
|
|
|
|
- inet_ntoa ( serv_addr.sin_addr ),
|
|
|
|
|
- ntohs ( serv_addr.sin_port ) );
|
|
|
|
|
- return 1;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- err_dump ( HERE, "Can't bind local address %s:%d",
|
|
|
|
|
- inet_ntoa ( serv_addr.sin_addr ),
|
|
|
|
|
- ntohs ( serv_addr.sin_port ) );
|
|
|
|
|
+ err_dump ( HERE, "Can't bind local address %s:%d",
|
|
|
|
|
+ inet_ntoa ( serv_addr.sin_addr ),
|
|
|
|
|
+ ntohs ( serv_addr.sin_port ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TRACE ( trace_file, POP_DEBUG, HERE,
|
|
|
|
|
Index: pop_dropcopy.c
|
|
|
|
|
--- popper/pop_dropcopy.c.orig 2003-01-02 03:39:02.000000000 +0100
|
|
|
|
|
+++ popper/pop_dropcopy.c 2003-10-01 17:33:31.000000000 +0200
|
|
|
|
|
@@ -1231,6 +1231,10 @@
|
|
|
|
|
return pop_msg ( p, POP_FAILURE, HERE,
|
|
|
|
|
"[SYS/TEMP] Unable to get temp drop name" );
|
|
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
|
+ * OpenPKG: enforce usage of "spool-dir" configuration option
|
|
|
|
|
+ */
|
|
|
|
|
+#if 0
|
|
|
|
|
if ( stat ( p->temp_drop, &mybuf ) == -1 || mybuf.st_size <= 0 ) {
|
|
|
|
|
if ( genpath ( p,
|
|
|
|
|
p->temp_drop,
|
|
|
|
|
@@ -1239,6 +1243,7 @@
|
|
|
|
|
return pop_msg ( p, POP_FAILURE, HERE,
|
|
|
|
|
"[SYS/TEMP] Unable to get temp drop name" );
|
|
|
|
|
}
|
|
|
|
|
+#endif
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/*
|