Subject: bug#3712: 23.1.50; SECURITY: Tramp creates -rwxrwxrwx permission files with /su and /sudo method

From: Teemu Likonen <[email-masked]>
Date: Tue, 30 Jun 2009 16:57:26 +0300

On 2009-06-30 14:21 (+0200), Michael Albinus wrote:

> When creating a new file, Tramp uses Emacs' default file modes. You
> can check them with "M-: (default-file-modes)".
>
> If you want to change them, you could apply for example "M-:
> (set-default-file-modes #o0400)". The value is used then for all newly
> created files, also for local ones.

Hmm, I didn't know about those functions, thanks. And I compiled my
Emacs with your recent changes too.

I still don't like the default difference between creating a file as a
normal user or through /su: or /sudo:. Here's again an example starting
from command

    umask 0022; emacs -Q

When I create a file without Tramp (C-x C-f ~/test.txt RET) to my home
directory it gets bits 0644. When I create a file through Tramp to
/sudo::/root/test.txt it gets bits 0755 (i.e. with executable bits). In
both cases Emacs's default-file-modes is the same, the untouched default
which is #o755. In fact, all the settings are the same.

I'm not sure where this difference should be fixed but from user's point
of view the Tramp part brings the unexpected end result. It's unexpected
because no other programs create new executable files by default, even
when umask doesn't mask executable bits.

I appreciate your hint about set-default-file-modes, and I'll use it if
necessary, but in my opinion user shouldn't need to run

    (set-default-file-modes #o0644)

in her ~/.emacs just because she wants Tramp to behave similarly to her
umask=0022 settings. Instead, the similar behavior should be the
default.

>> And when editing existing files it should obviously respect the bits
>> that the file already has. Currently -- even with this fix -- tramp
>> is adding "x" bits at some point because "backup by rename" moves old
>> version out of the way and new is created with -rwxr-xr-x bits.
>
> As I said already, I cannot reproduce it. However, there seems to be a
> small annoyance in special cases. I've fixed this. Could you, please,
> check, whether it is OK now for you?

I could reproduce it before but it seems that not anymore with your
newest changes. If you want clear steps how to reproduce it I can
inspect the issue more closely.

Anyway, thanks for your work on Tramp and Emacs! :-)