Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--create-dirs permissions different than files: 750 mode vs. 644 mode #4766

Closed
jidanni opened this issue Dec 28, 2019 · 13 comments · Fixed by sthagen/curl-curl#80
Closed

--create-dirs permissions different than files: 750 mode vs. 644 mode #4766

jidanni opened this issue Dec 28, 2019 · 13 comments · Fixed by sthagen/curl-curl#80

Comments

@jidanni
Copy link
Contributor

jidanni commented Dec 28, 2019

On the man page --create-dirs should mention that it uses odd
drwxr-x--- vs. -rw-r--r-- permissions for files downloaded.

One would think they would be
drwxr-xr-x and -rw-r--r--, or
drwxr-x--- and -rw-r-----

Also mention how to change it. curl 7.67.0, Debian.

@jay
Copy link
Member

jay commented Dec 29, 2019

I don't see how it's odd and I think it's unnecessary to add that. However I will leave this open for a bit to see what others think.

@jidanni
Copy link
Contributor Author

jidanni commented Dec 29, 2019

What Unix umask could come up with that combination?
Impossible. Thus very odd indeed!

@bagder
Copy link
Member

bagder commented Jan 4, 2020

I don't see any harm in documenting the mode (0750) it uses to create dirs with this option.

@jidanni
Copy link
Contributor Author

jidanni commented Jan 4, 2020

Also, there definitely needs to be a way offered for the user to change it. One might expect the user to simply use a different umask. However that would also change the modes of the files being downloaded, in addition to the directories being created.

@jidanni
Copy link
Contributor Author

jidanni commented Jan 4, 2020

Private directories and non private files, are just the same valid choice as non-private directories and private files. So the program should offer the user more flexibility.

@bagder
Copy link
Member

bagder commented Jan 5, 2020

there definitely needs to be a way offered for the user to change it

This option has existed in curl since December 2002 without that ability. I'm not sure saying it needs to be offered is correct; clearly people have managed without it.

You can easily change the mode after curl is completed if you want something different and changing the umask isn't enough. Is it really that important that curl does it by itself?

@jidanni
Copy link
Contributor Author

jidanni commented Jan 6, 2020

Well let's put things in perspective. It is curl that is changing
things, and the user needing to repair them back.

The user has set a umask, and curl has overridden it, and only in
certain cases (directories) too.

So the user needs to make odd scripts like

find -type -d -perm 0750 -cmin -10 -exec chmod <mode that would have been made with user's umask> {} \;

to "repair the damage."

Anyway, curl can go on making directories 0750, but the man page should
say what find(1) invocation would be best to "repair the damage" if the
user wanted to "repair the damage".

Also document the severity of the override: Does it combine 0750 with
the umask if more restrictive, creating e.g., 0700. Or does it create
0750 no matter what.

@bagder
Copy link
Member

bagder commented Jan 6, 2020

The user has set a umask, and curl has overridden it,

No it hasn't. The user's umask still masks off bits accordingly, as that's done by the mkdir function. Explained like this in my mkdir(2) man page:

The argument mode specifies the mode for the new directory. It is modified by the process's umask in the usual way: the mode of the created directory is (mode & ~umask & 0777).

... where mode is 0750 in this case.

@jidanni
Copy link
Contributor Author

jidanni commented Jan 7, 2020 via email

@bagder
Copy link
Member

bagder commented Jan 11, 2020

I'd call it inform rather than warn, but sure - feel free to propose a text for the man page!

We can of course also consider changing the mode we use.

@jidanni
Copy link
Contributor Author

jidanni commented Jan 12, 2020 via email

@bagder
Copy link
Member

bagder commented Jan 13, 2020

We didn't "inject" any "funny" umask. We use a mode. You can't use mkdir() without one.

I'm trying to work and be constructive here. It would be nice if your snark and attitude could be taken somewhere else.

@jidanni
Copy link
Contributor Author

jidanni commented Jan 14, 2020

OK, it seems it would be best to do as in tests/testcurl.pl:

mkdir $build, 0777;

bagder added a commit that referenced this issue Feb 12, 2020
Reported-by: Dan Jacobson
Fixes #4766
@bagder bagder closed this as completed in d78672b Feb 12, 2020
@lock lock bot locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging a pull request may close this issue.

3 participants