View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0007842 | mantisbt | bugtracker | public | 2007-03-20 14:22 | 2007-12-21 23:16 |
| Reporter | atomoid | Assigned To | giallu | ||
| Priority | normal | Severity | major | Reproducibility | always |
| Status | closed | Resolution | fixed | ||
| Product Version | 1.0.6 | ||||
| Target Version | 1.1.0 | Fixed in Version | 1.1.0a4 | ||
| Summary | 0007842: File attachment permissions | ||||
| Description | Currently, the permissions settings for file attachments is set to "0400". This results in non-admin users of the webserver not being able to back up their file attachments since apparently some 'cant-copy-this' bit is set by the '0400' setting. Workaround:
however, being a unix noob, i really dont know have a solid concept of what these numbers actually mean, or really what the appropriate setting really should be. | ||||
| Tags | No tags attached. | ||||
| Attached Files | permissions.patch (559 bytes)
Index: file_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/file_api.php,v
retrieving revision 1.76
diff -u -r1.76 file_api.php
--- file_api.php 15 Sep 2006 05:02:47 -0000 1.76
+++ file_api.php 22 Mar 2007 08:18:38 -0000
@@ -644,7 +644,7 @@
if ( !move_uploaded_file( $p_tmp_file, $t_disk_file_name ) ) {
trigger_error( FILE_MOVE_FAILED, ERROR );
}
- chmod( $t_disk_file_name, 0400 );
+ chmod( $t_disk_file_name, 0644 );
$c_content = '';
} else {
file-permissions.patch (2,166 bytes)
Index: mantisbt/config_defaults_inc.php
===================================================================
--- mantisbt.orig/config_defaults_inc.php
+++ mantisbt/config_defaults_inc.php
@@ -760,6 +760,10 @@
# DISK, DATABASE, or FTP.
$g_file_upload_method = DATABASE;
+ # When using FTP or DISK for storing uploaded files, they will be created
+ # with the following permissions
+ $g_new_file_permissions = 0400;
+
# FTP settings, used if $g_file_upload_method = FTP
$g_file_upload_ftp_server = 'ftp.myserver.com';
$g_file_upload_ftp_user = 'readwriteuser';
@@ -1798,4 +1802,6 @@
# access level required to run reports
$g_time_tracking_reporting_threshold = MANAGER;
+
+# vim: noexpandtab tabstop=4 softtabstop=0:
?>
Index: mantisbt/core/bug_api.php
===================================================================
--- mantisbt.orig/core/bug_api.php
+++ mantisbt/core/bug_api.php
@@ -595,7 +595,7 @@
$t_new_file_name = file_get_display_name( $t_bug_file['filename'] );
if ( ( config_get( 'file_upload_method' ) == DISK ) ) {
copy( $t_bug_file['diskfile'], $t_new_diskfile_name );
- chmod( $t_new_diskfile_name, 0400 ); # make file read only in the file system
+ chmod( $t_new_diskfile_name, $g_new_file_permissions );
}
$query = "INSERT INTO $t_mantis_bug_file_table
Index: mantisbt/core/file_api.php
===================================================================
--- mantisbt.orig/core/file_api.php
+++ mantisbt/core/file_api.php
@@ -636,7 +636,7 @@
trigger_error( FILE_MOVE_FAILED, ERROR );
}
- chmod( $t_disk_file_name, 0644 );
+ chmod( $t_disk_file_name, $g_new_file_permissions );
$c_content = '';
} else {
Index: mantisbt/proj_doc_update.php
===================================================================
--- mantisbt.orig/proj_doc_update.php
+++ mantisbt/proj_doc_update.php
@@ -107,7 +107,7 @@
if ( !move_uploaded_file( $v_tmp_name, $t_disk_file_name ) ) {
trigger_error( FILE_MOVE_FAILED, ERROR );
}
- chmod( $t_disk_file_name, 0400 );
+ chmod( $t_disk_file_name, $g_new_file_permissions );
$c_content = '';
break;
file-permissionsv2.patch (2,126 bytes)
Index: mantisbt/config_defaults_inc.php
===================================================================
--- mantisbt.orig/config_defaults_inc.php
+++ mantisbt/config_defaults_inc.php
@@ -760,6 +760,10 @@
# DISK, DATABASE, or FTP.
$g_file_upload_method = DATABASE;
+ # When using FTP or DISK for storing uploaded files, they will be created
+ # on the server with the following permissions
+ $g_attachments_file_permissions = 0400;
+
# FTP settings, used if $g_file_upload_method = FTP
$g_file_upload_ftp_server = 'ftp.myserver.com';
$g_file_upload_ftp_user = 'readwriteuser';
Index: mantisbt/core/bug_api.php
===================================================================
--- mantisbt.orig/core/bug_api.php
+++ mantisbt/core/bug_api.php
@@ -595,7 +595,7 @@
$t_new_file_name = file_get_display_name( $t_bug_file['filename'] );
if ( ( config_get( 'file_upload_method' ) == DISK ) ) {
copy( $t_bug_file['diskfile'], $t_new_diskfile_name );
- chmod( $t_new_diskfile_name, 0400 ); # make file read only in the file system
+ chmod( $t_new_diskfile_name, config_get( 'attachments_file_permissions' ) );
}
$query = "INSERT INTO $t_mantis_bug_file_table
Index: mantisbt/core/file_api.php
===================================================================
--- mantisbt.orig/core/file_api.php
+++ mantisbt/core/file_api.php
@@ -645,7 +645,7 @@ document.getElementById( span ).style.di
trigger_error( FILE_MOVE_FAILED, ERROR );
}
- chmod( $t_disk_file_name, 0644 );
+ chmod( $t_disk_file_name, config_get( 'attachments_file_permissions' ) );
$c_content = '';
} else {
Index: mantisbt/proj_doc_update.php
===================================================================
--- mantisbt.orig/proj_doc_update.php
+++ mantisbt/proj_doc_update.php
@@ -107,7 +107,7 @@
if ( !move_uploaded_file( $v_tmp_name, $t_disk_file_name ) ) {
trigger_error( FILE_MOVE_FAILED, ERROR );
}
- chmod( $t_disk_file_name, 0400 );
+ chmod( $t_disk_file_name, config_get( 'attachments_file_permissions' ) );
$c_content = '';
break;
| ||||
|
Crash course in *nix permissions :) each file in the filesystem has basically:
So, 400 means the file can be read only by the owner: that looks like too tight... on the other side 775 is too loose as it would be readable/writable by everyone I think a saner value could be 644 (everyone can read, ownly the owner can write) could you please verify if using 644 still fixes your problem? |
|
|
i tried using "0644" in line 578 (previously i said line 600, which was only because i had spliced in swf file format support) in core/file_api.php resulting in: tested it on our live Mantis installation running on a bonafide unix server and the resultant 'rights' of the newly uploaded file on the server are "rw-r--r--" sound right? |
|
|
glad to know it worked. I am attaching a patch for someone with access to CVS to commit. Try this to complete your understanding about file permissions: |
|
|
This patch does create a security hole, however. Any user that can log into the system can now view attachments. I'd suggest reverting this patch and running the web server backup as root, or the apache user. |
|
|
Reopening to address thraxisp concerns |
|
|
I uploaded a new patch which adds a new configuration parameter, so the user can select permissions for new files. The default value is 0400 as before, so I think it will be also acceptable from the security POV |
|
|
Following are my review comments for the patch:
|
|
|
|
|
patch applied |
|
|
MantisBT: master ebf9e99e 2007-06-08 11:42 Details Diff |
Fix 7842: File attachment permissions git-svn-id: http://mantisbt.svn.sourceforge.net/svnroot/mantisbt/trunk@4377 <a class="text" href="/?p=mantisbt.git;a=object;h=f5dc347c">f5dc347c</a>-c33d-0410-90a0-b07cc1902cb9 |
Affected Issues 0007842 |
|
| mod - config_defaults_inc.php | Diff File | ||
| mod - proj_doc_update.php | Diff File | ||
| mod - core/file_api.php | Diff File | ||
| mod - core/bug_api.php | Diff File | ||