aboutsummaryrefslogtreecommitdiffstats
path: root/src/fcopy
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2016-11-17 08:04:52 -0500
committerLibravatar netblue30 <netblue30@yahoo.com>2016-11-17 08:04:52 -0500
commitcee0a4d375092f5c9e1097ce056dd10435b33e49 (patch)
tree36429445464c22b9e545229e3169093a39da28f8 /src/fcopy
parenttesting (diff)
downloadfirejail-cee0a4d375092f5c9e1097ce056dd10435b33e49.tar.gz
firejail-cee0a4d375092f5c9e1097ce056dd10435b33e49.tar.zst
firejail-cee0a4d375092f5c9e1097ce056dd10435b33e49.zip
testing
Diffstat (limited to 'src/fcopy')
-rw-r--r--src/fcopy/main.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/fcopy/main.c b/src/fcopy/main.c
index 82d829bba..ca2643e7d 100644
--- a/src/fcopy/main.c
+++ b/src/fcopy/main.c
@@ -188,22 +188,19 @@ static int fs_copydir(const char *infname, const struct stat *st, int ftype, str
188static char *check(const char *src) { 188static char *check(const char *src) {
189 struct stat s; 189 struct stat s;
190 char *rsrc = realpath(src, NULL); 190 char *rsrc = realpath(src, NULL);
191 if (!rsrc || stat(rsrc, &s) == -1) { 191 if (!rsrc || stat(rsrc, &s) == -1)
192 fprintf(stderr, "Error fcopy: cannot find %s directory\n", src); 192 goto errexit;
193 exit(1);
194 }
195 193
196 // check uid 194 // check uid
197 if (s.st_uid != getuid() || s.st_gid != getgid()) { 195 if (s.st_uid != getuid() || s.st_gid != getgid())
198 fprintf(stderr, "Error fcopy: uid/gid mismatch for %s\n", rsrc); 196 goto errexit;
199 exit(1);
200 }
201 197
202 // dir, link, regular file 198 // dir, link, regular file
203 if (S_ISDIR(s.st_mode) || S_ISREG(s.st_mode) || S_ISLNK(s.st_mode)) { 199 if (S_ISDIR(s.st_mode) || S_ISREG(s.st_mode) || S_ISLNK(s.st_mode))
204 return rsrc; // normal exit from the function 200 return rsrc; // normal exit from the function
205 } 201
206 fprintf(stderr, "Error fcopy: invalid directory %s\n", rsrc); 202errexit:
203 fprintf(stderr, "Error fcopy: invalid file %s\n", src);
207 exit(1); 204 exit(1);
208} 205}
209 206