Skip to content

Can't save files in version 1.3.11 - Windows without admin privileges #1052

Open

Description

@rodolforg

Synfig version & platform:
1.3.11 - windows 10 64bit

Issue description:
A regular user account in a enterprise environment can't save any Synfig animation file.
Temporary and 'dangerous' workaround: administrators give permission to write on Synfig install folder.
Something related to temp dir/files maybe?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Activity

  1. Jose-Moreno commented on Dec 24, 2019

    @Jose-Moreno

    To be honest this is a problem with Windows crazy permissions. Krita was having issues with this as reported in the release notes for v4.2.8, although this was a problem with the Qt framework fileaccess on windows. Pencil2D is also having issues with this. It's just a pain in the arse 😒

    The first way to workaround this is to be the system admin and install everything as admin. I know most people care about security and all, but this is 100% what I always have to do, I don't even care to setup a "user" account for my home computer anymore due to this problem.

    The other way is for Synfig to sign the release binaries as Windows systems tend to reject any unsigned application and it also actively blocks them when it's downloaded from the internet. At first is sort of a soft lock, but sometimes this can extend itself to blocking the dynamic library files and plugins like FFMPEG.

    So you have to unblock the zip file or msi installer where Synfig comes in before extracting / installing it.

    When installing you do have to use the admin powers to install to avoid potential issues, but it's recommended to lower the UAC security rating system during installation, and you should install the program on C:\ Program Files . No other folder will give you enough flexibility in the Windows Security scheme as far as I know.

    I personally tend to run my programs from a separate folder on Windows 7, but for Windows 10 this has been actively enforced so you have to install them there if the app is not signed.

    There's also as you mentioned the possibility of the temp folder being actively blocked when the program files are trying to write, however this should be solved by installing to Program Files 90% of the time (you can google about this specific issue actually, there are a lot of people that have had this and it's been never solved by microsoft 😋 ).

    Lastly, if you have Windows10, make sure the default antivirus has a rule setup to exclude Synfig install folder from real-time scans. This can also prevent files from writing randomly.

    Other than this it boils down to either you ask or give full access to yourself, or for users that don't have admin access they have to take all of these cautionary steps before using Synfig.

    However If after doing this you still can't save the files themselves, then something must have changed in the FileSystem API's for Windows itself. I personally started reading about users having similar problems about 6 to 7 months ago mostly on Win10, so it can't be merely a coincidence.

    I leave this MSDN Article on Win32 File System permissions here in case it can help you get a better idea on how to track this issue on your computer.
    https://docs.microsoft.com/en-us/windows/win32/fileio/file-security-and-access-rights

  2. added this to the v1.4.0 milestone on Apr 29, 2020
  3. morevnaproject commented on Apr 30, 2020

    @morevnaproject
    Member

    It would be nice to try run Synfig through processmonitor app and look where it makes attempt to write.

    @rodolforg Do you still have access to environment where this issue is reproducible?

  4. rodolforg commented on Apr 30, 2020

    @rodolforg
    ContributorAuthor

    @morevnaproject no I don't, due to quarantine and I don't use Windows at home.

    But IT crew had to enable a write permission on synfig folder in c:[I don't remember the path] as far as I remember

  5. ice0 commented on May 1, 2020

    @ice0
    Collaborator

    Confirmed. I removed the write permissions on the Synfig folder, and I got this:

    Synfig tries to create file: C:\Users\user\Downloads\SynfigStudio-1.5.0-testing-2020.02.29-win64-478b0\config\tmp\synfig_instance_9D09952C5A99F75295558C2EAB0F6FF0

  6. morevnaproject commented on May 1, 2020

    @morevnaproject
    Member
  7. ice0 commented on May 1, 2020

    @ice0
    Collaborator

    I think the problem is here:

    std::string
    App::get_temporary_directory()
    {
    return synfigapp::Main::get_user_app_directory() + ETL_DIRECTORY_SEPARATOR + "tmp";
    }

  8. morevnaproject commented on May 1, 2020

    @morevnaproject
    Member

    synfig::String
    synfigapp::Main::get_user_app_directory()
    {
    String dir;
    if (char* synfig_user_settings_dir = getenv("SYNFIG_USER_SETTINGS")) {
    dir = Glib::locale_from_utf8(String(synfig_user_settings_dir));
    } else {
    dir = Glib::get_home_dir()+ETL_DIRECTORY_SEPARATOR+SYNFIG_USER_APP_DIR;
    }
    return dir;
    }

    So, get_user_app_directory() uses Glib::get_home_dir() and from Glib's sourcesL

    /** Gets the current user's home directory.
     * @return The current user's home directory or an empty string if not defined.
     */
    std::string get_home_dir();
    

    --> an empty string if not defined

    Should we check output of get_home_dir()?

    On the other hand, i do not see how "config/tmp" could appear in the code - it constructs different path.

    @ice0 are you sure you've got exactly this path?

  9. rodolforg commented on May 1, 2020

    @rodolforg
    ContributorAuthor

    FileSystemTemporary::Handle temporary_file_system = new FileSystemTemporary("instance", get_temporary_directory(), canvas_file_system);

    FileSystemTemporary::FileSystemTemporary(const String &tag, const String &temporary_directory, const FileSystem::Handle &sub_file_system):
    file_system(FileSystemNative::instance()),
    tag(tag),
    temporary_directory(temporary_directory.empty() ? get_system_temporary_directory() : temporary_directory),
    temporary_filename_base(generate_temporary_filename_base(tag)),
    keep_files_when_destroyed(false),
    autosave(true)
    {
    set_sub_file_system(sub_file_system);
    }

    String
    FileSystemTemporary::generate_temporary_filename_base(const String &tag)
    {
    return "synfig_" + tag + "_" + GUID().get_string();
    }

  10. morevnaproject commented on May 1, 2020

    @morevnaproject
    Member

    @rodolforg that part of code generate last part of save path (filename) - synfig_instance_9D09952C5A99F75295558C2EAB0F6FF0.

    I wonder where does tmp/config part comes from...

  11. rodolforg commented on May 1, 2020

    @rodolforg
    ContributorAuthor

    SYNFIG_USER_APP_DIR?

  12. rodolforg commented on May 1, 2020

    @rodolforg
    ContributorAuthor

    std::string
    App::get_temporary_directory()
    {
    return synfigapp::Main::get_user_app_directory() + ETL_DIRECTORY_SEPARATOR + "tmp";
    }

    Anyway, I think we should avoid duplicated methods for retrieving temporary dir (and with different results!). Maybe merge with:

    String
    FileSystemTemporary::get_system_temporary_directory()
    {
    const char *tmpdir;
    if ((tmpdir = getenv("TEMP")) == NULL)
    if ((tmpdir = getenv("TMP")) == NULL)
    if ((tmpdir = getenv("TMPDIR")) == NULL)
    tmpdir = "/tmp";
    return String(tmpdir);
    }

    Actually, it should have a (static?) class for deal with filesystem dirs and filenames.
    Dirs:

    • Temporary files : system-wide temporary folder but inside a "synfig" prefix (in unix-like OS: /tmp/synfig)
    • App data : system-wide plugins, icons, sound, ui files etc for Synfig
    • User app data : similar above but for user-scope (optional)
    • User app config : for Synfig user preferences & settings

    Did I miss any possible folder?

  13. ice0 commented on May 2, 2020

    @ice0
    Collaborator

    are you sure you've got exactly this path?

    Yep. This path is just copied from process monitor.

    The main problem was that I could not reproduce the problem using my own local build. Everything just works fine. So I continued digging and noticed that if I run synfigstudio from the bin folder, everything works fine.

    Then I looked inside synfigstudio.bat.

    And voila:

    cd "%~dp0\"
    set SYNFIG_USER_SETTINGS=%~dp0\config
    start "" "%~dp0\bin\synfigstudio.exe" --console
    

    So I think you can reproduce the problem on Linux if you set SYNFIG_USER_SETTINGS to read-only folder.

    P.S. Changed it to

    set SYNFIG_USER_SETTINGS=%USERPROFILE%\config
    

    and now all works fine.

  14. 13 remaining items

  15. morevnaproject commented on May 12, 2020

    @morevnaproject
    Member

    And compilation system sets:

    • IMAGE_DIR
    • PLUGIN_DIR
    • SOUNDDIR
    • UIDIR

    That's all subdirectories of "$PREFIX/share/synfig", where $PREFIX is Synfig installation.

  16. rodolforg commented on May 12, 2020

    @rodolforg
    ContributorAuthor

    Is Synfig writes any temporary files? I can remember only backups, but this seems to be a separate section. ^__^"

    It seem it does:

    Synfig tries to create file: C:\Users\user\Downloads\SynfigStudio-1.5.0-testing-2020.02.29-win64-478b0\config\tmp\synfig_instance_9D09952C5A99F75295558C2EAB0F6FF0


    I updated the proposal comment: #1052 (comment)

  17. rodolforg commented on May 13, 2020

    @rodolforg
    ContributorAuthor

    Something like this (but static):

    class FilePath {
    
    	/// Returns the full path for a temp file including its filename
    	/// It doesn't check if it exists, just creates the string
    	std::string get_temp_filepath(std::string filename);
    	/// Returns the full path for a temp dir for the Synfig.
    	/// Read and write access
    	std::string get_temp_dir();
    
    	enum DataType {
    		IMAGES,
    		ICONS, // maybe
    		BRUSHES,
    		SOUND,
    		UI,
    		LOCALE,
    		PLUGINS,
    		MODULES // current in /etc . Should it be under a new get_system_app_config_filepath()?
    	};
    	/// Returns the full path for a data file including its filename in a system-wide directory
    	/// It doesn't check if it exists, just creates the string
    	std::string get_system_app_data_filepath(DataType data_type, std::string filename);
    	/// Returns the full path for a data file including its filename in a user-scope directory
    	/// It doesn't check if it exists, just creates the string
    	std::string get_user_app_data_filepath(DataType data_type, std::string filename);
    	/// Returns the full path for a data file, including its filename
    	/// It searches for it first in current user directory and then in system one if not found
    	/// Returns an empty string if not found in any place
    	std::string get_app_data_filepath(DataType data_type, std::string filename);
    
    	/// Returns the full path for an app data dir for the Synfig.
    	/// Read-only access
    	std::string get_system_app_data_dir(DataType data_type);
    	/// Returns the full path for an app data dir for the Synfig.
    	/// Read-only access
    	std::string get_user_app_data_dir(DataType data_type);
    
    	std::string get_app_config_filepath(std::string filename);
    	/// Returns the full path for the dir for the Synfig settings.
    	/// Read and write access
    	std::string get_app_config_dir();
    
    	std::string get_app_cache_filepath(std::string filename);
    	/// Returns the full path for the dir for the Synfig backups.
    	/// Read and write access
    	std::string get_app_cache_dir();
    };
  18. ice0 commented on May 13, 2020

    @ice0
    Collaborator

    Another case for Linux that can be resolved with a relative path (like on Windows):

    When we compile synfig using the IDE / CMake, we do not do the install step before starting it.
    This currently works because we are creating the same directory structure (as for Windows) inside the build directory.
    Therefore, we also need the ability to search on relative paths (from binary).
    For instance:
    ../etc/
    ../share/

  19. rodolforg commented on May 13, 2020

    @rodolforg
    ContributorAuthor

    Linux software (sadly or not) don't rely on this path resolution like Windows does (current dir first, then system dir): it tries .local, /usr/local and /usr normally.
    But we could allow that in those methods I propose like get_app_data_filepath(). It could search for a file in these dirs: "current" dir first, then .local, then /usr/local and finally /usr , stopping where it finds first.
    Maybe creating an environment variable to limit it to "current" directory only: helpful to check if it has all inside the current strutcture

  20. rodolforg commented on May 14, 2020

    @rodolforg
    ContributorAuthor

    If I code such class… should be at synfig or studio?

    I ask it because some data are useless to core:
    IMAGES,
    ICONS,
    SOUND,
    UI,
    ?? PLUGINS,

    Argh

  21. morevnaproject commented on May 14, 2020

    @morevnaproject
    Member

    If I code such class… should be at synfig or studio?

    I ask it because some data are useless to core:
    IMAGES,
    ICONS,
    SOUND,
    UI,
    ?? PLUGINS,

    That's all resources only for studio ^__^

  22. morevnaproject commented on May 14, 2020

    @morevnaproject
    Member

    Is Synfig writes any temporary files? I can remember only backups, but this seems to be a separate section. ^__^"

    It seem it does:

    Synfig tries to create file: C:\Users\user\Downloads\SynfigStudio-1.5.0-testing-2020.02.29-win64-478b0\config\tmp\synfig_instance_9D09952C5A99F75295558C2EAB0F6FF0

    This is a part of autobackup system.
    When Synfig opens/creates any file it wraps the file into temporary filesystem, which is used for keeping autobackups and embed resources (which are not saved yet, i.e. embedded images).

    This is how saving works:
    app --> saved to temporary filesystem --> contents of saved filesystem dumped to real file location.

    For autosave there are no last step:
    app --> saved to temporary filesystem

    So, this is a part of backup infrastructure and should be stored in ~/.cache.

  23. rodolforg commented on May 14, 2020

    @rodolforg
    ContributorAuthor

    This is a part of autobackup system.

    Ops ;)

    That's all resources only for studio ^__^

    Well, so I'd split the class into both scope: core and studio, the latter derived from former.

    I'd move into this class related methods like: synfig::FileSystem::fix_slashes(), etl::relative_path(), etl::solve_relative_path(), etl::cleanup_path(), etl::basename()…

    I think they're misplaced anyway. It is strange they're at "etl/stringf.h"

    What do you think?

  24. ice0 commented on May 16, 2020

    @ice0
    Collaborator

    Agree. I think they must be moved outside stringf.

  25. ice0 commented on May 16, 2020

    @ice0
    Collaborator

    Maybe creating an environment variable to limit it to "current" directory only: helpful to check if it has all inside the current strutcture

    I think you can use SYNFIG_ROOT_DIR for this.

  26. modified the milestones: v1.4.0, v1.6.0 on Nov 14, 2020
  27. rodolforg commented on Nov 14, 2020

    @rodolforg
    ContributorAuthor

    This should be fixed soon, otherwise Windows users won't be able to save their work (if not using portable version)!

  28. morevnaproject commented on Nov 16, 2020

    @morevnaproject
    Member

    @rodolforg This issue is specific to portable build, installer do not use .bat file.
    Please see my #1052 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions