+Mon Aug 21 12:58:15 CEST 2000 Wichert Akkerman <wakkerma@debian.org>
+
+ * lib/lock.c, main/filesdb.c, main/archives.c, main/configure.c,
+ dpkg-deb/build.c, dpkg-deb/extract.c: updates from Chip Salzenberg
+ to clean up fd handling
+
Thu Aug 10 21:08:00 CEST 2000 peter karlsson <peterk@debian.org>
* po/sv.po: More corrections and translation updates.
* archtable: add ia64; revert sparc64 so that it turns into sparc. There
wont be a full binary-sparc64 port.
* dselect/main.cc: small fixups to get it to compile with gcc-2.96
+ * Clean up fd handling in some places. Closes: Bug#69359,#69360,#69361
-- Wichert Akkerman <wakkerma@debian.org> UNRELEASED
strcat(tfbuf,"/dpkg.XXXXXX");
/* And run gzip to compress our control archive */
if (!(c2= m_fork())) {
- m_dup2(p1[0],0); m_dup2(gzfd,1); close(p1[0]);
+ m_dup2(p1[0],0); m_dup2(gzfd,1); close(p1[0]); close(gzfd);
execlp(GZIP,"gzip","-9c",(char*)0); ohshite(_("failed to exec gzip -9c"));
}
close(p1[0]);
execlp(GZIP,"gzip","-dc",(char*)0); ohshite(_("failed to exec gzip -dc"));
}
if (readfromfd != fileno(ar)) close(readfromfd);
- close(p2[1]);
+ if (taroption) close(p2[1]);
if (taroption && directory) {
if (chdir(directory)) {
strcpy(buffer, taroption);
strcat(buffer, "f");
m_dup2(p2[0],0);
+ close(p2[0]);
execlp(TAR,"tar",buffer,"-",(char*)0);
ohshite(_("failed to exec tar"));
}
ohshit(_("status database area is locked by another process"));
ohshite(_("unable to lock dpkg status database"));
}
+ n= fcntl(dblockfd, F_GETFD);
+ if (n >= 0) fcntl(dblockfd, F_SETFD, n | FD_CLOEXEC);
push_cleanup(cu_unlockdb,~0, 0,0, 0);
}
if (!(fc= m_fork())) {
const char *const *ap;
int i;
- m_dup2(pi[1],1); close(pi[0]);
+ m_dup2(pi[1],1); close(pi[0]); close(pi[1]);
for (i=0, ap=argv; *ap; ap++, i++);
arglist= m_malloc(sizeof(char*)*(i+15));
arglist[0]= FIND;
execvp(FIND, (char* const*)arglist);
ohshite(_("failed to exec find for --recursive"));
}
+ close(pi[1]);
nfiles= 0;
pf= fdopen(pi[0],"r"); if (!pf) ohshite(_("failed to fdopen find's pipe"));
- close(pi[1]);
varbufreset(&findoutput);
while ((c= fgetc(pf)) != EOF) {
varbufaddc(&findoutput,c);
m_pipe(p1);
push_cleanup(cu_closepipe,ehflag_bombout, 0,0, 1,(void*)&p1[0]);
if (!(c1= m_fork())) {
- m_dup2(fd,0); m_dup2(p1[1],1); close(p1[0]);
+ m_dup2(fd,0); m_dup2(p1[1],1); close(p1[0]); close(p1[1]);
execlp(MD5SUM,MD5SUM,(char*)0);
ohshite(_("failed to exec md5sum"));
}
#include <assert.h>
#include <unistd.h>
+#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
fclose(file); onerr_abort--; return;
}
}
+ l= fcntl(fileno(file), F_GETFD);
+ if (l >= 0) fcntl(fileno(file), F_SETFD, l | FD_CLOEXEC);
if (diversionsfile) fclose(diversionsfile);
diversionsfile= file;