r19808 - in /trunk/pperl: ./ debian/ debian/patches/ t/

dmn at users.alioth.debian.org dmn at users.alioth.debian.org
Sat May 10 09:14:13 UTC 2008


Author: dmn
Date: Sat May 10 09:14:12 2008
New Revision: 19808

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=19808
Log:
split combined .diff into quilt patches

Added:
    trunk/pperl/debian/patches/287119_no-umask0.patch
    trunk/pperl/debian/patches/pass_PPERL_TMP_PATH.patch
    trunk/pperl/debian/patches/pass_fd.c.patch
    trunk/pperl/debian/patches/pperl-man.patch
    trunk/pperl/debian/patches/safe-socket-path.patch
    trunk/pperl/debian/patches/unclean-name-checks.patch
Modified:
    trunk/pperl/Makefile.PL
    trunk/pperl/PPerl.pm
    trunk/pperl/debian/changelog
    trunk/pperl/debian/patches/no-extra-libs.patch
    trunk/pperl/debian/patches/series
    trunk/pperl/main.c
    trunk/pperl/pass_fd.c
    trunk/pperl/pperl.h.header
    trunk/pperl/t/04args.t
    trunk/pperl/t/11autoclose.t
    trunk/pperl/t/env.plx

Modified: trunk/pperl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/pperl/Makefile.PL?rev=19808&op=diff
==============================================================================
--- trunk/pperl/Makefile.PL (original)
+++ trunk/pperl/Makefile.PL Sat May 10 09:14:12 2008
@@ -1,5 +1,4 @@
 use ExtUtils::MakeMaker;
-use ExtUtils::Embed;
 use Config;
 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
 # the contents of the Makefile that is written.
@@ -56,16 +55,10 @@
       (ABSTRACT_FROM => 'PPerl.pm', # retrieve abstract from module
        AUTHOR     => 'Matt Sergeant, matt at sergeant.org') : ()),
        DEFINE     => "-DVARIANT_$variant -DPERL_INTERP='\"$perl_path\"' -I.",
-       MAN1PODS   => { "PPerl.pm" => 'pperl.1p' },
-       MAN3PODS   => { },
 );
 
 
 sub MY::postamble {
-    my $ccopts = ccopts;
-    chomp $ccopts;
-    my $ldopts = ldopts;
-    chomp $ldopts;
     "
 # just hacking around
 $hacking
@@ -76,7 +69,7 @@
 main.o: Makefile main.c pperl.h
 
 pperl: main.o pass_fd.o
-\t\$(CC) \$(DEFINE) -o pperl main.o pass_fd.o $ldopts
+\t\$(CC) \$(CFLAGS) \$(LDFLAGS) \$(DEFINE) -o pperl main.o pass_fd.o $Config{libs}
 
 pass_fd.c: pass_fd.h
 

Modified: trunk/pperl/PPerl.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/pperl/PPerl.pm?rev=19808&op=diff
==============================================================================
--- trunk/pperl/PPerl.pm (original)
+++ trunk/pperl/PPerl.pm Sat May 10 09:14:12 2008
@@ -30,7 +30,7 @@
 
 This program turns ordinary perl scripts into long running daemons, making
 subsequent executions extremely fast. It forks several processes for each
-script, allowing many processes to call the script at once.
+script, allowing many proceses to call the script at once.
 
 It works a lot like SpeedyCGI, but is written a little differently. I didn't
 use the SpeedyCGI codebase, because I couldn't get it to compile, and needed
@@ -75,13 +75,6 @@
 Alternatively look for a .pid file for the script in your tmp directory, and
 kill (with SIGINT) the process with that PID.
 
-=head1 ENVIRONMENT
-
-B<pperl> uses the B<PPERL_TMP_PATH> environment variable to determine
-the directory where to store the files used for inter-process
-communication.  By default, the subdirectory I<.pperl> of the user's
-home directory is used.
-
 =head1 BUGS
 
 The process does not reload when the script or modules change.

Modified: trunk/pperl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/pperl/debian/changelog?rev=19808&op=diff
==============================================================================
--- trunk/pperl/debian/changelog (original)
+++ trunk/pperl/debian/changelog Sat May 10 09:14:12 2008
@@ -16,6 +16,7 @@
   * add debian/watch
   * add no-extra-libs.patch, removing unnecessary dyn-linkiing to perl, m, dl
     + bring quilt in debian/rules and debian/control
+  * split combined .diff into quilt patches
 
   [ gregor herrmann ]
   * Set Standards-Version to 3.7.3 (no changes).

Added: trunk/pperl/debian/patches/287119_no-umask0.patch
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/pperl/debian/patches/287119_no-umask0.patch?rev=19808&op=file
==============================================================================
--- trunk/pperl/debian/patches/287119_no-umask0.patch (added)
+++ trunk/pperl/debian/patches/287119_no-umask0.patch Sat May 10 09:14:12 2008
@@ -1,0 +1,48 @@
+--- pperl-0.25.orig/pperl.h.header
++++ pperl-0.25/pperl.h.header
+@@ -188,7 +188,6 @@
+   open(STDOUT,">/dev/null");
+   open(STDERR, '>&STDOUT');
+   chdir '/';           # change working directory
+-  umask(0);            # forget file mode creation mask
+   $ENV{PATH} = '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin';
+   delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
+   $SIG{CHLD} = \&reap_child;
+--- pperl-0.25.orig/t/11autoclose.t
++++ pperl-0.25/t/11autoclose.t
+@@ -1,16 +1,26 @@
+ #!perl -w
+ use Test;
+-BEGIN { plan tests => 4 }
++use Fcntl ':mode';
++BEGIN { plan tests => 6 }
+ 
+ `./pperl --prefork=1 t/autoclose.plx`;
+ 
+ my $file = "foo.$$";
+ my $foo;
+ 
++# Regression test for Debian bug #287119.
++sub check_perm () {
++    my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
++	$atime,$mtime,$ctime,$blksize,$blocks)
++	= stat($file);
++    ok(S_IMODE($mode), 0644);
++}
++
+ `$^X t/autoclose.plx $file foo`;
+ ok(`$^X t/cat.plx $file`, "foo\n");
+ `$^X t/autoclose.plx $file bar`;
+ ok(`$^X t/cat.plx $file`, "foo\nbar\n");
++check_perm;
+ 
+ unlink $file;
+ 
+@@ -18,6 +28,7 @@
+ ok(`$^X t/cat.plx $file`, "foo\n");
+ `./pperl t/autoclose.plx $file bar`;
+ ok(`$^X t/cat.plx $file`, "foo\nbar\n");
++check_perm;
+ 
+ `./pperl -k t/autoclose.plx`;
+ `./pperl -k t/cat.plx`;

Modified: trunk/pperl/debian/patches/no-extra-libs.patch
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/pperl/debian/patches/no-extra-libs.patch?rev=19808&op=diff
==============================================================================
--- trunk/pperl/debian/patches/no-extra-libs.patch (original)
+++ trunk/pperl/debian/patches/no-extra-libs.patch Sat May 10 09:14:12 2008
@@ -1,12 +1,28 @@
-Index: pperl/Makefile.PL
-===================================================================
---- pperl.orig/Makefile.PL	2008-05-09 15:33:07.000000000 +0300
+diff -u pperl-0.25/Makefile.PL pperl/Makefile.PL
+--- pperl-0.25/Makefile.PL
 +++ pperl/Makefile.PL	2008-05-09 15:33:10.000000000 +0300
-@@ -76,7 +76,7 @@
+@@ -1,4 +1,5 @@
+ use ExtUtils::MakeMaker;
++use ExtUtils::Embed;
+ use Config;
+ # See lib/ExtUtils/MakeMaker.pm for details of how to influence
+ # the contents of the Makefile that is written.
+@@ -55,6 +56,10 @@
+ 
+ 
+ sub MY::postamble {
++    my $ccopts = ccopts;
++    chomp $ccopts;
++    my $ldopts = ldopts;
++    chomp $ldopts;
+     "
+ # just hacking around
+ $hacking
+@@ -71,7 +76,7 @@
  main.o: Makefile main.c pperl.h
  
  pperl: main.o pass_fd.o
--\t\$(CC) \$(DEFINE) -o pperl main.o pass_fd.o $ldopts
+-\t\$(CC) \$(CFLAGS) \$(LDFLAGS) \$(DEFINE) -o pperl main.o pass_fd.o $Config{libs}
 +\t\$(CC) \$(DEFINE) -o pperl main.o pass_fd.o
  
  pass_fd.c: pass_fd.h

Added: trunk/pperl/debian/patches/pass_PPERL_TMP_PATH.patch
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/pperl/debian/patches/pass_PPERL_TMP_PATH.patch?rev=19808&op=file
==============================================================================
--- trunk/pperl/debian/patches/pass_PPERL_TMP_PATH.patch (added)
+++ trunk/pperl/debian/patches/pass_PPERL_TMP_PATH.patch Sat May 10 09:14:12 2008
@@ -1,0 +1,47 @@
+--- pperl-0.25.orig/t/env.plx
++++ pperl-0.25/t/env.plx
+@@ -1,3 +1,3 @@
+ #!perl -w
+ use strict;
+-print map { "'$_' => '$ENV{$_}'\n" } sort keys %ENV;
+\ No newline at end of file
++print map { "'$_' => '$ENV{$_}'\n" } sort grep { $_ ne 'PPERL_TMP_PATH' } keys %ENV;
+--- pperl-0.25.orig/PPerl.pm
++++ pperl-0.25/PPerl.pm
+@@ -30,7 +30,7 @@
+ 
+ This program turns ordinary perl scripts into long running daemons, making
+ subsequent executions extremely fast. It forks several processes for each
+-script, allowing many proceses to call the script at once.
++script, allowing many processes to call the script at once.
+ 
+ It works a lot like SpeedyCGI, but is written a little differently. I didn't
+ use the SpeedyCGI codebase, because I couldn't get it to compile, and needed
+@@ -75,6 +75,13 @@
+ Alternatively look for a .pid file for the script in your tmp directory, and
+ kill (with SIGINT) the process with that PID.
+ 
++=head1 ENVIRONMENT
++
++B<pperl> uses the B<PPERL_TMP_PATH> environment variable to determine
++the directory where to store the files used for inter-process
++communication.  By default, the subdirectory I<.pperl> of the user's
++home directory is used.
++
+ =head1 BUGS
+ 
+ The process does not reload when the script or modules change.
+--- pperl-0.25.orig/t/04args.t
++++ pperl-0.25/t/04args.t
+@@ -17,9 +17,11 @@
+ 
+ `./pperl t/env.plx`; # run it once so there's a $ENV{PATH} about
+ 
++my $tmp_path = $ENV{PPERL_TMP_PATH};
+ %ENV = ( foo       => "bar\nbaz",
+          "quu\nx"  => "wobble",
+          null      => '');
++$ENV{PPERL_TMP_PATH} = $tmp_path if $tmp_path;
+ 
+ ok(capture($^X, 't/env.plx'),
+   qq{'foo' => 'bar\nbaz'\n'null' => ''\n'quu\nx' => 'wobble'\n});

Added: trunk/pperl/debian/patches/pass_fd.c.patch
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/pperl/debian/patches/pass_fd.c.patch?rev=19808&op=file
==============================================================================
--- trunk/pperl/debian/patches/pass_fd.c.patch (added)
+++ trunk/pperl/debian/patches/pass_fd.c.patch Sat May 10 09:14:12 2008
@@ -1,0 +1,223 @@
+--- pperl-0.25.orig/pass_fd.c
++++ pperl-0.25/pass_fd.c
+@@ -1,165 +1,75 @@
+-/* code lifted from Stevens' APUE */
++/* Code based on Stevens' UNIX Network Programming, and simplified. */
++/* Florian Weimer <fw at deneb.enyo.de>, April 2008 */
+ 
+-#include	<errno.h>		/* for definition of errno */
+-#include	<stdarg.h>		/* ANSI C header file */
++#include	<errno.h>
+ #include	<sys/types.h>
+ #include	<sys/socket.h>
+-#include	<sys/uio.h>
+-#include	<string.h>
+ #include        <unistd.h>
+ #include	"pass_fd.h"
+ 
+-#if VARIANT_SVR4
+-
+ int
+ s_pipe(int fd[2])
+ {
+-    return( pipe(fd) );
++  return socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
+ }
+ 
+-#elif defined(VARIANT_43BSD) || defined(VARIANT_44BSD)
+-
+-int
+-s_pipe(int fd[2])
+-{
+-    return( socketpair(AF_UNIX, SOCK_STREAM, 0, fd) );
+-}
+-
+-#else
+-
+-#error "Couldn't guess variant"
+-
+-#endif
+-
+-
+-#if VARIANT_43BSD
+-
+ int
+ send_fd(int clifd, int fd)
+ {
+-    struct iovec  iov[1];
+-    struct msghdr msg;
+-    char   buf[2];
+-
+-    iov[0].iov_base = buf;
+-    iov[0].iov_len  = 2;
+-    msg.msg_iov     = iov;
+-    msg.msg_iovlen  = 1;
+-    msg.msg_name    = NULL;
+-    msg.msg_namelen = 0;
+-
+-    if (fd < 0) {
+-	msg.msg_accrights    = NULL;
+-	msg.msg_accrightslen = 0;
+-	buf[1] = -fd;
+-	if (buf[1] == 0)
+-	    buf[1] = 1;
+-    } 
+-    else {
+-	msg.msg_accrights    = (caddr_t) &fd;
+-	msg.msg_accrightslen = sizeof(int);
+-	buf[1] = 0;
+-    }
+-    buf[0] = 0;
+-
+-    if (sendmsg(clifd, &msg, 0) != 2)
+-	return(-1);
+-    
+-    return(0);
++  union {
++    struct cmsghdr cm;
++    char control[CMSG_SPACE(sizeof(int))];
++  } control_aligned;
++
++  struct msghdr msg = {0};
++  msg.msg_control = control_aligned.control;
++  msg.msg_controllen = sizeof(control_aligned.control);
++
++  struct cmsghdr *cmptr = CMSG_FIRSTHDR(&msg);
++  cmptr->cmsg_len = CMSG_LEN(sizeof(int));
++  cmptr->cmsg_level = SOL_SOCKET;
++  cmptr->cmsg_type = SCM_RIGHTS;
++  *((int *) CMSG_DATA(cmptr)) = fd;
++
++  char buf[1] = {0};
++  struct iovec iov = {.iov_base = buf, .iov_len = sizeof(buf)};
++  msg.msg_iov = &iov;
++  msg.msg_iovlen = 1;
++
++  if (sendmsg(clifd, &msg, 0) != 1)
++    return -1;
++  return 0;
+ }
+ 
+ int
+ recv_fd(int servfd)
+ {
+-    int newfd, nread, status;
+-    char *ptr, buf[2];
+-    struct iovec  iov[1];
+-    struct msghdr msg;
+-
+-    iov[0].iov_base = buf;
+-    iov[0].iov_len  = 2;
+-    msg.msg_iov     = iov;
+-    msg.msg_iovlen  = 1;
+-    msg.msg_name    = NULL;
+-    msg.msg_namelen = 0;
+-    msg.msg_accrights = (caddr_t) &newfd;
+-    msg.msg_accrightslen = sizeof(int);
+-    
+-    if ( (nread = recvmsg(servfd, &msg, 0)) <= 0)
+-	return(-1);
+-    
+-    return(newfd);/* descriptor, or -status */
++  union {
++    struct cmsghdr cm;
++    char control[CMSG_SPACE(sizeof(int))];
++  } control_aligned;
++
++  struct msghdr msg = {0};
++  msg.msg_control = control_aligned.control;
++  msg.msg_controllen = sizeof(control_aligned.control);
++
++  char buf[1] = {0};
++  struct iovec iov = {.iov_base = buf, .iov_len = sizeof(buf)};
++  msg.msg_iov = &iov;
++  msg.msg_iovlen = 1;
++
++  ssize_t result = recvmsg(servfd, &msg, 0);
++  if (result < 0)
++    return -1;
++  if (result != 1) {
++    errno = EINVAL;
++    return -1;
++  }
++
++  struct cmsghdr *cmptr = CMSG_FIRSTHDR(&msg);
++  if (cmptr && cmptr->cmsg_len == CMSG_LEN(sizeof(int))
++      && cmptr->cmsg_level == SOL_SOCKET && cmptr->cmsg_type == SCM_RIGHTS)
++    return *((int *) CMSG_DATA(cmptr));
++  errno = ENXIO;
++  return -1;
+ }
+-
+-#else 
+-
+-struct cmessage {
+-    struct cmsghdr cmsg;
+-    int fd;
+-};
+-
+-int
+-send_fd(int over, int this)
+-{
+-    struct iovec iov[1];
+-    struct msghdr msg;
+-    struct cmessage cm;
+-    char sendbuf[] = "";
+-
+-    iov[0].iov_base = (char *)&sendbuf;
+-    iov[0].iov_len = sizeof(sendbuf);
+-    
+-    cm.cmsg.cmsg_type  = SCM_RIGHTS;
+-    cm.cmsg.cmsg_level = SOL_SOCKET;
+-    cm.cmsg.cmsg_len = sizeof(struct cmessage);
+-    cm.fd = this;
+-
+-    msg.msg_iov = iov;
+-    msg.msg_iovlen = 1;
+-    msg.msg_name = NULL;
+-    msg.msg_namelen = 0;
+-    msg.msg_control = (caddr_t)&cm;
+-    msg.msg_controllen = sizeof(struct cmessage);
+-    msg.msg_flags = 0;
+-
+-    if (sendmsg(over, &msg, 0) < 0)
+-	return -1;
+-    return 0;
+-}
+-
+-int 
+-recv_fd(int over)
+-{
+-    struct iovec iov[1];
+-    struct msghdr msg;
+-    struct cmessage cm;
+-    ssize_t got;
+-    char recbuf;
+-
+-    /* in examples this was >1 but this causes too much to be read,
+-     * causing sync issues */
+-
+-    iov[0].iov_base = &recbuf;
+-    iov[0].iov_len = 1;
+-
+-    bzero((char *)&cm, sizeof(cm));
+-    bzero((char *)&msg, sizeof(msg));
+-
+-    msg.msg_iov = iov;
+-    msg.msg_iovlen = 1;
+-    msg.msg_name = NULL;
+-    msg.msg_namelen = 0;
+-    msg.msg_control = (caddr_t)&cm;
+-    msg.msg_controllen = sizeof(struct cmessage);
+-    msg.msg_flags = 0;
+-
+-    if ((got = recvmsg(over, &msg, 0)) < 0)
+-	return -1;
+-
+-    if (cm.cmsg.cmsg_type != SCM_RIGHTS)
+-	return -1;
+-
+-    return cm.fd;
+-}
+-
+-#endif

Added: trunk/pperl/debian/patches/pperl-man.patch
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/pperl/debian/patches/pperl-man.patch?rev=19808&op=file
==============================================================================
--- trunk/pperl/debian/patches/pperl-man.patch (added)
+++ trunk/pperl/debian/patches/pperl-man.patch Sat May 10 09:14:12 2008
@@ -1,0 +1,11 @@
+--- pperl-0.25.orig/Makefile.PL
++++ pperl-0.25/Makefile.PL
+@@ -55,10 +56,16 @@
+       (ABSTRACT_FROM => 'PPerl.pm', # retrieve abstract from module
+        AUTHOR     => 'Matt Sergeant, matt at sergeant.org') : ()),
+        DEFINE     => "-DVARIANT_$variant -DPERL_INTERP='\"$perl_path\"' -I.",
++       MAN1PODS   => { "PPerl.pm" => 'pperl.1p' },
++       MAN3PODS   => { },
+ );
+ 
+ 

Added: trunk/pperl/debian/patches/safe-socket-path.patch
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/pperl/debian/patches/safe-socket-path.patch?rev=19808&op=file
==============================================================================
--- trunk/pperl/debian/patches/safe-socket-path.patch (added)
+++ trunk/pperl/debian/patches/safe-socket-path.patch Sat May 10 09:14:12 2008
@@ -1,0 +1,122 @@
+--- pperl-0.25.orig/main.c
++++ pperl-0.25/main.c
+@@ -6,10 +6,12 @@
+ #include <stdarg.h>
+ #include <memory.h>
+ #include <errno.h>
++#include <pwd.h>
+ #include <sys/types.h>
+ #include <sys/wait.h>
+ #include <sys/socket.h>
+ #include <sys/un.h>
++#include <sys/file.h>
+ #include <sys/stat.h>
+ #include <sys/time.h>
+ #include <fcntl.h>
+@@ -45,6 +47,7 @@
+ int prefork = 5;
+ int maxclients = 100;
+ int path_max;
++char* tmp_path;
+ int no_cleanup = 0;
+ FILE *log_fd = NULL;
+ 
+@@ -68,11 +71,55 @@
+     fflush(log_fd);
+ }
+ 
++static void *my_malloc(size_t);
++
++/* Set tmp_path to a user-specific path for the pperl control files. */
++static void
++setup_tmp_path(void)
++{
++    uid_t me = getuid();
++    struct passwd *pw = getpwuid(me);
++
++    tmp_path = my_malloc(path_max);
++    if (pw) {
++        snprintf(tmp_path, path_max, "%s/.pperl", pw->pw_dir);
++        mkdir(tmp_path, 0700);  /* ignore failure */
++    } else {
++        snprintf(tmp_path, path_max, "%s/pperl.%u",
++                 P_tmpdir, (unsigned)pw->pw_uid);
++        if (mkdir(tmp_path, 0600) == -1) {
++            /* The directory already exists.  Check ownership and
++               permissions. */
++            struct stat buf;
++            if (lstat(tmp_path, &buf) == -1) {
++                fprintf(stderr, "could not stat %s: %s\n",
++                        tmp_path, strerror(errno));
++                exit(1);
++            }
++            if (!S_ISDIR(buf.st_mode)) {
++                fprintf(stderr, "%s: not a directory\n",
++                        tmp_path);
++                exit(1);
++            }
++            if (buf.st_uid != me) {
++                fprintf(stderr, "%s: wrong directory ownership\n",
++                        tmp_path);
++                exit(1);
++            }
++            if ((buf.st_mode & 0777) != 0700) {
++                fprintf(stderr, "%s: wrong directory mode\n",
++                        tmp_path);
++                exit(1);
++            }
++        }
++    }
++}
++
+ 
+ int main( int argc, char **argv )
+ {
+     int i;
+-    char *pArg;
++    char *pArg = 0;
+     int pperl_section = 0;
+     int return_code = 0;
+ 
+@@ -88,6 +135,10 @@
+     }
+ #endif
+ 
++    tmp_path = getenv("PPERL_TMP_PATH");
++    if (!tmp_path)
++        setup_tmp_path();
++
+     pperl_section = 0;
+     for ( i = 1; i < argc; i++ ) {
+         pArg = argv[i];
+@@ -230,10 +281,10 @@
+     }
+     Dx(Debug("realpath returned: %s\n", fullpath));
+     /* Ugh. I am a terrible C programmer! */
+-    sockname = my_malloc(strlen(P_tmpdir) + strlen(fullpath) + 3);
++    sockname = my_malloc(strlen(tmp_path) + strlen(fullpath) + 3);
+     save = sockname;
+-    sprintf(sockname, "%s/", P_tmpdir);
+-    sockname += strlen(P_tmpdir) + 1;
++    sprintf(sockname, "%s/", tmp_path);
++    sockname += strlen(tmp_path) + 1;
+     while (fullpath[i] != '\0') {
+         if (fullpath[i] == '/') {
+             *sockname = '_';
+@@ -264,7 +315,6 @@
+ static int DispatchCall( char *scriptname, int argc, char **argv )
+ {
+     register int i, sd, len;
+-    int error_number;
+     ssize_t readlen;
+     struct sockaddr_un saun;
+     struct stat stat_buf;
+@@ -446,7 +496,7 @@
+             goto cleanup;
+         }
+ 
+-        snprintf(temp_file, BUF_SIZE, "%s/%s", P_tmpdir, "pperlXXXXXX");
++        snprintf(temp_file, BUF_SIZE, "%s/%s", tmp_path, "pperlXXXXXX");
+         tmp_fd = mkstemp(temp_file);
+         if (tmp_fd == -1) {
+             perror("pperl: Cannot create temporary file");

Modified: trunk/pperl/debian/patches/series
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/pperl/debian/patches/series?rev=19808&op=diff
==============================================================================
--- trunk/pperl/debian/patches/series (original)
+++ trunk/pperl/debian/patches/series Sat May 10 09:14:12 2008
@@ -1,1 +1,8 @@
+287119_no-umask0.patch
 no-extra-libs.patch
+pass_fd.c.patch
+pass_PPERL_TMP_PATH.patch
+pperl-man.patch
+safe-socket-path.patch
+series
+unclean-name-checks.patch

Added: trunk/pperl/debian/patches/unclean-name-checks.patch
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/pperl/debian/patches/unclean-name-checks.patch?rev=19808&op=file
==============================================================================
--- trunk/pperl/debian/patches/unclean-name-checks.patch (added)
+++ trunk/pperl/debian/patches/unclean-name-checks.patch Sat May 10 09:14:12 2008
@@ -1,0 +1,15 @@
+--- pperl-0.25.orig/pperl.h.header
++++ pperl-0.25/pperl.h.header
+@@ -261,9 +260,11 @@
+ 
+ # $SIG{INT} = $SIG{TERM} = sub { $DONE++ };
+ 
+-$PPERL::SOCKET_NAME =~ m~^([a-z0-9/_-]+)$~i
++$PPERL::SOCKET_NAME =~ m~^(/.*)$~
+   or die "unclean socket name '$PPERL::SOCKET_NAME'";
+ $PPERL::SOCKET_NAME = $1;
++$PPERL::SOCKET_NAME =~ m~/\.\.(?:/|$)~
++  and die "unclean socket name '$PPERL::SOCKET_NAME'";
+ if (-e $PPERL::SOCKET_NAME) {
+   if (-e "${PPERL::SOCKET_NAME}.pid") {
+     die "socket and pid file both exist - possible error state. Delete both and retry";

Modified: trunk/pperl/main.c
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/pperl/main.c?rev=19808&op=diff
==============================================================================
--- trunk/pperl/main.c (original)
+++ trunk/pperl/main.c Sat May 10 09:14:12 2008
@@ -6,12 +6,10 @@
 #include <stdarg.h>
 #include <memory.h>
 #include <errno.h>
-#include <pwd.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <sys/socket.h>
 #include <sys/un.h>
-#include <sys/file.h>
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <fcntl.h>
@@ -47,7 +45,6 @@
 int prefork = 5;
 int maxclients = 100;
 int path_max;
-char* tmp_path;
 int no_cleanup = 0;
 FILE *log_fd = NULL;
 
@@ -71,55 +68,11 @@
     fflush(log_fd);
 }
 
-static void *my_malloc(size_t);
-
-/* Set tmp_path to a user-specific path for the pperl control files. */
-static void
-setup_tmp_path(void)
-{
-    uid_t me = getuid();
-    struct passwd *pw = getpwuid(me);
-
-    tmp_path = my_malloc(path_max);
-    if (pw) {
-        snprintf(tmp_path, path_max, "%s/.pperl", pw->pw_dir);
-        mkdir(tmp_path, 0700);  /* ignore failure */
-    } else {
-        snprintf(tmp_path, path_max, "%s/pperl.%u",
-                 P_tmpdir, (unsigned)pw->pw_uid);
-        if (mkdir(tmp_path, 0600) == -1) {
-            /* The directory already exists.  Check ownership and
-               permissions. */
-            struct stat buf;
-            if (lstat(tmp_path, &buf) == -1) {
-                fprintf(stderr, "could not stat %s: %s\n",
-                        tmp_path, strerror(errno));
-                exit(1);
-            }
-            if (!S_ISDIR(buf.st_mode)) {
-                fprintf(stderr, "%s: not a directory\n",
-                        tmp_path);
-                exit(1);
-            }
-            if (buf.st_uid != me) {
-                fprintf(stderr, "%s: wrong directory ownership\n",
-                        tmp_path);
-                exit(1);
-            }
-            if ((buf.st_mode & 0777) != 0700) {
-                fprintf(stderr, "%s: wrong directory mode\n",
-                        tmp_path);
-                exit(1);
-            }
-        }
-    }
-}
-
 
 int main( int argc, char **argv )
 {
     int i;
-    char *pArg = 0;
+    char *pArg;
     int pperl_section = 0;
     int return_code = 0;
 
@@ -134,10 +87,6 @@
         path_max = 4096;
     }
 #endif
-
-    tmp_path = getenv("PPERL_TMP_PATH");
-    if (!tmp_path)
-        setup_tmp_path();
 
     pperl_section = 0;
     for ( i = 1; i < argc; i++ ) {
@@ -281,10 +230,10 @@
     }
     Dx(Debug("realpath returned: %s\n", fullpath));
     /* Ugh. I am a terrible C programmer! */
-    sockname = my_malloc(strlen(tmp_path) + strlen(fullpath) + 3);
+    sockname = my_malloc(strlen(P_tmpdir) + strlen(fullpath) + 3);
     save = sockname;
-    sprintf(sockname, "%s/", tmp_path);
-    sockname += strlen(tmp_path) + 1;
+    sprintf(sockname, "%s/", P_tmpdir);
+    sockname += strlen(P_tmpdir) + 1;
     while (fullpath[i] != '\0') {
         if (fullpath[i] == '/') {
             *sockname = '_';
@@ -315,6 +264,7 @@
 static int DispatchCall( char *scriptname, int argc, char **argv )
 {
     register int i, sd, len;
+    int error_number;
     ssize_t readlen;
     struct sockaddr_un saun;
     struct stat stat_buf;
@@ -496,7 +446,7 @@
             goto cleanup;
         }
 
-        snprintf(temp_file, BUF_SIZE, "%s/%s", tmp_path, "pperlXXXXXX");
+        snprintf(temp_file, BUF_SIZE, "%s/%s", P_tmpdir, "pperlXXXXXX");
         tmp_fd = mkstemp(temp_file);
         if (tmp_fd == -1) {
             perror("pperl: Cannot create temporary file");

Modified: trunk/pperl/pass_fd.c
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/pperl/pass_fd.c?rev=19808&op=diff
==============================================================================
--- trunk/pperl/pass_fd.c (original)
+++ trunk/pperl/pass_fd.c Sat May 10 09:14:12 2008
@@ -1,75 +1,165 @@
-/* Code based on Stevens' UNIX Network Programming, and simplified. */
-/* Florian Weimer <fw at deneb.enyo.de>, April 2008 */
+/* code lifted from Stevens' APUE */
 
-#include	<errno.h>
+#include	<errno.h>		/* for definition of errno */
+#include	<stdarg.h>		/* ANSI C header file */
 #include	<sys/types.h>
 #include	<sys/socket.h>
+#include	<sys/uio.h>
+#include	<string.h>
 #include        <unistd.h>
 #include	"pass_fd.h"
+
+#if VARIANT_SVR4
 
 int
 s_pipe(int fd[2])
 {
-  return socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
+    return( pipe(fd) );
 }
+
+#elif defined(VARIANT_43BSD) || defined(VARIANT_44BSD)
+
+int
+s_pipe(int fd[2])
+{
+    return( socketpair(AF_UNIX, SOCK_STREAM, 0, fd) );
+}
+
+#else
+
+#error "Couldn't guess variant"
+
+#endif
+
+
+#if VARIANT_43BSD
 
 int
 send_fd(int clifd, int fd)
 {
-  union {
-    struct cmsghdr cm;
-    char control[CMSG_SPACE(sizeof(int))];
-  } control_aligned;
+    struct iovec  iov[1];
+    struct msghdr msg;
+    char   buf[2];
 
-  struct msghdr msg = {0};
-  msg.msg_control = control_aligned.control;
-  msg.msg_controllen = sizeof(control_aligned.control);
+    iov[0].iov_base = buf;
+    iov[0].iov_len  = 2;
+    msg.msg_iov     = iov;
+    msg.msg_iovlen  = 1;
+    msg.msg_name    = NULL;
+    msg.msg_namelen = 0;
 
-  struct cmsghdr *cmptr = CMSG_FIRSTHDR(&msg);
-  cmptr->cmsg_len = CMSG_LEN(sizeof(int));
-  cmptr->cmsg_level = SOL_SOCKET;
-  cmptr->cmsg_type = SCM_RIGHTS;
-  *((int *) CMSG_DATA(cmptr)) = fd;
+    if (fd < 0) {
+	msg.msg_accrights    = NULL;
+	msg.msg_accrightslen = 0;
+	buf[1] = -fd;
+	if (buf[1] == 0)
+	    buf[1] = 1;
+    } 
+    else {
+	msg.msg_accrights    = (caddr_t) &fd;
+	msg.msg_accrightslen = sizeof(int);
+	buf[1] = 0;
+    }
+    buf[0] = 0;
 
-  char buf[1] = {0};
-  struct iovec iov = {.iov_base = buf, .iov_len = sizeof(buf)};
-  msg.msg_iov = &iov;
-  msg.msg_iovlen = 1;
-
-  if (sendmsg(clifd, &msg, 0) != 1)
-    return -1;
-  return 0;
+    if (sendmsg(clifd, &msg, 0) != 2)
+	return(-1);
+    
+    return(0);
 }
 
 int
 recv_fd(int servfd)
 {
-  union {
-    struct cmsghdr cm;
-    char control[CMSG_SPACE(sizeof(int))];
-  } control_aligned;
+    int newfd, nread, status;
+    char *ptr, buf[2];
+    struct iovec  iov[1];
+    struct msghdr msg;
 
-  struct msghdr msg = {0};
-  msg.msg_control = control_aligned.control;
-  msg.msg_controllen = sizeof(control_aligned.control);
+    iov[0].iov_base = buf;
+    iov[0].iov_len  = 2;
+    msg.msg_iov     = iov;
+    msg.msg_iovlen  = 1;
+    msg.msg_name    = NULL;
+    msg.msg_namelen = 0;
+    msg.msg_accrights = (caddr_t) &newfd;
+    msg.msg_accrightslen = sizeof(int);
+    
+    if ( (nread = recvmsg(servfd, &msg, 0)) <= 0)
+	return(-1);
+    
+    return(newfd);/* descriptor, or -status */
+}
 
-  char buf[1] = {0};
-  struct iovec iov = {.iov_base = buf, .iov_len = sizeof(buf)};
-  msg.msg_iov = &iov;
-  msg.msg_iovlen = 1;
+#else 
 
-  ssize_t result = recvmsg(servfd, &msg, 0);
-  if (result < 0)
-    return -1;
-  if (result != 1) {
-    errno = EINVAL;
-    return -1;
-  }
+struct cmessage {
+    struct cmsghdr cmsg;
+    int fd;
+};
 
-  struct cmsghdr *cmptr = CMSG_FIRSTHDR(&msg);
-  if (cmptr && cmptr->cmsg_len == CMSG_LEN(sizeof(int))
-      && cmptr->cmsg_level == SOL_SOCKET && cmptr->cmsg_type == SCM_RIGHTS)
-    return *((int *) CMSG_DATA(cmptr));
-  errno = ENXIO;
-  return -1;
+int
+send_fd(int over, int this)
+{
+    struct iovec iov[1];
+    struct msghdr msg;
+    struct cmessage cm;
+    char sendbuf[] = "";
+
+    iov[0].iov_base = (char *)&sendbuf;
+    iov[0].iov_len = sizeof(sendbuf);
+    
+    cm.cmsg.cmsg_type  = SCM_RIGHTS;
+    cm.cmsg.cmsg_level = SOL_SOCKET;
+    cm.cmsg.cmsg_len = sizeof(struct cmessage);
+    cm.fd = this;
+
+    msg.msg_iov = iov;
+    msg.msg_iovlen = 1;
+    msg.msg_name = NULL;
+    msg.msg_namelen = 0;
+    msg.msg_control = (caddr_t)&cm;
+    msg.msg_controllen = sizeof(struct cmessage);
+    msg.msg_flags = 0;
+
+    if (sendmsg(over, &msg, 0) < 0)
+	return -1;
+    return 0;
 }
+
+int 
+recv_fd(int over)
+{
+    struct iovec iov[1];
+    struct msghdr msg;
+    struct cmessage cm;
+    ssize_t got;
+    char recbuf;
+
+    /* in examples this was >1 but this causes too much to be read,
+     * causing sync issues */
+
+    iov[0].iov_base = &recbuf;
+    iov[0].iov_len = 1;
+
+    bzero((char *)&cm, sizeof(cm));
+    bzero((char *)&msg, sizeof(msg));
+
+    msg.msg_iov = iov;
+    msg.msg_iovlen = 1;
+    msg.msg_name = NULL;
+    msg.msg_namelen = 0;
+    msg.msg_control = (caddr_t)&cm;
+    msg.msg_controllen = sizeof(struct cmessage);
+    msg.msg_flags = 0;
+
+    if ((got = recvmsg(over, &msg, 0)) < 0)
+	return -1;
+
+    if (cm.cmsg.cmsg_type != SCM_RIGHTS)
+	return -1;
+
+    return cm.fd;
+}
+
+#endif

Modified: trunk/pperl/pperl.h.header
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/pperl/pperl.h.header?rev=19808&op=diff
==============================================================================
--- trunk/pperl/pperl.h.header (original)
+++ trunk/pperl/pperl.h.header Sat May 10 09:14:12 2008
@@ -188,6 +188,7 @@
   open(STDOUT,">/dev/null");
   open(STDERR, '>&STDOUT');
   chdir '/';           # change working directory
+  umask(0);            # forget file mode creation mask
   $ENV{PATH} = '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin';
   delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
   $SIG{CHLD} = \&reap_child;
@@ -260,11 +261,9 @@
 
 # $SIG{INT} = $SIG{TERM} = sub { $DONE++ };
 
-$PPERL::SOCKET_NAME =~ m~^(/.*)$~
+$PPERL::SOCKET_NAME =~ m~^([a-z0-9/_-]+)$~i
   or die "unclean socket name '$PPERL::SOCKET_NAME'";
 $PPERL::SOCKET_NAME = $1;
-$PPERL::SOCKET_NAME =~ m~/\.\.(?:/|$)~
-  and die "unclean socket name '$PPERL::SOCKET_NAME'";
 if (-e $PPERL::SOCKET_NAME) {
   if (-e "${PPERL::SOCKET_NAME}.pid") {
     die "socket and pid file both exist - possible error state. Delete both and retry";

Modified: trunk/pperl/t/04args.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/pperl/t/04args.t?rev=19808&op=diff
==============================================================================
--- trunk/pperl/t/04args.t (original)
+++ trunk/pperl/t/04args.t Sat May 10 09:14:12 2008
@@ -17,11 +17,9 @@
 
 `./pperl t/env.plx`; # run it once so there's a $ENV{PATH} about
 
-my $tmp_path = $ENV{PPERL_TMP_PATH};
 %ENV = ( foo       => "bar\nbaz",
          "quu\nx"  => "wobble",
          null      => '');
-$ENV{PPERL_TMP_PATH} = $tmp_path if $tmp_path;
 
 ok(capture($^X, 't/env.plx'),
   qq{'foo' => 'bar\nbaz'\n'null' => ''\n'quu\nx' => 'wobble'\n});

Modified: trunk/pperl/t/11autoclose.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/pperl/t/11autoclose.t?rev=19808&op=diff
==============================================================================
--- trunk/pperl/t/11autoclose.t (original)
+++ trunk/pperl/t/11autoclose.t Sat May 10 09:14:12 2008
@@ -1,26 +1,16 @@
 #!perl -w
 use Test;
-use Fcntl ':mode';
-BEGIN { plan tests => 6 }
+BEGIN { plan tests => 4 }
 
 `./pperl --prefork=1 t/autoclose.plx`;
 
 my $file = "foo.$$";
 my $foo;
 
-# Regression test for Debian bug #287119.
-sub check_perm () {
-    my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
-	$atime,$mtime,$ctime,$blksize,$blocks)
-	= stat($file);
-    ok(S_IMODE($mode), 0644);
-}
-
 `$^X t/autoclose.plx $file foo`;
 ok(`$^X t/cat.plx $file`, "foo\n");
 `$^X t/autoclose.plx $file bar`;
 ok(`$^X t/cat.plx $file`, "foo\nbar\n");
-check_perm;
 
 unlink $file;
 
@@ -28,7 +18,6 @@
 ok(`$^X t/cat.plx $file`, "foo\n");
 `./pperl t/autoclose.plx $file bar`;
 ok(`$^X t/cat.plx $file`, "foo\nbar\n");
-check_perm;
 
 `./pperl -k t/autoclose.plx`;
 `./pperl -k t/cat.plx`;

Modified: trunk/pperl/t/env.plx
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/pperl/t/env.plx?rev=19808&op=diff
==============================================================================
--- trunk/pperl/t/env.plx (original)
+++ trunk/pperl/t/env.plx Sat May 10 09:14:12 2008
@@ -1,3 +1,3 @@
 #!perl -w
 use strict;
-print map { "'$_' => '$ENV{$_}'\n" } sort grep { $_ ne 'PPERL_TMP_PATH' } keys %ENV;
+print map { "'$_' => '$ENV{$_}'\n" } sort keys %ENV;




More information about the Pkg-perl-cvs-commits mailing list