unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Emacs on Windows keeps complaining: the directory ... is unsafe.
@ 2009-05-25 16:11 Óscar Fuentes
  2009-05-25 17:06 ` Juanma Barranquero
  2009-05-25 21:34 ` Eli Zaretskii
  0 siblings, 2 replies; 15+ messages in thread
From: Óscar Fuentes @ 2009-05-25 16:11 UTC (permalink / raw)
  To: emacs-devel

Yesterday I refreshed my build of Emacs CVS on a Windows machine after
some months and it keeps complaining:

error: The directory d:/home/.emacs.d/server is unsafe

when calling server-start. I see no references to this problem on News
or Known Problems.

Is there a cure for this? What I did until now is remove the check on
server.el, but this is hardly acceptable for the common user.

-- 
Óscar





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

* Re: Emacs on Windows keeps complaining: the directory ... is unsafe.
  2009-05-25 16:11 Emacs on Windows keeps complaining: the directory ... is unsafe Óscar Fuentes
@ 2009-05-25 17:06 ` Juanma Barranquero
  2009-05-25 21:34 ` Eli Zaretskii
  1 sibling, 0 replies; 15+ messages in thread
From: Juanma Barranquero @ 2009-05-25 17:06 UTC (permalink / raw)
  To: Óscar Fuentes; +Cc: emacs-devel

On Mon, May 25, 2009 at 18:11, Óscar Fuentes <ofv@wanadoo.es> wrote:

> Is there a cure for this? What I did until now is remove the check on
> server.el, but this is hardly acceptable for the common user.

I don't see that problem. Please try to debug `server-ensure-safe-dir'
to determine why is the server/ directory considered unsafe in your
setup.

    Juanma




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

* Re: Emacs on Windows keeps complaining: the directory ... is unsafe.
  2009-05-25 16:11 Emacs on Windows keeps complaining: the directory ... is unsafe Óscar Fuentes
  2009-05-25 17:06 ` Juanma Barranquero
@ 2009-05-25 21:34 ` Eli Zaretskii
  2009-05-25 22:42   ` Óscar Fuentes
  1 sibling, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2009-05-25 21:34 UTC (permalink / raw)
  To: Óscar Fuentes; +Cc: emacs-devel

> From: =?windows-1252?Q?=D3scar_Fuentes?= <ofv@wanadoo.es>
> Date: Mon, 25 May 2009 18:11:43 +0200
> 
> Yesterday I refreshed my build of Emacs CVS on a Windows machine after
> some months and it keeps complaining:
> 
> error: The directory d:/home/.emacs.d/server is unsafe
> 
> when calling server-start. I see no references to this problem on News
> or Known Problems.

That bug was fixed ages ago.  The test is made only if Emacs runs on
something other than Windows.  Are you sure you don't have a stale
server.el somewhere?

> Is there a cure for this? What I did until now is remove the check on
> server.el, but this is hardly acceptable for the common user.

What check did you remove, and how did it fail for you?  If none of
the above helps to solve the problem, please debug it like Juanma
suggested, and post the results here.

The first thing I'd look at is whether the owner of that directory (as
returned by `file-attributes', for example, is the same as what
`(user-uid)' returns on that system.

TIA




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

* Re: Emacs on Windows keeps complaining: the directory ... is unsafe.
  2009-05-25 21:34 ` Eli Zaretskii
@ 2009-05-25 22:42   ` Óscar Fuentes
  2009-05-25 23:57     ` Juanma Barranquero
  2009-05-26  3:22     ` Eli Zaretskii
  0 siblings, 2 replies; 15+ messages in thread
From: Óscar Fuentes @ 2009-05-25 22:42 UTC (permalink / raw)
  To: emacs-devel

Hello Eli and Juanma.

Eli Zaretskii <eliz@gnu.org> writes:

>> Yesterday I refreshed my build of Emacs CVS on a Windows machine after
>> some months and it keeps complaining:
>> 
>> error: The directory d:/home/.emacs.d/server is unsafe
>> 
>> when calling server-start. I see no references to this problem on News
>> or Known Problems.
>
> That bug was fixed ages ago.  The test is made only if Emacs runs on
> something other than Windows.  Are you sure you don't have a stale
> server.el somewhere?

I'm sure it is using the server.el installed with `make install`.

BTW, only a part of the test is elided on windows. This is the test
expression:

    (unless (and (eq t (car attrs)) (eql (nth 2 attrs) (user-uid))
                 (or (eq system-type 'windows-nt)
                     (zerop (logand ?\077 (file-modes dir)))))
      (error "The directory %s is unsafe" dir))

>> Is there a cure for this? What I did until now is remove the check on
>> server.el, but this is hardly acceptable for the common user.
>
> What check did you remove, and how did it fail for you?  If none of
> the above helps to solve the problem, please debug it like Juanma
> suggested, and post the results here.
>
> The first thing I'd look at is whether the owner of that directory (as
> returned by `file-attributes', for example, is the same as what
> `(user-uid)' returns on that system.

Thanks for the hint. This seems the problem:

the file uid returned by file-attributes is 544:

(file-attributes "d:/home/.emacs.d/server")

(t 1 544 513 (18971 5346) (18971 5346) (17735 22234) 0 "drwxrwxrwx" nil
(2360832 0 . 9198) (21721 . 11703))

and (user-uid) returns 500.

The directory is accesible only for Administrator (me). Even tried to
change the directory hierarchy where emacs is installed so only
Administrator can access it. (user-uid) still returns 500.

It's strange too the file modes string: "drwxrwxrwx" This is not
consistent with a directory accessible only by the current user
(Administrator). A cygwin shell shows this:

Administrator@k7 ~
$ ls -l .emacs.d/      
total 1
d---------+ 2 Administrators None   0 May 26 00:31 server
----------+ 1 Administrators None 902 May  7  2008 tramp
d---------+ 2 Administrators None   0 Feb 17  2007 url

Have no idea what's going on.

-- 
Óscar





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

* Re: Emacs on Windows keeps complaining: the directory ... is unsafe.
  2009-05-25 22:42   ` Óscar Fuentes
@ 2009-05-25 23:57     ` Juanma Barranquero
  2009-05-26  0:23       ` Óscar Fuentes
  2009-05-26  3:22     ` Eli Zaretskii
  1 sibling, 1 reply; 15+ messages in thread
From: Juanma Barranquero @ 2009-05-25 23:57 UTC (permalink / raw)
  To: Óscar Fuentes; +Cc: emacs-devel

On Tue, May 26, 2009 at 00:42, Óscar Fuentes <ofv@wanadoo.es> wrote:

> Thanks for the hint. This seems the problem:
>
> the file uid returned by file-attributes is 544:

Eli's the expert on this stuff, but take a look at a related
discussion from last year:

http://lists.gnu.org/archive/html/emacs-devel/2008-03/msg02886.html

    Juanma




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

* Re: Emacs on Windows keeps complaining: the directory ... is unsafe.
  2009-05-25 23:57     ` Juanma Barranquero
@ 2009-05-26  0:23       ` Óscar Fuentes
  2009-05-26  0:27         ` Jason Rumney
  2009-05-26  3:16         ` Eli Zaretskii
  0 siblings, 2 replies; 15+ messages in thread
From: Óscar Fuentes @ 2009-05-26  0:23 UTC (permalink / raw)
  To: emacs-devel

Juanma Barranquero <lekktu@gmail.com> writes:

> On Tue, May 26, 2009 at 00:42, Óscar Fuentes <ofv@wanadoo.es> wrote:
>
>> Thanks for the hint. This seems the problem:
>>
>> the file uid returned by file-attributes is 544:
>
> Eli's the expert on this stuff, but take a look at a related
> discussion from last year:
>
> http://lists.gnu.org/archive/html/emacs-devel/2008-03/msg02886.html

Thanks Juanma.

This gave me an idea: renamed away .emacs.d. Started a new emacs
instance, which complained:

File error: Opening output file, no such file or directory, d:/home/.emacs.d/server/server

so started eshell and created the directory d:/home/.emacs.d/server/

Now file-attributes returns 500 for the file uid, the same value as
user-uid returns, and server-ensure-safe-dir does not complain.

Why file-attributes returns 544 for the file uid on the old directory?
I still have it around, in case you want some info about it.

-- 
Óscar





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

* Re: Emacs on Windows keeps complaining: the directory ... is unsafe.
  2009-05-26  0:23       ` Óscar Fuentes
