unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [BUG] inconsistent user context handling w/ tramp 
@ 2013-03-02 11:46 Simon Campese
  2013-03-02 18:50 ` David Bremner
  2013-03-08 13:04 ` [PATCH] emacs: introduce notmuch-command-to-string, replace use of shell-command-to-string david
  0 siblings, 2 replies; 6+ messages in thread
From: Simon Campese @ 2013-03-02 11:46 UTC (permalink / raw)
  To: notmuch

Hello,

after using tramp to open a file using the 'su' or 'sudo' protocol as
user X, the next time I run 'compose-mail' to compose a message it
apparently looks in the home directory of user X for its config file,
mail directory etc. In the compose window, I get the error message

'Error reading configuration file $X_homedir/.notmuch-config: No such
file or directory'

in all header fields (From, Fcc etc.) that should be filled by notmuch
($X_homedir  is the home directory of user X from above).

This happens when using emacs in "standalone" mode or when connecting
to a running instance of emacs with emacsclient. In the latter case, if  
one connects with another emacsclient, everything works properly again. 

However, this all suggests that notmuch should gather the user who is
running emacs in a more robust way. 


Best wishes,

Simon

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

* Re: [BUG] inconsistent user context handling w/ tramp
  2013-03-02 11:46 [BUG] inconsistent user context handling w/ tramp Simon Campese
@ 2013-03-02 18:50 ` David Bremner
  2013-03-08 13:04 ` [PATCH] emacs: introduce notmuch-command-to-string, replace use of shell-command-to-string david
  1 sibling, 0 replies; 6+ messages in thread
From: David Bremner @ 2013-03-02 18:50 UTC (permalink / raw)
  To: Simon Campese, notmuch

Simon Campese <notmuchmail_org@campese.de> writes:

> Hello,
>
> after using tramp to open a file using the 'su' or 'sudo' protocol as
> user X, the next time I run 'compose-mail' to compose a message it
> apparently looks in the home directory of user X for its config file,
> mail directory etc. In the compose window, I get the error message
>
> 'Error reading configuration file $X_homedir/.notmuch-config: No such
> file or directory'
>
> in all header fields (From, Fcc etc.) that should be filled by notmuch
> ($X_homedir  is the home directory of user X from above).
>

I don't think this is specific to notmuch. Notmuch uses the HOME
environment variable to locate it's configuration file, and tramp is
modifying this environment variable. 

To verify this:

Start emacs with "emacs -Q"
open a file use /su:user_@localhost:filename
run M-! (or M-x shell-command) echo $HOME

you will see that the variable is changed to the home directory of
user_x.

If you think this behaviour of tramp is wrong (I didn't think through
all the implications), then you could file an emacs bug.

Do you see this behaviour when running compose-mail from a buffer that
is not a tramp buffer?

All that said, the patches of 

     mid:2f89028f7986f67792478f1728ca1f1fdd382d3c.1359495450.git.jani@nikula.org

could be used to work around this "feature" of tramp.  In fact since
they were stalled a bit waiting for a convincing use case, maybe your
report will help get them into notmuch more quickly.

Someone would still have to modify the emacs client side code, but at
least conceptually I don't think that would be difficult.

d

PS: all my tests where with Emacs 24.2.1

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

* [PATCH] emacs: introduce notmuch-command-to-string, replace use of shell-command-to-string
  2013-03-02 11:46 [BUG] inconsistent user context handling w/ tramp Simon Campese
  2013-03-02 18:50 ` David Bremner
@ 2013-03-08 13:04 ` david
  2013-03-29 15:14   ` David Bremner
  2013-04-01 13:33   ` David Bremner
  1 sibling, 2 replies; 6+ messages in thread
From: david @ 2013-03-08 13:04 UTC (permalink / raw)
  To: notmuch; +Cc: David Bremner, Simon Campese

From: David Bremner <bremner@debian.org>

This has two benefits: unified error handling, and avoiding tramp's
hooking into shell-command-string.

This seems to be a fix for id:874nguxbvq.fsf@tu-dortmund.de
---

Simon: can you check if this fixes your bug?

 emacs/notmuch-lib.el | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 270e3dc..556b1a4 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -112,13 +112,25 @@ For example, if you wanted to remove an \"inbox\" tag and add an
 		  (select-window (posn-window (event-start last-input-event)))
 		  (button-activate button)))
 
