Skip to content

Commit

Permalink
Ignore folder symlinks in /system path
Browse files Browse the repository at this point in the history
  • Loading branch information
lakeman committed May 18, 2015
1 parent 44af7c6 commit 1678616
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/org/servalproject/system/ChipsetDetection.java
Expand Up @@ -109,6 +109,12 @@ private boolean fileExists(String filename) {
return result;
}

private boolean isSymLink(File file) throws IOException {
File p = file.getParentFile();
File t = p == null ? file : new File(p.getCanonicalFile(), file.getName());
return !t.getCanonicalFile().equals(t.getAbsoluteFile());
}

private void scan(File folder, List<File> results,
Set<String> insmodCommands) {
File files[] = folder.listFiles();
Expand All @@ -117,7 +123,8 @@ private void scan(File folder, List<File> results,
for (File file : files) {
try {
if (file.isDirectory()) {
scan(file, results, insmodCommands);
if (!isSymLink(file))
scan(file, results, insmodCommands);
} else {
String path = file.getCanonicalPath();
if (path.contains("wifi") || path.endsWith(".ko")) {
Expand Down Expand Up @@ -169,7 +176,7 @@ private void scan(File folder, List<File> results,
}
}
} catch (IOException e) {
continue;
// ignore
}
}
}
Expand Down

0 comments on commit 1678616

Please sign in to comment.