dotfiles bugabingas dorkfiles
owned by bugabinga
README Source History Refs Reviews Compare Notes Search Review guide fix: reject outside-home symlinks
e614b0127828d6eaee514359796779505efd738a
Oliver Jan Krylow <oliver@bugabinga.net > · 4 Jul 2026
unsigned
Browse files Compare with HEAD
Changed files (3) 56 56 Blank lines separate pairs. Keep pairs ordered and complete. Hostname chooses `<host>.symlinks`.
57 - Managed symlinks must never point outside HOME; no `/usr`, `/etc`, or system target links.
57 + Managed symlinks must never point outside HOME; no `/usr`, `/etc`, or system target links. Treat outside-HOME symlinks as errors; do not relink/delete them.
bootstripper.java Modified 458 458 log(
"\nOK {0} -> {1}." , emphasize_global(target_path.toString()), emphasize_local(source_path.toString()));
461 - if (
! inside_home(actual)) {
462 - log(
"\nRELINK {0}: outside HOME {1} -> {2}." , emphasize_global(target_path.toString()), emphasize_local(actual.toString()), emphasize_local(expected.toString()));
463 - remove_owned_symlink(target_path);
461 + if (
! inside_home(actual))
462 + throw fail(
"Target symlink points outside HOME: {0} -> {1}. Move it manually." , target_path, actual);
465 464 if (
! actual.startsWith(root.toRealPath()))
466 465 throw fail(
"Target symlink points outside dorkfiles: {0} -> {1}. Move it manually." , target_path, actual);
467 466 log(
"\nRELINK {0}: {1} -> {2}." , emphasize_global(target_path.toString()), emphasize_local(actual.toString()), emphasize_local(expected.toString()));
scripts/dotfiles_integration_test.java Modified 145 145 if (
! run(repo,
"git" ,
"show" ,
":secret.txt" ).startsWith(
"DFAES1" )) fail(
"fresh-staged-encrypted" );
146 146 var env2
= new HashMap <>(env); env2.put(
"HOSTNAME" ,
"mini" );
147 147 Files .createSymbolicLink(home.resolve(
"dummy.txt" ),
Path .of(
"/usr/lib/outside-home" ));
148 + if (
! runExpectFail(repo, env2,
"java" ,
"bootstripper.java" ,
"bootstrap" ).contains(
"outside HOME" )) fail(
"outside-home-symlink-not-rejected" );
149 + Files .delete(home.resolve(
"dummy.txt" ));
148 150 run(repo, env2,
"java" ,
"bootstripper.java" ,
"bootstrap" );
149 151 if (
! Files .isSymbolicLink(home.resolve(
"dummy.txt" ))) fail(
"fresh-link" );
150 - if (
! Files .readSymbolicLink(home.resolve(
"dummy.txt" )).toAbsolutePath().normalize().startsWith(home)) fail(
"fresh-link-outside-home" );
151 152 run(repo, env2,
"java" ,
"bootstripper.java" ,
"clean" );
152 153 ok(
"fresh-crypto" );
205 206 if (code
!= 0 )
throw new RuntimeException (
String .join(
" " , cmd)
+ " exited " + code);
209 + static String runExpectFail(
Path dir,
Map <
String ,
String > env,
String ... cmd) throws
Exception {
211 + var out
= run(dir, env, cmd);
212 + throw new AssertionError (
"expected failure: " + String .join(
" " , cmd)
+ "\n" + out);
213 + }
catch (
RuntimeException error) {
214 + return error.getMessage();
208 218 static void runAllowFail(
Path dir,
String ... cmd) {
209 219 try { run(dir, cmd); }
catch (
Exception ignored) {}