aboutsummaryrefslogtreecommitdiffstats
path: root/src/firejail/bandwidth.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/firejail/bandwidth.c')
-rw-r--r--src/firejail/bandwidth.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/firejail/bandwidth.c b/src/firejail/bandwidth.c
index 5ff67b644..22be5b23c 100644
--- a/src/firejail/bandwidth.c
+++ b/src/firejail/bandwidth.c
@@ -130,14 +130,8 @@ static void bandwidth_create_run_file(pid_t pid) {
130 /* coverity[toctou] */ 130 /* coverity[toctou] */
131 FILE *fp = fopen(fname, "w"); 131 FILE *fp = fopen(fname, "w");
132 if (fp) { 132 if (fp) {
133 SET_PERMS_STREAM(fp, 0, 0, 0644);
133 fclose(fp); 134 fclose(fp);
134
135 /* coverity[toctou] */
136 if (chmod(fname, 0644) == -1)
137 errExit("chmod");
138 /* coverity[toctou] */
139 if (chown(fname, 0, 0) == -1)
140 errExit("chown");
141 } 135 }
142 else { 136 else {
143 fprintf(stderr, "Error: cannot create bandwidth file\n"); 137 fprintf(stderr, "Error: cannot create bandwidth file\n");
@@ -180,12 +174,9 @@ void network_set_run_file(pid_t pid) {
180 fprintf(fp, "%s:%s\n", cfg.bridge2.dev, cfg.bridge2.devsandbox); 174 fprintf(fp, "%s:%s\n", cfg.bridge2.dev, cfg.bridge2.devsandbox);
181 if (cfg.bridge3.configured) 175 if (cfg.bridge3.configured)
182 fprintf(fp, "%s:%s\n", cfg.bridge3.dev, cfg.bridge3.devsandbox); 176 fprintf(fp, "%s:%s\n", cfg.bridge3.dev, cfg.bridge3.devsandbox);
183 fclose(fp);
184 177
185 if (chmod(fname, 0644) == -1) 178 SET_PERMS_STREAM(fp, 0, 0, 0644);
186 errExit("chmod"); 179 fclose(fp);
187 if (chown(fname, 0, 0) == -1)
188 errExit("chown");
189 } 180 }
190 else { 181 else {
191 fprintf(stderr, "Error: cannot create network map file\n"); 182 fprintf(stderr, "Error: cannot create network map file\n");