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

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

Comments

5 participants
@JayH5

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

This comment has been minimized.

Show comment
Hide comment
@benoitc

benoitc Aug 8, 2016

Owner

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

Owner

benoitc commented Aug 8, 2016

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

@berkerpeksag

This comment has been minimized.

Show comment
Hide comment
@berkerpeksag

berkerpeksag Aug 8, 2016

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);
Collaborator

berkerpeksag commented Aug 8, 2016

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

This comment has been minimized.

Show comment
Hide comment
@JayH5

JayH5 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 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

This comment has been minimized.

Show comment
Hide comment
@JayH5

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

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

This comment has been minimized.

Show comment
Hide comment
@benoitc

benoitc Aug 8, 2016

Owner

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.

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.

@benoitc benoitc added Improvement and removed bug :( labels Jan 27, 2017

@hramezani

This comment has been minimized.

Show comment
Hide comment
Contributor

hramezani commented Feb 19, 2017

@benoitc benoitc added this to Other in Mailing List Feb 26, 2017

@tilgovi tilgovi closed this Mar 20, 2017

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