Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
agent
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
7
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a38e1fe0
authored
Jul 24, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix symlink vulnerability
parent
682c53d2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
notify.py
+21
-0
No files found.
notify.py
View file @
a38e1fe0
...
...
@@ -75,6 +75,10 @@ def notify(url):
olddisplay
=
os
.
environ
.
get
(
"DISPLAY"
)
try
:
file_path
=
os
.
path
.
join
(
get_temp_dir
(),
file_name
)
if
file_already_exists
(
file_path
):
os
.
remove
(
file_path
)
if
file_already_exists
(
file_path
):
raise
Exception
(
"Couldn't create file
%
s as new"
%
file_path
)
with
open
(
file_path
,
"w"
)
as
f
:
json
.
dump
(
url
,
f
)
...
...
@@ -94,6 +98,23 @@ def notify(url):
os
.
environ
[
"DISPLAY"
]
=
olddisplay
def
file_already_exists
(
name
):
"""Return whether file already exists, create it if not.
Other errors are silently ignored as the file will be reopened anyways.
Creating it is needed to avoid race condition.
"""
try
:
fd
=
os_open
(
name
,
O_CREAT
|
O_EXCL
)
except
OSError
as
e
:
if
e
.
errno
==
EEXIST
:
return
True
else
:
close
(
fd
)
return
False
def
search_display
():
"""Search a valid DISPLAY env var in processes
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment