FancyMenu [Fabric] [MOVED TO NEW PROJECT]

FancyMenu [Fabric] [MOVED TO NEW PROJECT]

17M Downloads

FancyMenu creates directories in / when loaded server-side

9ary opened this issue · 2 comments

commented

Describe the bug

As the title says, I noticed directories that shouldn't be there in the filesystem root of my server container:

$ eza -T  overlay/06c7686880a7c6ef71ccc2bc97e16c14207d882a8b6059ae3da9755a6fe53d66/diff/ -a
overlay/06c7686880a7c6ef71ccc2bc97e16c14207d882a8b6059ae3da9755a6fe53d66/diff/
├── config/
│   ├── drippyloadingscreen/
│   └── fancymenu/
├── dev/
├── etc/
│   ├── hostname*
│   ├── hosts*
│   ├── mtab -> /proc/mounts
│   └── resolv.conf*
├── fancymenu_data/
│   ├── cached_data/
│   └── fancymenu_temp/
├── proc/
├── run/
│   └── .containerenv*
├── sys/
├── tmp/

I took a look with a decompiler to see if my container environment was missing something to help fancymenu choose the right location, but no:

FancyMenu.class:

   static {
      MOD_LOADER = Services.PLATFORM.getPlatformName();
      MOD_DIR = createDirectory(new File(GameDirectoryUtils.getGameDirectory(), "/config/fancymenu"));
      INSTANCE_DATA_DIR = createDirectory(new File(GameDirectoryUtils.getGameDirectory(), "/fancymenu_data"));
      TEMP_DATA_DIR = (File)ObjectUtils.build(() -> {
         File f = new File(INSTANCE_DATA_DIR, "/fancymenu_temp");
         if (f.isDirectory()) {
            org.apache.commons.io.FileUtils.deleteQuietly(f);
         }

         return createDirectory(f);
      });
      CACHE_DIR = createDirectory(new File(INSTANCE_DATA_DIR, "/cached_data"));
   }

GameDirectoryUtils.class:

   public static File getGameDirectory() {
      return Services.PLATFORM.isOnClient() ? Minecraft.m_91087_().f_91069_ : new File("");
   }

So on servers, it attempts to create the directories "" + "/config/fancymenu" and so on. Seems like errors are ignored, so in normal unprivileged scenarios the server doesn't crash because of permission denied.
The correct "game directory" for a server should be the current working directory, not the empty string.

To Reproduce

  1. Run a server with FancyMenu or DLS inside of a container
  2. Observe the unwanted directories at filesystem root

Expected behavior

The directories are created in the right place, or not at all.

Game Log

Irrelevant.

Screenshots

Irrelevant

Basic Informations (please complete the following information):

  • OS: custom-built container
  • FancyMenu Version: 3.3.2
  • Forge/Fabric Version: Forge 47.3.7
  • Minecraft Version: 1.20.1
  • Active Mods: too many to list here, I'm running a slightly modified version of Monifactory 0.11.3
commented

The correct "game directory" for a server should be the current working directory, not the empty string.

I know that. Minecraft was always a bit special about its "working directory". Using "" was at some point the only way to correctly gets MC's instance directory on servers. I don't know how it is now, but it used to be like that.

Also Drippy shouldn't be loaded on servers anyways.

Btw, you don't need to decompile FM. It is open-source.

commented

Also Drippy shouldn't be loaded on servers anyways.

Yeah, I ended up removing both from the server, should be fine.

Btw, you don't need to decompile FM. It is open-source.

Oh, I saw the empty master branch and the funny license and made an assumption. 😅 Didn't realize the source was in other branches.