+(defun notmuch-command-to-string (&rest args)
+  "Synchronously invoke \"notmuch\" with the given list of arguments.
+
+If notmuch exits with a non-zero status, output from the process
+will appear in a buffer named \"*Notmuch errors*\" and an error
+will be signaled.
+
+Otherwise the output will be returned"
+  (with-temp-buffer
+    (let* ((status (apply #'call-process notmuch-command nil t nil args))
+	   (output (buffer-string)))
+      (notmuch-check-exit-status status (cons notmuch-command args) output)
+      output)))
+
 (defun notmuch-version ()
   "Return a string with the notmuch version number."
   (let ((long-string
 	 ;; Trim off the trailing newline.
-	 (substring (shell-command-to-string
-		     (concat notmuch-command " --version"))
-		    0 -1)))
+	 (substring (notmuch-command-to-string "--version") 0 -1))
     (if (string-match "^notmuch\\( version\\)? \\(.*\\)$"
 		      long-string)
 	(match-string 2 long-string)
@@ -127,9 +139,7 @@ For example, if you wanted to remove an \"inbox\" tag and add an
 (defun notmuch-config-get (item)
   "Return a value from the notmuch configuration."
   ;; Trim off the trailing newline
-  (substring (shell-command-to-string
-	      (concat notmuch-command " config get " item))
-	      0 -1))
+  (substring (notmuch-command-to-string "config" "get" item) 0 -1))
 
 (defun notmuch-database-path ()
   "Return the database.path value from the notmuch configuration."
-- 
1.8.2.rc1

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

* Re: [PATCH] emacs: introduce notmuch-command-to-string, replace use of shell-command-to-string
  2013-03-08 13:04 ` [PATCH] emacs: introduce notmuch-command-to-string, replace use of shell-command-to-string david
@ 2013-03-29 15:14   ` David Bremner
  2013-03-29 15:54     ` Tomi Ollila
  2013-04-01 13:33   ` David Bremner
  1 sibling, 1 reply; 6+ messages in thread
From: David Bremner @ 2013-03-29 15:14 UTC (permalink / raw)
  To: notmuch; +Cc: Simon Campese

david@tethera.net writes:

> From: David Bremner <bremner@debian.org>
>
> This has two benefits: unified error handling, and avoiding tramp's
> hooking into shell-command-string.
>
> This seems to be a fix for id:874nguxbvq.fsf@tu-dortmund.de
> ---
>
> Simon: can you check if this fixes your bug?

Anyone willing to sanity check my e-lisp?

d

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

* Re: [PATCH] emacs: introduce notmuch-command-to-string, replace use of shell-command-to-string
  2013-03-29 15:14   ` David Bremner
@ 2013-03-29 15:54     ` Tomi Ollila
  0 siblings, 0 replies; 6+ messages in thread
From: Tomi Ollila @ 2013-03-29 15:54 UTC (permalink / raw)
  To: David Bremner, notmuch

On Fri, Mar 29 2013, David Bremner <david@tethera.net> wrote:

> david@tethera.net writes:
>
>> From: David Bremner <bremner@debian.org>
>>
>> This has two benefits: unified error handling, and avoiding tramp's
>> hooking into shell-command-string.
>>
>> This seems to be a fix for id:874nguxbvq.fsf@tu-dortmund.de
>> ---
>>
>> Simon: can you check if this fixes your bug?
>
> Anyone willing to sanity check my e-lisp?

LGTM. The implementation is quite much the same as in 
notmuch-call-notmuch-process, just that this function returns
the output as a string.

> d

Tomi

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

* Re: [PATCH] emacs: introduce notmuch-command-to-string, replace use of shell-command-to-string
  2013-03-08 13:04 ` [PATCH] emacs: introduce notmuch-command-to-string, replace use of shell-command-to-string david
  2013-03-29 15:14   ` David Bremner
@ 2013-04-01 13:33   ` David Bremner
  1 sibling, 0 replies; 6+ messages in thread
From: David Bremner @ 2013-04-01 13:33 UTC (permalink / raw)
  To: notmuch; +Cc: Simon Campese

david@tethera.net writes:

> From: David Bremner <bremner@debian.org>
>
> This has two benefits: unified error handling, and avoiding tramp's
> hooking into shell-command-string.
>
> This seems to be a fix for id:874nguxbvq.fsf@tu-dortmund.de
> ---
>
> Simon: can you check if this fixes your bug?

I have pushed this to master, after adding a mysteriously missing
close-parenthesis.

d

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

end of thread, other threads:[~2013-04-01 13:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-02 11:46 [BUG] inconsistent user context handling w/ tramp Simon Campese
2013-03-02 18:50 ` David Bremner
2013-03-08 13:04 ` [PATCH] emacs: introduce notmuch-command-to-string, replace use of shell-command-to-string david
2013-03-29 15:14   ` David Bremner
2013-03-29 15:54     ` Tomi Ollila
2013-04-01 13:33   ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

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).