this repo has no description
1
fork

Configure Feed

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

Create our own passwd files during prefix setup

Previously, we were just using Linux's passwd, which caused inconsistencies, e.g., with home directory lookups.

Now, we also add the user to /etc/master.passwd so programs running as fake root within the prefix can still look our user up (since libinfo checks /etc/master.passwd when running as root instead of /etc/passwd).

+68 -3
+2 -2
CMakeLists.txt
··· 151 151 InstallSymlink(private/tmp ${CMAKE_INSTALL_PREFIX}/libexec/darling/tmp) 152 152 153 153 InstallSymlink(/proc/self/mounts ${CMAKE_INSTALL_PREFIX}/libexec/darling/etc/mtab) 154 - InstallSymlink(/Volumes/SystemRoot/etc/passwd ${CMAKE_INSTALL_PREFIX}/libexec/darling/etc/passwd) 155 - InstallSymlink(/Volumes/SystemRoot/etc/group ${CMAKE_INSTALL_PREFIX}/libexec/darling/etc/group) 154 + #InstallSymlink(/Volumes/SystemRoot/etc/passwd ${CMAKE_INSTALL_PREFIX}/libexec/darling/etc/passwd) 155 + #InstallSymlink(/Volumes/SystemRoot/etc/group ${CMAKE_INSTALL_PREFIX}/libexec/darling/etc/group) 156 156 InstallSymlink(/Volumes/SystemRoot/etc/localtime ${CMAKE_INSTALL_PREFIX}/libexec/darling/etc/localtime) 157 157 158 158 InstallSymlink(/Volumes/SystemRoot/usr/share/zoneinfo ${CMAKE_INSTALL_PREFIX}/libexec/darling/usr/share/zoneinfo)
+1 -1
src/libinfo/CMakeLists.txt
··· 70 70 ) 71 71 72 72 install(TARGETS system_info DESTINATION libexec/darling/usr/lib/system) 73 - install(FILES master.passwd DESTINATION libexec/darling/etc) 73 + #install(FILES master.passwd DESTINATION libexec/darling/etc) 74 74
+65
src/startup/darling.c
··· 1092 1092 { 1093 1093 char path[4096]; 1094 1094 size_t plen; 1095 + FILE* file; 1096 + struct passwd* passwd_entry; 1095 1097 1096 1098 const char* dirs[] = { 1097 1099 "/Volumes", ··· 1103 1105 "/private/var", 1104 1106 "/private/var/log", 1105 1107 "/private/var/db", 1108 + "/private/etc", 1106 1109 "/var", 1107 1110 "/var/run", 1108 1111 "/var/tmp", ··· 1125 1128 strcat(path, dirs[i]); 1126 1129 createDir(path); 1127 1130 } 1131 + 1132 + // create passwd, master.passwd, and group 1133 + 1134 + passwd_entry = getpwuid(g_originalUid); 1135 + if (!passwd_entry) { 1136 + fprintf(stderr, "Failed to find Linux /etc/passwd entry for current user\n"); 1137 + exit(1); 1138 + } 1139 + 1140 + path[plen] = '\0'; 1141 + strcat(path, "/private/etc/passwd"); 1142 + file = fopen(path, "w"); 1143 + if (!file) { 1144 + fprintf(stderr, "Failed to open /private/etc/passwd within the prefix\n"); 1145 + exit(1); 1146 + } 1147 + 1148 + fprintf(file, 1149 + "root:*:0:0:System Administrator:/var/root:/bin/sh\n" 1150 + "%s:*:%d:%d:Darling User:/Users/%s:/bin/bash\n", 1151 + passwd_entry->pw_name, 1152 + passwd_entry->pw_uid, 1153 + passwd_entry->pw_gid, 1154 + passwd_entry->pw_name 1155 + ); 1156 + fclose(file); 1157 + 1158 + path[plen] = '\0'; 1159 + strcat(path, "/private/etc/master.passwd"); 1160 + file = fopen(path, "w"); 1161 + if (!file) { 1162 + fprintf(stderr, "Failed to open /private/etc/master.passwd within the prefix\n"); 1163 + exit(1); 1164 + } 1165 + 1166 + fprintf(file, 1167 + "root:*:0:0::0:0:System Administrator:/var/root:/bin/sh\n" 1168 + "%s:*:%d:%d::0:0:Darling User:/Users/%s:/bin/bash\n", 1169 + passwd_entry->pw_name, 1170 + passwd_entry->pw_uid, 1171 + passwd_entry->pw_gid, 1172 + passwd_entry->pw_name 1173 + ); 1174 + fclose(file); 1175 + 1176 + path[plen] = '\0'; 1177 + strcat(path, "/private/etc/group"); 1178 + file = fopen(path, "w"); 1179 + if (!file) { 1180 + fprintf(stderr, "Failed to open /private/etc/group within the prefix\n"); 1181 + exit(1); 1182 + } 1183 + 1184 + fprintf(file, 1185 + "wheel:*:0:root,%s\n" 1186 + "%s:*:%d:%s\n", 1187 + passwd_entry->pw_name, 1188 + passwd_entry->pw_name, 1189 + passwd_entry->pw_gid, 1190 + passwd_entry->pw_name 1191 + ); 1192 + fclose(file); 1128 1193 1129 1194 seteuid(0); 1130 1195 setegid(0);