diff options
Diffstat (limited to 'src/firejail/util.c')
-rw-r--r-- | src/firejail/util.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/firejail/util.c b/src/firejail/util.c index f38b02fd0..4b2e09953 100644 --- a/src/firejail/util.c +++ b/src/firejail/util.c | |||
@@ -171,11 +171,17 @@ void logerr(const char *msg) { | |||
171 | } | 171 | } |
172 | 172 | ||
173 | 173 | ||
174 | // return -1 if error, 0 if no error | 174 | // return -1 if error, 0 if no error; if destname already exists, return error |
175 | int copy_file(const char *srcname, const char *destname, uid_t uid, gid_t gid, mode_t mode) { | 175 | int copy_file(const char *srcname, const char *destname, uid_t uid, gid_t gid, mode_t mode) { |
176 | assert(srcname); | 176 | assert(srcname); |
177 | assert(destname); | 177 | assert(destname); |
178 | 178 | ||
179 | struct stat s; | ||
180 | if (stat(destname, &s) == 0) { | ||
181 | fprintf(stderr, "Error: file %s already exists\n", destname); | ||
182 | return -1; | ||
183 | } | ||
184 | |||
179 | // open source | 185 | // open source |
180 | int src = open(srcname, O_RDONLY); | 186 | int src = open(srcname, O_RDONLY); |
181 | if (src < 0) { | 187 | if (src < 0) { |