[Mono-dev] Patch for environment specific location for .mono folder

Tom Philpot tom.philpot at logos.com
Tue Jun 1 12:44:42 EDT 2010

Attached is a patch that allows the user (or an embedded application) to set MONO_USER_CONFIG to specify a directory location for the .mono folder, similar to the MONO_CONFIG environment variable for mono configuration folder.

We have an app which embeds Mono and we'd like to be certain that other Mono apps won't be tinkering with our configuration. This also allows us to make sure that the .mono folder can be created/updated as certain users don't have write access to their home folder, but do have access to sub-folders. We'd prefer not to have to ask for elevated permissions just to create a hidden config folder. Finally, this allows our application not to scatter configuration information throughout the file system as we can put all our configuration under an application specific folder.

This patch is MIT/X11 licensed.

Index: mono-config.c
--- mono-config.c	(revision 158291)
+++ mono-config.c	(working copy)
@@ -560,7 +560,9 @@
 	g_free (mono_cfg);
 #ifndef TARGET_WIN32
-	home = g_get_home_dir ();
+	home = g_getenv ("MONO_USER_CONFIG");
+	if (home == NULL)
+		home = g_get_home_dir ();
 	user_cfg = g_strconcat (home, G_DIR_SEPARATOR_S, ".mono/config", NULL);
 	mono_config_parse_file (user_cfg);
 	g_free (user_cfg);


More information about the Mono-devel-list mailing list