diff --git a/ecrire/inc/flock.php b/ecrire/inc/flock.php
index 992b58d7a85c036e6adffd519ed8b771e6e0de3e..46ce641b2c11bda94b3ead2bcfc48b68c3423538 100644
--- a/ecrire/inc/flock.php
+++ b/ecrire/inc/flock.php
@@ -163,7 +163,7 @@ function sous_repertoire($base, $subdir, $nobase = false) {
 		return "$baseaff$subdir/";
 
 	@mkdir($path, 0777);
-	@chmod($path, 0777);
+	@chmod($path, _DIR_CHMOD);
 
 	$ok = false;
 	if ($f = @fopen("$path/dir_test.php", "w")) {
diff --git a/ecrire/inc/getdocument.php b/ecrire/inc/getdocument.php
index 58b9790996d01f3eed8d1b695a5c3fb92d698a7d..88c845891847e754eb48109649b9e2db000112f2 100644
--- a/ecrire/inc/getdocument.php
+++ b/ecrire/inc/getdocument.php
@@ -88,7 +88,7 @@ function deplacer_fichier_upload($source, $dest, $move=false) {
 	else				$ok = @copy($source, $dest);
 	if (!$ok) $ok = @move_uploaded_file($source, $dest);
 	if ($ok)
-		@chmod($dest, 0666);
+		@chmod($dest, _DIR_CHMOD & ~0111);
 	else {
 		$f = @fopen($dest,'w');
 		if ($f) {
diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php
index a1504d89d61bb672857f13e04aa10d4fc6a2c163..919a73fbd4bd414ac25abe9e5325a4becb7a9f29 100644
--- a/ecrire/inc/utils.php
+++ b/ecrire/inc/utils.php
@@ -508,7 +508,7 @@ function spip_touch($fichier, $duree=0, $touch=true) {
 	|| (@filemtime($fichier) < time() - $duree)) {
 		if ($touch) {
 			if (!@touch($fichier)) { @unlink($fichier); @touch($fichier); };
-			if (!$exists) @chmod($fichier, 0666);
+			if (!$exists) @chmod($fichier, _DIR_CHMOD & ~0111);
 		}
 		return true;
 	}
diff --git a/ecrire/inc_version.php b/ecrire/inc_version.php
index d7448b755e89d2d9025bc820844d26a40a9b95ac..a9e7f1e57512fb0f68bfdcccf147d7badf3d9b61 100644
--- a/ecrire/inc_version.php
+++ b/ecrire/inc_version.php
@@ -265,6 +265,8 @@ function spip_initialisation_parametree($dir1, $dir2) {
 	if ($too_late) return;
 	$too_late = true;
 
+	define('_DIR_CHMOD', 0777);
+	
 	define('_DIR_IMG', $dir1 ."IMG/");
 	define('_DIR_DOC', $dir1 ."IMG/");
 	define('_DIR_LOGOS', $dir1 ."IMG/");