Skip to content

Commit 933552c

Browse files
Merge pull request #25 from appdevforall/fix/fast-install-resolv-conf
fix(install): inject resolv.conf + hosts on fast-install AND restore (no-DNS fix)
2 parents f3a6327 + a36c7b1 commit 933552c

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

‎controller/app/src/main/java/org/iiab/controller/DeployFragment.java‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,10 @@ public void onComplete(String destDir) {
10961096
}
10971097
}
10981098

1099+
// Freshly fast-installed rootfs ships without resolv.conf; give it
1100+
// DNS before the companion-data (maps/kiwix) steps that need network.
1101+
ensureRuntimeNetworkConfig(debianRootfs);
1102+
10991103
if (chkCompanionData.isChecked()) {
11001104
editLocalVarsForMaps(debianRootfs, safeTier);
11011105
android.content.SharedPreferences prefs = requireContext().getSharedPreferences(getString(R.string.pref_file_internal), Context.MODE_PRIVATE);
@@ -2143,6 +2147,8 @@ private void refreshRestoreButtonLogic() {
21432147
tarExtractor.startExtraction(requireContext(), backupFile.getAbsolutePath(), iiabRootDir.getAbsolutePath(), new TarExtractor.ExtractionListener() {
21442148
@Override
21452149
public void onComplete(String destDir) {
2150+
// Restored artifact ships without resolv.conf; the app owns runtime DNS.
2151+
ensureRuntimeNetworkConfig(new File(iiabRootDir, "installed-rootfs/iiab"));
21462152
mainAct.runOnUiThread(() -> {
21472153
isRestoring = false;
21482154
disableSystemProtection();
@@ -2169,6 +2175,33 @@ public void onError(String error) {
21692175
}
21702176
}
21712177

2178+
// Runtime network config for the proot guest: proot has no resolver daemon, and our build
2179+
// artifact ships WITHOUT /etc/resolv.conf on purpose (the app is the single owner of runtime
2180+
// network state). Mirrors the reset path. Called from fast-install and restore.
2181+
// TODO [tech-debt]: imperative side-effect inside DeployFragment (god-object); not Clean
2182+
// Architecture. Fold into the rootfs domain/data slice during the strangler refactor.
2183+
private void ensureRuntimeNetworkConfig(File debianRootfs) {
2184+
try {
2185+
File etc = new File(debianRootfs, "etc");
2186+
if (!etc.isDirectory()) {
2187+
Log.w(TAG, "ensureRuntimeNetworkConfig: missing " + etc.getAbsolutePath() + " - skipping DNS write");
2188+
return;
2189+
}
2190+
File resolvConf = new File(etc, "resolv.conf");
2191+
if (resolvConf.exists()) resolvConf.delete();
2192+
try (java.io.FileOutputStream fos = new java.io.FileOutputStream(resolvConf)) {
2193+
fos.write("nameserver 1.1.1.1\nnameserver 8.8.8.8\n".getBytes());
2194+
}
2195+
File hostsFile = new File(etc, "hosts");
2196+
try (java.io.FileOutputStream fosH = new java.io.FileOutputStream(hostsFile)) {
2197+
fosH.write("127.0.0.1 localhost\n".getBytes());
2198+
}
2199+
Log.i(TAG, "ensureRuntimeNetworkConfig: wrote resolv.conf + hosts under " + etc.getAbsolutePath());
2200+
} catch (Exception e) {
2201+
Log.w(TAG, "ensureRuntimeNetworkConfig failed", e);
2202+
}
2203+
}
2204+
21722205
private void importBackupSafely(Uri sourceUri) {
21732206
isImporting = true;
21742207
updateDynamicButtons();

0 commit comments

Comments
 (0)