Merge pull request #1144 from joe-lawrence/obj-output-perms

kpatch-elf: pass new ELF output file mode to kpatch_write_output_elf()
This commit is contained in:
Joe Lawrence 2020-09-28 09:10:04 -04:00 committed by GitHub
commit 141f57f016
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 7 deletions

View File

@ -3796,7 +3796,7 @@ int main(int argc, char *argv[])
kpatch_create_strtab(kelf_out);
kpatch_create_symtab(kelf_out);
kpatch_dump_kelf(kelf_out);
kpatch_write_output_elf(kelf_out, kelf_patched->elf, output_obj);
kpatch_write_output_elf(kelf_out, kelf_patched->elf, output_obj, 0664);
lookup_close(lookup);
kpatch_elf_free(kelf_patched);

View File

@ -503,7 +503,7 @@ int main(int argc, char *argv[])
kpatch_create_strtab(kelf);
kpatch_create_symtab(kelf);
kpatch_write_output_elf(kelf, kelf->elf, arguments.args[1]);
kpatch_write_output_elf(kelf, kelf->elf, arguments.args[1], 0664);
kpatch_elf_teardown(kelf);
kpatch_elf_free(kelf);

View File

@ -257,7 +257,7 @@ int main(int argc, char *argv[])
kpatch_create_strtab(kelf);
kpatch_create_symtab(kelf);
kpatch_write_output_elf(kelf, kelf->elf, arguments.args[1]);
kpatch_write_output_elf(kelf, kelf->elf, arguments.args[1], 0664);
kpatch_elf_teardown(kelf);
kpatch_elf_free(kelf);

View File

@ -759,7 +759,8 @@ void kpatch_rebuild_rela_section_data(struct section *sec)
ERROR("size mismatch in rebuilt rela section");
}
void kpatch_write_output_elf(struct kpatch_elf *kelf, Elf *elf, char *outfile)
void kpatch_write_output_elf(struct kpatch_elf *kelf, Elf *elf, char *outfile,
mode_t mode)
{
int fd;
struct section *sec;
@ -770,8 +771,7 @@ void kpatch_write_output_elf(struct kpatch_elf *kelf, Elf *elf, char *outfile)
Elf_Data *data;
GElf_Shdr sh;
/* TODO make this argv */
fd = creat(outfile, 0777);
fd = creat(outfile, mode);
if (fd == -1)
ERROR("creat");

View File

@ -164,7 +164,8 @@ struct section *create_section_pair(struct kpatch_elf *kelf, char *name,
void kpatch_remove_and_free_section(struct kpatch_elf *kelf, char *secname);
void kpatch_reindex_elements(struct kpatch_elf *kelf);
void kpatch_rebuild_rela_section_data(struct section *sec);
void kpatch_write_output_elf(struct kpatch_elf *kelf, Elf *elf, char *outfile);
void kpatch_write_output_elf(struct kpatch_elf *kelf, Elf *elf, char *outfile,
mode_t mode);
void kpatch_elf_teardown(struct kpatch_elf *kelf);
void kpatch_elf_free(struct kpatch_elf *kelf);
#endif /* _KPATCH_ELF_H_ */