#14398 closed (fixed)
runfcgi umask option should use literal value
Reported by: | Gordon Pettey | Owned by: | nobody |
---|---|---|---|
Component: | Core (Management commands) | Version: | 1.2 |
Severity: | Keywords: | ||
Cc: | anthony@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The umask option is converted to an int, instead of taken as typed.
./manage.py runfcgi umask=0111 (decimal int) creates a socket with umask 0157 (octal). umask=0022 creates a socket with umask 0026. umask=0027 creares a socket with umask 0033.
A user on IRC suggested use of ast.literal_eval() instead.
Attachments (1)
Change History (11)
comment:1 by , 14 years ago
comment:2 by , 14 years ago
Has patch: | set |
---|---|
Needs tests: | set |
Triage Stage: | Unreviewed → Accepted |
Patch for this issue using the radix parameter to int()
taht allows to pass octal numbers in the usual 0nnn
notation. Plus associated yak shaving: Intended to clarificate of the notations accepted for the umask
runfcgi
command option docs -> Addition of docs for the command -> Modification of our Sphinx customization to accept command options not prefixed with '--'
so the :djadminopt:
xrefs work as expected.
follow-up: 4 comment:3 by , 14 years ago
You are using int(umask, 0). This means that the interpretation will not always be octal. int('755', 0) is interpreted as decimal. Wouldn't it be better to use int(umask, 8)?
comment:4 by , 14 years ago
Replying to aptiko:
You are using int(umask, 0). This means that the interpretation will not always be octal. int('755', 0) is interpreted as decimal. Wouldn't it be better to use int(umask, 8)?
The historical notation for octal numbers in C and Unix (and others) is prefixing them with a '0'. So IMHO we should respect that and interpret the argument as an octal value only if it has such prefix, that's why I'm using the radix=0
argument to int()
(although this means we will also allow base 10 values and even hexadecimal '0xn' values)
I will ask other Django developers for opinions.
comment:5 by , 14 years ago
In C yes, but not in Unix generally. The chmod and umask commands accept octals, like chmod 755 or umask 222. Here we are talking about a command, ./manage.py ... umask=...
As a Unix user, I would definitely expect to write an octal there. As a programmer, I would expect the leading zero convention only when writing a program.
comment:6 by , 14 years ago
You are completely right, I realize now I've been passing zero-prefixed arguments to chmod for years. Thanks.
comment:7 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Replying to petteyg:
The
ast
module was added to the stdlib in python 2.6 and Django (currently) needs to be compatible with Python 2.4.