@ 2009-05-26  0:27         ` Jason Rumney
  2009-05-26  1:28           ` Óscar Fuentes
  2009-05-26  3:16         ` Eli Zaretskii
  1 sibling, 1 reply; 15+ messages in thread
From: Jason Rumney @ 2009-05-26  0:27 UTC (permalink / raw)
  To: Óscar Fuentes; +Cc: emacs-devel

Óscar Fuentes wrote:
> Why file-attributes returns 544 for the file uid on the old directory?
> I still have it around, in case you want some info about it.
>   

What user does 544 correspond to? dired should tell you.






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

* Re: Emacs on Windows keeps complaining: the directory ... is unsafe.
  2009-05-26  0:27         ` Jason Rumney
@ 2009-05-26  1:28           ` Óscar Fuentes
  0 siblings, 0 replies; 15+ messages in thread
From: Óscar Fuentes @ 2009-05-26  1:28 UTC (permalink / raw)
  To: emacs-devel

Jason Rumney <jasonr@gnu.org> writes:

> Óscar Fuentes wrote:
>> Why file-attributes returns 544 for the file uid on the old directory?
>> I still have it around, in case you want some info about it.
>>   
>
> What user does 544 correspond to? dired should tell you.

The working `server' directory:

  -rw-rw-rw-  1 Administrator None 84 05-26 03:11 server

The problematic `server' directory:

  drwxrwxrwx  1 Administrators None    0 05-26 01:49 server

So the problem is that the faulty .emacs.d/server directory was not
owned by Administrator (the current user) but by Administrators (a group
of users).

Now checked again: exit emacs and deleted .emacs.d. Then started emacs
and .emacs.d/server was created succesfully as owned by Administrator
(.emacs.d is owned by Administrator too).

So the problem was that at some point .emacs.d/server was created as
owned by Administrators. The directory is almost 3 years old, so maybe
the problem was the bug Eli mentioned as fixed time ago.

On a previous message I mentioned that server-start complained about the
inexistence of .emacs.d/server. This was my fault. The `server'
directory is created by server-ensure-safe-dir and the call to it was
commented out for avoiding the error it throwed when the user-uid and
the file uid didn't match.

Thanks for your help and patience.

-- 
Óscar





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

* Re: Emacs on Windows keeps complaining: the directory ... is unsafe.
  2009-05-26  0:23       ` Óscar Fuentes
  2009-05-26  0:27         ` Jason Rumney
@ 2009-05-26  3:16         ` Eli Zaretskii
  2009-05-26 14:30           ` Óscar Fuentes
  1 sibling, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2009-05-26  3:16 UTC (permalink / raw)
  To: Óscar Fuentes; +Cc: emacs-devel

> From: =?windows-1252?Q?=D3scar_Fuentes?= <ofv@wanadoo.es>
> Date: Tue, 26 May 2009 02:23:25 +0200
> 
> This gave me an idea: renamed away .emacs.d. Started a new emacs
> instance, which complained:
> 
> File error: Opening output file, no such file or directory, d:/home/.emacs.d/server/server
> 
> so started eshell and created the directory d:/home/.emacs.d/server/
> 
> Now file-attributes returns 500 for the file uid, the same value as
> user-uid returns, and server-ensure-safe-dir does not complain.
> 
> Why file-attributes returns 544 for the file uid on the old directory?

544 is the uid of the Administrators group.  Files created by the user
Administrator are frequently seen on Windows as owned by the
Administrators group, not by the user Administrator.

But since recreating that directory from Emacs had the directory
attributed to the user Administrator (uid = 500), perhaps the owner
Windows records depends on how the directory is created.  Can you
experiment with different ways of creating directories, like from the
Windows shell, from Explorer, with the Emacs make-directory function,
and tell the results?

Thanks.




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

* Re: Emacs on Windows keeps complaining: the directory ... is unsafe.
  2009-05-25 22:42   ` Óscar Fuentes
  2009-05-25 23:57     ` Juanma Barranquero
@ 2009-05-26  3:22     ` Eli Zaretskii
  2009-05-26 14:33       ` Óscar Fuentes
  1 sibling, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2009-05-26  3:22 UTC (permalink / raw)
  To: Óscar Fuentes; +Cc: emacs-devel

> From: =?windows-1252?Q?=D3scar_Fuentes?= <ofv@wanadoo.es>
> Date: Tue, 26 May 2009 00:42:07 +0200
> 
> It's strange too the file modes string: "drwxrwxrwx" This is not
> consistent with a directory accessible only by the current user
> (Administrator).

Emacs does not yet support the Windows native security when it
computes the mode bits of the files.  So the only thing it pays
attention to is the Read-only bit, which in this case is off, so the
directory is shown as accessible by everyone.

> A cygwin shell shows this:
> 
> Administrator@k7 ~
> $ ls -l .emacs.d/      
> total 1
> d---------+ 2 Administrators None   0 May 26 00:31 server
> ----------+ 1 Administrators None 902 May  7  2008 tramp
> d---------+ 2 Administrators None   0 Feb 17  2007 url
> 
> Have no idea what's going on.

Cygwin does pay attention to the Windows security features, but it
does that in order to emulate Posix user/group/world model, which is
more restricted than Windows ACLs.  For that reason, what Cygwin shows
as mode bits may be incorrect if the file was not created by Cygwin
tools in the first place.

Anyway, this is a different, although related, problem.

By the way, was the .emacs.d directory created originally by some
Cygwin tool?




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

* Re: Emacs on Windows keeps complaining: the directory ... is unsafe.
  2009-05-26  3:16         ` Eli Zaretskii
@ 2009-05-26 14:30           ` Óscar Fuentes
  2009-05-26 19:42             ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Óscar Fuentes @ 2009-05-26 14:30 UTC (permalink / raw)
  To: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> 544 is the uid of the Administrators group.  Files created by the user
> Administrator are frequently seen on Windows as owned by the
> Administrators group, not by the user Administrator.
>
> But since recreating that directory from Emacs had the directory
> attributed to the user Administrator (uid = 500), perhaps the owner
> Windows records depends on how the directory is created.  Can you
> experiment with different ways of creating directories, like from the
> Windows shell, from Explorer, with the Emacs make-directory function,
> and tell the results?

  drwxrwxrwx  1 Administrators None           0 05-26 16:16 explorer
  drwxrwxrwx  1 Administrator  None           0 05-26 16:17 make-directory
  drwxrwxrwx  1 Administrators None           0 05-26 16:17 mkdir_cmd_shell
  drwxrwxrwx  1 Administrator  None           0 05-26 16:16 mkdir_cygwin_bash
  drwxrwxrwx  1 Administrator  None           0 05-26 16:17 mkdir_eshell
  drwxrwxrwx  1 Administrators None           0 05-26 16:26 mkdir_msys_bash

so Explorer and the CMD shell assigns ownership to Administrators, while
cygwin and Emacs assigns ownership to Administrator. MSYS, which, as you
know, is a fork of cygwin, assigns ownership to Administrators.

Emacs is the fully native one and does not use cygwin's shell nor MSYS
shell.

This is on Windows 2000 Professional SP4.

-- 
Óscar





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

* Re: Emacs on Windows keeps complaining: the directory ... is unsafe.
  2009-05-26  3:22     ` Eli Zaretskii
@ 2009-05-26 14:33       ` Óscar Fuentes
  2009-05-26 19:41         ` Eli Zaretskii
  0 siblings, 1 reply; 15+ messages in thread
From: Óscar Fuentes @ 2009-05-26 14:33 UTC (permalink / raw)
  To: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

> By the way, was the .emacs.d directory created originally by some
> Cygwin tool?

That happened long time ago. However, I doubt that anything else than
emacs created that directory.

-- 
Óscar





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

* Re: Emacs on Windows keeps complaining: the directory ... is unsafe.
  2009-05-26 14:33       ` Óscar Fuentes
@ 2009-05-26 19:41         ` Eli Zaretskii
  2009-05-26 21:00           ` Óscar Fuentes
  0 siblings, 1 reply; 15+ messages in thread
From: Eli Zaretskii @ 2009-05-26 19:41 UTC (permalink / raw)
  To: Óscar Fuentes; +Cc: emacs-devel

> From: =?windows-1252?Q?=D3scar_Fuentes?= <ofv@wanadoo.es>
> Date: Tue, 26 May 2009 16:33:12 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> > By the way, was the .emacs.d directory created originally by some
> > Cygwin tool?
> 
> That happened long time ago. However, I doubt that anything else than
> emacs created that directory.

Hmm, strange.  That would mean something's changed in Emacs since
then, but I don't think make-directory was ever changed on Windows wrt
file ownership.  We just call a Windows _mkdir function.




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

* Re: Emacs on Windows keeps complaining: the directory ... is unsafe.
  2009-05-26 14:30           ` Óscar Fuentes
@ 2009-05-26 19:42             ` Eli Zaretskii
  0 siblings, 0 replies; 15+ messages in thread
From: Eli Zaretskii @ 2009-05-26 19:42 UTC (permalink / raw)
  To: Óscar Fuentes; +Cc: emacs-devel

> From: =?windows-1252?Q?=D3scar_Fuentes?= <ofv@wanadoo.es>
> Date: Tue, 26 May 2009 16:30:41 +0200
> 
>   drwxrwxrwx  1 Administrators None           0 05-26 16:16 explorer
>   drwxrwxrwx  1 Administrator  None           0 05-26 16:17 make-directory
>   drwxrwxrwx  1 Administrators None           0 05-26 16:17 mkdir_cmd_shell
>   drwxrwxrwx  1 Administrator  None           0 05-26 16:16 mkdir_cygwin_bash
>   drwxrwxrwx  1 Administrator  None           0 05-26 16:17 mkdir_eshell
>   drwxrwxrwx  1 Administrators None           0 05-26 16:26 mkdir_msys_bash

Thanks.  This means a workaround for this problem is to delete
~/.emacs.d and then recreate it from within Emacs.  I will make an
entry in PROBLEMS about this.




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

* Re: Emacs on Windows keeps complaining: the directory ... is unsafe.
  2009-05-26 19:41         ` Eli Zaretskii
@ 2009-05-26 21:00           ` Óscar Fuentes
  0 siblings, 0 replies; 15+ messages in thread
From: Óscar Fuentes @ 2009-05-26 21:00 UTC (permalink / raw)
  To: emacs-devel; +Cc: Eli Zaretskii

Eli Zaretskii <eliz@gnu.org> writes:

>> > By the way, was the .emacs.d directory created originally by some
>> > Cygwin tool?
>> 
>> That happened long time ago. However, I doubt that anything else than
>> emacs created that directory.
>
> Hmm, strange.  That would mean something's changed in Emacs since
> then, but I don't think make-directory was ever changed on Windows wrt
> file ownership.  We just call a Windows _mkdir function.

The mystery is solved: on the past my home directory changed. I checked
that copying a directory with Explorer reassigns the owner to
Administrators. It keeps the owner with cut&paste, but my custom is to
leave the original behind and certainly used copy&paste when migrated
the contents from the old home directory to the new one.

I guess the same is applicable to other tools that assigns the ownership
to Administrators, such as CMD, the MSYS shell, etc.

-- 
Óscar





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

end of thread, other threads:[~2009-05-26 21:00 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-25 16:11 Emacs on Windows keeps complaining: the directory ... is unsafe Óscar Fuentes
2009-05-25 17:06 ` Juanma Barranquero
2009-05-25 21:34 ` Eli Zaretskii
2009-05-25 22:42   ` Óscar Fuentes
2009-05-25 23:57     ` Juanma Barranquero
2009-05-26  0:23       ` Óscar Fuentes
2009-05-26  0:27         ` Jason Rumney
2009-05-26  1:28           ` Óscar Fuentes
2009-05-26  3:16         ` Eli Zaretskii
2009-05-26 14:30           ` Óscar Fuentes
2009-05-26 19:42             ` Eli Zaretskii
2009-05-26  3:22     ` Eli Zaretskii
2009-05-26 14:33       ` Óscar Fuentes
2009-05-26 19:41         ` Eli Zaretskii
2009-05-26 21:00           ` Óscar Fuentes

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

	https://git.savannah.gnu.org/cgit/emacs.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).