Skip to content

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

Closed

Description

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

Activity

  1. benoitc commented on Aug 8, 2016

    @benoitc
    Owner

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

  2. berkerpeksag commented on Aug 8, 2016

    @berkerpeksag
    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);
  3. JayH5 commented on Aug 8, 2016

    @JayH5
    Author

    @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).

  4. JayH5 commented on Aug 8, 2016

    @JayH5
    Author

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

  5. benoitc commented on Aug 8, 2016

    @benoitc
    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.

  6. hramezani commented on Feb 19, 2017

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions