Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
ffworker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Video AG Infrastruktur
ffworker
Commits
fcfdcfbb
Commit
fcfdcfbb
authored
7 years ago
by
Julian Rother
Browse files
Options
Downloads
Patches
Plain Diff
Added sanity checks
parent
831c1a69
No related branches found
No related tags found
No related merge requests found
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
remux.c
+4
-0
4 additions, 0 deletions
remux.c
thumbnail.c
+2
-0
2 additions, 0 deletions
thumbnail.c
transcode.c
+4
-0
4 additions, 0 deletions
transcode.c
util.h
+1
-0
1 addition, 0 deletions
util.h
util/overwrite_check.c
+14
-0
14 additions, 0 deletions
util/overwrite_check.c
with
25 additions
and
0 deletions
remux.c
+
4
−
0
View file @
fcfdcfbb
...
@@ -23,6 +23,7 @@ int main(int argc, char *argv[])
...
@@ -23,6 +23,7 @@ int main(int argc, char *argv[])
jobid
=
atoi
(
argv
[
1
]);
jobid
=
atoi
(
argv
[
1
]);
path
=
mprintf
(
"%s/%s"
,
getenv
(
WORKER_RELEASED
),
jstr
(
jlookup
(
argv
[
4
],
"path"
),
""
));
path
=
mprintf
(
"%s/%s"
,
getenv
(
WORKER_RELEASED
),
jstr
(
jlookup
(
argv
[
4
],
"path"
),
""
));
tmp
=
mprintf
(
"%s/.tmp-%i"
,
getenv
(
WORKER_TMP
),
jobid
);
tmp
=
mprintf
(
"%s/.tmp-%i"
,
getenv
(
WORKER_TMP
),
jobid
);
overwrite_check
(
path
);
ping_job
(
jobid
,
"running"
,
0
);
ping_job
(
jobid
,
"running"
,
0
);
demux
=
0
;
demux
=
0
;
...
@@ -74,6 +75,9 @@ int main(int argc, char *argv[])
...
@@ -74,6 +75,9 @@ int main(int argc, char *argv[])
if
(
err
=
av_write_trailer
(
mux
))
if
(
err
=
av_write_trailer
(
mux
))
job_failed
(
"Error writing trailer to temporary file"
,
av_err2str
(
err
));
job_failed
(
"Error writing trailer to temporary file"
,
av_err2str
(
err
));
avio_closep
(
&
mux
->
pb
);
avio_closep
(
&
mux
->
pb
);
if
(
!
filesize
(
tmp
))
job_failed
(
"Sanity check failed: Output file is empty"
);
overwrite_check
(
path
);
if
(
rename
(
tmp
,
path
))
if
(
rename
(
tmp
,
path
))
job_failed
(
"Overwriting output file failed: %s"
,
strerror
(
errno
));
job_failed
(
"Overwriting output file failed: %s"
,
strerror
(
errno
));
unlink
(
tmp
);
unlink
(
tmp
);
...
...
This diff is collapsed.
Click to expand it.
thumbnail.c
+
2
−
0
View file @
fcfdcfbb
...
@@ -98,6 +98,8 @@ int main(int argc, char *argv[])
...
@@ -98,6 +98,8 @@ int main(int argc, char *argv[])
if
(
err
=
av_write_trailer
(
mux
))
if
(
err
=
av_write_trailer
(
mux
))
job_failed
(
"Error writing trailer to temporary file: %s"
,
av_err2str
(
err
));
job_failed
(
"Error writing trailer to temporary file: %s"
,
av_err2str
(
err
));
avio_closep
(
&
mux
->
pb
);
avio_closep
(
&
mux
->
pb
);
if
(
!
filesize
(
tmp
))
job_failed
(
"Sanity check failed: Output file is empty"
);
if
(
rename
(
tmp
,
dest
))
if
(
rename
(
tmp
,
dest
))
job_failed
(
"Overwriting output file failed: %s"
,
strerror
(
errno
));
job_failed
(
"Overwriting output file failed: %s"
,
strerror
(
errno
));
unlink
(
tmp
);
unlink
(
tmp
);
...
...
This diff is collapsed.
Click to expand it.
transcode.c
+
4
−
0
View file @
fcfdcfbb
...
@@ -274,6 +274,7 @@ int main(int argc, char *argv[])
...
@@ -274,6 +274,7 @@ int main(int argc, char *argv[])
output
=
jlookup
(
argv
[
4
],
"output"
);
output
=
jlookup
(
argv
[
4
],
"output"
);
outpath
=
mprintf
(
"%s/%s"
,
getenv
(
WORKER_RELEASED
),
jstr
(
jlookup
(
output
,
"path"
),
""
));
outpath
=
mprintf
(
"%s/%s"
,
getenv
(
WORKER_RELEASED
),
jstr
(
jlookup
(
output
,
"path"
),
""
));
tmppath
=
mprintf
(
"%s/.tmp-%i"
,
getenv
(
WORKER_TMP
),
jobid
);
tmppath
=
mprintf
(
"%s/.tmp-%i"
,
getenv
(
WORKER_TMP
),
jobid
);
overwrite_check
(
outpath
);
demux
=
0
;
demux
=
0
;
opts
=
0
;
opts
=
0
;
...
@@ -356,6 +357,9 @@ int main(int argc, char *argv[])
...
@@ -356,6 +357,9 @@ int main(int argc, char *argv[])
if
(
err
=
av_write_trailer
(
mux
))
if
(
err
=
av_write_trailer
(
mux
))
job_failed
(
"Error writing trailer to temporary file"
,
av_err2str
(
err
));
job_failed
(
"Error writing trailer to temporary file"
,
av_err2str
(
err
));
avio_closep
(
&
mux
->
pb
);
avio_closep
(
&
mux
->
pb
);
if
(
!
filesize
(
tmppath
))
job_failed
(
"Sanity check failed: Output file is empty"
);
overwrite_check
(
outpath
);
if
(
rename
(
tmppath
,
outpath
))
if
(
rename
(
tmppath
,
outpath
))
job_failed
(
"Overwriting output file
\"
%s
\"
failed: %s"
,
outpath
,
strerror
(
errno
));
job_failed
(
"Overwriting output file
\"
%s
\"
failed: %s"
,
outpath
,
strerror
(
errno
));
unlink
(
tmppath
);
unlink
(
tmppath
);
...
...
This diff is collapsed.
Click to expand it.
util.h
+
1
−
0
View file @
fcfdcfbb
...
@@ -16,6 +16,7 @@ char *hashfile(char *path);
...
@@ -16,6 +16,7 @@ char *hashfile(char *path);
double
fileduration
(
char
*
path
);
double
fileduration
(
char
*
path
);
size_t
filesize
(
char
*
path
);
size_t
filesize
(
char
*
path
);
char
*
json_fileinfo
(
char
*
path
);
char
*
json_fileinfo
(
char
*
path
);
void
overwrite_check
(
char
*
path
);
#define WORKER_APIKEY "WORKER_APIKEY"
#define WORKER_APIKEY "WORKER_APIKEY"
#define WORKER_APIBASE "WORKER_APIBASE"
#define WORKER_APIBASE "WORKER_APIBASE"
...
...
This diff is collapsed.
Click to expand it.
util/overwrite_check.c
0 → 100644
+
14
−
0
View file @
fcfdcfbb
#include
<unistd.h>
#include
<sys/stat.h>
#include
"../util.h"
void
overwrite_check
(
char
*
path
)
{
struct
stat
s
;
if
(
stat
(
path
,
&
s
)
||
!
s
.
st_size
)
return
;
/* We can overwrite non-existing or empty files */
if
(
s
.
st_uid
!=
getuid
())
job_failed
(
"Refusing to overwrite output file
\"
%s
\"
: File was not created by worker"
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment