From 9dd0b37817747f9f5464a6108cd3027ec63767ee Mon Sep 17 00:00:00 2001
From: moodler <moodler>
Date: Mon, 21 Apr 2003 07:11:29 +0000
Subject: [PATCH] Make sure to change the ownership of uploaded files

---
 mod/assignment/upload.php | 1 +
 mod/forum/lib.php         | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/mod/assignment/upload.php b/mod/assignment/upload.php
index 56c5e53676..a482131e52 100644
--- a/mod/assignment/upload.php
+++ b/mod/assignment/upload.php
@@ -53,6 +53,7 @@
             $newfile_name = clean_filename($newfile['name']);
             if ($newfile_name) {
                 if (move_uploaded_file($newfile['tmp_name'], "$dir/$newfile_name")) {
+                    chmod("$dir/$newfile_name", $CFG->directorypermissions);
                     assignment_delete_user_files($assignment, $USER, $newfile_name);
                     if ($submission) {
                         $submission->timemodified = time();
diff --git a/mod/forum/lib.php b/mod/forum/lib.php
index 957182cd8a..a43288d31b 100644
--- a/mod/forum/lib.php
+++ b/mod/forum/lib.php
@@ -1178,6 +1178,8 @@ function forum_add_attachment($post, $newfile) {
 // $newfile is a full upload array from $_FILES
 // If successful, this function returns the name of the file
 
+    global $CFG;
+
     if (empty($newfile['name'])) {
         return "";
     }
@@ -1194,6 +1196,7 @@ function forum_add_attachment($post, $newfile) {
 
         } else {
             if (move_uploaded_file($newfile['tmp_name'], "$dir/$newfile_name")) {
+                chmod("$dir/$newfile_name", $CFG->directorypermissions);
                 forum_delete_old_attachments($post, $newfile_name);
             } else {
                 notify("An error happened while saving the file on the server");
-- 
2.39.5