cockpitValidateCanonicalRegularFile function

Future<void> cockpitValidateCanonicalRegularFile(
  1. String path, {
  2. 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);
  }
}