diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/firejail/fs_hostname.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/firejail/fs_hostname.c b/src/firejail/fs_hostname.c index fd823b812..1884f6597 100644 --- a/src/firejail/fs_hostname.c +++ b/src/firejail/fs_hostname.c | |||
@@ -124,6 +124,7 @@ void fs_resolvconf(void) { | |||
124 | if (asprintf(&dest, "%s/%s", RUN_DNS_ETC, entry->d_name) == -1) | 124 | if (asprintf(&dest, "%s/%s", RUN_DNS_ETC, entry->d_name) == -1) |
125 | errExit("asprintf"); | 125 | errExit("asprintf"); |
126 | 126 | ||
127 | int symlink_done = 0; | ||
127 | if (is_link(src)) { | 128 | if (is_link(src)) { |
128 | char *rp =realpath(src, NULL); | 129 | char *rp =realpath(src, NULL); |
129 | if (rp == NULL) { | 130 | if (rp == NULL) { |
@@ -133,14 +134,19 @@ void fs_resolvconf(void) { | |||
133 | } | 134 | } |
134 | if (symlink(rp, dest)) | 135 | if (symlink(rp, dest)) |
135 | errExit("symlink"); | 136 | errExit("symlink"); |
137 | else | ||
138 | symlink_done = 1; | ||
136 | } | 139 | } |
137 | else if (S_ISDIR(s.st_mode)) | 140 | else if (S_ISDIR(s.st_mode)) |
138 | create_empty_dir_as_root(dest, s.st_mode); | 141 | create_empty_dir_as_root(dest, s.st_mode); |
139 | else | 142 | else |
140 | create_empty_file_as_root(dest, s.st_mode); | 143 | create_empty_file_as_root(dest, s.st_mode); |
144 | |||
141 | // bind-mount src on top of dest | 145 | // bind-mount src on top of dest |
142 | if (mount(src, dest, NULL, MS_BIND|MS_REC, NULL) < 0) | 146 | if (!symlink_done) { |
143 | errExit("mount bind mirroring /etc"); | 147 | if (mount(src, dest, NULL, MS_BIND|MS_REC, NULL) < 0) |
148 | errExit("mount bind mirroring /etc"); | ||
149 | } | ||
144 | fs_logger2("clone", src); | 150 | fs_logger2("clone", src); |
145 | 151 | ||
146 | free(src); | 152 | free(src); |