Error checking and marking in preserve_static_entr

Appends "# rhosts begin\n" after static entries
Cleanly errors out if failes to write to tmp file
stable
Justin Reichardt 2021-08-26 15:13:36 -05:00
parent 8c377d6234
commit 66251c6c2a
1 changed files with 11 additions and 0 deletions

View File

@ -136,10 +136,21 @@ int preserve_static_entries(){
if (strncmp(buff, "# rhosts begin", 14) == 0){c = EOF;}
if (c == '\n'){
rc = fputs(buff, tmpf);
if (rc == EOF){
fclose(hostsf);
fclose(tmpf);
return 1;
}
printf("%s",buff);
buff[0] = '\0';
}
}while ( c != EOF);
rc = fputs("# rhosts begin\n", tmpf);
if (rc == EOF){
fclose(hostsf);
fclose(tmpf);
return 1;
}