wget 1.17.x creates odd permissions on downloaded files

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

wget 1.17.x creates odd permissions on downloaded files

Zube
wget 1.16.3 seemed to work fine for a simple task, that is to download
putty.exe from a local http site.  Start up a normal windows cmd.exe,
download, run, no muss, no fuss.

The last two wget versions (1.17.1-1 and -2) seem to exhibit the
following issues when putty.exe is downloaded.

1) putty will not execute.  Error is "Access is denied".

2) Examining the permissions on putty.exe, the first thing that
comes up is an error that reads:

"The permissions on putty.exe are incorrectly ordered, which may
cause some entries to be ineffective."

The permissions are odd.  When compared to a working machine (wget
1.16.3, cygwin 2.3.1) there is an additional group ("NULL SID") with
special access of type Deny and several of the other users and groups
have similar "type Deny" restrictions.

If I use a browser to download the file or a different version of wget
(e.g. https://eternallybored.org/misc/wget/) and drop putty.exe in
the same directory, there are no issues.  It also doesn't matter where
the file is dropped.  

This occurs on both a Windows 7 64-bit machine that has had
32-bit cygwin upgraded multiple times and on a new Windows 10
64-bit machine with 32-bit cygwin installed fresh.  It occurs
under cmd.exe and also under Cygwin.bat, for both administrators
and non-administrators.

Any help greatly appreciated.  Thank you for your time.

Cheers,
Zube

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: wget 1.17.x creates odd permissions on downloaded files

Larry Hall (Cygwin)
On 06/22/2016 02:40 PM, Zube wrote:

> wget 1.16.3 seemed to work fine for a simple task, that is to download
> putty.exe from a local http site.  Start up a normal windows cmd.exe,
> download, run, no muss, no fuss.
>
> The last two wget versions (1.17.1-1 and -2) seem to exhibit the
> following issues when putty.exe is downloaded.
>
> 1) putty will not execute.  Error is "Access is denied".
>
> 2) Examining the permissions on putty.exe, the first thing that
> comes up is an error that reads:
>
> "The permissions on putty.exe are incorrectly ordered, which may
> cause some entries to be ineffective."
>
> The permissions are odd.  When compared to a working machine (wget
> 1.16.3, cygwin 2.3.1) there is an additional group ("NULL SID") with
> special access of type Deny and several of the other users and groups
> have similar "type Deny" restrictions.
>
> If I use a browser to download the file or a different version of wget
> (e.g. https://eternallybored.org/misc/wget/) and drop putty.exe in
> the same directory, there are no issues.  It also doesn't matter where
> the file is dropped.
>
> This occurs on both a Windows 7 64-bit machine that has had
> 32-bit cygwin upgraded multiple times and on a new Windows 10
> 64-bit machine with 32-bit cygwin installed fresh.  It occurs
> under cmd.exe and also under Cygwin.bat, for both administrators
> and non-administrators.
>
> Any help greatly appreciated.  Thank you for your time.

Remember, Cygwin's wget will not create a file with execute permissions
automatically.  You have to do a "chmod +x putty.exe" if you want it to
be recognized as an executable.

--
Larry

_____________________________________________________________________

A: Yes.
 > Q: Are you sure?
 >> A: Because it reverses the logical flow of conversation.
 >>> Q: Why is top posting annoying in email?

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: wget 1.17.x creates odd permissions on downloaded files

Warren Young-2
In reply to this post by Zube
On Jun 22, 2016, at 12:40 PM, Zube <[hidden email]> wrote:
>
> 1) putty will not execute.  Error is "Access is denied”.

Is it getting the +x permission for your user or one of its groups?  Windows requires this just as Unix does.

Post the getfacl and icalcs output for putty.exe if you think it’s correct.

> 2) Examining the permissions on putty.exe, the first thing that
> comes up is an error that reads:
>
> "The permissions on putty.exe are incorrectly ordered, which may
> cause some entries to be ineffective.”

That’s Explorer saying that, not Cygwin, right?  Let Explorer fix it.

> The permissions are odd.

If it doesn’t need any Windows-specific permissions, you can strip all non-Cygwin/POSIX permissions:

   $ setfacl -kb putty.exe
   $ chmod +x putty.exe

Do it in that order.  (The second command may not work or may do strange things if you do it before stripping the non-POSIX permissions.)

If that still fails, setfacl -kb the directory you’re doing this in, but only if it’s a directory that only Cygwin uses.  Otherwise, you risk breaking some ACL Windows or a native Windows program depends on.

> If I use a browser to download the file or a different version of wget
> (e.g. https://eternallybored.org/misc/wget/) and drop putty.exe in
> the same directory, there are no issues.

Yes, Windows seems to set the +x permission the way some people use table salt.

> It also doesn't matter where
> the file is dropped.

Oh, that might not be true.  Windows’ permission inheritance model can result in the destination mattering.  What you mean to say is, you have yet to find a target directory where the results are different. :)

This may not be a wget problem.  cygwin1.dll is becoming more POSIX-compliant in its permission handling lately.
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: wget 1.17.x creates odd permissions on downloaded files

Zube
In reply to this post by Larry Hall (Cygwin)
On Wed Jun 22 03:03:38 PM, Larry Hall (Cygwin) wrote:

> Remember, Cygwin's wget will not create a file with execute permissions
> automatically.  You have to do a "chmod +x putty.exe" if you want it to
> be recognized as an executable.

This was it, thanks.  It is /fairly/ new behavior, however.  Certainly
cygwin 2.3.1 installed in, if memory serves, Dec of 2015 did not need
the chmod to get putty to run.

Thanks also to Warren Young for taking the time to reply.  His comment
that "cygwin1.dll is becoming more POSIX-compliant in its permission
handling lately" seems to be right.  If I install ncftp under
cygwin and download putty.exe that way, it too gives the "Access is
denied." error.  So the changes are in cygwin, not wget.

Cheers,
Zube

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: wget 1.17.x creates odd permissions on downloaded files

Andrey Repin
In reply to this post by Warren Young-2
Greetings, Warren Young!

>> 2) Examining the permissions on putty.exe, the first thing that
>> comes up is an error that reads:
>>
>> "The permissions on putty.exe are incorrectly ordered, which may
>> cause some entries to be ineffective.”

> That’s Explorer saying that, not Cygwin, right?  Let Explorer fix it.

Do NOT do that. It'll screw Cygwin permission handling.


--
With best regards,
Andrey Repin
Thursday, June 23, 2016 13:21:00

Sorry for my terrible english...
Reply | Threaded
Open this post in threaded view
|

Re: wget 1.17.x creates odd permissions on downloaded files

Andrey Repin
In reply to this post by Zube
Greetings, Zube!

> wget 1.16.3 seemed to work fine for a simple task, that is to download
> putty.exe from a local http site.  Start up a normal windows cmd.exe,
> download, run, no muss, no fuss.

> The last two wget versions (1.17.1-1 and -2) seem to exhibit the
> following issues when putty.exe is downloaded.

> 1) putty will not execute.  Error is "Access is denied".

That depends on the permission model you're using for directory, where you are
downloading the file to.
If you are using Cygwin ACL's, then the behavior is POSIX, and the new file
will not receive +x by default.

> 2) Examining the permissions on putty.exe, the first thing that
> comes up is an error that reads:

> "The permissions on putty.exe are incorrectly ordered, which may
> cause some entries to be ineffective."

> The permissions are odd.  When compared to a working machine (wget
> 1.16.3, cygwin 2.3.1) there is an additional group ("NULL SID") with
> special access of type Deny and several of the other users and groups
> have similar "type Deny" restrictions.

This is how Cygwin works around certain incompatibilities between Windows and
POSIX permission models.
Do NOT fall into a trap and believe that Explorer trying to drag you to.
The permissions are correct, it's just that Explorer is unable to deal with
them, because all it knows is so-called "canonical" order.

> If I use a browser to download the file or a different version of wget
> (e.g. https://eternallybored.org/misc/wget/) and drop putty.exe in
> the same directory, there are no issues.  It also doesn't matter where
> the file is dropped.  

> This occurs on both a Windows 7 64-bit machine that has had
> 32-bit cygwin upgraded multiple times and on a new Windows 10
> 64-bit machine with 32-bit cygwin installed fresh.  It occurs
> under cmd.exe and also under Cygwin.bat, for both administrators
> and non-administrators.

> Any help greatly appreciated.  Thank you for your time.

If you want Windows behavior, use noacl flag on non-Cygwin mounts.

F.e.

# RAM disk
W:/ /var/run ntfs acl,binary,nouser,posix=0 0 0
# /cygdrive mount
none /cygdrive cygdrive noacl,binary,nouser,posix=0 0 0
# Map user homes to /home
C:/Users /home bind noacl,binary,exec,posix=0 0 0
# And /tmp to user %TEMP%
none /tmp usertemp binary,user,notexec,posix=0 0 0


--
With best regards,
Andrey Repin
Thursday, June 23, 2016 13:21:51

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: wget 1.17.x creates odd permissions on downloaded files

Zube
On Thu Jun 23 01:34:17 PM, Andrey Repin wrote:

> Greetings, Zube!

Thanks very much for taking the time to reply.

>  This is how Cygwin works around certain incompatibilities between
>  Windows and POSIX permission models.  Do NOT fall into a trap
>  and believe that Explorer trying to drag you to.  The permissions
>  are correct, it's just that Explorer is unable to deal with them,
>  because all it knows is so-called "canonical" order.

OK.

> If you want Windows behavior, use noacl flag on non-Cygwin mounts.

Thank you.  As you might have seen in my follow-up, it was simply
a change in behavior that I wasn't expecting.  Now that I expect
it, I can certainly set the execute bit on whatever executables
I download.

Cheers,
Zube

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: wget 1.17.x creates odd permissions on downloaded files

Andrey Repin
Greetings, Zube!

>>  This is how Cygwin works around certain incompatibilities between
>>  Windows and POSIX permission models.  Do NOT fall into a trap
>>  and believe that Explorer trying to drag you to.  The permissions
>>  are correct, it's just that Explorer is unable to deal with them,
>>  because all it knows is so-called "canonical" order.

> OK.

>> If you want Windows behavior, use noacl flag on non-Cygwin mounts.

> Thank you.  As you might have seen in my follow-up, it was simply
> a change in behavior that I wasn't expecting.  Now that I expect
> it, I can certainly set the execute bit on whatever executables
> I download.

Yeah, that caught me not once, too, on new installations. But I was expecting
something like that, knowing how Cygwin handles file permissions in general.
(Read: same as Linux.)
The actual fix in each case depends on the typical usage of a given Cygwin
install. There's no silver bullet.


--
With best regards,
Andrey Repin
Thursday, June 23, 2016 15:23:31

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: wget 1.17.x creates odd permissions on downloaded files

Warren Young-2
In reply to this post by Andrey Repin
On Jun 23, 2016, at 4:21 AM, Andrey Repin <[hidden email]> wrote:

>
> Greetings, Warren Young!
>
>>> 2) Examining the permissions on putty.exe, the first thing that
>>> comes up is an error that reads:
>>>
>>> "The permissions on putty.exe are incorrectly ordered, which may
>>> cause some entries to be ineffective.”
>
>> That’s Explorer saying that, not Cygwin, right?  Let Explorer fix it.
>
> Do NOT do that. It'll screw Cygwin permission handling.

Not necessarily.

If you can restrict Cygwin to a known set of directories, you can use Cygwin-only permissions in those directories and let Windows do whatever it wants with everything else.

Here’s my fixperms script, which keeps both sides happy:

    #!/bin/bash
    if [ -z "$1" ]
    then
    for d in /usr/local ~/bin ~/tmp
    do
    echo Fixing permissions in $d...
    chown -R $(id -nu) "$d"
    find "$d" -exec "$0" {} \;
    done
    elif ! setfacl -kb "$1"
    then
    echo "   ...in $1"
    fi

