summaryrefslogtreecommitdiff
path: root/distrib
diff options
context:
space:
mode:
authorPaul de Weerd <weerd@cvs.openbsd.org>2008-12-02 01:54:56 +0000
committerPaul de Weerd <weerd@cvs.openbsd.org>2008-12-02 01:54:56 +0000
commit4e9f2fdd95ee369f210c8d4d2e5e77f2c244c2ef (patch)
tree9de91ed0b4dfe2cde1e8214375940f520227d2de /distrib
parent5f2527ce2cff6bfe3b1cef6f835d1294b0c45642 (diff)
Allow the kernelfile to be read-only when doing extraction.
'Sure' deraadt@
Diffstat (limited to 'distrib')
-rw-r--r--distrib/common/elfrdsetroot.c7
-rw-r--r--distrib/common/rdsetroot.c7
2 files changed, 8 insertions, 6 deletions
diff --git a/distrib/common/elfrdsetroot.c b/distrib/common/elfrdsetroot.c
index e6c249311cb..82c44105bf9 100644
--- a/distrib/common/elfrdsetroot.c
+++ b/distrib/common/elfrdsetroot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: elfrdsetroot.c,v 1.17 2008/12/02 01:03:52 deraadt Exp $ */
+/* $OpenBSD: elfrdsetroot.c,v 1.18 2008/12/02 01:54:55 weerd Exp $ */
/* $NetBSD: rdsetroot.c,v 1.2 1995/10/13 16:38:39 gwr Exp $ */
/*
@@ -103,7 +103,7 @@ main(int argc, char *argv[])
usage();
file = argv[0];
- fd = open(file, O_RDWR, 0644);
+ fd = open(file, xflag ? O_RDONLY : O_RDWR, 0644);
if (fd < 0) {
perror(file);
exit(1);
@@ -142,7 +142,8 @@ main(int argc, char *argv[])
* Map in the whole data segment.
* The file offset needs to be page aligned.
*/
- dataseg = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE,
+ dataseg = mmap(NULL, mmap_size,
+ xflag ? PROT_READ : PROT_READ | PROT_WRITE,
MAP_SHARED, fd, mmap_offs);
if (dataseg == MAP_FAILED) {
fprintf(stderr, "%s: can not map data seg\n", file);
diff --git a/distrib/common/rdsetroot.c b/distrib/common/rdsetroot.c
index a993337a4a5..2650d15eb59 100644
--- a/distrib/common/rdsetroot.c
+++ b/distrib/common/rdsetroot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rdsetroot.c,v 1.16 2008/12/02 01:03:52 deraadt Exp $ */
+/* $OpenBSD: rdsetroot.c,v 1.17 2008/12/02 01:54:55 weerd Exp $ */
/* $NetBSD: rdsetroot.c,v 1.2 1995/10/13 16:38:39 gwr Exp $ */
/*
@@ -93,7 +93,7 @@ main(int argc, char *argv[])
usage();
file = argv[0];
- fd = open(file, O_RDWR, 0644);
+ fd = open(file, xflag ? O_RDONLY : O_RDWR, 0644);
if (fd < 0) {
perror(file);
exit(1);
@@ -153,7 +153,8 @@ main(int argc, char *argv[])
data_off -= data_pgoff;
data_len += data_pgoff;
/* map in in... */
- dataseg = mmap(NULL, data_len, PROT_READ | PROT_WRITE,
+ dataseg = mmap(NULL, data_len,
+ xflag ? PROT_READ : PROT_READ | PROT_WRITE,
MAP_SHARED, fd, data_off);
if (dataseg == MAP_FAILED) {
fprintf(stderr, "%s: can not map data seg\n", file);