Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Harden Linux local auth policy setup

Neeraj Gupta9556431da18f
diff --git a/mobile/apps/auth/changes/01-current.md b/mobile/apps/auth/changes/01-current.md
index 3a452695f4..14c5deda3f 100644
--- a/mobile/apps/auth/changes/01-current.md
+++ b/mobile/apps/auth/changes/01-current.md
@@ -17,6 +17,7 @@
- Fixed Auth desktop custom icons flashing for Amazon and other monochrome icons ([#8264](https://github.com/ente-io/ente/issues/8264), [#8499](https://github.com/ente-io/ente/issues/8499))
- Fixed missing Auth tray icons in sandboxed Linux builds ([#4608](https://github.com/ente-io/ente/issues/4608), [#7815](https://github.com/ente-io/ente/issues/7815), [flathub/io.ente.auth#75](https://github.com/flathub/io.ente.auth/issues/75))
- Fixed Auth AppImage startup failures on some Linux systems by preferring host runtime libraries before bundled AppImage fallbacks ([#6705](https://github.com/ente-io/ente/issues/6705), [#7646](https://github.com/ente-io/ente/issues/7646), [#9738](https://github.com/ente-io/ente/issues/9738), [#6976](https://github.com/ente-io/ente/issues/6976), [#6600](https://github.com/ente-io/ente/issues/6600))
+- Added Linux system authentication for Auth desktop. Fingerprint prompts depend on the host PAM/fprintd setup.
- Fixed Auth tray close, exit, and menu actions on Windows ([#8164](https://github.com/ente-io/ente/issues/8164), [#4360](https://github.com/ente-io/ente/issues/4360), [#3518](https://github.com/ente-io/ente/issues/3518))
- Fixed stale or duplicate Auth tray icons on Windows ([#8165](https://github.com/ente-io/ente/issues/8165))
- Improved Auth tray icon contrast in the Windows tray overflow ([#9491](https://github.com/ente-io/ente/issues/9491))
diff --git a/mobile/apps/auth/linux/packaging/build_rpm.sh b/mobile/apps/auth/linux/packaging/build_rpm.sh
index eb643c0213..217a40816a 100755
--- a/mobile/apps/auth/linux/packaging/build_rpm.sh
+++ b/mobile/apps/auth/linux/packaging/build_rpm.sh
@@ -75,7 +75,7 @@ cp linux/packaging/enteauth.desktop "$STAGING_DIR/usr/share/applications/"
# Copy Polkit policy.
echo -e "${YELLOW}Copying Polkit policy...${NC}"
-cp assets/polkit/io.ente.auth.policy "$STAGING_DIR/usr/share/polkit-1/actions/"
+install -D -m 0644 assets/polkit/io.ente.auth.policy "$STAGING_DIR/usr/share/polkit-1/actions/io.ente.auth.policy"
# Create symlink
echo -e "${YELLOW}Creating symlink...${NC}"
diff --git a/mobile/apps/auth/linux/packaging/deb/make_config.yaml b/mobile/apps/auth/linux/packaging/deb/make_config.yaml
index 8cb8ef3369..d3c8e08fa8 100644
--- a/mobile/apps/auth/linux/packaging/deb/make_config.yaml
+++ b/mobile/apps/auth/linux/packaging/deb/make_config.yaml
@@ -24,7 +24,8 @@ dependencies:
- libayatana-ido3-0.4-0
postinstall_scripts:
- - install -D -m 0644 /usr/share/enteauth/data/flutter_assets/assets/polkit/io.ente.auth.policy /usr/share/polkit-1/actions/io.ente.auth.policy
+ - install -D -o root -g root -m 0644 /usr/share/enteauth/data/flutter_assets/assets/polkit/io.ente.auth.policy /usr/share/polkit-1/actions/io.ente.auth.policy
+ - if command -v chcon >/dev/null 2>&1; then chcon system_u:object_r:usr_t:s0 /usr/share/polkit-1/actions/io.ente.auth.policy || true; fi
postuninstall_scripts:
- rm -f /usr/share/polkit-1/actions/io.ente.auth.policy
diff --git a/mobile/apps/auth/linux/packaging/pacman/make_config.yaml b/mobile/apps/auth/linux/packaging/pacman/make_config.yaml
index fab9a782fd..80a61cfa92 100644
--- a/mobile/apps/auth/linux/packaging/pacman/make_config.yaml
+++ b/mobile/apps/auth/linux/packaging/pacman/make_config.yaml
@@ -31,7 +31,8 @@ supported_mime_type:
postinstall_scripts:
- gtk-update-icon-cache -q -t -f usr/share/icons/hicolor
- update-desktop-database -q
- - install -D -m 0644 /usr/share/enteauth/data/flutter_assets/assets/polkit/io.ente.auth.policy /usr/share/polkit-1/actions/io.ente.auth.policy
+ - install -D -o root -g root -m 0644 /usr/share/enteauth/data/flutter_assets/assets/polkit/io.ente.auth.policy /usr/share/polkit-1/actions/io.ente.auth.policy
+ - if command -v chcon >/dev/null 2>&1; then chcon system_u:object_r:usr_t:s0 /usr/share/polkit-1/actions/io.ente.auth.policy || true; fi
- if [ ! -e /usr/lib/libsodium.so.23 ]; then
- " ln -s /usr/lib/libsodium.so /usr/lib/libsodium.so.23"
- fi
diff --git a/mobile/apps/auth/linux/packaging/rpm/make_config.yaml b/mobile/apps/auth/linux/packaging/rpm/make_config.yaml
index 65f3df1f3c..4c87f64cc8 100644
--- a/mobile/apps/auth/linux/packaging/rpm/make_config.yaml
+++ b/mobile/apps/auth/linux/packaging/rpm/make_config.yaml
@@ -20,7 +20,8 @@ requires:
- polkit
postinstall_scripts:
- - install -D -m 0644 /usr/share/enteauth/data/flutter_assets/assets/polkit/io.ente.auth.policy /usr/share/polkit-1/actions/io.ente.auth.policy
+ - install -D -o root -g root -m 0644 /usr/share/enteauth/data/flutter_assets/assets/polkit/io.ente.auth.policy /usr/share/polkit-1/actions/io.ente.auth.policy
+ - if command -v chcon >/dev/null 2>&1; then chcon system_u:object_r:usr_t:s0 /usr/share/polkit-1/actions/io.ente.auth.policy || true; fi
postuninstall_scripts:
- rm -f /usr/share/polkit-1/actions/io.ente.auth.policy
diff --git a/mobile/packages/local_auth_linux/lib/local_auth_linux.dart b/mobile/packages/local_auth_linux/lib/local_auth_linux.dart
index f80c158242..c572b568ba 100644
--- a/mobile/packages/local_auth_linux/lib/local_auth_linux.dart
+++ b/mobile/packages/local_auth_linux/lib/local_auth_linux.dart
@@ -40,12 +40,16 @@ class LinuxLocalAuthSetupStatus {
String get policyInstallCommand {
if (isFlatpak) {
return '''
-install_dir="\$(flatpak info --show-location io.ente.auth)"
-pkexec install -D -m 0644 "\$install_dir/files/share/enteauth/data/flutter_assets/assets/polkit/io.ente.auth.policy" /usr/share/polkit-1/actions/io.ente.auth.policy
+app_id="\${FLATPAK_ID:-io.ente.auth}"
+install_dir="\$(flatpak info --show-location "\$app_id")"
+policy="\$install_dir/files/share/enteauth/data/flutter_assets/assets/polkit/io.ente.auth.policy"
+sudo install -D -o root -g root -m 0644 "\$policy" /usr/share/polkit-1/actions/io.ente.auth.policy
+if command -v chcon >/dev/null 2>&1; then sudo chcon system_u:object_r:usr_t:s0 /usr/share/polkit-1/actions/io.ente.auth.policy || true; fi
pkaction --action-id $actionId --verbose''';
}
return '''
-pkexec install -D -m 0644 "$policyAssetPath" /usr/share/polkit-1/actions/io.ente.auth.policy
+sudo install -D -o root -g root -m 0644 "$policyAssetPath" /usr/share/polkit-1/actions/io.ente.auth.policy
+if command -v chcon >/dev/null 2>&1; then sudo chcon system_u:object_r:usr_t:s0 /usr/share/polkit-1/actions/io.ente.auth.policy || true; fi
pkaction --action-id $actionId --verbose''';
}
}
diff --git a/mobile/packages/local_auth_linux/linux/local_auth_linux_plugin.cc b/mobile/packages/local_auth_linux/linux/local_auth_linux_plugin.cc
index 4cbe4b9a19..7d1fef4465 100644
--- a/mobile/packages/local_auth_linux/linux/local_auth_linux_plugin.cc
+++ b/mobile/packages/local_auth_linux/linux/local_auth_linux_plugin.cc
@@ -61,6 +61,17 @@ static gchar* policy_asset_path() {
}
}
+ g_autofree gchar* executable_path =
+ g_file_read_link("/proc/self/exe", nullptr);
+ if (executable_path != nullptr && executable_path[0] != '\0') {
+ g_autofree gchar* executable_dir = g_path_get_dirname(executable_path);
+ g_autofree gchar* executable_relative_path = g_build_filename(
+ executable_dir, kBundledPolicyAssetRelativePath, nullptr);
+ if (g_file_test(executable_relative_path, G_FILE_TEST_IS_REGULAR)) {
+ return g_strdup(executable_relative_path);
+ }
+ }
+
g_autofree gchar* cwd = g_get_current_dir();
g_autofree gchar* cwd_path =
g_build_filename(cwd, kBundledPolicyAssetRelativePath, nullptr);