mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-21 06:45:29 -06:00
fix cppcheck/scan-build problems
This commit is contained in:
parent
6330e0e3e1
commit
dc2f554fde
1 changed files with 5 additions and 6 deletions
|
|
@ -53,7 +53,8 @@ static char *random_hostname(void) {
|
|||
}
|
||||
|
||||
void fs_hostname(void) {
|
||||
const char *hostname = (cfg.hostname)? cfg.hostname: random_hostname();
|
||||
if (!cfg.hostname)
|
||||
cfg.hostname = random_hostname();
|
||||
struct stat s;
|
||||
|
||||
// create a new /etc/hostname
|
||||
|
|
@ -63,11 +64,9 @@ void fs_hostname(void) {
|
|||
|
||||
create_empty_file_as_root(RUN_HOSTNAME_FILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
FILE *fp = fopen(RUN_HOSTNAME_FILE, "we");
|
||||
if (!fp) {
|
||||
fclose(fp);
|
||||
if (!fp)
|
||||
goto errexit;
|
||||
}
|
||||
fprintf(fp, "%s\n", hostname);
|
||||
fprintf(fp, "%s\n", cfg.hostname);
|
||||
SET_PERMS_STREAM(fp, 0, 0, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||
fclose(fp);
|
||||
|
||||
|
|
@ -104,7 +103,7 @@ void fs_hostname(void) {
|
|||
// copy line
|
||||
if (strstr(buf, "127.0.0.1") && done == 0) {
|
||||
done = 1;
|
||||
fprintf(fp2, "127.0.0.1 %s\n", hostname);
|
||||
fprintf(fp2, "127.0.0.1 %s\n", cfg.hostname);
|
||||
}
|
||||
else
|
||||
fprintf(fp2, "%s\n", buf);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue