From: Wichert Akkerman Date: Thu, 23 Nov 2000 17:54:19 +0000 (+0000) Subject: lib/mlib.c: fix error reporting for reading data in do_fd_copy X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14224556bab508da1d768b93f2781b145543c9e6;p=dpkg lib/mlib.c: fix error reporting for reading data in do_fd_copy optlib/Makefile.am: remove (can't believe this still existed!) utils/Makefile.in: link md5sum with our own libintl if needed archtable, scripts/dpkg-architecture.pl: add freebsd-i386 acconfig.h, configure.in, doc/Makefile.in: make building documentation and start-stop-daemon optional main/help.c: only check for start-stop-daemon in checkpatch() if we build it --- diff --git a/ChangeLog b/ChangeLog index f2d83fe4..7d2ee259 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,21 @@ Thu Nov 23 17:52:44 CET 2000 Wichert Akkerman * lib/fields.c, lib/dump.c: fix two memory leaks + * More Adam Heath patches: + + lib/mlib.c, include/dpkg.h.in: add new option for do_fd_copy to + specify buffersize + + dpkg-deb/build.c, lib/info.c, lib/showcright.c: update for new + do_fd_copy + + dpkg-deb/extract.c: use do_fd_copy to read data instead of reading + per character. + * lib/mlib.c: fix error reporting for reading data in do_fd_copy + * optlib/Makefile.am: remove (can't believe this still existed!) + * utils/Makefile.in: link md5sum with our own libintl if needed + * archtable, scripts/dpkg-architecture.pl: add freebsd-i386 + * acconfig.h, configure.in, doc/Makefile.in: make building documentation + and start-stop-daemon optional + * main/help.c: only check for start-stop-daemon in checkpatch() if we + build it Thu Nov 23 15:48:53 CET 2000 Wichert Akkerman diff --git a/acconfig.h b/acconfig.h index b3414010..e5716f6f 100644 --- a/acconfig.h +++ b/acconfig.h @@ -72,3 +72,5 @@ /* Define the ptrdiff_t type if your system doesn't have it */ #undef ptrdiff_t +/* Define if start-stop-daemon is compiled */ +#undef USE_START_STOP_DAEMON diff --git a/archtable b/archtable index 14d3be68..bdd17de8 100644 --- a/archtable +++ b/archtable @@ -38,3 +38,4 @@ shel-linux-gnu sh sh hppa-linux-gnu hppa hppa hppa1.1-linux-gnu hppa hppa hppa2.0-linux-gnu hppa hppa +i386-freebsd freebsd-i386 freebsd-i386 diff --git a/configure.in b/configure.in index ac81e589..3fdce460 100644 --- a/configure.in +++ b/configure.in @@ -16,6 +16,30 @@ AC_ARG_WITH(dselect, esac]) AC_SUBST(DSELECTDIR) +USE_START_STOP_DAEMON="true" +AC_ARG_WITH(start-stop-daemon, +[ --with-start-stop-daemon + start and stop system daemons], +[case "$withval" in + "false" | "no" ) + USE_START_STOP_DAEMON="" + ;; + esac]) +AC_SUBST(USE_START_STOP_DAEMON) +if test "$USE_START_STOP_DAEMON" != ""; then + AC_DEFINE(USE_START_STOP_DAEMON) +fi + +USE_SGML_DOC="true" +AC_ARG_WITH(sgml-doc, +[ --with-sgml-doc SGML documentation converted to HTML], +[case "$withval" in + "false" | "no" ) + USE_SGML_DOC="" + ;; + esac]) +AC_SUBST(USE_SGML_DOC) + admindir="$libdir/db" AC_ARG_WITH(admindir, [ --with-admindir=DIR store dpkg database in DIR [LIBDIR/db]], diff --git a/doc/Makefile.in b/doc/Makefile.in index 01e1bb4e..060e6713 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -8,7 +8,11 @@ include ../Makefile.conf MAN5PAGES = deb-control.5 deb-old.5 deb.5 +ifeq (@USE_SGML_DOC@, true) all: internals.html/index.html all-recursive +else +all: all-recursive +endif clean: clean-recursive $(RM) $(srcdir)/manuals-version @@ -33,11 +37,13 @@ install-doc: install-doc-recursive if test -f $$i ; then d= ; else d="$(srcdir)/" ; fi ; \ $(INSTALL_DATA) $$d$$i $(DESTDIR)$(man5dir) ; \ done +ifeq (@USE_SGML_DOC@, true) $(mkinstalldirs) $(DESTDIR)$(docdir)/internals/ set -e ; for i in internals.html/* ; do \ bn=`basename $$i` ; \ $(INSTALL_DATA) $$i $(DESTDIR)$(docdir)/internals/$$bn ; \ done +endif $(INSTALL_DATA) $(srcdir)/ChangeLog $(DESTDIR)$(docdir)/ChangeLog.manuals set -e ; for i in ChangeLog THANKS TODO ; do \ $(INSTALL_DATA) $(top_srcdir)/$$i $(DESTDIR)$(docdir) ; \ diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c index 60398f29..6e4add37 100644 --- a/dpkg-deb/build.c +++ b/dpkg-deb/build.c @@ -364,7 +364,7 @@ void do_build(const char *const *argv) { } if (lseek(gzfd,0,SEEK_SET)) ohshite(_("failed to rewind tmpfile (control)")); - do_fd_copy(gzfd, fileno(ar), _("control")); + do_fd_copy(gzfd, fileno(ar), -1, _("control")); /* Control is done, now we need to archive the data. Start by creating * a new temporary file. Immediately unlink the temporary file so others @@ -422,7 +422,7 @@ void do_build(const char *const *argv) { combuf = strdup("-9c"); if(compression != NULL) { if(*compression == '0') { - do_fd_copy(0, 1, _("no compression copy loop")); + do_fd_copy(0, 1, -1, _("no compression copy loop")); exit(0); } combuf[1] = *compression; @@ -456,11 +456,7 @@ void do_build(const char *const *argv) { werr(debar); if (lseek(gzfd,0,SEEK_SET)) ohshite(_("failed to rewind tmpfile (data)")); - if (!(c3= m_fork())) { - m_dup2(gzfd,0); m_dup2(fileno(ar),1); - execlp(CAT,"cat",(char*)0); ohshite(_("failed to exec cat (data)")); - } - waitsubproc(c3,"cat (data)",0); + do_fd_copy(gzfd, fileno(ar), -1, _("cat (data)")); if (datastab.st_size & 1) if (putc('\n',ar) == EOF) diff --git a/dpkg-deb/info.c b/dpkg-deb/info.c index d9253558..324009f6 100644 --- a/dpkg-deb/info.c +++ b/dpkg-deb/info.c @@ -90,7 +90,7 @@ static void info_spew(const char *debar, const char *directory, while ((component= *argv++) != 0) { co= fopen(component,"r"); if (co) { - do_fd_copy(fileno(co), 1, _("info_spew")); + do_fd_copy(fileno(co), 1, -1, _("info_spew")); } else if (errno == ENOENT) { if (fprintf(stderr, _("dpkg-deb: `%.255s' contains no control component `%.255s'\n"), debar, component) == EOF) werr("stderr"); diff --git a/include/dpkg.h.in b/include/dpkg.h.in index 8bbc5ca8..eca92c1d 100644 --- a/include/dpkg.h.in +++ b/include/dpkg.h.in @@ -199,7 +199,7 @@ void m_pipe(int fds[2]); void checksubprocerr(int status, const char *description, int sigpipeok); void waitsubproc(pid_t pid, const char *description, int sigpipeok); -int do_fd_copy(int fd1, int fd2, char *desc); +int do_fd_copy(int fd1, int fd2, int limit, char *desc); extern volatile int onerr_abort; diff --git a/lib/mlib.c b/lib/mlib.c index a700db02..33f8957b 100644 --- a/lib/mlib.c +++ b/lib/mlib.c @@ -123,9 +123,9 @@ void waitsubproc(pid_t pid, const char *description, int sigpipeok) { checksubprocerr(status,description,sigpipeok); } -int do_fd_copy(int fd1, int fd2, char *desc) { +int do_fd_copy(int fd1, int fd2, int limit, char *desc) { char *buf, *sbuf; - int count; + int count, bufsize = 32768; char *er_msg_1 = _("failed to allocate buffer for copy (%s)"); char *er_msg_2 = _("failed in copy on write (%s)"); char *er_msg_3 = _("failed in copy on read (%s)"); @@ -137,32 +137,40 @@ int do_fd_copy(int fd1, int fd2, char *desc) { snprintf(sbuf, count, er_msg_1, desc); sbuf[count-1] = 0; - buf = malloc(32768); + if((limit != -1) && (limit < bufsize)) + bufsize = limit; + buf = malloc(bufsize); if(buf == NULL) ohshite(sbuf); free(sbuf); - count = strlen(er_msg_2) + strlen(desc) + 1; - sbuf = malloc(count); - if(sbuf == NULL) - ohshite(_("failed to allocate buffer for snprintf 2")); - snprintf(sbuf, count, er_msg_2, desc); - sbuf[count-1] = 0; - - while((count = read(fd1, buf, 32768)) > 0) - if(write(fd2, buf, count) < count) - ohshite(sbuf); - + while((count = read(fd1, buf, bufsize)) > 0) { + if(write(fd2, buf, count) < count) { + count = strlen(er_msg_2) + strlen(desc) + 1; + sbuf = malloc(count); + if(sbuf == NULL) + ohshite(_("failed in copy on write")); + snprintf(sbuf, count, er_msg_2, desc); + sbuf[count-1] = 0; + ohshite(sbuf); + } + if(limit != -1) { + limit -= count; + if(limit < bufsize) + bufsize = limit; + } + } free(sbuf); - count = strlen(er_msg_3) + strlen(desc) + 1; - sbuf = malloc(count); - if(sbuf == NULL) - ohshite(_("failed to allocate buffer for snprintf 2")); - snprintf(sbuf, count, er_msg_3, desc); - sbuf[count-1] = 0; + if (count<0) { + count = strlen(er_msg_3) + strlen(desc) + 1; + sbuf = malloc(count); + if(sbuf == NULL) + ohshite(_("failed in copy on read")); + snprintf(sbuf, count, er_msg_3, desc); + sbuf[count-1] = 0; + ohsite(sbuf); + } - if(count < 0) - ohshite(_("failed in copy on read (control)")); free(sbuf); free(buf); } diff --git a/lib/showcright.c b/lib/showcright.c index acd3fe1e..ab4f6c11 100644 --- a/lib/showcright.c +++ b/lib/showcright.c @@ -29,6 +29,6 @@ void showcopyright(const struct cmdinfo *c, const char *v) { int fd; fd= open(COPYINGFILE,O_RDONLY); if (fd < 0) ohshite(_("cannot open GPL file ")); - do_fd_copy(fd, 1, "showcopyright"); + do_fd_copy(fd, 1, -1, "showcopyright"); exit(0); } diff --git a/main/help.c b/main/help.c index b798226e..9653ea94 100644 --- a/main/help.c +++ b/main/help.c @@ -69,8 +69,11 @@ struct filenamenode *namenodetouse(struct filenamenode *namenode, struct pkginfo void checkpath(void) { /* Verify that some programs can be found in the PATH. */ - static const char *const checklist[]= { - "ldconfig", "start-stop-daemon", "install-info", "update-rc.d", 0 + static const char *const checklist[]= { "ldconfig", +#ifdef USE_START_STOP_DAEMON + "start-stop-daemon", +#endif + "install-info", "update-rc.d", 0 }; struct stat stab; diff --git a/optlib/Makefile.am b/optlib/Makefile.am deleted file mode 100644 index 361656cd..00000000 --- a/optlib/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -## Process this file with automake to produce Makefile.in -noinst_LIBRARIES = liboptlib.a - -EXTRA_DIST = getdate.c - -INCLUDES = -I.. -I$(srcdir) - -liboptlib_a_SOURCES = getopt.c getopt1.c long-options.c closeout.c - -#liboptlib_a_LIBADD = @LIBOBJS@ @ALLOCA@ -liboptlib_a_DEPENDENCIES = $(liboptlib_a_LIBADD) - -noinst_HEADERS = getopt.h long-options.h closeout.h error.h - -BUILT_SOURCES = - -# Remove these files here... they are created locally -DISTCLEANFILES = $(BUILT_SOURCES) .deps/* *~ - diff --git a/scripts/dpkg-architecture.pl b/scripts/dpkg-architecture.pl index 987cb70f..06e4b30d 100755 --- a/scripts/dpkg-architecture.pl +++ b/scripts/dpkg-architecture.pl @@ -59,7 +59,8 @@ require 'controllib.pl'; 'sh', 'sh-linux', 'shed', 'shed-linux', 'hppa', 'hppa-linux', - 'hurd-i386', 'i386-gnu'); + 'hurd-i386', 'i386-gnu', + 'freebsd-i386', 'i386-freebsd'); sub usageversion { print STDERR diff --git a/utils/Makefile.in b/utils/Makefile.in index bb73b7cf..c95ded66 100644 --- a/utils/Makefile.in +++ b/utils/Makefile.in @@ -15,11 +15,17 @@ MD5_SOURCES = md5sum.c md5.c MD5_OBJECTS = $(patsubst %.c, %.o, $(MD5_SOURCES)) MD5_MANPAGES = md5sum.1 -GENFILES = $(SSD_OBJECTS) start-stop-daemon \ - $(MD5_OBJECTS) md5sum +GENFILES = $(MD5_OBJECTS) md5sum +ifeq (@USE_START_STOP_DAEMON@, true) +GENFILES += $(SSD_OBJECTS) start-stop-daemon +endif .PHONY: all +ifeq (@USE_START_STOP_DAEMON@, true) all:: start-stop-daemon md5sum +else +all:: md5sum +endif .PHONY: install install:: all @@ -37,15 +43,19 @@ install:: install-program install-doc .PHONY: install-program install-program: +ifeq (@USE_START_STOP_DAEMON@, true) $(mkinstalldirs) $(DESTDIR)/$(sbindir) $(INSTALL) start-stop-daemon $(DESTDIR)/$(sbindir) +endif $(mkinstalldirs) $(DESTDIR)/$(bindir) $(INSTALL) md5sum $(DESTDIR)/$(bindir) .PHONY: install-doc install-doc: +ifeq (@USE_START_STOP_DAEMON@, true) $(mkinstalldirs) $(DESTDIR)/$(man8dir) $(INSTALL_DATA) $(srcdir)/$(SSD_MANPAGES) $(DESTDIR)/$(man8dir) +endif $(mkinstalldirs) $(DESTDIR)/$(man1dir) $(INSTALL_DATA) $(srcdir)/$(MD5_MANPAGES) $(DESTDIR)/$(man1dir) @@ -53,4 +63,5 @@ start-stop-daemon: $(SSD_OBJECTS) ../optlib/libopt.a $(CC) $(LDFLAGS) -o $@ $^ $(SSD_LIBS) md5sum: $(MD5_OBJECTS) ../optlib/libopt.a + $(CC) $(LDFLAGS) -o $@ $^ $(NLS_LIBS)