···11#!/bin/sh
22set -e
3344+echo ">>> Correcting permissions"
55+setcap cap_sys_rawio,cap_sys_resource+ep /usr/bin/darlingserver
66+setcap cap_sys_rawio,cap_sys_resource+ep /usr/libexec/darling/usr/libexec/darling/mldr
77+setcap cap_sys_rawio,cap_sys_resource+ep /usr/libexec/darling/usr/libexec/darling/mldr32
88+49echo ">>> Shutting down old instances of Darling"
510bash /usr/lib/darling/shutdown-user.sh
+17-5
src/startup/mldr/loader.c
···174174 rv = mmap((void*)addr, seg->vmsize, useprot, MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED_NOREPLACE, -1, 0);
175175 if (rv == (void*)MAP_FAILED)
176176 {
177177- if (addr == 0 && useprot == 0) {
177177+ if (seg->vmaddr == 0 && useprot == 0) {
178178 // this is the PAGEZERO segment;
179179 // if we can't map it, assume everything is fine and the system has already made that area inaccessible
180180 rv = 0;
···191191 MAP_ANONYMOUS | MAP_PRIVATE | MAP_FIXED_NOREPLACE, -1, 0);
192192 if (rv == (void*)MAP_FAILED)
193193 {
194194- fprintf(stderr, "Cannot mmap segment %s at %p: %s\n", seg->segname, (void*)(uintptr_t)seg->vmaddr, strerror(errno));
195195- exit(1);
194194+ if (seg->vmaddr == 0 && useprot == 0) {
195195+ // this is the PAGEZERO segment;
196196+ // if we can't map it, assume everything is fine and the system has already made that area inaccessible
197197+ rv = 0;
198198+ } else {
199199+ fprintf(stderr, "Cannot mmap segment %s at %p: %s\n", seg->segname, (void*)(uintptr_t)seg->vmaddr, strerror(errno));
200200+ exit(1);
201201+ }
196202 }
197203 }
198204 }
···208214 flag | MAP_PRIVATE, fd, seg->fileoff + fat_offset);
209215 if (rv == (void*)MAP_FAILED)
210216 {
211211- fprintf(stderr, "Cannot mmap segment %s at %p: %s\n", seg->segname, (void*)(uintptr_t)seg->vmaddr, strerror(errno));
212212- exit(1);
217217+ if (seg->vmaddr == 0 && useprot == 0) {
218218+ // this is the PAGEZERO segment;
219219+ // if we can't map it, assume everything is fine and the system has already made that area inaccessible
220220+ rv = 0;
221221+ } else {
222222+ fprintf(stderr, "Cannot mmap segment %s at %p: %s\n", seg->segname, (void*)(uintptr_t)seg->vmaddr, strerror(errno));
223223+ exit(1);
224224+ }
213225 }
214226215227 if (seg->fileoff == 0)