From 19fdcab7acc03ceb6aaf57f7ccdd754a41aa7b6e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 31 Jul 2008 12:01:43 +0200 Subject: * python/apt_instmodule.cc: - do not change working dir in debExtractArchive() (LP: #184093) --- python/apt_instmodule.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'python') diff --git a/python/apt_instmodule.cc b/python/apt_instmodule.cc index 43d5e7f7..6e6c89dd 100644 --- a/python/apt_instmodule.cc +++ b/python/apt_instmodule.cc @@ -74,6 +74,7 @@ static char *doc_debExtractArchive = static PyObject *debExtractArchive(PyObject *Self,PyObject *Args) { char *Rootdir = NULL; + char cwd[512]; PyObject *File; if (PyArg_ParseTuple(Args,"O!|s",&PyFile_Type,&File,&Rootdir) == 0) return 0; @@ -83,21 +84,27 @@ static PyObject *debExtractArchive(PyObject *Self,PyObject *Args) { if(Rootdir != NULL) { + getcwd(cwd, sizeof(cwd)); chdir(Rootdir); } // Open the file and associate the .deb FileFd Fd(fileno(PyFile_AsFile(File)),false); debDebFile Deb(Fd); - if (_error->PendingError() == true) - return HandleErrors(); + if (_error->PendingError() == true) { + if (cwd != NULL) + chdir (cwd); + return HandleErrors(Py_BuildValue("b",false)); + } // extracts relative to the current dir pkgDirStream Extract; res = Deb.ExtractArchive(Extract); + if (cwd != NULL) + chdir (cwd); if (res == false) - return HandleErrors(); + return HandleErrors(Py_BuildValue("b",res)); } return HandleErrors(Py_BuildValue("b",res)); } -- cgit v1.2.3