unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* TRAMP and umask (and git)
@ 2021-08-07 18:30 akater
  2021-08-08 15:15 ` Michael Albinus
  0 siblings, 1 reply; 4+ messages in thread
From: akater @ 2021-08-07 18:30 UTC (permalink / raw)
  To: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 977 bytes --]

I work with a git repository via TRAMP (and magit, but that doesn't seem
to be important).  Repository's owner is user x, and x's umask is 022.
All operations on the repository are done via /sudo:x@.../ My umask,
however, is 077.  I can't make Emacs use a umask that would be
appropriate to the context.  It seems to always use a global umask.

I searched the mailing list, found this thread
https://lists.gnu.org/archive/html/help-gnu-emacs/2016-06/msg00214.html
It resolves with the recommendation to use
tramp-handle-write-region-hook.  With git repository, this won't help as
operations are performed by git.  E.g. a rebase messes up everything.

There is another suggestion there that recommends to alter x's .profile
and set umask depending on a value passed via
tramp-remote-process-environment.  I just altered x's .profile to set
umask *unconditionally*, and it has no effect.  So far, the way Tramp
treats umask makes absolutely no sense to me.

What are my options?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 865 bytes --]

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

* Re: TRAMP and umask (and git)
  2021-08-07 18:30 TRAMP and umask (and git) akater
@ 2021-08-08 15:15 ` Michael Albinus
  2021-08-08 16:23   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-09-11 13:56   ` akater
  0 siblings, 2 replies; 4+ messages in thread
From: Michael Albinus @ 2021-08-08 15:15 UTC (permalink / raw)
  To: akater; +Cc: help-gnu-emacs

akater <nuclearspace@gmail.com> writes:

Hi,

> There is another suggestion there that recommends to alter x's .profile
> and set umask depending on a value passed via
> tramp-remote-process-environment.  I just altered x's .profile to set
> umask *unconditionally*, and it has no effect.

sudo requires an additional "-i" argument in order to to run the shell
as login shell, reading ~/.profile. So you must teach the "sudo" entry
in tramp-methods to add this argument, via tramp-login-args.

Furthermore, if x's remote shell is bash or zsh, Tramp tries to avoid
reading ~/.profile. See tramp-sh-extra-args.

Best regards, Michael.



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

* Re: TRAMP and umask (and git)
  2021-08-08 15:15 ` Michael Albinus
@ 2021-08-08 16:23   ` Emanuel Berg via Users list for the GNU Emacs text editor
  2021-09-11 13:56   ` akater
  1 sibling, 0 replies; 4+ messages in thread
From: Emanuel Berg via Users list for the GNU Emacs text editor @ 2021-08-08 16:23 UTC (permalink / raw)
  To: help-gnu-emacs

Michael Albinus wrote:

>> There is another suggestion there that recommends to alter
>> x's .profile and set umask depending on a value passed via
>> tramp-remote-process-environment. I just altered x's
>> .profile to set umask *unconditionally*, and it has
>> no effect.
>
> sudo requires an additional "-i" argument in order to to run
> the shell as login shell, reading ~/.profile. So you must
> teach the "sudo" entry in tramp-methods to add this
> argument, via tramp-login-args.
>
> Furthermore, if x's remote shell is bash or zsh, Tramp tries
> to avoid reading ~/.profile. See tramp-sh-extra-args.

Tramp... zsh... this rings a bell. No, actually the bell rings
clear, it was rather that when we finally got it to work, we
had tried so many things conclusions were... inconclusive
at best.

I don't even remember if it was indeed zsh, or my remote SunOS
and OpenBSD, that caused the trouble. They are trouble spot
OSs, right?

Anyway I yank the file, maybe Mr. Albinus can have a second
look and detect what was going on :) Maybe it can help the OP
as well.

Anyway it works great, thanks again :) "Hooray!"

;;; -*- lexical-binding: t -*-
;;;
;;; this file:
;;;   http://user.it.uu.se/~embe8573/emacs-init/tramp-incal.el
;;;   https://dataswamp.org/~incal/emacs-init/tramp-incal.el

(require 'tramp)

(setq tramp-histfile-override nil)

(add-to-list 'tramp-methods
  '("sunos-ssh"
    (tramp-login-program "ssh")
    (tramp-login-args (("-l" "%u")
                       ("-p" "%p")
                       ("%c")
                       ("-e" "none")
                       ("-t" "-t")
                       ("%h")
                       ("\"/bin/sh -i\"") ))
    (tramp-async-args (("-q")))
    (tramp-remote-shell "/bin/sh")
    (tramp-remote-shell-login ("-l"))
    (tramp-remote-shell-args  ("-c"))
    ))

;; SunOS system:
;; (find-file "/sunos-ssh:embe8573@polhem.it.uu.se:public_html/darn.txt")
;;
;; OpenBSD system:
;; (find-file "/-:incal@srv.dataswamp.org:public_html/bot/sth.py")

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: TRAMP and umask (and git)
  2021-08-08 15:15 ` Michael Albinus
  2021-08-08 16:23   ` Emanuel Berg via Users list for the GNU Emacs text editor
@ 2021-09-11 13:56   ` akater
  1 sibling, 0 replies; 4+ messages in thread
From: akater @ 2021-09-11 13:56 UTC (permalink / raw)
  To: Michael Albinus; +Cc: help-gnu-emacs

Michael Albinus <michael.albinus@gmx.de> writes:

> sudo requires an additional "-i" argument in order to to run the shell
> as login shell, reading ~/.profile. So you must teach the "sudo" entry
> in tramp-methods to add this argument, via tramp-login-args.

I've had it for some time (I wonder why it's not built-in), and tried it
but it didn't work for this particular user.  I ended up used a
workaround but thank you anyway.  At least I now know it's possible to
use different umasks from a single Emacs process.



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

end of thread, other threads:[~2021-09-11 13:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-07 18:30 TRAMP and umask (and git) akater
2021-08-08 15:15 ` Michael Albinus
2021-08-08 16:23   ` Emanuel Berg via Users list for the GNU Emacs text editor
2021-09-11 13:56   ` akater

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).