this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

First successful run under vchroot

+81 -70
-7
CMakeLists.txt
··· 107 107 InstallSymlink(/Volumes/SystemRoot/etc/group ${CMAKE_INSTALL_PREFIX}/libexec/darling/etc/group) 108 108 InstallSymlink(/Volumes/SystemRoot/etc/localtime ${CMAKE_INSTALL_PREFIX}/libexec/darling/etc/localtime) 109 109 110 - install(DIRECTORY DESTINATION libexec/darling/etc/ld.so.conf.d) 111 - install(DIRECTORY DESTINATION libexec/darling/etc/fonts/conf.d) 112 - if(NOT DEBIAN_PACKAGING) 113 - install(CODE "execute_process(COMMAND bash ${DARLING_TOP_DIRECTORY}/src/setup-ld-so.sh WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/libexec/darling)") 114 - install(CODE "execute_process(COMMAND bash ${DARLING_TOP_DIRECTORY}/src/setup-fonts.sh WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/libexec/darling)") 115 - endif(NOT DEBIAN_PACKAGING) 116 - 117 110 InstallSymlink(/Volumes/SystemRoot/lib ${CMAKE_INSTALL_PREFIX}/libexec/darling/lib) 118 111 InstallSymlink(/Volumes/SystemRoot/lib64 ${CMAKE_INSTALL_PREFIX}/libexec/darling/lib64) 119 112 InstallSymlink(/Volumes/SystemRoot/usr/lib64 ${CMAKE_INSTALL_PREFIX}/libexec/darling/usr/lib64)
-5
src/kernel/emulation/linux/fcntl/openat.c
··· 57 57 strcpy(vc.path, filename); 58 58 ret = vchroot_expand(&vc); 59 59 if (ret < 0) { 60 - __simple_kprintf("vchroot_expand failed for %s: %d\n", filename, ret); 61 60 return errno_linux_to_bsd(ret); 62 61 } 63 - __simple_kprintf("vchroot_expand: %s -> %s\n", filename, vc.path); 64 62 65 63 ret = LINUX_SYSCALL(__NR_openat, vc.dfd, vc.path, linux_flags, mode); 66 64 if (ret < 0) 67 - { 68 - __simple_kprintf("open failed with error %d\n", ret); 69 65 ret = errno_linux_to_bsd(ret); 70 - } 71 66 72 67 return ret; 73 68 }
+19
src/kernel/emulation/linux/network/bind.c
··· 7 7 8 8 extern void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n); 9 9 10 + #include "../vchroot_expand.h" 11 + #include "../bsdthread/per_thread_wd.h" 12 + 10 13 long sys_bind(int fd, const void* name, int socklen) 11 14 { 12 15 int ret; ··· 19 22 memcpy(fixed, name, socklen); 20 23 21 24 fixed->linux_family = sfamily_bsd_to_linux(fixed->bsd_family); 25 + 26 + if (fixed->linux_family == LINUX_PF_LOCAL) 27 + { 28 + struct vchroot_expand_args vc; 29 + vc.flags = VCHROOT_FOLLOW; 30 + vc.dfd = get_perthread_wd(); 31 + 32 + strcpy(vc.path, fixed->sun_path); 33 + 34 + ret = vchroot_expand(&vc); 35 + if (ret < 0) 36 + return errno_linux_to_bsd(ret); 37 + 38 + strncpy(fixed->sun_path, vc.path, sizeof(fixed->sun_path) - 1); 39 + fixed->sun_path[sizeof(fixed->sun_path) - 1] = '\0'; 40 + } 22 41 23 42 #ifdef __NR_socketcall 24 43 ret = LINUX_SYSCALL(__NR_socketcall, LINUX_SYS_BIND, ((long[6]) { fd, fixed, socklen }));
+19
src/kernel/emulation/linux/network/connect.c
··· 9 9 10 10 extern void *memcpy(void *dest, const void *src, __SIZE_TYPE__ n); 11 11 12 + #include "../vchroot_expand.h" 13 + #include "../bsdthread/per_thread_wd.h" 14 + 12 15 long sys_connect(int fd, const void* name, int socklen) 13 16 { 14 17 CANCELATION_POINT(); ··· 28 31 memcpy(fixed, name, socklen); 29 32 30 33 fixed->linux_family = sfamily_bsd_to_linux(fixed->bsd_family); 34 + 35 + if (fixed->linux_family == LINUX_PF_LOCAL) 36 + { 37 + struct vchroot_expand_args vc; 38 + vc.flags = VCHROOT_FOLLOW; 39 + vc.dfd = get_perthread_wd(); 40 + 41 + strcpy(vc.path, fixed->sun_path); 42 + 43 + ret = vchroot_expand(&vc); 44 + if (ret < 0) 45 + return errno_linux_to_bsd(ret); 46 + 47 + strncpy(fixed->sun_path, vc.path, sizeof(fixed->sun_path) - 1); 48 + fixed->sun_path[sizeof(fixed->sun_path) - 1] = '\0'; 49 + } 31 50 32 51 #ifdef __NR_socketcall 33 52 ret = LINUX_SYSCALL(__NR_socketcall, LINUX_SYS_CONNECT, ((long[6]) { fd, fixed, socklen }));
+4
src/kernel/emulation/linux/network/duct.h
··· 17 17 unsigned char bsd_family; 18 18 }; 19 19 }; 20 + union 21 + { 22 + char sun_path[104]; 23 + }; 20 24 }; 21 25 22 26 #define LINUX_PF_LOCAL 1
+31 -19
src/kernel/emulation/linux/vchroot_userspace.c
··· 49 49 #define LINUX_S_IFMT 00170000 50 50 #define LINUX_S_IFLNK 0120000 51 51 52 - #define __simple_printf(...) 52 + #define __simple_printf __simple_kprintf 53 53 54 54 #endif 55 55 ··· 72 72 73 73 int symlink_depth; 74 74 bool unknown_component; 75 + bool follow; 75 76 }; 76 77 77 78 static int vchroot_run(const char* path, struct context* ctxt); ··· 136 137 ctxt.symlink_depth = 0; 137 138 ctxt.current_root = prefix_path; 138 139 ctxt.current_root_len = prefix_path_len; 140 + ctxt.follow = !!(args->flags & VCHROOT_FOLLOW); 139 141 140 142 const char* input_path = args->path; 141 143 ··· 284 286 } 285 287 else if ((st.st_mode & LINUX_S_IFMT) == LINUX_S_IFLNK) 286 288 { 287 - char link[512]; 288 - int rv; 289 + // Follow symlink if follow is true or if we haven't reached the end of the input path yet 290 + if (ctxt->follow || *end) 291 + { 292 + char link[512]; 293 + int rv; 289 294 290 - rv = LINUX_SYSCALL(__NR_readlink, ctxt->current_path, link, sizeof(link) - 1); 295 + rv = LINUX_SYSCALL(__NR_readlink, ctxt->current_path, link, sizeof(link) - 1); 291 296 292 - if (rv < 0) 293 - return rv; 297 + if (rv < 0) 298 + return rv; 294 299 295 - link[rv] = '\0'; 300 + link[rv] = '\0'; 296 301 297 - // Remove the last component (because it will be substituted with symlink contents) 298 - if (link[0] != '/') // Only bother to do that if we know that the symlink is not absolute 299 - { 300 - ctxt->current_path_len = prevlen - 1; // kill the last slash as well 301 - ctxt->current_path[ctxt->current_path_len] = '\0'; 302 - } 302 + // Remove the last component (because it will be substituted with symlink contents) 303 + if (link[0] != '/') // Only bother to do that if we know that the symlink is not absolute 304 + { 305 + ctxt->current_path_len = prevlen - 1; // kill the last slash as well 306 + ctxt->current_path[ctxt->current_path_len] = '\0'; 307 + } 308 + 309 + // Symbolic link resolution 310 + const bool orig_follow = ctxt->follow; 311 + 312 + ctxt->follow = true; 313 + ctxt->symlink_depth++; 314 + 315 + rv = vchroot_run(link, ctxt); 303 316 304 - // Symbolic link resolution 305 - ctxt->symlink_depth++; 306 - rv = vchroot_run(link, ctxt); 307 - ctxt->symlink_depth--; 317 + ctxt->symlink_depth--; 318 + ctxt->follow = orig_follow; 308 319 309 - if (rv != 0) 310 - return rv; 320 + if (rv != 0) 321 + return rv; 322 + } 311 323 } 312 324 } 313 325
-18
src/setup-fonts.sh
··· 1 - #! /bin/bash 2 - 3 - # This runs as root, 4 - # with the current directory set to ${CMAKE_INSTALL_PREFIX}/libexec/darling 5 - 6 - root=/Volumes/SystemRoot 7 - 8 - for file in $(find /etc/fonts/ -type f); do 9 - mkdir -p $(dirname .$file) 10 - sed "s|/usr/|$root/usr/|" $file > .$file 11 - done 12 - 13 - for link in $(find /etc/fonts/ -type l); do 14 - if [[ ! -L .$link ]]; then 15 - mkdir -p $(dirname .$link) 16 - ln -s $root$(realpath $link) .$link 17 - fi 18 - done
-19
src/setup-ld-so.sh
··· 1 - #! /bin/bash 2 - 3 - # This runs as root, 4 - # with the current directory set to ${CMAKE_INSTALL_PREFIX}/libexec/darling 5 - 6 - for file in /etc/ld.so.conf $(find -L /etc/ld.so.conf.d/ -type f); do 7 - # Copy lines from e.g. /etc/ld.so.conf into ./etc/ld.so.conf, 8 - # prepending "/Volumes/SystemRoot" to each line that starts with a slash 9 - awk '/^\// { print "/Volumes/SystemRoot" $0 }; /^[^\/]/' $file > .$file 10 - done 11 - 12 - # These are the defaults used by the ELF dynamic linker. 13 - # They don't need to be explicitly listed in /etc/ld.so.conf. 14 - cat > ./etc/ld.so.conf.d/defaults.conf <<END 15 - /Volumes/SystemRoot/lib 16 - /Volumes/SystemRoot/usr/lib 17 - END 18 - 19 - unshare --mount bash -c "mount --rbind / Volumes/SystemRoot && ldconfig -r . -X"
+6 -1
src/startup/darling.c
··· 539 539 // Connect to the shellspawn daemon in the container 540 540 addr.sun_family = AF_UNIX; 541 541 #if USE_LINUX_4_11_HACK 542 - strcpy(addr.sun_path, SHELLSPAWN_SOCKPATH); 542 + addr.sun_path[0] = '\0'; 543 + 544 + if (g_useVchroot) 545 + strcpy(addr.sun_path, prefix); 546 + 547 + strcat(addr.sun_path, SHELLSPAWN_SOCKPATH); 543 548 #else 544 549 snprintf(addr.sun_path, sizeof(addr.sun_path), "%s" SHELLSPAWN_SOCKPATH, prefix); 545 550 #endif
+2 -1
src/vchroot/vchroot.c
··· 6 6 #include <lkm/api.h> 7 7 8 8 extern int lkm_call(int nr, ...); 9 + extern int __darling_vchroot(int dfd); 9 10 10 11 int main(int argc, const char** argv) 11 12 { ··· 37 38 return 2; 38 39 } 39 40 40 - if (lkm_call(NR_vchroot, dfd) == -1) 41 + if (__darling_vchroot(dfd) < 0) 41 42 { 42 43 perror("vchroot"); 43 44 return 3;