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
be4cc756
Commit
be4cc756
authored
7 years ago
by
Julian Rother
Browse files
Options
Downloads
Patches
Plain Diff
Extended overwrite_check to check source file hash
parent
b4e10d39
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
remux.c
+4
-3
4 additions, 3 deletions
remux.c
transcode.c
+2
-2
2 additions, 2 deletions
transcode.c
util.h
+1
-1
1 addition, 1 deletion
util.h
util/overwrite_check.c
+3
-1
3 additions, 1 deletion
util/overwrite_check.c
with
10 additions
and
7 deletions
remux.c
+
4
−
3
View file @
be4cc756
...
...
@@ -7,7 +7,7 @@ int main(int argc, char *argv[])
{
int
i
,
err
;
int
*
idxmap
;
char
*
p
,
*
path
,
*
tmp
;
char
*
p
,
*
path
,
*
srcpath
,
*
tmp
;
AVFormatContext
*
demux
,
*
mux
;
AVPacket
pkt
;
AVStream
*
stream
;
...
...
@@ -22,8 +22,9 @@ int main(int argc, char *argv[])
jobid
=
atoi
(
argv
[
1
]);
path
=
mprintf
(
"%s/%s"
,
getenv
(
WORKER_RELEASED
),
jstr
(
jlookup
(
argv
[
4
],
"path"
),
""
));
srcpath
=
mprintf
(
"%s/%s"
,
getenv
(
WORKER_RAW
),
jstr
(
jlookup
(
argv
[
4
],
"srcpath"
),
""
));
tmp
=
mprintf
(
"%s/.tmp-%i"
,
getenv
(
WORKER_TMP
),
jobid
);
overwrite_check
(
path
);
overwrite_check
(
path
,
srcpath
,
jstr
(
jlookup
(
argv
[
4
],
"srchash"
),
""
)
);
ping_job
(
jobid
,
"running"
,
0
);
demux
=
0
;
...
...
@@ -79,7 +80,7 @@ int main(int argc, char *argv[])
avio_closep
(
&
mux
->
pb
);
if
(
!
filesize
(
tmp
))
job_failed
(
"Sanity check failed: Output file is empty"
);
overwrite_check
(
path
);
overwrite_check
(
path
,
srcpath
,
jstr
(
jlookup
(
argv
[
4
],
"srchash"
),
""
)
);
if
(
rename
(
tmp
,
path
))
job_failed
(
"Overwriting output file failed: %s"
,
strerror
(
errno
));
unlink
(
tmp
);
...
...
This diff is collapsed.
Click to expand it.
transcode.c
+
2
−
2
View file @
be4cc756
...
...
@@ -274,7 +274,7 @@ int main(int argc, char *argv[])
output
=
jlookup
(
argv
[
4
],
"output"
);
outpath
=
mprintf
(
"%s/%s"
,
getenv
(
WORKER_RELEASED
),
jstr
(
jlookup
(
output
,
"path"
),
""
));
tmppath
=
mprintf
(
"%s/.tmp-%i"
,
getenv
(
WORKER_TMP
),
jobid
);
overwrite_check
(
outpath
);
overwrite_check
(
outpath
,
inpath
,
jstr
(
jlookup
(
input
,
"hash"
),
""
)
);
demux
=
0
;
opts
=
0
;
...
...
@@ -359,7 +359,7 @@ int main(int argc, char *argv[])
avio_closep
(
&
mux
->
pb
);
if
(
!
filesize
(
tmppath
))
job_failed
(
"Sanity check failed: Output file is empty"
);
overwrite_check
(
outpath
);
overwrite_check
(
outpath
,
0
,
0
);
if
(
rename
(
tmppath
,
outpath
))
job_failed
(
"Overwriting output file
\"
%s
\"
failed: %s"
,
outpath
,
strerror
(
errno
));
unlink
(
tmppath
);
...
...
This diff is collapsed.
Click to expand it.
util.h
+
1
−
1
View file @
be4cc756
...
...
@@ -16,7 +16,7 @@ char *hashfile(char *path);
double
fileduration
(
char
*
path
);
size_t
filesize
(
char
*
path
);
char
*
json_fileinfo
(
char
*
path
);
void
overwrite_check
(
char
*
path
);
void
overwrite_check
(
char
*
path
,
char
*
srcpath
,
char
*
srchash
);
int
checktime
(
time_t
min
);
#define WORKER_APIKEY "WORKER_APIKEY"
...
...
This diff is collapsed.
Click to expand it.
util/overwrite_check.c
+
3
−
1
View file @
be4cc756
...
...
@@ -3,11 +3,13 @@
#include
"../util.h"
void
overwrite_check
(
char
*
path
)
void
overwrite_check
(
char
*
path
,
char
*
srcpath
,
char
*
srchash
)
{
struct
stat
s
;
if
(
stat
(
path
,
&
s
)
||
!
s
.
st_size
)
return
;
/* We can overwrite non-existing or empty files */
if
(
srcpath
&&
strcmp
(
hashfile
(
srcpath
),
srchash
))
job_failed
(
"Refusing to overwrite output file
\"
%s
\"
: Source file hash mismatch"
,
path
);
if
(
s
.
st_uid
!=
getuid
())
job_failed
(
"Refusing to overwrite output file
\"
%s
\"
: File was not created by worker"
,
path
);
}
...
...
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