commit current patch list
[debian/pax] / debian / patches / lump-debian-diffs
1 Description: <short summary of the patch>
2  TODO: Put a short summary on the line above and replace this paragraph
3  with a longer explanation of this change. Complete the meta-information
4  with other relevant fields (see below for details). To make it easier, the
5  information below has been extracted from the changelog. Adjust it or drop
6  it.
7  .
8  pax (1:20090728-3) UNRELEASED; urgency=low
9  .
10    * switch to use of dh
11 Author: Bdale Garbee <bdale@gag.com>
12
13 ---
14 The information above should follow the Patch Tagging Guidelines, please
15 checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
16 are templates for supplementary fields that you might want to add:
17
18 Origin: <vendor|upstream|other>, <url of original patch>
19 Bug: <url in upstream bugtracker>
20 Bug-Debian: http://bugs.debian.org/<bugnumber>
21 Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
22 Forwarded: <no|not-needed|url proving that it has been forwarded>
23 Reviewed-By: <name and email of someone who approved the patch>
24 Last-Update: <YYYY-MM-DD>
25
26 --- pax-20090728.orig/pax.c
27 +++ pax-20090728/pax.c
28 @@ -105,7 +105,7 @@ char        *dirptr;                /* destination dir in a c
29  char   *ltmfrmt;               /* -v locale time format (if any) */
30  char   *argv0;                 /* root of argv[0] */
31  sigset_t s_mask;               /* signal mask for cleanup critical sect */
32 -FILE   *listf = stderr;        /* file pointer to print file list to */
33 +FILE   *listf; /* file pointer to print file list to */
34  char   *tempfile;              /* tempfile to use for mkstemp(3) */
35  char   *tempbase;              /* basename of tempfile to use for mkstemp(3) */
36  
37 @@ -235,6 +235,12 @@ main(int argc, char **argv)
38         char *tmpdir;
39         size_t tdlen;
40  
41 +       /* 
42 +        * On some systems, stderr is not a constant, so we initialize listf
43 +        * immediately to emulate the behavior.
44 +        */
45 +       listf=stderr;
46 +
47         /*
48          * Keep a reference to cwd, so we can always come back home.
49          */
50 --- pax-20090728.orig/ar_subs.c
51 +++ pax-20090728/ar_subs.c
52 @@ -44,6 +44,7 @@ static const char rcsid[] = "$OpenBSD: a
53  
54  #include <sys/types.h>
55  #include <sys/time.h>
56 +#include <time.h>
57  #include <sys/stat.h>
58  #include <sys/param.h>
59  #include <signal.h>
60 --- pax-20090728.orig/cache.c
61 +++ pax-20090728/cache.c
62 @@ -200,7 +200,11 @@ name_uid(uid_t uid, int frc)
63          * No entry for this uid, we will add it
64          */
65         if (!pwopn) {
66 +#ifdef DEBIAN
67 +               setpwent();
68 +#else
69                 setpassent(1);
70 +#endif
71                 ++pwopn;
72         }
73         if (ptr == NULL)
74 @@ -266,7 +270,11 @@ name_gid(gid_t gid, int frc)
75          * No entry for this gid, we will add it
76          */
77         if (!gropn) {
78 +#ifdef DEBIAN
79 +               setgrent();
80 +#else
81                 setgroupent(1);
82 +#endif
83                 ++gropn;
84         }
85         if (ptr == NULL)
86 @@ -333,7 +341,11 @@ uid_name(char *name, uid_t *uid)
87         }
88  
89         if (!pwopn) {
90 +#ifdef DEBIAN
91 +               setpwent();
92 +#else
93                 setpassent(1);
94 +#endif
95                 ++pwopn;
96         }
97  
98 @@ -396,7 +408,11 @@ gid_name(char *name, gid_t *gid)
99         }
100  
101         if (!gropn) {
102 +#ifdef DEBIAN
103 +               setgrent();
104 +#else
105                 setgroupent(1);
106 +#endif
107                 ++gropn;
108         }
109         if (ptr == NULL)
110 --- pax-20090728.orig/pax.h
111 +++ pax-20090728/pax.h
112 @@ -242,3 +242,8 @@ typedef struct oplist {
113  #define OCT            8
114  #define _PAX_          1
115  #define _TFILE_BASE    "paxXXXXXXXXXX"
116 +
117 +/* hack since we're pulling routines in from OpenBSD library to this dir */
118 +size_t strlcpy(char *, const char *, size_t);
119 +char * vis(char *, int, int, int);
120 +
121 --- pax-20090728.orig/sel_subs.c
122 +++ pax-20090728/sel_subs.c
123 @@ -44,6 +44,7 @@ static const char rcsid[] = "$OpenBSD: s
124  
125  #include <sys/types.h>
126  #include <sys/time.h>
127 +#include <time.h>
128  #include <sys/stat.h>
129  #include <sys/param.h>
130  #include <ctype.h>
131 @@ -52,12 +53,14 @@ static const char rcsid[] = "$OpenBSD: s
132  #include <stdio.h>
133  #include <stdlib.h>
134  #include <string.h>
135 -#include <tzfile.h>
136 +#include <time.h>
137  #include <unistd.h>
138  #include "pax.h"
139  #include "sel_subs.h"
140  #include "extern.h"
141  
142 +#define TM_YEAR_BASE 1900
143 +
144  static int str_sec(const char *, time_t *);
145  static int usr_match(ARCHD *);
146  static int grp_match(ARCHD *);
147 --- /dev/null
148 +++ pax-20090728/types.h
149 @@ -0,0 +1,169 @@
150 +/*-
151 + * Copyright (c) 1982, 1986, 1991, 1993
152 + *     The Regents of the University of California.  All rights reserved.
153 + * (c) UNIX System Laboratories, Inc.
154 + * All or some portions of this file are derived from material licensed
155 + * to the University of California by American Telephone and Telegraph
156 + * Co. or Unix System Laboratories, Inc. and are reproduced herein with
157 + * the permission of UNIX System Laboratories, Inc.
158 + *
159 + * Redistribution and use in source and binary forms, with or without
160 + * modification, are permitted provided that the following conditions
161 + * are met:
162 + * 1. Redistributions of source code must retain the above copyright
163 + *    notice, this list of conditions and the following disclaimer.
164 + * 2. Redistributions in binary form must reproduce the above copyright
165 + *    notice, this list of conditions and the following disclaimer in the
166 + *    documentation and/or other materials provided with the distribution.
167 + * 3. All advertising materials mentioning features or use of this software
168 + *    must display the following acknowledgement:
169 + *     This product includes software developed by the University of
170 + *     California, Berkeley and its contributors.
171 + * 4. Neither the name of the University nor the names of its contributors
172 + *    may be used to endorse or promote products derived from this software
173 + *    without specific prior written permission.
174 + *
175 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
176 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
177 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
178 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
179 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
180 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
181 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
182 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
183 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
184 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
185 + * SUCH DAMAGE.
186 + *
187 + *     @(#)types.h     8.4 (Berkeley) 1/21/94
188 + * $Id: types.h,v 1.1 2001-07-23 05:20:01 bdale Exp $
189 + */
190 +
191 +#ifndef _SYS_TYPES_H_
192 +#define        _SYS_TYPES_H_
193 +
194 +#include <sys/cdefs.h>
195 +
196 +/* Machine type dependent parameters. */
197 +#include <machine/endian.h>
198 +
199 +#ifndef _POSIX_SOURCE
200 +typedef        unsigned char   u_char;
201 +typedef        unsigned short  u_short;
202 +typedef        unsigned int    u_int;
203 +typedef        unsigned long   u_long;
204 +typedef        unsigned short  ushort;         /* Sys V compatibility */
205 +typedef        unsigned int    uint;           /* Sys V compatibility */
206 +#endif
207 +
208 +typedef        unsigned long long u_quad_t;    /* quads */
209 +typedef        long long       quad_t;
210 +typedef        quad_t *        qaddr_t;
211 +
212 +typedef        char *          caddr_t;        /* core address */
213 +typedef        long            daddr_t;        /* disk address */
214 +typedef        unsigned long   dev_t;          /* device number */
215 +typedef unsigned long  fixpt_t;        /* fixed point number */
216 +typedef        unsigned long   gid_t;          /* group id */
217 +typedef        unsigned long   ino_t;          /* inode number */
218 +typedef        unsigned short  mode_t;         /* permissions */
219 +typedef        unsigned short  nlink_t;        /* link count */
220 +typedef        quad_t          off_t;          /* file offset */
221 +typedef        long            pid_t;          /* process id */
222 +typedef        long            segsz_t;        /* segment size */
223 +typedef        long            swblk_t;        /* swap offset */
224 +typedef        unsigned long   uid_t;          /* user id */
225 +
226 +/*
227 + * This belongs in unistd.h, but is placed here to ensure that programs
228 + * casting the second parameter of lseek to off_t will get the correct
229 + * version of lseek.
230 + */
231 +#ifndef KERNEL
232 +__BEGIN_DECLS
233 +off_t   lseek __P((int, off_t, int));
234 +__END_DECLS
235 +#endif
236 +
237 +#ifndef _POSIX_SOURCE
238 +/*
239 + * minor() gives a cookie instead of an index since we don't want to
240 + * change the meanings of bits 0-15 or waste time and space shifting
241 + * bits 16-31 for devices that don't use them.
242 + */
243 +#define        major(x)        ((int)(((u_int)(x) >> 8)&0xff)) /* major number */
244 +#define        minor(x)        ((int)((x)&0xffff00ff))         /* minor number */
245 +#define        makedev(x,y)    ((dev_t)(((x)<<8) | (y)))       /* create dev_t */
246 +#endif
247 +
248 +#include <machine/ansi.h>
249 +#include <machine/types.h>
250 +
251 +#ifdef _BSD_CLOCK_T_
252 +typedef        _BSD_CLOCK_T_   clock_t;
253 +#undef _BSD_CLOCK_T_
254 +#endif
255 +
256 +#ifdef _BSD_SIZE_T_
257 +typedef        _BSD_SIZE_T_    size_t;
258 +#undef _BSD_SIZE_T_
259 +#endif
260 +
261 +#ifdef _BSD_SSIZE_T_
262 +typedef        _BSD_SSIZE_T_   ssize_t;
263 +#undef _BSD_SSIZE_T_
264 +#endif
265 +
266 +#ifdef _BSD_TIME_T_
267 +typedef        _BSD_TIME_T_    time_t;
268 +#undef _BSD_TIME_T_
269 +#endif
270 +
271 +#ifndef _POSIX_SOURCE
272 +#define        NBBY    8               /* number of bits in a byte */
273 +
274 +/*
275 + * Select uses bit masks of file descriptors in longs.  These macros
276 + * manipulate such bit fields (the filesystem macros use chars).
277 + * FD_SETSIZE may be defined by the user, but the default here should
278 + * be enough for most uses.
279 + */
280 +#ifndef        FD_SETSIZE
281 +#define        FD_SETSIZE      256
282 +#endif
283 +
284 +typedef long   fd_mask;
285 +#define NFDBITS        (sizeof(fd_mask) * NBBY)        /* bits per mask */
286 +
287 +#ifndef howmany
288 +#define        howmany(x, y)   (((x)+((y)-1))/(y))
289 +#endif
290 +
291 +typedef        struct fd_set {
292 +       fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
293 +} fd_set;
294 +
295 +#define        FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
296 +#define        FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
297 +#define        FD_ISSET(n, p)  ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
298 +#define        FD_COPY(f, t)   bcopy(f, t, sizeof(*(f)))
299 +#define        FD_ZERO(p)      bzero(p, sizeof(*(p)))
300 +
301 +#if defined(__STDC__) && defined(KERNEL)
302 +/*
303 + * Forward structure declarations for function prototypes.  We include the
304 + * common structures that cross subsystem boundaries here; others are mostly
305 + * used in the same place that the structure is defined.
306 + */
307 +struct proc;
308 +struct pgrp;
309 +struct ucred;
310 +struct rusage;
311 +struct file;
312 +struct buf;
313 +struct tty;
314 +struct uio;
315 +#endif
316 +
317 +#endif /* !_POSIX_SOURCE */
318 +#endif /* !_SYS_TYPES_H_ */
319 --- /dev/null
320 +++ pax-20090728/strmode.h
321 @@ -0,0 +1,34 @@
322 +/*-
323 + * Copyright (c) 1990, 1993
324 + *     The Regents of the University of California.  All rights reserved.
325 + *
326 + * Redistribution and use in source and binary forms, with or without
327 + * modification, are permitted provided that the following conditions
328 + * are met:
329 + * 1. Redistributions of source code must retain the above copyright
330 + *    notice, this list of conditions and the following disclaimer.
331 + * 2. Redistributions in binary form must reproduce the above copyright
332 + *    notice, this list of conditions and the following disclaimer in the
333 + *    documentation and/or other materials provided with the distribution.
334 + * 3. All advertising materials mentioning features or use of this software
335 + *    must display the following acknowledgement:
336 + *     This product includes software developed by the University of
337 + *     California, Berkeley and its contributors.
338 + * 4. Neither the name of the University nor the names of its contributors
339 + *    may be used to endorse or promote products derived from this software
340 + *    without specific prior written permission.
341 + *
342 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
343 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
344 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
345 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
346 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
347 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
348 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
349 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
350 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
351 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
352 + * SUCH DAMAGE.
353 + */
354 +
355 +void strmode(mode_t mode, char *p);
356 --- pax-20090728.orig/tar.c
357 +++ pax-20090728/tar.c
358 @@ -43,6 +43,7 @@ static const char rcsid[] = "$OpenBSD: t
359  #endif /* not lint */
360  
361  #include <sys/types.h>
362 +#include <sys/sysmacros.h>
363  #include <sys/time.h>
364  #include <sys/stat.h>
365  #include <sys/param.h>
366 @@ -763,6 +764,12 @@ ustar_rd(ARCHD *arcn, char *buf)
367         /*
368          * see if the filename is split into two parts. if, so joint the parts.
369          * we copy the prefix first and add a / between the prefix and name.
370 +        *
371 +        * the length passed to l_strncpy must be the length of the field
372 +        * being copied *from*, since these fields are NOT null terminated
373 +        * when full.  the destination buffer is plenty big enough to hold
374 +        * the longest supported ustar path length, so there's no need
375 +        * to check against that.
376          */
377         dest = arcn->name;
378         if (*(hd->prefix) != '\0') {
379 @@ -1072,6 +1079,15 @@ ustar_wr(ARCHD *arcn)
380         strncpy(hd->uname, name_uid(arcn->sb.st_uid, 0), sizeof(hd->uname));
381         strncpy(hd->gname, name_gid(arcn->sb.st_gid, 0), sizeof(hd->gname));
382  
383 +       /*
384 +        * Always add devmajor and devminor
385 +        */
386 +       if (ul_oct ((u_long) MAJOR (arcn->sb.st_rdev), hd->devmajor,
387 +             sizeof (hd->devmajor), 3) ||
388 +           ul_oct ((u_long) MINOR (arcn->sb.st_rdev), hd->devminor,
389 +             sizeof (hd->devminor), 3))
390 +               goto out;
391 +
392         /*
393          * calculate and store the checksum write the header to the archive
394          * return 0 tells the caller to now write the file data, 1 says no data
395 --- /dev/null
396 +++ pax-20090728/strmode.c
397 @@ -0,0 +1,147 @@
398 +/*-
399 + * Copyright (c) 1990, 1993
400 + *     The Regents of the University of California.  All rights reserved.
401 + *
402 + * Redistribution and use in source and binary forms, with or without
403 + * modification, are permitted provided that the following conditions
404 + * are met:
405 + * 1. Redistributions of source code must retain the above copyright
406 + *    notice, this list of conditions and the following disclaimer.
407 + * 2. Redistributions in binary form must reproduce the above copyright
408 + *    notice, this list of conditions and the following disclaimer in the
409 + *    documentation and/or other materials provided with the distribution.
410 + * 3. All advertising materials mentioning features or use of this software
411 + *    must display the following acknowledgement:
412 + *     This product includes software developed by the University of
413 + *     California, Berkeley and its contributors.
414 + * 4. Neither the name of the University nor the names of its contributors
415 + *    may be used to endorse or promote products derived from this software
416 + *    without specific prior written permission.
417 + *
418 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
419 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
420 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
421 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
422 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
423 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
424 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
425 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
426 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
427 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
428 + * SUCH DAMAGE.
429 + */
430 +
431 +#if defined(LIBC_SCCS) && !defined(lint)
432 +static char sccsid[] = "@(#)strmode.c  8.1 (Berkeley) 6/4/93";
433 +#endif /* LIBC_SCCS and not lint */
434 +
435 +#include <sys/types.h>
436 +#include <sys/stat.h>
437 +#include <string.h>
438 +
439 +void
440 +strmode(mode, p)
441 +       register mode_t mode;
442 +       register char *p;
443 +{
444 +        /* print type */
445 +       switch (mode & S_IFMT) {
446 +       case S_IFDIR:                   /* directory */
447 +               *p++ = 'd';
448 +               break;
449 +       case S_IFCHR:                   /* character special */
450 +               *p++ = 'c';
451 +               break;
452 +       case S_IFBLK:                   /* block special */
453 +               *p++ = 'b';
454 +               break;
455 +       case S_IFREG:                   /* regular */
456 +               *p++ = '-';
457 +               break;
458 +       case S_IFLNK:                   /* symbolic link */
459 +               *p++ = 'l';
460 +               break;
461 +       case S_IFSOCK:                  /* socket */
462 +               *p++ = 's';
463 +               break;
464 +#ifdef S_IFIFO
465 +       case S_IFIFO:                   /* fifo */
466 +               *p++ = 'p';
467 +               break;
468 +#endif
469 +       default:                        /* unknown */
470 +               *p++ = '?';
471 +               break;
472 +       }
473 +       /* usr */
474 +       if (mode & S_IRUSR)
475 +               *p++ = 'r';
476 +       else
477 +               *p++ = '-';
478 +       if (mode & S_IWUSR)
479 +               *p++ = 'w';
480 +       else
481 +               *p++ = '-';
482 +       switch (mode & (S_IXUSR | S_ISUID)) {
483 +       case 0:
484 +               *p++ = '-';
485 +               break;
486 +       case S_IXUSR:
487 +               *p++ = 'x';
488 +               break;
489 +       case S_ISUID:
490 +               *p++ = 'S';
491 +               break;
492 +       case S_IXUSR | S_ISUID:
493 +               *p++ = 's';
494 +               break;
495 +       }
496 +       /* group */
497 +       if (mode & S_IRGRP)
498 +               *p++ = 'r';
499 +       else
500 +               *p++ = '-';
501 +       if (mode & S_IWGRP)
502 +               *p++ = 'w';
503 +       else
504 +               *p++ = '-';
505 +       switch (mode & (S_IXGRP | S_ISGID)) {
506 +       case 0:
507 +               *p++ = '-';
508 +               break;
509 +       case S_IXGRP:
510 +               *p++ = 'x';
511 +               break;
512 +       case S_ISGID:
513 +               *p++ = 'S';
514 +               break;
515 +       case S_IXGRP | S_ISGID:
516 +               *p++ = 's';
517 +               break;
518 +       }
519 +       /* other */
520 +       if (mode & S_IROTH)
521 +               *p++ = 'r';
522 +       else
523 +               *p++ = '-';
524 +       if (mode & S_IWOTH)
525 +               *p++ = 'w';
526 +       else
527 +               *p++ = '-';
528 +       switch (mode & (S_IXOTH | S_ISVTX)) {
529 +       case 0:
530 +               *p++ = '-';
531 +               break;
532 +       case S_IXOTH:
533 +               *p++ = 'x';
534 +               break;
535 +       case S_ISVTX:
536 +               *p++ = 'T';
537 +               break;
538 +       case S_IXOTH | S_ISVTX:
539 +               *p++ = 't';
540 +               break;
541 +       }
542 +       *p++ = ' ';             /* will be a '+' if ACL's implemented */
543 +       *p = '\0';
544 +}
545 --- pax-20090728.orig/Makefile
546 +++ pax-20090728/Makefile
547 @@ -14,8 +14,25 @@
548  PROG=   pax
549  SRCS=  ar_io.c ar_subs.c buf_subs.c cache.c cpio.c file_subs.c ftree.c\
550         gen_subs.c getoldopt.c options.c pat_rep.c pax.c sel_subs.c tables.c\
551 -       tar.c tty_subs.c
552 -MAN=   pax.1 tar.1 cpio.1
553 -LINKS= ${BINDIR}/pax ${BINDIR}/tar ${BINDIR}/pax ${BINDIR}/cpio
554 +       tar.c tty_subs.c fgetln.c strmode.c strlcpy.c vis.c
555 +OBJS=  $(SRCS:.c=.o)
556 +MAN=   pax.1
557  
558 -.include <bsd.prog.mk>
559 +CFLAGS= -Wall -O2 -g -DLONG_OFF_T\
560 +       -DNET2_STAT -D_PATH_DEFTAPE=\"/dev/rmt0\" -DDEBIAN -D_GNU_SOURCE
561 +
562 +prefix=/usr
563 +
564 +pax:   $(OBJS)
565 +       $(CC) $(CFLAGS) $(OBJS) -o $@ $(LIBS)
566 +
567 +clean:
568 +       $(RM) *.o
569 +
570 +realclean: clean
571 +       $(RM) $(PROG)
572 +
573 +install:
574 +       install -d -m 755 $(DESTDIR)$(prefix)/bin $(DESTDIR)$(prefix)/share/man/man1
575 +       install -s -m 755 $(PROG) $(DESTDIR)$(prefix)/bin
576 +       install    -m 644 $(MAN)  $(DESTDIR)$(prefix)/share/man/man1
577 --- /dev/null
578 +++ pax-20090728/strlcpy.c
579 @@ -0,0 +1,51 @@
580 +/*     $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $    */
581 +
582 +/*
583 + * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
584 + *
585 + * Permission to use, copy, modify, and distribute this software for any
586 + * purpose with or without fee is hereby granted, provided that the above
587 + * copyright notice and this permission notice appear in all copies.
588 + *
589 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
590 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
591 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
592 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
593 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
594 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
595 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
596 + */
597 +
598 +#include <sys/types.h>
599 +#include <string.h>
600 +
601 +/*
602 + * Copy src to string dst of size siz.  At most siz-1 characters
603 + * will be copied.  Always NUL terminates (unless siz == 0).
604 + * Returns strlen(src); if retval >= siz, truncation occurred.
605 + */
606 +size_t
607 +strlcpy(char *dst, const char *src, size_t siz)
608 +{
609 +       char *d = dst;
610 +       const char *s = src;
611 +       size_t n = siz;
612 +
613 +       /* Copy as many bytes as will fit */
614 +       if (n != 0) {
615 +               while (--n != 0) {
616 +                       if ((*d++ = *s++) == '\0')
617 +                               break;
618 +               }
619 +       }
620 +
621 +       /* Not enough room in dst, add NUL and traverse rest of src */
622 +       if (n == 0) {
623 +               if (siz != 0)
624 +                       *d = '\0';              /* NUL-terminate dst */
625 +               while (*s++)
626 +                       ;
627 +       }
628 +
629 +       return(s - src - 1);    /* count does not include NUL */
630 +}
631 --- pax-20090728.orig/ar_io.c
632 +++ pax-20090728/ar_io.c
633 @@ -1248,8 +1248,9 @@ ar_next(void)
634  
635  /*
636   * ar_start_gzip()
637 - * starts the gzip compression/decompression process as a child, using magic
638 - * to keep the fd the same in the calling function (parent).
639 + * starts the compress, gzip or bzip2 compression/decompression process
640 + * as a child, using magic to keep the fd the same in the calling function
641 + * (parent).
642   */
643  void
644  ar_start_gzip(int fd, const char *gzip_program, int wr)
645 --- /dev/null
646 +++ pax-20090728/Makefile.bsd
647 @@ -0,0 +1,34 @@
648 +#      $OpenBSD: Makefile,v 1.9 1997/09/21 11:35:28 deraadt Exp $
649 +
650 +# To install on versions prior to BSD 4.4 the following may have to be
651 +# defined with CFLAGS +=
652 +#
653 +# -DNET2_STAT  Use NET2 or older stat structure. The version of the
654 +#              stat structure is easily determined by looking at the
655 +#              basic type of an off_t (often defined in the file:
656 +#              /usr/include/sys/types.h). If off_t is a long (and is
657 +#              NOT A quad) then you must define NET2_STAT.
658 +#              This define is important, as if you do have a quad_t
659 +#              off_t and define NET2_STAT, pax will compile but will
660 +#              NOT RUN PROPERLY.
661 +#
662 +# -DNET2_FTS   Use the older NET2 fts. To identify the version,
663 +#              examine the file: /usr/include/fts.h. If FTS_COMFOLLOW
664 +#              is not defined then you must define NET2_FTS.
665 +#              Pax may not compile if this not (un)defined properly.
666 +#
667 +# -DNET2_REGEX Use the older regexp.h not regex.h. The regex version
668 +#              is determined by looking at the value returned by
669 +#              regexec() (man 3 regexec). If regexec return a 1 for
670 +#              success (and NOT a 0 for success) you have the older
671 +#              regex routines and must define NET2_REGEX.
672 +#              Pax may not compile if this not (un)defined properly.
673 +
674 +PROG=   pax
675 +SRCS=  ar_io.c ar_subs.c buf_subs.c cache.c cpio.c file_subs.c ftree.c\
676 +       gen_subs.c getoldopt.c options.c pat_rep.c pax.c sel_subs.c tables.c\
677 +       tar.c tty_subs.c
678 +MAN=   pax.1 tar.1 cpio.1
679 +LINKS= ${BINDIR}/pax ${BINDIR}/tar ${BINDIR}/pax ${BINDIR}/cpio
680 +
681 +.include <bsd.prog.mk>
682 --- /dev/null
683 +++ pax-20090728/vis.c
684 @@ -0,0 +1,219 @@
685 +/*     $OpenBSD: vis.c,v 1.19 2005/09/01 17:15:49 millert Exp $ */
686 +/*-
687 + * Copyright (c) 1989, 1993
688 + *     The Regents of the University of California.  All rights reserved.
689 + *
690 + * Redistribution and use in source and binary forms, with or without
691 + * modification, are permitted provided that the following conditions
692 + * are met:
693 + * 1. Redistributions of source code must retain the above copyright
694 + *    notice, this list of conditions and the following disclaimer.
695 + * 2. Redistributions in binary form must reproduce the above copyright
696 + *    notice, this list of conditions and the following disclaimer in the
697 + *    documentation and/or other materials provided with the distribution.
698 + * 3. Neither the name of the University nor the names of its contributors
699 + *    may be used to endorse or promote products derived from this software
700 + *    without specific prior written permission.
701 + *
702 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
703 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
704 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
705 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
706 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
707 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
708 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
709 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
710 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
711 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
712 + * SUCH DAMAGE.
713 + */
714 +
715 +#include <sys/types.h>
716 +#include <limits.h>
717 +#include <ctype.h>
718 +#include <string.h>
719 +#include "vis.h"
720 +
721 +#define        isoctal(c)      (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7')
722 +#define        isvisible(c)                                                    \
723 +       (((u_int)(c) <= UCHAR_MAX && isascii((u_char)(c)) &&            \
724 +       (((c) != '*' && (c) != '?' && (c) != '[' && (c) != '#') ||      \
725 +               (flag & VIS_GLOB) == 0) && isgraph((u_char)(c))) ||     \
726 +       ((flag & VIS_SP) == 0 && (c) == ' ') ||                         \
727 +       ((flag & VIS_TAB) == 0 && (c) == '\t') ||                       \
728 +       ((flag & VIS_NL) == 0 && (c) == '\n') ||                        \
729 +       ((flag & VIS_SAFE) && ((c) == '\b' ||                           \
730 +               (c) == '\007' || (c) == '\r' ||                         \
731 +               isgraph((u_char)(c)))))
732 +
733 +/*
734 + * vis - visually encode characters
735 + */
736 +char *
737 +vis(char *dst, int c, int flag, int nextc)
738 +{
739 +       if (isvisible(c)) {
740 +               *dst++ = c;
741 +               if (c == '\\' && (flag & VIS_NOSLASH) == 0)
742 +                       *dst++ = '\\';
743 +               *dst = '\0';
744 +               return (dst);
745 +       }
746 +
747 +       if (flag & VIS_CSTYLE) {
748 +               switch(c) {
749 +               case '\n':
750 +                       *dst++ = '\\';
751 +                       *dst++ = 'n';
752 +                       goto done;
753 +               case '\r':
754 +                       *dst++ = '\\';
755 +                       *dst++ = 'r';
756 +                       goto done;
757 +               case '\b':
758 +                       *dst++ = '\\';
759 +                       *dst++ = 'b';
760 +                       goto done;
761 +               case '\a':
762 +                       *dst++ = '\\';
763 +                       *dst++ = 'a';
764 +                       goto done;
765 +               case '\v':
766 +                       *dst++ = '\\';
767 +                       *dst++ = 'v';
768 +                       goto done;
769 +               case '\t':
770 +                       *dst++ = '\\';
771 +                       *dst++ = 't';
772 +                       goto done;
773 +               case '\f':
774 +                       *dst++ = '\\';
775 +                       *dst++ = 'f';
776 +                       goto done;
777 +               case ' ':
778 +                       *dst++ = '\\';
779 +                       *dst++ = 's';
780 +                       goto done;
781 +               case '\0':
782 +                       *dst++ = '\\';
783 +                       *dst++ = '0';
784 +                       if (isoctal(nextc)) {
785 +                               *dst++ = '0';
786 +                               *dst++ = '0';
787 +                       }
788 +                       goto done;
789 +               }
790 +       }
791 +       if (((c & 0177) == ' ') || (flag & VIS_OCTAL) ||
792 +           ((flag & VIS_GLOB) && (c == '*' || c == '?' || c == '[' || c == '#'))) {
793 +               *dst++ = '\\';
794 +               *dst++ = ((u_char)c >> 6 & 07) + '0';
795 +               *dst++ = ((u_char)c >> 3 & 07) + '0';
796 +               *dst++ = ((u_char)c & 07) + '0';
797 +               goto done;
798 +       }
799 +       if ((flag & VIS_NOSLASH) == 0)
800 +               *dst++ = '\\';
801 +       if (c & 0200) {
802 +               c &= 0177;
803 +               *dst++ = 'M';
804 +       }
805 +       if (iscntrl((u_char)c)) {
806 +               *dst++ = '^';
807 +               if (c == 0177)
808 +                       *dst++ = '?';
809 +               else
810 +                       *dst++ = c + '@';
811 +       } else {
812 +               *dst++ = '-';
813 +               *dst++ = c;
814 +       }
815 +done:
816 +       *dst = '\0';
817 +       return (dst);
818 +}
819 +
820 +/*
821 + * strvis, strnvis, strvisx - visually encode characters from src into dst
822 + *     
823 + *     Dst must be 4 times the size of src to account for possible
824 + *     expansion.  The length of dst, not including the trailing NULL,
825 + *     is returned. 
826 + *
827 + *     Strnvis will write no more than siz-1 bytes (and will NULL terminate).
828 + *     The number of bytes needed to fully encode the string is returned.
829 + *
830 + *     Strvisx encodes exactly len bytes from src into dst.
831 + *     This is useful for encoding a block of data.
832 + */
833 +int
834 +strvis(char *dst, const char *src, int flag)
835 +{
836 +       char c;
837 +       char *start;
838 +
839 +       for (start = dst; (c = *src);)
840 +               dst = vis(dst, c, flag, *++src);
841 +       *dst = '\0';
842 +       return (dst - start);
843 +}
844 +
845 +int
846 +strnvis(char *dst, const char *src, size_t siz, int flag)
847 +{
848 +       char *start, *end;
849 +       char tbuf[5];
850 +       int c, i;
851 +
852 +       i = 0;
853 +       for (start = dst, end = start + siz - 1; (c = *src) && dst < end; ) {
854 +               if (isvisible(c)) {
855 +                       i = 1;
856 +                       *dst++ = c;
857 +                       if (c == '\\' && (flag & VIS_NOSLASH) == 0) {
858 +                               /* need space for the extra '\\' */
859 +                               if (dst < end)
860 +                                       *dst++ = '\\';
861 +                               else {
862 +                                       dst--;
863 +                                       i = 2;
864 +                                       break;
865 +                               }
866 +                       }
867 +                       src++;
868 +               } else {
869 +                       i = vis(tbuf, c, flag, *++src) - tbuf;
870 +                       if (dst + i <= end) {
871 +                               memcpy(dst, tbuf, i);
872 +                               dst += i;
873 +                       } else {
874 +                               src--;
875 +                               break;
876 +                       }
877 +               }
878 +       }
879 +       if (siz > 0)
880 +               *dst = '\0';
881 +       if (dst + i > end) {
882 +               /* adjust return value for truncation */
883 +               while ((c = *src))
884 +                       dst += vis(tbuf, c, flag, *++src) - tbuf;
885 +       }
886 +       return (dst - start);
887 +}
888 +
889 +int
890 +strvisx(char *dst, const char *src, size_t len, int flag)
891 +{
892 +       char c;
893 +       char *start;
894 +
895 +       for (start = dst; len > 1; len--) {
896 +               c = *src;
897 +               dst = vis(dst, c, flag, *++src);
898 +       }
899 +       if (len)
900 +               dst = vis(dst, *src, flag, '\0');
901 +       *dst = '\0';
902 +       return (dst - start);
903 +}
904 --- pax-20090728.orig/gen_subs.c
905 +++ pax-20090728/gen_subs.c
906 @@ -43,19 +43,23 @@ static const char rcsid[] = "$OpenBSD: g
907  #endif /* not lint */
908  
909  #include <sys/types.h>
910 +#include <sys/sysmacros.h>
911  #include <sys/time.h>
912 +#include <time.h>
913  #include <sys/stat.h>
914  #include <sys/param.h>
915  #include <stdio.h>
916 -#include <tzfile.h>
917 +#include "tzfile.h"
918  #include <utmp.h>
919  #include <unistd.h>
920  #include <stdlib.h>
921  #include <string.h>
922 -#include <vis.h>
923 +#include "vis.h"
924  #include "pax.h"
925  #include "extern.h"
926  
927 +#include "strmode.h"
928 +
929  /*
930   * a collection of general purpose subroutines used by pax
931   */
932 @@ -65,6 +69,9 @@ static const char rcsid[] = "$OpenBSD: g
933   */
934  #define MODELEN 20
935  #define DATELEN 64
936 +#define DAYSPERNYEAR 365
937 +/* #define SECSPERDAY 86400 */
938 +/* #define VIS_CSTYLE 0 */
939  #define SIXMONTHS       ((DAYSPERNYEAR / 2) * SECSPERDAY)
940  #define CURFRMT                "%b %e %H:%M"
941  #define OLDFRMT                "%b %e  %Y"
942 @@ -205,7 +212,7 @@ safe_print(const char *str, FILE *fp)
943         /*
944          * if printing to a tty, use vis(3) to print special characters.
945          */
946 -       if (isatty(fileno(fp))) {
947 +       if (0 && isatty(fileno(fp))) {
948                 for (cp = str; *cp; cp++) {
949                         (void)vis(visbuf, cp[0], VIS_CSTYLE, cp[1]);
950                         (void)fputs(visbuf, fp);
951 --- pax-20090728.orig/pax.1
952 +++ pax-20090728/pax.1
953 @@ -1143,7 +1143,7 @@ completes it will exit with a non-zero e
954  The
955  .Nm
956  utility is compliant with the
957 -.St -p1003.1-2008
958 +POSIX 1003.1-2008
959  specification.
960  .Pp
961  The flags
962 --- /dev/null
963 +++ pax-20090728/fgetln.c
964 @@ -0,0 +1,134 @@
965 +/* fgetline:  Read one line of input and return a pointer to
966 +   that line.  Necessary space is obtained from malloc.
967 +   (char *) NULL is returned on EOF.
968 +
969 +    Andy Dougherty             doughera@lafcol.lafayette.edu
970 +    Dept. of Physics
971 +    Lafayette College, Easton PA 18042
972 +
973 +    Successive calls to fgetline() overwrite the original buffer.
974 +    If you want to preserve the data, you must do something like
975 +    the following (the +1's are for '\0' characters):
976 +
977 +       tmp = fgetline(fp);
978 +       ntmp = Ealloc(strlen(tmp)+1, sizeof(char));  
979 +       strncpy(ntmp, tmp, strlen(tmp)+1);
980 +
981 +    A line is defined as all characters up to (and including) the next
982 +    newline character or end of file.
983 +    The string is terminated by a NULL character.
984 +
985 + * Version 1.1   A. Dougherty  2/7/94
986 +   Don't call realloc() just to save a few bytes.
987 +   Check return value from realloc().  (NULL is allowed under POSIX,
988 +   though I've never hit it.)
989 +
990 + * Version 1.0  A. Dougherty  2/27/91
991 +
992 + This fgetline implementation was written by Andrew Dougherty
993 + <doughera@lafayette.edu>.  I hearby place it in the public domain.
994 + As a courtesy, please leave my name attached to the source.
995 +
996 + This code comes with no warranty whatsoever, and I take no
997 + responsibility for any consequences of its use.
998 +*/
999 +
1000 +/* Algorithm:  A local static buffer "buf" is maintained.  The current
1001 +   length (space available) is in the static variable "avail".  
1002 +   Read in characters into this buffer.  If need more space, call
1003 +   malloc().
1004 +
1005 +   Aside:  We have computed strlen(buf) in this function.  It
1006 +   seems a shame to throw it away.
1007 +*/
1008 +
1009 +#include <stdio.h>
1010 +#include <stdlib.h>
1011 +#include <sys/types.h>
1012 +
1013 +#define LINELEN 128 /* A decent guess that should only rarely be
1014 +                       overwritten.
1015 +                   */
1016 +#define OK_TO_WASTE 512 /* Don't bother trying to realloc() back to
1017 +                          a smaller buffer if you'd only end up
1018 +                          wasting OK_TO_WASTE bytes.
1019 +                       */
1020 +
1021 +void *Emalloc(size_t len) /* David */
1022 +{
1023 +       char *p;
1024 +
1025 +       p=malloc(len);
1026 +       if (p == NULL) {
1027 +               perror("out of memory (Emalloc)");
1028 +               exit(2);
1029 +
1030 +       }
1031 +       return p;
1032 +}
1033 +
1034 +void *Erealloc(char *p, size_t len) /* David */
1035 +{
1036 +       p=realloc(p, len);
1037 +       if (p == NULL) {
1038 +               perror("out of memory (Erealloc)");
1039 +               exit(2);
1040 +
1041 +       }
1042 +       return p;
1043 +}
1044 +
1045 +char *
1046 +fgetln(FILE *fp, size_t *length)
1047 +  {
1048 +    static char *buf = NULL;
1049 +    static size_t avail = 0;
1050 +    int c;
1051 +    char *p; /* Temporary used for reducing length. */
1052 +    int len;
1053 +
1054 +    if (avail == 0)
1055 +      {
1056 +       buf = (char *) Emalloc(LINELEN * sizeof(char));
1057 +       avail = LINELEN;
1058 +      }
1059 +
1060 +    len = 0; /* Current length */
1061 +
1062 +    while ((c=getc(fp)) != EOF)
1063 +      {
1064 +       if (len >= avail) /* Need to ask for space */
1065 +         {
1066 +           avail += LINELEN;  /* Maybe avail *= 2 would be better */
1067 +           buf = (char *) Erealloc((void *) buf, avail * sizeof(char));
1068 +         }
1069 +       buf[len] = c;
1070 +       len++;
1071 +       if (c == '\n')
1072 +           break;
1073 +      }
1074 +
1075 +    if (c == EOF && len == 0)
1076 +       return (char *) NULL;
1077 +
1078 +    /* Add terminating '\0' character */
1079 +    if (len >= avail)  /* Need 1 more space */
1080 +       buf = (char *) Erealloc((void *) buf, (len+1) * sizeof(char));
1081 +    buf[len] = '\0';
1082 +
1083 +    /* Should we bother to try reclaiming memory?  (Otherwise, this
1084 +       function will hold onto enough memory to hold the longest
1085 +       line for the entire duration of the program.)
1086 +    */
1087 +    if (avail - len  > OK_TO_WASTE)
1088 +      {
1089 +       p = (char *) Erealloc((void *) buf, (len+1) * sizeof(char));
1090 +       if (p != NULL)
1091 +         {
1092 +           buf = p;
1093 +           avail = len + 1;
1094 +         }
1095 +      }
1096 +    *length=len-1;
1097 +    return buf;
1098 +  }
1099 --- pax-20090728.orig/cpio.c
1100 +++ pax-20090728/cpio.c
1101 @@ -43,6 +43,7 @@ static const char rcsid[] = "$OpenBSD: c
1102  #endif /* not lint */
1103  
1104  #include <sys/types.h>
1105 +#include <sys/sysmacros.h>
1106  #include <sys/time.h>
1107  #include <sys/stat.h>
1108  #include <sys/param.h>
1109 --- /dev/null
1110 +++ pax-20090728/tzfile.h
1111 @@ -0,0 +1,158 @@
1112 +/*
1113 + *     Ported to Linux's Second Extended File System as part of the
1114 + *     dump and restore backup suit
1115 + *     Remy Card <Remy.Card@freenix.fr>, 1994, 1995
1116 + *
1117 + */
1118 +
1119 +/*
1120 + * Copyright (c) 1988, 1993
1121 + *     The Regents of the University of California.  All rights reserved.
1122 + *
1123 + * This code is derived from software contributed to Berkeley by
1124 + * Arthur David Olson of the National Cancer Institute.
1125 + *
1126 + * Redistribution and use in source and binary forms, with or without
1127 + * modification, are permitted provided that the following conditions
1128 + * are met:
1129 + * 1. Redistributions of source code must retain the above copyright
1130 + *    notice, this list of conditions and the following disclaimer.
1131 + * 2. Redistributions in binary form must reproduce the above copyright
1132 + *    notice, this list of conditions and the following disclaimer in the
1133 + *    documentation and/or other materials provided with the distribution.
1134 + * 3. All advertising materials mentioning features or use of this software
1135 + *    must display the following acknowledgement:
1136 + *     This product includes software developed by the University of
1137 + *     California, Berkeley and its contributors.
1138 + * 4. Neither the name of the University nor the names of its contributors
1139 + *    may be used to endorse or promote products derived from this software
1140 + *    without specific prior written permission.
1141 + *
1142 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1143 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1144 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1145 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1146 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1147 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1148 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1149 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1150 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1151 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1152 + * SUCH DAMAGE.
1153 + *
1154 + *     @(#)tzfile.h    8.1 (Berkeley) 6/2/93
1155 + */
1156 +
1157 +#ifndef _TZFILE_H_
1158 +#define        _TZFILE_H_
1159 +
1160 +/*
1161 + * Information about time zone files.
1162 + */
1163 +                       /* Time zone object file directory */
1164 +#define TZDIR          "/usr/share/zoneinfo"
1165 +#define TZDEFAULT      "/etc/localtime"
1166 +#define TZDEFRULES     "posixrules"
1167 +
1168 +/*
1169 +** Each file begins with. . .
1170 +*/
1171 +
1172 +struct tzhead {
1173 +       char    tzh_reserved[24];       /* reserved for future use */
1174 +       char    tzh_ttisstdcnt[4];      /* coded number of trans. time flags */
1175 +       char    tzh_leapcnt[4];         /* coded number of leap seconds */
1176 +       char    tzh_timecnt[4];         /* coded number of transition times */
1177 +       char    tzh_typecnt[4];         /* coded number of local time types */
1178 +       char    tzh_charcnt[4];         /* coded number of abbr. chars */
1179 +};
1180 +
1181 +/*
1182 +** . . .followed by. . .
1183 +**
1184 +**     tzh_timecnt (char [4])s         coded transition times a la time(2)
1185 +**     tzh_timecnt (unsigned char)s    types of local time starting at above
1186 +**     tzh_typecnt repetitions of
1187 +**             one (char [4])          coded GMT offset in seconds
1188 +**             one (unsigned char)     used to set tm_isdst
1189 +**             one (unsigned char)     that's an abbreviation list index
1190 +**     tzh_charcnt (char)s             '\0'-terminated zone abbreviations
1191 +**     tzh_leapcnt repetitions of
1192 +**             one (char [4])          coded leap second transition times
1193 +**             one (char [4])          total correction after above
1194 +**     tzh_ttisstdcnt (char)s          indexed by type; if TRUE, transition
1195 +**                                     time is standard time, if FALSE,
1196 +**                                     transition time is wall clock time
1197 +**                                     if absent, transition times are
1198 +**                                     assumed to be wall clock time
1199 +*/
1200 +
1201 +/*
1202 +** In the current implementation, "tzset()" refuses to deal with files that
1203 +** exceed any of the limits below.
1204 +*/
1205 +
1206 +/*
1207 +** The TZ_MAX_TIMES value below is enough to handle a bit more than a
1208 +** year's worth of solar time (corrected daily to the nearest second) or
1209 +** 138 years of Pacific Presidential Election time
1210 +** (where there are three time zone transitions every fourth year).
1211 +*/
1212 +#define TZ_MAX_TIMES   370
1213 +
1214 +#define NOSOLAR                        /* 4BSD doesn't currently handle solar time */
1215 +
1216 +#ifndef NOSOLAR
1217 +#define TZ_MAX_TYPES   256     /* Limited by what (unsigned char)'s can hold */
1218 +#else
1219 +#define TZ_MAX_TYPES   10      /* Maximum number of local time types */
1220 +#endif
1221 +
1222 +#define TZ_MAX_CHARS   50      /* Maximum number of abbreviation characters */
1223 +
1224 +#define        TZ_MAX_LEAPS    50      /* Maximum number of leap second corrections */
1225 +
1226 +#define SECSPERMIN     60
1227 +#define MINSPERHOUR    60
1228 +#define HOURSPERDAY    24
1229 +#define DAYSPERWEEK    7
1230 +#define DAYSPERNYEAR   365
1231 +#define DAYSPERLYEAR   366
1232 +#define SECSPERHOUR    (SECSPERMIN * MINSPERHOUR)
1233 +#define SECSPERDAY     ((long) SECSPERHOUR * HOURSPERDAY)
1234 +#define MONSPERYEAR    12
1235 +
1236 +#define TM_SUNDAY      0
1237 +#define TM_MONDAY      1
1238 +#define TM_TUESDAY     2
1239 +#define TM_WEDNESDAY   3
1240 +#define TM_THURSDAY    4
1241 +#define TM_FRIDAY      5
1242 +#define TM_SATURDAY    6
1243 +
1244 +#define TM_JANUARY     0
1245 +#define TM_FEBRUARY    1
1246 +#define TM_MARCH       2
1247 +#define TM_APRIL       3
1248 +#define TM_MAY         4
1249 +#define TM_JUNE                5
1250 +#define TM_JULY                6
1251 +#define TM_AUGUST      7
1252 +#define TM_SEPTEMBER   8
1253 +#define TM_OCTOBER     9
1254 +#define TM_NOVEMBER    10
1255 +#define TM_DECEMBER    11
1256 +
1257 +#define TM_YEAR_BASE   1900
1258 +
1259 +#define EPOCH_YEAR     1970
1260 +#define EPOCH_WDAY     TM_THURSDAY
1261 +
1262 +/*
1263 +** Accurate only for the past couple of centuries;
1264 +** that will probably do.
1265 +*/
1266 +
1267 +#define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0)
1268 +
1269 +#endif /* !_TZFILE_H_ */
1270 --- /dev/null
1271 +++ pax-20090728/vis.h
1272 @@ -0,0 +1,90 @@
1273 +/*     $OpenBSD: vis.h,v 1.11 2005/08/09 19:38:31 millert Exp $        */
1274 +/*     $NetBSD: vis.h,v 1.4 1994/10/26 00:56:41 cgd Exp $      */
1275 +
1276 +/*-
1277 + * Copyright (c) 1990 The Regents of the University of California.
1278 + * All rights reserved.
1279 + *
1280 + * Redistribution and use in source and binary forms, with or without
1281 + * modification, are permitted provided that the following conditions
1282 + * are met:
1283 + * 1. Redistributions of source code must retain the above copyright
1284 + *    notice, this list of conditions and the following disclaimer.
1285 + * 2. Redistributions in binary form must reproduce the above copyright
1286 + *    notice, this list of conditions and the following disclaimer in the
1287 + *    documentation and/or other materials provided with the distribution.
1288 + * 3. Neither the name of the University nor the names of its contributors
1289 + *    may be used to endorse or promote products derived from this software
1290 + *    without specific prior written permission.
1291 + *
1292 + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1293 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1294 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1295 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
1296 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1297 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1298 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1299 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1300 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1301 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1302 + * SUCH DAMAGE.
1303 + *
1304 + *     @(#)vis.h       5.9 (Berkeley) 4/3/91
1305 + */
1306 +
1307 +#ifndef _VIS_H_
1308 +#define        _VIS_H_
1309 +
1310 +/*
1311 + * to select alternate encoding format
1312 + */
1313 +#define        VIS_OCTAL       0x01    /* use octal \ddd format */
1314 +#define        VIS_CSTYLE      0x02    /* use \[nrft0..] where appropriate */
1315 +
1316 +/*
1317 + * to alter set of characters encoded (default is to encode all
1318 + * non-graphic except space, tab, and newline).
1319 + */
1320 +#define        VIS_SP          0x04    /* also encode space */
1321 +#define        VIS_TAB         0x08    /* also encode tab */
1322 +#define        VIS_NL          0x10    /* also encode newline */
1323 +#define        VIS_WHITE       (VIS_SP | VIS_TAB | VIS_NL)
1324 +#define        VIS_SAFE        0x20    /* only encode "unsafe" characters */
1325 +
1326 +/*
1327 + * other
1328 + */
1329 +#define        VIS_NOSLASH     0x40    /* inhibit printing '\' */
1330 +#define        VIS_GLOB        0x100   /* encode glob(3) magics and '#' */
1331 +
1332 +/*
1333 + * unvis return codes
1334 + */
1335 +#define        UNVIS_VALID      1      /* character valid */
1336 +#define        UNVIS_VALIDPUSH  2      /* character valid, push back passed char */
1337 +#define        UNVIS_NOCHAR     3      /* valid sequence, no character produced */
1338 +#define        UNVIS_SYNBAD    -1      /* unrecognized escape sequence */
1339 +#define        UNVIS_ERROR     -2      /* decoder in unknown state (unrecoverable) */
1340 +
1341 +/*
1342 + * unvis flags
1343 + */
1344 +#define        UNVIS_END       1       /* no more characters */
1345 +
1346 +#include <sys/cdefs.h>
1347 +
1348 +__BEGIN_DECLS
1349 +char   *vis(char *, int, int, int);
1350 +int    strvis(char *, const char *, int);
1351 +int    strnvis(char *, const char *, size_t, int)
1352 +               __attribute__ ((__bounded__(__string__,1,3)));
1353 +int    strvisx(char *, const char *, size_t, int)
1354 +               __attribute__ ((__bounded__(__string__,1,3)));
1355 +int    strunvis(char *, const char *);
1356 +int    unvis(char *, char, int *, int);
1357 +ssize_t strnunvis(char *, const char *, size_t)
1358 +               __attribute__ ((__bounded__(__string__,1,3)));
1359 +
1360 +__END_DECLS
1361 +
1362 +#endif /* !_VIS_H_ */
1363 --- /dev/null
1364 +++ pax-20090728/fgetln.h
1365 @@ -0,0 +1,17 @@
1366 +/* fgetline:  Read one line of input and return a pointer to
1367 +   that line.  Necessary space is obtained from malloc.
1368 +   (char *) NULL is returned on EOF.
1369 +
1370 +    Andy Dougherty             doughera@lafcol.lafayette.edu
1371 +    Dept. of Physics
1372 +    Lafayette College, Easton PA 18042
1373 +
1374 +    This fgetline implementation was written by Andrew Dougherty
1375 +    <doughera@lafayette.edu>.  I hearby place it in the public domain.
1376 +    As a courtesy, please leave my name attached to the source.
1377 +
1378 +    This code comes with no warranty whatsoever, and I take no
1379 +    responsibility for any consequences of its use.
1380 +*/
1381 +
1382 +char *fgetln(FILE *fp, size_t *length);
1383 --- pax-20090728.orig/options.c
1384 +++ pax-20090728/options.c
1385 @@ -60,6 +60,8 @@ static const char rcsid[] = "$OpenBSD: o
1386  #include "tar.h"
1387  #include "extern.h"
1388  
1389 +#include "fgetln.h"    /* added, David */
1390 +
1391  /*
1392   * Routines which handle command line options
1393   */
1394 @@ -72,7 +74,7 @@ static int no_op(void);
1395  static void printflg(unsigned int);
1396  static int c_frmt(const void *, const void *);
1397  static off_t str_offt(char *);
1398 -static char *getline(FILE *fp);
1399 +static char *bsd_getline(FILE *fp);
1400  static void pax_options(int, char **);
1401  static void pax_usage(void);
1402  static void tar_options(int, char **);
1403 @@ -882,7 +884,7 @@ tar_options(int argc, char **argv)
1404                                                 paxwarn(1, "Unable to open file '%s' for read", file);
1405                                                 tar_usage();
1406                                         }
1407 -                                       while ((str = getline(fp)) != NULL) {
1408 +                                       while ((str = bsd_getline(fp)) != NULL) {
1409                                                 if (pat_add(str, dir) < 0)
1410                                                         tar_usage();
1411                                                 sawpat = 1;
1412 @@ -961,7 +963,7 @@ tar_options(int argc, char **argv)
1413                                         paxwarn(1, "Unable to open file '%s' for read", file);
1414                                         tar_usage();
1415                                 }
1416 -                               while ((str = getline(fp)) != NULL) {
1417 +                               while ((str = bsd_getline(fp)) != NULL) {
1418                                         if (ftree_add(str, 0) < 0)
1419                                                 tar_usage();
1420                                 }
1421 @@ -1183,7 +1185,7 @@ cpio_options(int argc, char **argv)
1422                                         paxwarn(1, "Unable to open file '%s' for read", optarg);
1423                                         cpio_usage();
1424                                 }
1425 -                               while ((str = getline(fp)) != NULL) {
1426 +                               while ((str = bsd_getline(fp)) != NULL) {
1427                                         pat_add(str, NULL);
1428                                 }
1429                                 fclose(fp);
1430 @@ -1282,7 +1284,7 @@ cpio_options(int argc, char **argv)
1431                          * no read errors allowed on updates/append operation!
1432                          */
1433                         maxflt = 0;
1434 -                       while ((str = getline(stdin)) != NULL) {
1435 +                       while ((str = bsd_getline(stdin)) != NULL) {
1436                                 ftree_add(str, 0);
1437                         }
1438                         if (getline_error) {
1439 @@ -1459,7 +1461,7 @@ str_offt(char *val)
1440         if ((num == LONG_MAX) || (num <= 0) || (expr == val))
1441  #      else
1442         num = strtoq(val, &expr, 0);
1443 -       if ((num == QUAD_MAX) || (num <= 0) || (expr == val))
1444 +       if ((num == LLONG_MAX) || (num <= 0) || (expr == val))
1445  #      endif
1446                 return(0);
1447  
1448 @@ -1511,7 +1513,7 @@ str_offt(char *val)
1449  }
1450  
1451  char *
1452 -getline(FILE *f)
1453 +bsd_getline(FILE *f)
1454  {
1455         char *name, *temp;
1456         size_t len;