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

--umask doesn't support non-decimal values #1325

Closed
JayH5 opened this issue Aug 8, 2016 · 6 comments
Closed

--umask doesn't support non-decimal values #1325

JayH5 opened this issue Aug 8, 2016 · 6 comments

Comments

@JayH5
Copy link

JayH5 commented Aug 8, 2016

/app $ gunicorn --version
gunicorn (version 19.6.0)
/app $ python --version
Python 2.7.12

The documentation says that Gunicorn should accept "a string compatible with int(value, 0)". I don't know about in a config file, but when specifying via the command line (--umask,-m), only integers are supported. Hex strings are rejected...

/app $ gunicorn -m 0xFF
usage: gunicorn [OPTIONS] [APP_MODULE]
gunicorn: error: argument -m/--umask: invalid int value: '0xFF'

... and octals seem to be treated as decimals.

@benoitc
Copy link
Owner

benoitc commented Aug 8, 2016

It's not expected to give the umask as hexadecimal? Why do you need it?

@berkerpeksag
Copy link
Collaborator

I don't find any int(..., 0) call in codebase. In any case, we should update documentation and examples/example_config.py. Also, os.umask() does the following:

int i = (int)umask(mask);
return PyLong_FromLong((long)i);

@JayH5
Copy link
Author

JayH5 commented Aug 8, 2016

@benoitc well.. I didn't actually want to use hexadecimal, it was just the easiest example to show Gunicorn not working as documented.

Octal, on the other hand, is much friendlier than decimal for setting a umask and I spent quite a while trying to figure out why my permissions were all wrong before I realised the octal number I'd passed to Gunicorn (0117) was being interpreted as decimal (117) instead of what the documentation suggests (int('0117', 0) -> 79).

@JayH5
Copy link
Author

JayH5 commented Aug 8, 2016

@berkerpeksag there's an int(..., 0) call when the argument is validated as a number: https://github.com/benoitc/gunicorn/blob/19.6.0/gunicorn/config.py#L320

That just doesn't seem to apply at the right stage in the processing of arguments... or something.. I'm not sure.

@benoitc benoitc added the bug :( label Aug 8, 2016
@benoitc
Copy link
Owner

benoitc commented Aug 8, 2016

ok so the real issue is the validation:
https://github.com/benoitc/gunicorn/blob/19.6.0/gunicorn/config.py#L975

we need to make sure we can handle the octal version.

@hramezani
Copy link
Contributor

#1465

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants