all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Tramp: creating new files with 0644 permissions rather than 0664?
@ 2016-06-08  9:28 egarrulo
  2016-06-08  9:32 ` egarrulo
  2016-06-08 15:20 ` Barry Margolin
  0 siblings, 2 replies; 10+ messages in thread
From: egarrulo @ 2016-06-08  9:28 UTC (permalink / raw)
  To: help-gnu-emacs

When I create a file with C-x C-f (ido-find-file) in Tramp, Tramp 
creates the file with 0664 permissions instead of 0644 permissions.

Here is the relevant configuration:

(setq tramp-default-user "myuser")
(require 'tramp)

How can I make Tramp create new files with 0644 permissions?  Thanks.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Tramp: creating new files with 0644 permissions rather than 0664?
  2016-06-08  9:28 Tramp: creating new files with 0644 permissions rather than 0664? egarrulo
@ 2016-06-08  9:32 ` egarrulo
  2016-06-08 15:20 ` Barry Margolin
  1 sibling, 0 replies; 10+ messages in thread
From: egarrulo @ 2016-06-08  9:32 UTC (permalink / raw)
  To: help-gnu-emacs

Sorry, but maybe the relevant command is C-x C-s (save-buffer) and not 
C-x C-f (ido-find-file).

On 08/06/16 11:28, egarrulo wrote:
> When I create a file with C-x C-f (ido-find-file) in Tramp, Tramp
> creates the file with 0664 permissions instead of 0644 permissions.
>
> Here is the relevant configuration:
>
> (setq tramp-default-user "myuser")
> (require 'tramp)
>
> How can I make Tramp create new files with 0644 permissions?  Thanks.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Tramp: creating new files with 0644 permissions rather than 0664?
  2016-06-08  9:28 Tramp: creating new files with 0644 permissions rather than 0664? egarrulo
  2016-06-08  9:32 ` egarrulo
@ 2016-06-08 15:20 ` Barry Margolin
  2016-06-08 19:37   ` Tramp: changing umask? egarrulo
  1 sibling, 1 reply; 10+ messages in thread
From: Barry Margolin @ 2016-06-08 15:20 UTC (permalink / raw)
  To: help-gnu-emacs

In article <drq6pqFb3dsU1@mid.individual.net>,
 egarrulo <egarrulo@gmail.com> wrote:

> When I create a file with C-x C-f (ido-find-file) in Tramp, Tramp 
> creates the file with 0664 permissions instead of 0644 permissions.
> 
> Here is the relevant configuration:
> 
> (setq tramp-default-user "myuser")
> (require 'tramp)
> 
> How can I make Tramp create new files with 0644 permissions?  Thanks.

It sounds like the target user's umask is different from your umask.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Tramp: changing umask?
  2016-06-08 15:20 ` Barry Margolin
@ 2016-06-08 19:37   ` egarrulo
  2016-06-08 20:33     ` Barry Margolin
  2016-06-08 21:55     ` egarrulo
  0 siblings, 2 replies; 10+ messages in thread
From: egarrulo @ 2016-06-08 19:37 UTC (permalink / raw)
  To: help-gnu-emacs

On 08/06/16 17:20, Barry Margolin wrote:
> In article <drq6pqFb3dsU1@mid.individual.net>,
>   egarrulo <egarrulo@gmail.com> wrote:
>
>> When I create a file with C-x C-f (ido-find-file) in Tramp, Tramp
>> creates the file with 0664 permissions instead of 0644 permissions.
>>
>> Here is the relevant configuration:
>>
>> (setq tramp-default-user "myuser")
>> (require 'tramp)
>>
>> How can I make Tramp create new files with 0644 permissions?  Thanks.
>
> It sounds like the target user's umask is different from your umask.

Thanks for your suggestion.  Indeed the user's umask is 0002, which explains
the 0664 permissions.  Can I change the umask from Tramp before
creating/saving files?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Tramp: changing umask?
  2016-06-08 19:37   ` Tramp: changing umask? egarrulo
@ 2016-06-08 20:33     ` Barry Margolin
  2016-06-08 21:55     ` egarrulo
  1 sibling, 0 replies; 10+ messages in thread
From: Barry Margolin @ 2016-06-08 20:33 UTC (permalink / raw)
  To: help-gnu-emacs

In article <drrag5Fi9grU1@mid.individual.net>,
 egarrulo <egarrulo@gmail.com> wrote:

> On 08/06/16 17:20, Barry Margolin wrote:
> > In article <drq6pqFb3dsU1@mid.individual.net>,
> >   egarrulo <egarrulo@gmail.com> wrote:
> >
> >> When I create a file with C-x C-f (ido-find-file) in Tramp, Tramp
> >> creates the file with 0664 permissions instead of 0644 permissions.
> >>
> >> Here is the relevant configuration:
> >>
> >> (setq tramp-default-user "myuser")
> >> (require 'tramp)
> >>
> >> How can I make Tramp create new files with 0644 permissions?  Thanks.
> >
> > It sounds like the target user's umask is different from your umask.
> 
> Thanks for your suggestion.  Indeed the user's umask is 0002, which explains
> the 0664 permissions.  Can I change the umask from Tramp before
> creating/saving files?

You can use tramp-remote-process-environment to set environment 
variables for the remote shell. 

(add-to-list 'tramp-remote-process-environment "TRAMP_UMASK=022")

The .profile can look for an environment variable that's set there, and 
set umask appropriately.

if [ "$TRAMP_UMASK" ]
then umask "$TRAMP_UMASK"
else umask 002
fi

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Tramp: changing umask?
  2016-06-08 19:37   ` Tramp: changing umask? egarrulo
  2016-06-08 20:33     ` Barry Margolin
@ 2016-06-08 21:55     ` egarrulo
  2016-06-08 22:21       ` Nick Dokos
       [not found]       ` <mailman.1173.1465424514.1216.help-gnu-emacs@gnu.org>
  1 sibling, 2 replies; 10+ messages in thread
From: egarrulo @ 2016-06-08 21:55 UTC (permalink / raw)
  To: help-gnu-emacs

On 08/06/16 21:37, egarrulo wrote:
> On 08/06/16 17:20, Barry Margolin wrote:
>> In article <drq6pqFb3dsU1@mid.individual.net>,
>>   egarrulo <egarrulo@gmail.com> wrote:
>>
>>> When I create a file with C-x C-f (ido-find-file) in Tramp, Tramp
>>> creates the file with 0664 permissions instead of 0644 permissions.
>>>
>>> Here is the relevant configuration:
>>>
>>> (setq tramp-default-user "myuser")
>>> (require 'tramp)
>>>
>>> How can I make Tramp create new files with 0644 permissions?  Thanks.
>>
>> It sounds like the target user's umask is different from your umask.
>
> Thanks for your suggestion.  Indeed the user's umask is 0002, which
> explains
> the 0664 permissions.  Can I change the umask from Tramp before
> creating/saving files?

I have tried to connect with SSH, running the command:

umask 0022

then disconnecting and connecting again, but umask was 0002 again.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Tramp: changing umask?
  2016-06-08 21:55     ` egarrulo
@ 2016-06-08 22:21       ` Nick Dokos
       [not found]       ` <mailman.1173.1465424514.1216.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 10+ messages in thread
From: Nick Dokos @ 2016-06-08 22:21 UTC (permalink / raw)
  To: help-gnu-emacs

egarrulo <egarrulo@gmail.com> writes:

> On 08/06/16 21:37, egarrulo wrote:
>> On 08/06/16 17:20, Barry Margolin wrote:
>>> In article <drq6pqFb3dsU1@mid.individual.net>,
>>>   egarrulo <egarrulo@gmail.com> wrote:
>>>
>>>> When I create a file with C-x C-f (ido-find-file) in Tramp, Tramp
>>>> creates the file with 0664 permissions instead of 0644 permissions.
>>>>
>>>> Here is the relevant configuration:
>>>>
>>>> (setq tramp-default-user "myuser")
>>>> (require 'tramp)
>>>>
>>>> How can I make Tramp create new files with 0644 permissions?  Thanks.
>>>
>>> It sounds like the target user's umask is different from your umask.
>>
>> Thanks for your suggestion.  Indeed the user's umask is 0002, which
>> explains
>> the 0664 permissions.  Can I change the umask from Tramp before
>> creating/saving files?
>
> I have tried to connect with SSH, running the command:
>
> umask 0022
>
> then disconnecting and connecting again, but umask was 0002 again.

That's correct: umask is set for a shell session through an init file
(.bash_profile, /etc/profile or similar) and it persists only for that
session. I don't know if there is a tramp way of doing it, but you
can certainly do what you want by adding

umask 022

to the shell initialization file of the user on the remote host.

--
Nick




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Tramp: changing umask?
       [not found]       ` <mailman.1173.1465424514.1216.help-gnu-emacs@gnu.org>
@ 2016-06-08 22:44         ` egarrulo
  2016-06-09  6:43           ` Michael Albinus
       [not found]           ` <mailman.1187.1465454639.1216.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 10+ messages in thread
From: egarrulo @ 2016-06-08 22:44 UTC (permalink / raw)
  To: help-gnu-emacs

On 09/06/16 00:21, Nick Dokos wrote:
> egarrulo <egarrulo@gmail.com> writes:
>
>> On 08/06/16 21:37, egarrulo wrote:
>>> On 08/06/16 17:20, Barry Margolin wrote:
>>>> In article <drq6pqFb3dsU1@mid.individual.net>,
>>>> egarrulo <egarrulo@gmail.com> wrote:
>>>>
>>>>> When I create a file with C-x C-f (ido-find-file) in Tramp, Tramp
>>>>> creates the file with 0664 permissions instead of 0644 permissions.
>>>>>
>>>>> Here is the relevant configuration:
>>>>>
>>>>> (setq tramp-default-user "myuser")
>>>>> (require 'tramp)
>>>>>
>>>>> How can I make Tramp create new files with 0644 permissions? Thanks.
>>>>
>>>> It sounds like the target user's umask is different from your umask.
>>>
>>> Thanks for your suggestion. Indeed the user's umask is 0002, which
>>> explains
>>> the 0664 permissions. Can I change the umask from Tramp before
>>> creating/saving files?
>>
>> I have tried to connect with SSH, running the command:
>>
>> umask 0022
>>
>> then disconnecting and connecting again, but umask was 0002 again.
>
> That's correct: umask is set for a shell session through an init file
> (.bash_profile, /etc/profile or similar) and it persists only for that
> session. I don't know if there is a tramp way of doing it, but you
> can certainly do what you want by adding
>
> umask 022
>
> to the shell initialization file of the user on the remote host.

I have tried doing so, but it hasn't worked. I am working with a remote
web host and I don't know much about the environment.

I have found that I can run "chmod 0644" on files, therefore
if there were a way to run this command after saving a file via Tramp,
that would could be a way to solve the problem, I think.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Tramp: changing umask?
  2016-06-08 22:44         ` egarrulo
@ 2016-06-09  6:43           ` Michael Albinus
       [not found]           ` <mailman.1187.1465454639.1216.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 10+ messages in thread
From: Michael Albinus @ 2016-06-09  6:43 UTC (permalink / raw)
  To: egarrulo; +Cc: help-gnu-emacs

egarrulo <egarrulo@gmail.com> writes:

> I have found that I can run "chmod 0644" on files, therefore
> if there were a way to run this command after saving a file via Tramp,
> that would could be a way to solve the problem, I think.

There is `tramp-handle-write-region-hook'. Here you can add any function
you want to be executed after writing a file remotely. Like this:

(add-hook 'tramp-handle-write-region-hook
          (lambda () (set-file-modes (buffer-file-name) #o644)))

Best regards, Michael.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Tramp: changing umask?
       [not found]           ` <mailman.1187.1465454639.1216.help-gnu-emacs@gnu.org>
@ 2016-06-09  8:47             ` egarrulo
  0 siblings, 0 replies; 10+ messages in thread
From: egarrulo @ 2016-06-09  8:47 UTC (permalink / raw)
  To: help-gnu-emacs

On 09/06/16 08:43, Michael Albinus wrote:
> egarrulo <egarrulo@gmail.com> writes:
>
>> I have found that I can run "chmod 0644" on files, therefore
>> if there were a way to run this command after saving a file via Tramp,
>> that would could be a way to solve the problem, I think.
>
> There is `tramp-handle-write-region-hook'. Here you can add any function
> you want to be executed after writing a file remotely. Like this:
>
> (add-hook 'tramp-handle-write-region-hook
>            (lambda () (set-file-modes (buffer-file-name) #o644)))

This fix worked.  Thanks.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-06-09  8:47 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-08  9:28 Tramp: creating new files with 0644 permissions rather than 0664? egarrulo
2016-06-08  9:32 ` egarrulo
2016-06-08 15:20 ` Barry Margolin
2016-06-08 19:37   ` Tramp: changing umask? egarrulo
2016-06-08 20:33     ` Barry Margolin
2016-06-08 21:55     ` egarrulo
2016-06-08 22:21       ` Nick Dokos
     [not found]       ` <mailman.1173.1465424514.1216.help-gnu-emacs@gnu.org>
2016-06-08 22:44         ` egarrulo
2016-06-09  6:43           ` Michael Albinus
     [not found]           ` <mailman.1187.1465454639.1216.help-gnu-emacs@gnu.org>
2016-06-09  8:47             ` egarrulo

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.