Skip to content

Commit

Permalink
Add /opt/ and /var/opt/ to FSOverlay allowed paths list (tkashkin…
Browse files Browse the repository at this point in the history
…#290)

Wait for overlays to mount before updating game status (tkashkin#291)
  • Loading branch information
tkashkin committed Jul 29, 2019
1 parent 4bb1b7f commit f28cc89
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/data/Game.vala
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ namespace GameHub.Data
dirs += install_dir.get_child(FSUtils.GAMEHUB_DIR).get_child(Overlay.BASE);
}
dirs += install_dir;
mount_overlays();
mount_overlays.begin();
}
foreach(var dir in dirs)
{
Expand Down Expand Up @@ -395,7 +395,7 @@ namespace GameHub.Data
}
}

public void mount_overlays(File? persist=null)
public async void mount_overlays(File? persist=null)
{
if(!overlays_enabled) return;
load_overlays();
Expand All @@ -418,9 +418,9 @@ namespace GameHub.Data
fs_overlay = new FSOverlay(merged_dir, dirs, persist_dir, work_dir);
if(fs_overlay.options != fs_overlay_last_options)
{
fs_overlay.mount.begin();
fs_overlay_last_options = fs_overlay.options;
yield fs_overlay.mount();
}
fs_overlay_last_options = fs_overlay.options;
}

public async void umount_overlays()
Expand Down
4 changes: 2 additions & 2 deletions src/data/sources/gog/GOGGame.vala
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ namespace GameHub.Data.Sources.GOG

update_status();

mount_overlays();
yield mount_overlays();

if(info_detailed == null || info_detailed.length == 0)
{
Expand Down Expand Up @@ -964,7 +964,7 @@ namespace GameHub.Data.Sources.GOG

game.overlays.add(dlc_overlay);
game.save_overlays();
game.mount_overlays();
yield game.mount_overlays();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/data/sources/humble/HumbleGame.vala
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ namespace GameHub.Data.Sources.Humble

update_status();

mount_overlays();
yield mount_overlays();

if((icon == null || icon == "") && (info != null && info.length > 0))
{
Expand Down
2 changes: 1 addition & 1 deletion src/data/sources/user/UserGame.vala
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ namespace GameHub.Data.Sources.User
{
update_status();

mount_overlays();
yield mount_overlays();

if(installer == null && info != null && info.length > 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/ui/dialogs/GameFSOverlaysDialog.vala
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ namespace GameHub.UI.Dialogs

destroy.connect(() => {
game.save_overlays();
game.mount_overlays();
game.mount_overlays.begin();
});

show_all();
Expand Down
14 changes: 13 additions & 1 deletion src/utils/FSOverlay.vala
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,24 @@ namespace GameHub.Utils
{
SAFE, UNSAFE, RESTRICTED;

private const string[] ALLOWED_PATHS = { "/home/", "/mnt/", "/media/", "/run/media/", "/opt/", "/var/opt/" };

public static RootPathSafety for(File? root)
{
if(root == null || !root.query_exists()) return RESTRICTED;
var path = root.get_path().down();

if(!path.has_prefix("/home/") && !path.has_prefix("/mnt/") && !path.has_prefix("/media/") && !path.has_prefix("/run/media/"))
var allowed = false;
foreach(var prefix in ALLOWED_PATHS)
{
if(path.has_prefix(prefix))
{
allowed = true;
break;
}
}

if(!allowed)
{
return RESTRICTED;
}
Expand Down

0 comments on commit f28cc89

Please sign in to comment.