aboutsummaryrefslogtreecommitdiffstats
path: root/src/fcopy/main.c
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2017-10-13 23:01:43 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2017-10-13 23:01:43 -0400
commit1bb9bb67022cd5c4eed127b920a6c2f5dd00b3e1 (patch)
treedfbb1b36f69e01c67e9da0266a66e6bf6b5880e3 /src/fcopy/main.c
parentMerge branch 'master' of https://github.com/netblue30/firejail (diff)
downloadfirejail-1bb9bb67022cd5c4eed127b920a6c2f5dd00b3e1.tar.gz
firejail-1bb9bb67022cd5c4eed127b920a6c2f5dd00b3e1.tar.zst
firejail-1bb9bb67022cd5c4eed127b920a6c2f5dd00b3e1.zip
fcopy fix: remove warnings for private-bin python* on Arch Linux
Diffstat (limited to 'src/fcopy/main.c')
-rw-r--r--src/fcopy/main.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/fcopy/main.c b/src/fcopy/main.c
index e7b4ffa8a..cbb551125 100644
--- a/src/fcopy/main.c
+++ b/src/fcopy/main.c
@@ -41,6 +41,11 @@ static void copy_file(const char *srcname, const char *destname, mode_t mode, ui
41 assert(destname); 41 assert(destname);
42 mode &= 07777; 42 mode &= 07777;
43 43
44 // don't copy the file if it is already there
45 struct stat s;
46 if (stat(destname, &s) == 0)
47 return;
48
44 // open source 49 // open source
45 int src = open(srcname, O_RDONLY); 50 int src = open(srcname, O_RDONLY);
46 if (src < 0) { 51 if (src < 0) {
@@ -113,10 +118,18 @@ void copy_link(const char *target, const char *linkpath, mode_t mode, uid_t uid,
113 (void) mode; 118 (void) mode;
114 (void) uid; 119 (void) uid;
115 (void) gid; 120 (void) gid;
121
122 // if the link is already there, don't create it
123 struct stat s;
124 if (stat(linkpath, &s) == 0)
125 return;
126
116 char *rp = realpath(target, NULL); 127 char *rp = realpath(target, NULL);
117 if (rp) { 128 if (rp) {
118 if (symlink(rp, linkpath) == -1) 129 if (symlink(rp, linkpath) == -1) {
130 free(rp);
119 goto errout; 131 goto errout;
132 }
120 free(rp); 133 free(rp);
121 } 134 }
122 else 135 else
@@ -129,6 +142,7 @@ errout:
129} 142}
130 143
131 144
145
132static int first = 1; 146static int first = 1;
133static int fs_copydir(const char *infname, const struct stat *st, int ftype, struct FTW *sftw) { 147static int fs_copydir(const char *infname, const struct stat *st, int ftype, struct FTW *sftw) {
134 (void) st; 148 (void) st;