this repo has no description
1
fork

Configure Feed

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

Remove gnumake; the preffered way will be to install it from Apple's .pkg along with other tools Integrate darling-dmg, add hdiutil Add fake sudo and sw_vers Add darling-installer submodule (not working yet)

+226 -43
+6 -4
.gitmodules
··· 57 57 path = src/external/bash 58 58 url = ../darling-bash.git 59 59 branch = darling 60 - [submodule "src/external/gnumake"] 61 - path = src/external/gnumake 62 - url = ../darling-gnumake.git 63 - branch = darling 60 + [submodule "src/external/darling-dmg"] 61 + path = src/external/darling-dmg 62 + url = ../darling-dmg.git 63 + [submodule "src/external/installer"] 64 + path = src/external/installer 65 + url = ../darling-installer.git
+1 -1
src/CFF/CFUtilities.c
··· 1 1 2 - #include "CFUtilities.h" 2 + #include "CoreFoundation/CFPriv.h" 3 3 #include <CoreFoundation/CFString.h> 4 4 #include <CoreFoundation/CFData.h> 5 5 #include <CoreFoundation/CFPropertyList.h>
-15
src/CFF/CFUtilities.h
··· 1 - #ifndef CFUTILITIES_H 2 - #define CFUTILITIES_H 3 - 4 - #include <CoreFoundation/CFBase.h> 5 - #include <CoreFoundation/CFDictionary.h> 6 - 7 - typedef int CFSystemVersion; 8 - 9 - CF_EXPORT Boolean _CFExecutableLinkedOnOrAfter(CFSystemVersion version); 10 - 11 - CF_EXPORT CFDictionaryRef _CFCopySystemVersionDictionary(void); 12 - CF_EXPORT CFDictionaryRef _CFCopyServerVersionDictionary(void); 13 - 14 - #endif 15 -
+26
src/CFF/CoreFoundation/CFPriv.h
··· 1 + #ifndef CFUTILITIES_H 2 + #define CFUTILITIES_H 3 + 4 + #include <stddef.h> 5 + #include <stdio.h> 6 + #include <CoreFoundation/CFBase.h> 7 + #include <CoreFoundation/CFDictionary.h> 8 + 9 + typedef int CFSystemVersion; 10 + 11 + extern const CFStringRef _kCFSystemVersionProductNameKey; 12 + extern const CFStringRef _kCFSystemVersionProductCopyrightKey; 13 + extern const CFStringRef _kCFSystemVersionProductVersionKey; 14 + extern const CFStringRef _kCFSystemVersionProductVersionExtraKey; 15 + extern const CFStringRef _kCFSystemVersionProductUserVisibleVersionKey; 16 + extern const CFStringRef _kCFSystemVersionBuildVersionKey; 17 + extern const CFStringRef _kCFSystemVersionProductVersionStringKey; 18 + extern const CFStringRef _kCFSystemVersionBuildStringKey; 19 + 20 + CF_EXPORT Boolean _CFExecutableLinkedOnOrAfter(CFSystemVersion version); 21 + 22 + CF_EXPORT CFDictionaryRef _CFCopySystemVersionDictionary(void); 23 + CF_EXPORT CFDictionaryRef _CFCopyServerVersionDictionary(void); 24 + 25 + #endif 26 +
+4 -1
src/CMakeLists.txt
··· 51 51 add_subdirectory(libdyld) 52 52 add_subdirectory(dyld) 53 53 add_subdirectory(motool) 54 + add_subdirectory(external/darling-dmg) 54 55 55 56 if (FRAMEWORK_COREAUDIO) 56 57 add_subdirectory(AudioToolbox) ··· 111 112 add_subdirectory(external/shell_cmds) 112 113 add_subdirectory(external/file_cmds) 113 114 add_subdirectory(external/bash) 114 - add_subdirectory(external/gnumake) 115 + add_subdirectory(tools) 116 + #add_subdirectory(external/gnumake) 117 + #add_subdirectory(external/ld64) 115 118 116 119 ###################### 117 120 # libc++ & libc++abi #
+4 -4
src/dyld/CMakeLists.txt
··· 37 37 set_target_properties(dyld-bin PROPERTIES OUTPUT_NAME dyld${SUFFIX}) 38 38 target_link_libraries(dyld-bin dyld darling-util mach-o) 39 39 40 - #if (NOT DEFINED SUFFIX OR SUFFIX STREQUAL "64") 40 + if (NOT DEFINED SUFFIX OR SUFFIX STREQUAL "64") 41 41 add_executable(dyldd dyldd.cpp) 42 42 target_link_libraries(dyldd dyld darling-util mach-o) 43 43 install(TARGETS dyldd DESTINATION bin) 44 - install(PROGRAMS darling DESTINATION bin 44 + install(PROGRAMS darling DESTINATION bin 45 45 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ 46 46 GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) 47 - #endif (NOT DEFINED SUFFIX OR SUFFIX STREQUAL "64") 47 + endif (NOT DEFINED SUFFIX OR SUFFIX STREQUAL "64") 48 48 49 - install(TARGETS dyld-bin DESTINATION bin) 49 + install(TARGETS dyld-bin DESTINATION bin) 50 50 51 51 if (CMAKE_INSTALL_LIBDIR STREQUAL "lib64") 52 52 add_executable(dyld-multilib dyld-multilib.c)
+15 -15
src/dyld/darling
··· 22 22 SCRIPTPATH=$(dirname "$SCRIPT") 23 23 DARLING_PREFIX=$(realpath "$SCRIPTPATH/..") 24 24 25 - SYSTEM_ROOT_NAME="system-root" 26 - BIND_DIRECTORIES="dev etc home tmp" 27 - MAKE_DIRECTORIES="Applications Volumes usr" 28 - 29 25 setup_prefix() { 26 + SYSTEM_ROOT_NAME="system-root" 27 + BIND_DIRECTORIES="dev etc home tmp" 28 + MAKE_DIRECTORIES="Applications Volumes usr usr/share" 29 + 30 30 >&2 echo "Setting up prefix at $1" 31 31 32 32 mkdir -p "$1" ··· 43 43 44 44 ln -s home Users 45 45 46 - # TODO: install bash and coreutils 47 46 ln -s "${SYSTEM_ROOT_NAME}${DARLING_PREFIX}/libexec/darling/bin" "bin" 48 47 ln -s "../${SYSTEM_ROOT_NAME}${DARLING_PREFIX}/libexec/darling/usr/bin" "usr/bin" 48 + ln -s "/${SYSTEM_ROOT_NAME}${DARLING_PREFIX}/share/darling" "usr/share/darling" 49 49 50 50 popd >/dev/null 51 51 } ··· 58 58 >&2 echo 59 59 >&2 echo -e "Usage:\tdarling PROGRAM [ARGUMENTS...]\tRun the specified program" 60 60 >&2 echo -e "\tdarling shell\t\t\tStart bash shell in prefix" 61 - >&2 echo -e "\tdarling hdiutil\t\t\tMount DMG disk images" 62 - >&2 echo -e "\tdarling pkgutil\t\t\tInstall PKG packages" 61 + #>&2 echo -e "\tdarling hdiutil\t\t\tMount DMG disk images" 62 + #>&2 echo -e "\tdarling pkgutil\t\t\tInstall PKG packages" 63 63 >&2 echo 64 64 >&2 echo "The prefix is specified by the DPREFIX environment variable." 65 65 >&2 echo "The default DPREFIX is \$HOME/.darling" ··· 87 87 exec "${dyld_path}" "${DPREFIX}/bin/bash" 88 88 fi 89 89 ;; 90 - "hdiutil") 91 - >2& echo "Not implemented yet" 92 - exit 1 93 - ;; 94 - "pkgutil") 95 - >2& echo "Not implemented yet" 96 - exit 1 97 - ;; 90 + #"hdiutil") 91 + # exec "${DPREFIX}/usr/bin/hdiutil" "${@:2}" 92 + # exit $? 93 + # ;; 94 + #"pkgutil") 95 + # >2& echo "Not implemented yet" 96 + # exit 1 97 + # ;; 98 98 "load") 99 99 if [ "$(id -u)" != 0 ]; then 100 100 2>&1 "You need to be root for this command."
+9 -1
src/dyld/dyld.cpp
··· 53 53 try 54 54 { 55 55 MachOMgr* mgr = MachOMgr::instance(); 56 - std::string executable; 56 + std::string executable, unprefixed_argv0; 57 57 58 58 executable = locateBundleExecutable(argv[1]); 59 59 argv[1] = const_cast<char*>(executable.c_str()); ··· 80 80 if (const char* path = getenv("DYLD_TRAMPOLINE")) 81 81 mgr->setUseTrampolines(true, path); 82 82 if (const char* path = getenv("DPREFIX")) 83 + { 83 84 __prefix_set(path); 85 + unprefixed_argv0 = __prefix_untranslate_path(argv[1], strlen(argv[1])); 86 + } 84 87 85 88 if (isELF(argv[1])) 86 89 { ··· 96 99 if (!main) 97 100 throw std::runtime_error("No entry point found in Darling-native executable"); 98 101 102 + if (!unprefixed_argv0.empty()) 103 + argv[1] = (char*) unprefixed_argv0.c_str(); 99 104 exit(main(argc-1, &argv[1], envp)); 100 105 } 101 106 else ··· 109 114 "kernel extensions and other Mach-O files cannot be executed with dyld"); 110 115 } 111 116 117 + if (!unprefixed_argv0.empty()) 118 + argv[1] = (char*) unprefixed_argv0.c_str(); 119 + 112 120 obj->setCommandLine(argc-1, &argv[1], envp); 113 121 114 122 obj->load();
+3 -2
src/kernel/emulation/linux/process/execve.c
··· 129 129 modargvp[i++] = interp; 130 130 if (arg != NULL) 131 131 modargvp[i++] = arg; 132 + modargvp[i] = fname; 132 133 133 134 // Append original arguments 134 - for (j = 0; j < len+1; j++) 135 + for (j = 1; j < len+1; j++) 135 136 modargvp[i+j] = argvp[j]; 136 137 137 138 argvp = modargvp; 138 - fname = modargvp[0]; 139 + fname = (char*) __prefix_translate_path(modargvp[0]); 139 140 } 140 141 else 141 142 {
+6
src/kernel/emulation/linux/unistd/geteuid.c
··· 2 2 #include "../base.h" 3 3 #include "../errno.h" 4 4 #include <asm/unistd.h> 5 + #include <stddef.h> 6 + 7 + extern char* getenv(const char* p); 5 8 6 9 long sys_geteuid(void) 7 10 { 8 11 int ret; 12 + 13 + if (getenv("__FAKE_SETUID_ROOT") != NULL) 14 + return 0; 9 15 10 16 #ifdef __NR_geteuid32 11 17 ret = LINUX_SYSCALL0(__NR_geteuid32);
+6
src/kernel/emulation/linux/unistd/getuid.c
··· 2 2 #include "../base.h" 3 3 #include "../errno.h" 4 4 #include <asm/unistd.h> 5 + #include <stddef.h> 6 + 7 + extern char* getenv(const char* p); 5 8 6 9 long sys_getuid(void) 7 10 { 8 11 int ret; 12 + 13 + if (getenv("__FAKE_SETUID_ROOT") != NULL) 14 + return 0; 9 15 10 16 #ifdef __NR_getuid32 11 17 ret = LINUX_SYSCALL0(__NR_getuid32);
+31
src/tools/CMakeLists.txt
··· 1 + project(tools) 2 + 3 + cmake_minimum_required(VERSION 2.4.0) 4 + 5 + if(COMMAND cmake_policy) 6 + cmake_policy(SET CMP0003 NEW) 7 + endif(COMMAND cmake_policy) 8 + 9 + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostdinc -D__DARWIN_UNIX03 -fPIC -w -ggdb -O0") 10 + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib -Wl,--version-script=${DARLING_TOP_DIRECTORY}/darwin.map") 11 + 12 + include_directories(${DARLING_TOP_DIRECTORY}/src/external/corefoundation/Headers) 13 + include_directories(${CMAKE_BINARY_DIR}/src/external/corefoundation/Headers) 14 + include_directories(${DARLING_TOP_DIRECTORY}/src/external/foundation/Headers) 15 + include_directories(${DARLING_TOP_DIRECTORY}/src/CFF) 16 + 17 + include(darling_exe) 18 + 19 + if (NOT DEFINED SUFFIX OR SUFFIX STREQUAL "64") 20 + 21 + add_darling_executable(sw_vers sw_vers.c) 22 + 23 + install(TARGETS sw_vers DESTINATION libexec/darling/usr/bin) 24 + target_link_libraries(sw_vers CFF CFFExtra) 25 + 26 + install(PROGRAMS sudo DESTINATION libexec/darling/usr/bin 27 + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ 28 + GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) 29 + 30 + endif (NOT DEFINED SUFFIX OR SUFFIX STREQUAL "64") 31 +
+30
src/tools/sudo
··· 1 + #!/bin/sh 2 + # 3 + # This file is part of Darling. 4 + # 5 + # Copyright (C) 2015 Lubos Dolezel 6 + # 7 + # Darling is free software: you can redistribute it and/or modify 8 + # it under the terms of the GNU General Public License as published by 9 + # the Free Software Foundation, either version 3 of the License, or 10 + # (at your option) any later version. 11 + # 12 + # Darling is distributed in the hope that it will be useful, 13 + # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 + # GNU General Public License for more details. 16 + # 17 + # You should have received a copy of the GNU General Public License 18 + # along with Darling. If not, see <http://www.gnu.org/licenses/>. 19 + # 20 + 21 + if [ $# -lt 1 ]; then 22 + >&2 echo "This is Darling fake sudo." 23 + >&2 echo "Processes will think they run as UID 0, but Linux kernel will still see your original UID." 24 + >&2 echo "The purpose is to convince some tools that they can write into /." 25 + 26 + exit 1 27 + fi 28 + 29 + export __FAKE_SETUID_ROOT=1 30 + exec "${@:1}"
+85
src/tools/sw_vers.c
··· 1 + /* 2 + * Copyright (c) 2005 Finlay Dobbie 3 + * All rights reserved. 4 + * 5 + * Redistribution and use in source and binary forms, with or without 6 + * modification, are permitted provided that the following conditions 7 + * are met: 8 + * 1. Redistributions of source code must retain the above copyright 9 + * notice, this list of conditions and the following disclaimer. 10 + * 2. Redistributions in binary form must reproduce the above copyright 11 + * notice, this list of conditions and the following disclaimer in the 12 + * documentation and/or other materials provided with the distribution. 13 + * 3. Neither the name of Finlay Dobbie nor the names of his contributors 14 + * may be used to endorse or promote products derived from this software 15 + * without specific prior written permission. 16 + * 17 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 18 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 21 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 + * POSSIBILITY OF SUCH DAMAGE. 28 + */ 29 + 30 + #include <CoreFoundation/CoreFoundation.h> 31 + #include <CoreFoundation/CFPriv.h> 32 + 33 + void usage(char *progname) { 34 + fprintf(stderr, "Usage: %s [-productName|-productVersion|-buildVersion]\n", progname); 35 + exit(1); 36 + } 37 + 38 + int main(int argc, char *argv[]) { 39 + CFDictionaryRef dict= NULL; 40 + CFStringRef str = NULL; 41 + char cstr[256]; 42 + 43 + dict = _CFCopyServerVersionDictionary(); 44 + if (dict == NULL) 45 + dict = _CFCopySystemVersionDictionary(); 46 + if (dict == NULL) 47 + exit(1); 48 + 49 + if (argc == 2) { 50 + if (!strcmp(argv[1], "-productName")) 51 + str = CFDictionaryGetValue(dict, _kCFSystemVersionProductNameKey); 52 + else if (!strcmp(argv[1], "-productVersion")) { 53 + /* On Darwin, we set MacOSXProductVersion to the corresponding OS X release. 54 + This is for compatibility with scripts that set MACOSX_DEPLOYMENT_TARGET 55 + based on sw_vers -productVersion */ 56 + str = CFDictionaryGetValue(dict, CFSTR("MacOSXProductVersion")); 57 + if (str == NULL) 58 + str = CFDictionaryGetValue(dict, _kCFSystemVersionProductVersionKey); 59 + } 60 + else if (!strcmp(argv[1], "-buildVersion")) 61 + str = CFDictionaryGetValue(dict, _kCFSystemVersionBuildVersionKey); 62 + else 63 + usage(argv[0]); 64 + CFRetain(str); 65 + } else if (argc == 1) { 66 + str = CFStringCreateWithFormat(NULL, NULL, 67 + CFSTR("ProductName: %@\n" 68 + "ProductVersion: %@\n" 69 + "BuildVersion: %@"), 70 + CFDictionaryGetValue(dict, _kCFSystemVersionProductNameKey), 71 + CFDictionaryGetValue(dict, _kCFSystemVersionProductVersionKey), 72 + CFDictionaryGetValue(dict, _kCFSystemVersionBuildVersionKey)); 73 + } else { 74 + usage(argv[0]); 75 + } 76 + 77 + if (!CFStringGetCString(str, cstr, sizeof(cstr), CFStringGetSystemEncoding())) 78 + exit(1); 79 + 80 + printf("%s\n", cstr); 81 + 82 + CFRelease(str); 83 + CFRelease(dict); 84 + return 0; 85 + }