PDF: pdftk as snap (ubuntu): print warning about pdf attachments if TMPDIR does not belong to user
This commit is contained in:
parent
1d7868d93c
commit
2c0fd8502a
@ -193,7 +193,6 @@ class PDFExtractor:
|
|||||||
if not tmpdir or not self.pdftk:
|
if not tmpdir or not self.pdftk:
|
||||||
# no big deal
|
# no big deal
|
||||||
return True
|
return True
|
||||||
|
|
||||||
try:
|
try:
|
||||||
vacuumdir(tmpdir)
|
vacuumdir(tmpdir)
|
||||||
subprocess.check_call([self.pdftk, self.filename, "unpack_files",
|
subprocess.check_call([self.pdftk, self.filename, "unpack_files",
|
||||||
@ -433,6 +432,21 @@ class PDFExtractor:
|
|||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
tmpdir = tempfile.mkdtemp(prefix='rclmpdf')
|
tmpdir = tempfile.mkdtemp(prefix='rclmpdf')
|
||||||
|
if self.pdftk and re.match("/snap/", self.pdftk):
|
||||||
|
# We know this is Unix (Ubuntu actually). Check that tmpdir
|
||||||
|
# belongs to the user as snap commands can't use /tmp to share
|
||||||
|
# files. Don't generate an error as this only affects
|
||||||
|
# attachment extraction
|
||||||
|
ok = False
|
||||||
|
if "TMPDIR" in os.environ:
|
||||||
|
st = os.stat(os.environ["TMPDIR"])
|
||||||
|
if st.st_uid == os.getuid():
|
||||||
|
ok = True
|
||||||
|
if not ok:
|
||||||
|
self.em.rclog(
|
||||||
|
"pdftk is a snap command and needs TMPDIR to be "
|
||||||
|
"a directory you own")
|
||||||
|
|
||||||
|
|
||||||
###### File type handler api, used by rclexecm ---------->
|
###### File type handler api, used by rclexecm ---------->
|
||||||
def openfile(self, params):
|
def openfile(self, params):
|
||||||
|
|||||||
14
tests/pdfattach/pdfattach.sh
Executable file
14
tests/pdfattach/pdfattach.sh
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
topdir=`dirname $0`/..
|
||||||
|
. $topdir/shared.sh
|
||||||
|
|
||||||
|
initvariables $0
|
||||||
|
|
||||||
|
(
|
||||||
|
recollq -S url '"Rosetten von Spitzwegerich"'
|
||||||
|
) 2> $mystderr | egrep -v '^Recoll query: ' > $mystdout
|
||||||
|
|
||||||
|
diff -w ${myname}.txt $mystdout > $mydiffs 2>&1
|
||||||
|
|
||||||
|
checkresult
|
||||||
2
tests/pdfattach/pdfattach.txt
Normal file
2
tests/pdfattach/pdfattach.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
1 results
|
||||||
|
application/pdf [file:///home/dockes/projets/fulltext/testrecoll/pdfattach/Turnierausschreibung.pdf] [Rezept] 57269 bytes
|
||||||
Loading…
x
Reference in New Issue
Block a user