<<< Date Index >>>     <<< Thread Index >>>

Re: mutt_adv_mktemp() ?



Hi,

On Wed, Oct 04, 2006 at 07:45:34AM +0000, Rocco Rutte wrote:
>* Pawel S. Veselov [06-10-03 13:46:56 -0700] wrote:
>>why would mutt_adv_mktemp() start creating temp files with '.z' at the end 
>>?
>By default it asks the system to create 'muttXXXXXX' and make it replace 
>'XXXXXX' with some random sequence so that the resulting file doesn't 
>exist yet.
>In your case 'XXXXXX' is replaced by '06a0.z'.

It'a a little bit worse than that, actually. For this process, it's
always '.z'. I still have it running, and it still generates these
filenames:

mutta7aO.z
muttb7aO.z
muttc7aO.z

Hmm, isn't there a pattern.

So, I guess it's just luck of PID 13301...

>>I don't have nametemplate in the
>>mailcap file:
>
>The nametemplate should be used. The only effect is that mutt adds the 
>extension on its own because mktemp() and mkstemp() cannot replace a 
>sequence within a string but only at the end (...which is why we cannot 
>use mkstemp() all over the place).

Er... the extension will not be added, if the "nametemplate" doesn't exist,
It will just use nametemplate. The logic of mutt_adv_mktemp() is interesting
alltogether:

    if (have template) {
        file = TEMP + '/' + template;
        if (!exists(file)) { return file; }
        file = mktemp(TEMP + '/' + (template w/o extension) + '.XXXXXX');
        if (template has extension) {
            file = file + '.' + template_extension
        }
        return file;
    }

Notice there is no check for whether the file exists after extension
has been added.

So if nametemplate is 1.html, and /tmp/1.html exists, and mkfile creates
/tmp/1uadbcr, and /tmp/1uadbcr.html did exist, oops...

Also, I don't like that filename will be well known, since whatever I put
as a template will most likely not exist... Though then I can actually
a file with the same name to force mktemp().... err, enough paranoia..

>It's bad coinsidence that '.z' in the random part can by considered an 
>extension by humans (or machines). I'm not sure, but a wild guess is 
>that elinks thinks by '.z' 'extension' it's a compressed file which 
>isn't true in this case... Using the nametemplate should be fine.

duh, and I couldn't teach w3m that whatever's coming in is not gzipped,
which is fine, I mean, I can get around this, I was just wondering...

>  bye, Rocco
>-- 
>:wq!
ZZ

Bye.
--
 Pawel S. Veselov [vps], Sun Microsystems, Inc.
 Staff Engineer, Java Mobile Systems and Services Engineering __ __(O) _ __
   (408) 276-5410   e-mail: Pawel.Veselov@xxxxxxx             \ V /| || '  \
fax(408) 276-6090 HomePage: http://manticore.2y.net            \_/ |_||_|_|_|