cockpitValidateCanonicalRegularFile function
Future<void>
cockpitValidateCanonicalRegularFile(
- String path, {
- required String diagnostic,
})
Implementation
Future<void> cockpitValidateCanonicalRegularFile(
String path, {
required String diagnostic,
}) async {
final type = await FileSystemEntity.type(path, followLinks: false);
if (type != FileSystemEntityType.file) {
throw FileSystemException(diagnostic, path);
}
final canonical = p.normalize(await File(path).resolveSymbolicLinks());
if (!p.equals(canonical, p.normalize(path))) {
throw FileSystemException(diagnostic, path);
}
}