diff options
-rw-r--r-- | src/firejail/chroot.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/firejail/chroot.c b/src/firejail/chroot.c index c99af1d52..4eff84494 100644 --- a/src/firejail/chroot.c +++ b/src/firejail/chroot.c | |||
@@ -141,14 +141,14 @@ static void copy_resolvconf(int parentfd) { | |||
141 | fwarning("/etc/resolv.conf not initialized\n"); | 141 | fwarning("/etc/resolv.conf not initialized\n"); |
142 | return; | 142 | return; |
143 | } | 143 | } |
144 | struct stat instat; | 144 | struct stat src; |
145 | if (fstat(in, &instat) == -1) | 145 | if (fstat(in, &src) == -1) |
146 | errExit("fstat"); | 146 | errExit("fstat"); |
147 | // try to detect if resolv.conf has been bind mounted into the chroot | 147 | // try to detect if resolv.conf has been bind mounted into the chroot |
148 | // do nothing in this case in order to not truncate the real file | 148 | // do nothing in this case in order to not truncate the real file |
149 | struct stat outstat; | 149 | struct stat dst; |
150 | if (fstatat(parentfd, "etc/resolv.conf", &outstat, 0) == 0) { | 150 | if (fstatat(parentfd, "etc/resolv.conf", &dst, 0) == 0) { |
151 | if (instat.st_dev == outstat.st_dev && instat.st_ino == outstat.st_ino) { | 151 | if (src.st_dev == dst.st_dev && src.st_ino == dst.st_ino) { |
152 | close(in); | 152 | close(in); |
153 | return; | 153 | return; |
154 | } | 154 | } |
@@ -158,7 +158,7 @@ static void copy_resolvconf(int parentfd) { | |||
158 | int out = openat(parentfd, "etc/resolv.conf", O_CREAT|O_WRONLY|O_TRUNC|O_CLOEXEC, S_IRUSR | S_IWRITE | S_IRGRP | S_IROTH); | 158 | int out = openat(parentfd, "etc/resolv.conf", O_CREAT|O_WRONLY|O_TRUNC|O_CLOEXEC, S_IRUSR | S_IWRITE | S_IRGRP | S_IROTH); |
159 | if (out == -1) | 159 | if (out == -1) |
160 | errExit("open"); | 160 | errExit("open"); |
161 | if (sendfile(out, in, NULL, instat.st_size) == -1) | 161 | if (sendfile(out, in, NULL, src.st_size) == -1) |
162 | errExit("sendfile"); | 162 | errExit("sendfile"); |
163 | close(in); | 163 | close(in); |
164 | close(out); | 164 | close(out); |