diff --git a/kpatch-build/create-diff-object.c b/kpatch-build/create-diff-object.c index cee8adf..8a41158 100644 --- a/kpatch-build/create-diff-object.c +++ b/kpatch-build/create-diff-object.c @@ -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); diff --git a/kpatch-build/create-klp-module.c b/kpatch-build/create-klp-module.c index e0b62e6..d1b03fe 100644 --- a/kpatch-build/create-klp-module.c +++ b/kpatch-build/create-klp-module.c @@ -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); diff --git a/kpatch-build/create-kpatch-module.c b/kpatch-build/create-kpatch-module.c index ac1bc88..2884f93 100644 --- a/kpatch-build/create-kpatch-module.c +++ b/kpatch-build/create-kpatch-module.c @@ -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); diff --git a/kpatch-build/kpatch-elf.c b/kpatch-build/kpatch-elf.c index 377dc7f..7e272e2 100644 --- a/kpatch-build/kpatch-elf.c +++ b/kpatch-build/kpatch-elf.c @@ -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"); diff --git a/kpatch-build/kpatch-elf.h b/kpatch-build/kpatch-elf.h index d2bb454..36f500a 100644 --- a/kpatch-build/kpatch-elf.h +++ b/kpatch-build/kpatch-elf.h @@ -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_ */