linuxCheckAppArmorError method
Returns true when there is an AppArmor error when trying to read a value.
When used inside a snap, there might be app armor limitations which lead to an error like: org.freedesktop.DBus.Error.AccessDenied: An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.140" (uid=1000 pid=94358 comm="/snap/biometric-storage-example/x1/biometric_stora" label="snap.biometric-storage-example.biometric (enforce)") interface="org.freedesktop.Secret.Service" member="OpenSession" error name="(unset)" requested_reply="0" destination=":1.30" (uid=1000 pid=1153 comm="/usr/bin/gnome-keyring-daemon --daemonize --login " label="unconfined")
Implementation
@override
Future<bool> linuxCheckAppArmorError() async {
if (!Platform.isLinux) {
return false;
}
final tmpStorage = await getStorage('appArmorCheck',
options: StorageFileInitOptions(authenticationRequired: false));
_logger.finer('Checking app armor');
try {
await tmpStorage.read();
_logger.finer('Everything okay.');
return false;
} on AuthException catch (e, stackTrace) {
if (e.code == AuthExceptionCode.linuxAppArmorDenied) {
return true;
}
_logger.warning(
'Unknown error while checking for app armor.', e, stackTrace);
// some other weird error?
rethrow;
}
}