Re: mutt deletes attachement before libreoffice tries to open it

2012-06-22 Thread Luis Mochan
On Fri, Jun 22, 2012 at 11:27:23AM -0700, Gary Johnson wrote:
> On 2012-06-22, Luis Mochan wrote:
> > > But that would defeat the purpose of the copy which is to have a
> > > stable file for LibreOffice to read while allowing mutt to wipe and
> > > delete its temporary file.  A hard link would work if it wasn't that
> > > mutt wipes the file before unlinking it.
> > > 
> > 
> > I guess not. If I understand correctly, the file will remain alive
> > while its link count of the file is possitive. Even if mutt deletes
> > (it's link), the other link (and the file) will survive. 
> 
> Yes, but mutt overwrites the contents of the file with zeros first
> (what I meant by wiping), leaving the other link pointing to a file
> full of zeros, and leaving LibreOffice with nothing useful to read.
> 
Got it. Anyway, what is the rationale for wiping the file contents? 
Security?   
Regards,
Luis 

-- 

  o
W. Luis Mochán,  | tel:(52)(777)329-1734 /<(*)
Instituto de Ciencias Físicas, UNAM  | fax:(52)(777)317-5388 `>/   /\
Apdo. Postal 48-3, 62251 |   (*)/\/  \
Cuernavaca, Morelos, México  | moc...@fis.unam.mx   /\_/\__/

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org 




Re: mutt deletes attachement before libreoffice tries to open it

2012-06-22 Thread Gary Johnson
On 2012-06-22, David Champion wrote:
> * On 22 Jun 2012, Gary Johnson wrote: 
> > 
> > But that would defeat the purpose of the copy which is to have a
> > stable file for LibreOffice to read while allowing mutt to wipe and
> > delete its temporary file.  A hard link would work if it wasn't that
> > mutt wipes the file before unlinking it.
> 
> The last time I worried about this, mutt didn't zero out temporary files
> before unlinking them.  If it does that now then hard links are not a
> solution.

The last time I looked at this was a few years ago, so mutt's
behavior could well have changed in the mean time.  I just assumed
it still did that.  It seemed like an unusual, deliberate design
decision that was not likely to change.

Regards,
Gary



Re: mutt deletes attachement before libreoffice tries to open it

2012-06-22 Thread David Champion
* On 22 Jun 2012, Gary Johnson wrote: 
> 
> But that would defeat the purpose of the copy which is to have a
> stable file for LibreOffice to read while allowing mutt to wipe and
> delete its temporary file.  A hard link would work if it wasn't that
> mutt wipes the file before unlinking it.

The last time I worried about this, mutt didn't zero out temporary files
before unlinking them.  If it does that now then hard links are not a
solution.

If only every OS had a modern filesystem with copy on write available at
the file level to unprivileged users.  Maybe a COW shim (FUSE?) using
sparse backing store of rewritten blocks over an arbitrary backend
fs

-- 
David Champion • d...@uchicago.edu • IT Services • University of Chicago


Re: mutt deletes attachement before libreoffice tries to open it

2012-06-22 Thread Gary Johnson
On 2012-06-22, Luis Mochan wrote:
> > But that would defeat the purpose of the copy which is to have a
> > stable file for LibreOffice to read while allowing mutt to wipe and
> > delete its temporary file.  A hard link would work if it wasn't that
> > mutt wipes the file before unlinking it.
> > 
> 
> I guess not. If I understand correctly, the file will remain alive
> while its link count of the file is possitive. Even if mutt deletes
> (it's link), the other link (and the file) will survive. 

Yes, but mutt overwrites the contents of the file with zeros first
(what I meant by wiping), leaving the other link pointing to a file
full of zeros, and leaving LibreOffice with nothing useful to read.

Regards,
Gary



Re: mutt deletes attachement before libreoffice tries to open it

2012-06-22 Thread Luis Mochan
> But that would defeat the purpose of the copy which is to have a
> stable file for LibreOffice to read while allowing mutt to wipe and
> delete its temporary file.  A hard link would work if it wasn't that
> mutt wipes the file before unlinking it.
> 

I guess not. If I understand correctly, the file will remain alive
while its link count of the file is possitive. Even if mutt deletes
(it's link), the other link (and the file) will survive. 

Regards,
Luis


Re: mutt deletes attachement before libreoffice tries to open it

2012-06-22 Thread Luis Mochan
David,
Thanks for the suggestion!
Luis


On Fri, Jun 22, 2012 at 12:50:02PM -0500, David Champion wrote:
> * On 22 Jun 2012, Luis Mochan wrote: 
> > I guess a solution used for browsing html attachments (discussed
> > here some time ago; see attached perl script) may be adapted for
> > running libreoffice. The main idea would be to make a copy of the
> > file, send it to libreoffice and sleep a short time before returning
> > to mutt,
> 
> I usually recommend hard linking (not symbolic linking!) over copying,
> if possible.
> 
> -- 
> David Champion • d...@uchicago.edu • IT Services • University of Chicago

-- 

  o
W. Luis Mochán,  | tel:(52)(777)329-1734 /<(*)
Instituto de Ciencias Físicas, UNAM  | fax:(52)(777)317-5388 `>/   /\
Apdo. Postal 48-3, 62251 |   (*)/\/  \
Cuernavaca, Morelos, México  | moc...@fis.unam.mx   /\_/\__/

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org 




Re: mutt deletes attachement before libreoffice tries to open it

2012-06-22 Thread Gary Johnson
On 2012-06-22, David Champion wrote:
> * On 22 Jun 2012, Luis Mochan wrote: 
> > I guess a solution used for browsing html attachments (discussed
> > here some time ago; see attached perl script) may be adapted for
> > running libreoffice. The main idea would be to make a copy of the
> > file, send it to libreoffice and sleep a short time before returning
> > to mutt,
> 
> I usually recommend hard linking (not symbolic linking!) over copying,
> if possible.

But that would defeat the purpose of the copy which is to have a
stable file for LibreOffice to read while allowing mutt to wipe and
delete its temporary file.  A hard link would work if it wasn't that
mutt wipes the file before unlinking it.

Regards,
Gary



Re: mutt deletes attachement before libreoffice tries to open it

2012-06-22 Thread David Champion
* On 22 Jun 2012, Luis Mochan wrote: 
> I guess a solution used for browsing html attachments (discussed
> here some time ago; see attached perl script) may be adapted for
> running libreoffice. The main idea would be to make a copy of the
> file, send it to libreoffice and sleep a short time before returning
> to mutt,

I usually recommend hard linking (not symbolic linking!) over copying,
if possible.

-- 
David Champion • d...@uchicago.edu • IT Services • University of Chicago


Re: mutt deletes attachement before libreoffice tries to open it

2012-06-22 Thread Luis Mochan
Thanks Chris! You're right (it was a fast translation from Spanish).
Regards,
Luis

On Sat, Jun 23, 2012 at 04:57:04AM +1200, Chris Bannister wrote:
> On Fri, Jun 22, 2012 at 09:38:10AM -0500, Luis Mochan wrote:
> > # DESCRIPTION
> > #   Runs a browser on a copy of a file, and sleeps for a while
> > #   before deleting it. It solves the problem that mutt may delete
> > #   the file too fast.
> 
> IMHO, change "fast" to "soon".  The *speed* of deletion is not the issue
> but *when* it is deleted.
> 
> -- 
> "If you're not careful, the newspapers will have you hating the people
> who are being oppressed, and loving the people who are doing the 
> oppressing." --- Malcolm X

-- 

  o
W. Luis Mochán,  | tel:(52)(777)329-1734 /<(*)
Instituto de Ciencias Físicas, UNAM  | fax:(52)(777)317-5388 `>/   /\
Apdo. Postal 48-3, 62251 |   (*)/\/  \
Cuernavaca, Morelos, México  | moc...@fis.unam.mx   /\_/\__/

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org 




Re: mutt deletes attachement before libreoffice tries to open it

2012-06-22 Thread Chris Bannister
On Fri, Jun 22, 2012 at 09:38:10AM -0500, Luis Mochan wrote:
> # DESCRIPTION
> # Runs a browser on a copy of a file, and sleeps for a while
> #   before deleting it. It solves the problem that mutt may delete
> #   the file too fast.

IMHO, change "fast" to "soon".  The *speed* of deletion is not the issue
but *when* it is deleted.

-- 
"If you're not careful, the newspapers will have you hating the people
who are being oppressed, and loving the people who are doing the 
oppressing." --- Malcolm X


Re: mutt deletes attachement before libreoffice tries to open it

2012-06-22 Thread Luis Mochan
I guess a solution used for browsing html attachments (discussed
here some time ago; see attached perl script) may be adapted for
running libreoffice. The main idea would be to make a copy of the
file, send it to libreoffice and sleep a short time before returning
to mutt,
Regards,
Luis


On Fri, Jun 22, 2012 at 10:52:08AM -0300, Marcelo Laia wrote:
> Hi
> 
> 2012/6/22 steve :
> > Have you found a solution?
> 
> Unfortunately, no!
> 
> 
> -- 
> Marcelo Luiz de Laia

-- 

  o
W. Luis Mochán,  | tel:(52)(777)329-1734 /<(*)
Instituto de Ciencias Físicas, UNAM  | fax:(52)(777)317-5388 `>/   /\
Apdo. Postal 48-3, 62251 |   (*)/\/  \
Cuernavaca, Morelos, México  | moc...@fis.unam.mx   /\_/\__/

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org 


#!/usr/bin/env perl

use warnings;
use strict;

# SYNOPSIS
#   mutt_browse file
#
# DESCRIPTION
#   Runs a browser on a copy of a file, and sleeps for a while
#   before deleting it. It solves the problem that mutt may delete
#   the file too fast.
# EXAMPLE
#   To use a sensible browser to view HTML attachments from mutt, add the
#   following line to the .mailcap file.
#
#   text/html;  /path/to/mutt_browse %s
#
# AUTHOR
#   Luis Mochan 
#   Shamelessly adapted from mutt_netscape by
#   Gary A. Johnson 
# 
# WARNING
#   This program has been tested in a Debian system
#   The temporal file is created in the /tmp directory
#   


# Variables to be customized
#
# template filename for temporal file
my $template="muttX"; 

# Path to desired browser. Under Debian sensible-browser defaults to
# my prefered browser, but an explicit choice such as chrome,
# iceweasel, etc. may be used here.
my $browser="/usr/bin/sensible-browser"; 

# Delay to give time for browser to read file before it is destroyed
my $delay=3; #in seconds
#
# End of customizations


use File::Temp qw(tempfile);

die <<"EOF" unless @ARGV==1;
Usage $0 file
  to run a sensible-browser over copy of file
EOF
die "Can't read $ARGV[0]" unless -r $ARGV[0];
my ($fh, $fname) = tempfile($template, DIR=>"/tmp", SUFFIX=>".html", 
UNLINK=>1);
open IN, "<", $ARGV[0];
while(){
print $fh $_;
}
close $fh;
system $browser, $fname;
sleep $delay; 


Re: mutt deletes attachement before libreoffice tries to open it

2012-06-22 Thread Marcelo Laia
Hi

2012/6/22 steve :
> Have you found a solution?

Unfortunately, no!


-- 
Marcelo Luiz de Laia


Re: mutt deletes attachement before libreoffice tries to open it

2012-06-22 Thread steve
Hi,


Le 26-04-2012, à 08:07:42 -0300, Marcelo Luiz de Laia (marcelol...@gmail.com) a 
écrit :

> On Thu, 26 Apr 2012, Jostein Berntsen wrote:
> 
> > It seems like most of your entries are bound to openoffice(soffice) instead
> > of libreoffice. Try to change all entries to libreoffice instead.
> > 
> > Jostein
> > 
> 
> Thank you very much, but, it dosen't solve that problem.
> 
> If libreoffice is alread running, I coundn't open the attachment.

I fell on your post while searching the web for a solution to the exact same 
issue than yours.
This problem arises only when trying to open a document with libreoffice while 
libreoffice is already opened.

Have you found a solution?

I'm running mutt 1.5.21 on Debian wheezy.

Thank you.

Best regards,
Steve



Re: mutt deletes attachement before libreoffice tries to open it

2012-04-26 Thread Jostein Berntsen
On 26.04.12,08:07, Marcelo Luiz de Laia wrote:
> On Thu, 26 Apr 2012, Jostein Berntsen wrote:
> 
> > It seems like most of your entries are bound to openoffice(soffice) instead
> > of libreoffice. Try to change all entries to libreoffice instead.
> > 
> > Jostein
> > 
> 
> Thank you very much, but, it dosen't solve that problem.
> 
> If libreoffice is alread running, I coundn't open the attachment.
> 

Could you try use mutt_bgrun with you mailcap entries?

Enter this script into your path:

https://github.com/jgm/scripts/blob/master/mutt_bgrun

and entries like these in your mailcap file:

application/msword; mutt_bgrun libreoffice3.5 %s; 
#test=RunningXapplication/vnd.msword; mutt_bgrun libreoffice3.5 %s; 
#test=RunningX
application/vnd.openxmlformats-officedocument.wordprocessingml.document; 
mutt_bgrun libreoffice3.5 %s; #test=RunningX
application/excel;  mutt_bgrun libreoffice3.5 %s; #test=Running
application/msexcel;mutt_bgrun libreoffice3.5 %s; #test=RunningX
application/excel;  mutt_bgrun libreoffice3.5 %s; #test=RunningX
application/msexcel;mutt_bgrun libreoffice3.5 %s; #test=Running
application/vnd.ms-excel;   mutt_bgrun libreoffice3.5 %s; #test=Running
application/vnd.ms-excel;   mutt_bgrun libreoffice3.5 %s; #test=RunningX
application/x-excel;mutt_bgrun libreoffice3.5 %s; #test=RunningX
application/x-excel;mutt_bgrun libreoffice3.5 %s; #test=RunningX
application/x-msexcel;  mutt_bgrun libreoffice3.5 %s; #test=RunningX
application/ms-Excel;   mutt_bgrun libreoffice3.5 %s; #test=RunningX
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;  
mutt_bgrun libreoffice3.5 %s; #test=RunningX
application/vnd.openxmlformats; mutt_bgrun libreoffice3.5 %s; 
application/vnd.ms-powerpoint;  mutt_bgrun libreoffice3.5 %s; #test=RunningX
application/x-mspowerpoint; mutt_bgrun libreoffice3.5 %s; #test=RunningX
application/ppt;mutt_bgrun libreoffice3.5 %s; #test=RunningX
application/pdf; mutt_bgrun okular %s; #test=RunningX
application/postscript; mutt_bgrun ghostview %s; #test=RunningX
application/rtf;mutt_bgrun libreoffice3.5 %s; #test=RunningX
image/*;mutt_bgrun okular %s;# test=RunningX
image/*;mutt_bgrun gwenview %s;#test=RunnningX  


Jostein



Re: mutt deletes attachement before libreoffice tries to open it

2012-04-26 Thread Marcelo Luiz de Laia
On Thu, 26 Apr 2012, Jostein Berntsen wrote:

> It seems like most of your entries are bound to openoffice(soffice) instead
> of libreoffice. Try to change all entries to libreoffice instead.
> 
> Jostein
> 

Thank you very much, but, it dosen't solve that problem.

If libreoffice is alread running, I coundn't open the attachment.

-- 
  O___   - Marcelo Luiz de Laia
 c/  /'_ - Diamantina
(*)  \(*)- Minas Gerais
~- Brazil
^- Linux user number 487797


Re: mutt deletes attachement before libreoffice tries to open it

2012-04-26 Thread Jostein Berntsen
On 26.04.12,06:17, Marcelo Luiz de Laia wrote:
> On Thu, 26 Apr 2012, Jostein Berntsen wrote:
> 
> > On 25.04.12,18:12, Marcelo Luiz de Laia wrote:
> > > On Wed, 25 Apr 2012, David Haguenauer wrote:
> > > 
> > > > > Sometime I got the same problem here. However, I see that I only get
> > > > > this issue when libreoffice is already running!
> > > > 
> > > > I believe this is a different issue. What probably happens in your
> > > > in your case ...
> > > 
> > > > ... if LibreOffice is already running, Mutt's call does
> > > > not start a new instance; rather, the second invocation returns very
> > > > quickly after forwarding the filename to the existing LibreOffice
> > > > instance: there is a race condition between Mutt (that deletes the
> > > > attachment file) and LibreOffice (that tries to open it).
> > > 
> > > 
> > > Yes! You are right! This is a different issue and mutt deletes the
> > > attachment before libreoffice tries to open it.
> > > 
> > > So, I have oppened a new thread.
> > > 
> > 
> > Could you post the output of this command?
> > 
> > egrep "vnd|word" ~/.mailcap
> > 
> > 
> > Jostein
> 
> Please, found it here:
> 
> http://pastebin.com/J0WXpmtz
> 
> My mailcap is into ~/.mutt/mailcap
> 

It seems like most of your entries are bound to openoffice(soffice) instead
of libreoffice. Try to change all entries to libreoffice instead.

Jostein




Re: mutt deletes attachement before libreoffice tries to open it

2012-04-26 Thread Marcelo Luiz de Laia
On Thu, 26 Apr 2012, Jostein Berntsen wrote:

> On 25.04.12,18:12, Marcelo Luiz de Laia wrote:
> > On Wed, 25 Apr 2012, David Haguenauer wrote:
> > 
> > > > Sometime I got the same problem here. However, I see that I only get
> > > > this issue when libreoffice is already running!
> > > 
> > > I believe this is a different issue. What probably happens in your
> > > in your case ...
> > 
> > > ... if LibreOffice is already running, Mutt's call does
> > > not start a new instance; rather, the second invocation returns very
> > > quickly after forwarding the filename to the existing LibreOffice
> > > instance: there is a race condition between Mutt (that deletes the
> > > attachment file) and LibreOffice (that tries to open it).
> > 
> > 
> > Yes! You are right! This is a different issue and mutt deletes the
> > attachment before libreoffice tries to open it.
> > 
> > So, I have oppened a new thread.
> > 
> 
> Could you post the output of this command?
> 
> egrep "vnd|word" ~/.mailcap
> 
> 
> Jostein

Please, found it here:

http://pastebin.com/J0WXpmtz

My mailcap is into ~/.mutt/mailcap

-- 
  O___   - Marcelo Luiz de Laia
 c/  /'_ - Diamantina
(*)  \(*)- Minas Gerais
~- Brazil
^- Linux user number 487797


Re: mutt deletes attachement before libreoffice tries to open it

2012-04-26 Thread Jostein Berntsen
On 25.04.12,18:12, Marcelo Luiz de Laia wrote:
> On Wed, 25 Apr 2012, David Haguenauer wrote:
> 
> > > Sometime I got the same problem here. However, I see that I only get
> > > this issue when libreoffice is already running!
> > 
> > I believe this is a different issue. What probably happens in your
> > in your case ...
> 
> > ... if LibreOffice is already running, Mutt's call does
> > not start a new instance; rather, the second invocation returns very
> > quickly after forwarding the filename to the existing LibreOffice
> > instance: there is a race condition between Mutt (that deletes the
> > attachment file) and LibreOffice (that tries to open it).
> 
> 
> Yes! You are right! This is a different issue and mutt deletes the
> attachment before libreoffice tries to open it.
> 
> So, I have oppened a new thread.
> 

Could you post the output of this command?

egrep "vnd|word" ~/.mailcap


Jostein


mutt deletes attachement before libreoffice tries to open it

2012-04-25 Thread Marcelo Luiz de Laia
On Wed, 25 Apr 2012, David Haguenauer wrote:

> > Sometime I got the same problem here. However, I see that I only get
> > this issue when libreoffice is already running!
> 
> I believe this is a different issue. What probably happens in your
> in your case ...

> ... if LibreOffice is already running, Mutt's call does
> not start a new instance; rather, the second invocation returns very
> quickly after forwarding the filename to the existing LibreOffice
> instance: there is a race condition between Mutt (that deletes the
> attachment file) and LibreOffice (that tries to open it).


Yes! You are right! This is a different issue and mutt deletes the
attachment before libreoffice tries to open it.

So, I have oppened a new thread.

-- 
  O___   - Marcelo Luiz de Laia
 c/  /'_ - Diamantina
(*)  \(*)- Minas Gerais
~- Brazil
^- Linux user number 487797