Don't use fchdir() as it's not terribly portable.

CVS patchset: 1637
CVS date: 1997/05/16 15:25:31
This commit is contained in:
ewt 1997-05-16 15:25:31 +00:00
parent d526f6299b
commit 95eca93972
1 changed files with 12 additions and 7 deletions

View File

@ -995,6 +995,8 @@ static int installSources(Header h, char * rootdir, int fd,
struct fileInfo * files; struct fileInfo * files;
int i; int i;
char * chptr; char * chptr;
char * currDir;
int currDirLen;
rpmMessage(RPMMESS_DEBUG, "installing a source package\n"); rpmMessage(RPMMESS_DEBUG, "installing a source package\n");
@ -1070,22 +1072,25 @@ static int installSources(Header h, char * rootdir, int fd,
fflush(stdout); fflush(stdout);
} }
i = open(".", O_RDONLY); currDirLen = 50;
currDir = malloc(currDirLen);
while (!getcwd(currDir, currDirLen)) {
currDirLen += 50;
currDir = realloc(currDir, currDirLen);
}
chdir(realSourceDir); chdir(realSourceDir);
if (installArchive(fd, fileCount > 0 ? files : NULL, if (installArchive(fd, fileCount > 0 ? files : NULL,
fileCount, notify, fileCount, notify,
specFileIndex >=0 ? NULL : &specFile, specFileIndex >=0 ? NULL : &specFile,
archiveSizePtr ? *archiveSizePtr : 0)) { archiveSizePtr ? *archiveSizePtr : 0)) {
if (fileCount > 0) freeFileMemory(fileMem); if (fileCount > 0) freeFileMemory(fileMem);
free(currDir);
return 2; return 2;
} }
if (i >= 0) { chdir(currDir);
fchdir(i); free(currDir);
close(i);
} else {
chdir("/");
}
if (specFileIndex == -1) { if (specFileIndex == -1) {
if (!specFile) { if (!specFile) {