BaseLogFile should not call os.umask
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 6k
- Forks
- 1.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 10
Description
| @mithrandi reported | |
|---|---|
| Trac ID | trac#9215 |
| Type | defect |
| Created | 2017-07-08 06:11:24Z |
BaseLogFile sets and restores umask here: https://github.com/twisted/twisted/blob/3d11cba9fe1f50fc55cb5622d4f47dfcc9c9f204/src/twisted/python/logfile.py#L79-L83
Unfortunately, umask is process-global state, which means that any other threads doing file-related operations at the same time are affected, which is bad. We should instead rely on something like #9214 to set the mode directly (the underlying open(2) libc call supports this).
The way I ran into this: in our application, when certain types of external request are made, we dump the request and response contents to a file on disk, in a directory named after the date. We also have Eliot logs going to a DailyLogFile, which are written out in a separate thread for performance reasons. This means that for the first operation of every new day, there is a race between DailyLogFile setting the umask to 0 briefly as the first log message triggers log rotation, and our dumping code creating the new day's dumps directory, resulting in this directory randomly having 0o0000 permissions occasionally.
Searchable metadata
trac-id__9215 9215
type__defect defect
reporter__mithrandi mithrandi
priority__normal normal
milestone__None None
branch__
branch_author__
status__new new
resolution__None None
component__core core
keywords__None None
time__1499494284859101 1499494284859101
changetime__1499494284859101 1499494284859101
version__None None
owner__None None
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/twisted/python/logfile.py at BaseLogFile and inspect the umask handling linked in the issue. Review issue #9214 for the proposed direct mode-setting approach; done means BaseLogFile no longer changes process-global umask while creating log files and the existing behavior remains covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100