Modify the list of Cygwin-only directories at the top of the script to suit your local situation.

I don’t bother doing this to the entirety of c:\cygwin*.  I only include directories I’m likely to open in both Cygwin and Explorer in that list.

You might have to run it a few times to fix everything, due to the way Windows permission inheritance works.  (I prefer that to the alternative, which is the breadth-first find(1) hacks: http://stackoverflow.com/q/1086907)

You’ll probably also need to run it as Administrator, at least the first time.  After that, new permission changes should be ones your user has the ability to revert without Admin level privileges.

If you’ve set your Cygwin HOME directory to be the same as your Windows user profile directory, be sure NOT to include ~ in the list of directories you modify with this script.  There are files under %APPDATA% at the very least that will break horribly if you run this on them.  Do this only on files that your user personally owns and uses, not files owned and used by Windows on your user’s behalf.

Directories you run this script on do not show the “incorrectly ordered” symptom in Explorer.
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: wget 1.17.x creates odd permissions on downloaded files

Andrey Repin
Greetings, Warren Young!

> On Jun 23, 2016, at 4:21 AM, Andrey Repin <[hidden email]> wrote:
>>
>> Greetings, Warren Young!
>>
>>>> 2) Examining the permissions on putty.exe, the first thing that
>>>> comes up is an error that reads:
>>>>
>>>> "The permissions on putty.exe are incorrectly ordered, which may
>>>> cause some entries to be ineffective.”
>>
>>> That’s Explorer saying that, not Cygwin, right?  Let Explorer fix it.
>>
>> Do NOT do that. It'll screw Cygwin permission handling.

> Not necessarily.

> If you can restrict Cygwin to a known set of directories, you can use
> Cygwin-only permissions in those directories and let Windows do whatever it
> wants with everything else.

> Here’s my fixperms script, which keeps both sides happy:

Overengineered.
Just use noacl mounts and you'll not have this problem again.


--
With best regards,
Andrey Repin
Thursday, June 23, 2016 21:16:43

Sorry for my terrible english...
Reply | Threaded
Open this post in threaded view
|

Re: wget 1.17.x creates odd permissions on downloaded files

Warren Young-2
On Jun 23, 2016, at 12:17 PM, Andrey Repin wrote:
>
>>>> Let Explorer fix it.
>>>
>>> Do NOT do that. It'll screw Cygwin permission handling.
>
>> Here’s my fixperms script, which keeps both sides happy:
>
> Overengineered.
> Just use noacl mounts and you'll not have this problem again.

Let me get this straight: removing Windows permissions that conflict with POSIX permissions is “overengineered,” so your solution is to ignore all permissions?  I think I’ll stick with my solution.

I couldn’t use noacl anyway, because I use db_home: windows in my nsswitch.conf file, which means my $HOME is outside Cygwin’s mount table.  I’d have to individually map each %USERPROFILE% subdir I wanted into /home/warren in order to use noacl.
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Reply | Threaded
Open this post in threaded view
|

Re: wget 1.17.x creates odd permissions on downloaded files

Andrey Repin
Greetings, Warren Young!

>> Just use noacl mounts and you'll not have this problem again.

> Let me get this straight: removing Windows permissions that conflict with
> POSIX permissions is “overengineered,” so your solution is to ignore all
> permissions?  I think I’ll stick with my solution.

WAT?
"noacl" defers permissions management to OS. It DO NOT "ignore" them.

> I couldn’t use noacl anyway, because I use db_home: windows in my
> nsswitch.conf file, which means my $HOME is outside Cygwin’s mount table.

Yes, you do and, realistically speaking, should.

> I’d have to individually map each %USERPROFILE% subdir I wanted into
> /home/warren in order to use noacl.

No, just set /cygpath to noacl.


--
With best regards,
Andrey Repin
Saturday, June 25, 2016 02:33:47

Sorry for my terrible english...