Make sure SELinux labels are correct after move-to operations

In some circumstances wallpaper-related files are moved into position,
and must then take proper effect.  Make sure that they have the
correct SELinux labels afterwards to avoid preventing some valid
accesses.

Bug 29469965

Change-Id: I6d7c86be63d568fa0ad8841d109a7ff2149fdd54
This commit is contained in:
Christopher Tate
2016-06-30 12:21:57 -07:00
committed by Chris Tate
parent 4ce343881c
commit fa7d97fa15

View File

@@ -229,10 +229,12 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
if (moved && lockWallpaperChanged) { if (moved && lockWallpaperChanged) {
// We just migrated sys -> lock to preserve imagery for an impending // We just migrated sys -> lock to preserve imagery for an impending
// new system-only wallpaper. Tell keyguard about it but that's it. // new system-only wallpaper. Tell keyguard about it and make sure it
// has the right SELinux label.
if (DEBUG) { if (DEBUG) {
Slog.i(TAG, "Sys -> lock MOVED_TO"); Slog.i(TAG, "Sys -> lock MOVED_TO");
} }
SELinux.restorecon(changedFile);
notifyLockWallpaperChanged(); notifyLockWallpaperChanged();
return; return;
} }
@@ -254,9 +256,11 @@ public class WallpaperManagerService extends IWallpaperManager.Stub {
if (moved) { if (moved) {
// This is a restore, so generate the crop using any just-restored new // This is a restore, so generate the crop using any just-restored new
// crop guidelines, making sure to preserve our local dimension hints. // crop guidelines, making sure to preserve our local dimension hints.
// We also make sure to reapply the correct SELinux label.
if (DEBUG) { if (DEBUG) {
Slog.v(TAG, "moved-to, therefore restore; reloading metadata"); Slog.v(TAG, "moved-to, therefore restore; reloading metadata");
} }
SELinux.restorecon(changedFile);
loadSettingsLocked(wallpaper.userId, true); loadSettingsLocked(wallpaper.userId, true);
} }
generateCrop(wallpaper); generateCrop(wallpaper);