File ownership problem in uploads folder
File ownership problem in uploads folder
My webhost is moving all my accounts to a new server and we are having problems with all the directories and files in the uploads directory.
The files and directories are showing the user and owner as httpd:httpd
with a CHMOD value of 600.
I cannot download, change ownership of, change permissions or do anything with these files with an FTP program, through CPANEL file manager or any other means. The hosting service is even unable to copy the files to another server.
All actions result in 'Action Denied' 'Permission Denied'
Does anyone have a solution?
The files and directories are showing the user and owner as httpd:httpd
with a CHMOD value of 600.
I cannot download, change ownership of, change permissions or do anything with these files with an FTP program, through CPANEL file manager or any other means. The hosting service is even unable to copy the files to another server.
All actions result in 'Action Denied' 'Permission Denied'
Does anyone have a solution?
Greg
Re: File ownership problem in uploads folder
If You want a fastest solution, just put in Your root directory file named (for example) 'privs.php' with this content:
and run it in Your browser.
Note: this only fix directories which are necessary for full CMSMS functionality, not other dirs and files - upgrade will be not so painless... But now You have a lot of time for sending request by e-mail to Your provider. To be honest, I would like to see those rows of code in CMSMS install procedure
Code: Select all
<?php
include './config.php';
$dirs = array(
$config["previews_path"],
$config["root_path"]."/tmp/templates_c",
$config["uploads_path"],
$config["image_uploads_path"]
);
$result = "";
foreach ($dirs as $dir) {
result .= $dir." - ";
if (chmod($dir, 0777)) result .= "OK";
else result .= "ERROR";
result .= "<br>";
}
echo $result;
?>
Note: this only fix directories which are necessary for full CMSMS functionality, not other dirs and files - upgrade will be not so painless... But now You have a lot of time for sending request by e-mail to Your provider. To be honest, I would like to see those rows of code in CMSMS install procedure
Last edited by 100rk on Sat Feb 19, 2005 8:24 pm, edited 1 time in total.
File ownership problem in uploads folder
Thanks 100rk - ran the script and just get:
Warning: chmod(): No such file or directory in /hsphere/local/home/weyburnc/weyburncap.com/privs.php on line 16
Warning: chmod(): Operation not permitted in /hsphere/local/home/weyburnc/weyburncap.com/privs.php on line 16
Warning: chmod(): Operation not permitted in /hsphere/local/home/weyburnc/weyburncap.com/privs.php on line 16
Warning: chmod(): Operation not permitted in /hsphere/local/home/weyburnc/weyburncap.com/privs.php on line 16
/hsphere/local/home/weyburnc/weyburncap.com/smarty/cms/cache - ERROR /hsphere/local/home/weyburnc/weyburncap.com/tmp/templates_c - ERROR /hsphere/local/home/weyburnc/weyburncap.com/uploads - ERROR /hsphere/local/home/weyburnc/weyburncap.com/uploads/images - ERROR
Greg
File ownership problem in uploads folder
This error message seems like:
a) You use nonstandard 'cache' directory - '/smarty/cms/cache '
b) all directories specified in file config.php are unaccessible for the system - Your web provider did some changes in directory structure also - not only move data (maybe )
OK, now compare lines
if they are identical with proper lines of Your file /config.php and write back - so, if they will be not identical, correct it by hand. ALSO CHECK, if they directories exists in Your webroot directory structure.
a) You use nonstandard 'cache' directory - '/smarty/cms/cache '
b) all directories specified in file config.php are unaccessible for the system - Your web provider did some changes in directory structure also - not only move data (maybe )
OK, now compare lines
Code: Select all
$config["root_path"] = "/hsphere/local/home/weyburnc/weyburncap.com";
$config["previews_path"] = "/hsphere/local/home/weyburnc/weyburncap.com/tmp/cache";
$config["uploads_path"] = "/hsphere/local/home/weyburnc/weyburncap.com/uploads";
$config["uploads_path"] = "/hsphere/local/home/weyburnc/weyburncap.com/uploads/images";
File ownership problem in uploads folder
Thanks for the info 100rk.
I made the change to the tmp directory, I ensured all config.php settings are exactly as in your post and still get this result:
I made the change to the tmp directory, I ensured all config.php settings are exactly as in your post and still get this result:
Warning: chmod(): Operation not permitted in /hsphere/local/home/weyburnc/weyburncap.com/privs.php on line 16
Warning: chmod(): Operation not permitted in /hsphere/local/home/weyburnc/weyburncap.com/privs.php on line 16
Warning: chmod(): Operation not permitted in /hsphere/local/home/weyburnc/weyburncap.com/privs.php on line 16
Warning: chmod(): Operation not permitted in /hsphere/local/home/weyburnc/weyburncap.com/privs.php on line 16
/hsphere/local/home/weyburnc/weyburncap.com/tmp/cache - ERROR /hsphere/local/home/weyburnc/weyburncap.com/tmp/templates_c - ERROR /hsphere/local/home/weyburnc/weyburncap.com/uploads - ERROR /hsphere/local/home/weyburnc/weyburncap.com/uploads/images - ERROR
Greg
File ownership problem in uploads folder
Ok Greg, now create file named for example 'dirpath.php', copy into it this code
and load it by browser. This script just display directory of running script, nothing more. Is this output Your 'root_path' from config.php?
Code: Select all
<?php
echo dirname(__FILE__));
?>
File ownership problem in uploads folder
/hsphere/local/home/weyburnc/weyburncap.com
Which is the same as my root path in the config.php file.
Which is the same as my root path in the config.php file.
Greg
File ownership problem in uploads folder
Next code:
Code: Select all
<?php
$destfile = "uploads/test.bak";
if (copy(__FILE__, $destfile)) {
$fileowneruid=fileowner($destfile);
$fileownerarray=posix_getpwuid($fileowneruid);
$fileowner=$fileownerarray['name'];
$filegroupgid=filegroup($destfile);
$filegrouparray=posix_getgrgid($filegroupgid);
$filegroup=$filegrouparray['name'];
@unlink($destfile);
echo "Ownership is ".$fileowner.":".$filegroup;
}
else {
echo "cannot copy file";
}
?>
It is one of last chances find out reason of Your problems, Greg...
a) Your script runs under other user/group then httpd:httpd
b) new server configuration has some problems with 'open_basedir' settings or virtual directory support or something
c) I am absolutely stupid
File ownership problem in uploads folder
Thanks for all the help. Webhost is moving files now, we will have to re-create them on the new server.
Greg
File ownership problem in uploads folder
Not at all, nice practice for me
Send my regards to Your provider
Send my regards to Your provider
CHMOD()
file: ibrowser.php
// upload image
function uploadImg($img) {
global $HTTP_POST_FILES;
global $HTTP_SERVER_VARS;
global $tinyMCE_valid_imgs;
global $imglib;
global $errors;
global $l;
global $tinyMCE_upload_allowed;
global $config;
if (!$tinyMCE_upload_allowed) return false;
$_root = $config['image_uploads_path'].'/';
if ($HTTP_POST_FILES[$img]['size']>0) {
$data['type'] = $HTTP_POST_FILES[$img]['type'];
$data['name'] = $HTTP_POST_FILES[$img]['name'];
$data['size'] = $HTTP_POST_FILES[$img]['size'];
$data['tmp_name'] = $HTTP_POST_FILES[$img]['tmp_name'];
// get file extension
$ext = strtolower(substr(strrchr($data['name'],'.'), 1));
if (in_array($ext,$tinyMCE_valid_imgs)) {
$dir_name = $_root.$imglib;
$img_name = $data['name'];
$i = 1;
while (file_exists($dir_name.$img_name)) {
$img_name = ereg_replace('(.*)(\.[a-zA-Z]+)$', '\1_'.$i.'\2', $data['name']);
$i++;
}
if (!move_uploaded_file($data['tmp_name'], $dir_name.$img_name)) {
$errors[] = '{lang_ibrowser_errorupload}';
return false;
}
## this is change##
if (chmod($dir_name.$img_name, 0666)) $result = "OK";
else $result= "ERROR";
echo $result;
return $img_name;
## this is change##
}
else
{
$errors[] = '{$lang_ibrowser_errortype}';
}
}
return false;
}
// upload image
function uploadImg($img) {
global $HTTP_POST_FILES;
global $HTTP_SERVER_VARS;
global $tinyMCE_valid_imgs;
global $imglib;
global $errors;
global $l;
global $tinyMCE_upload_allowed;
global $config;
if (!$tinyMCE_upload_allowed) return false;
$_root = $config['image_uploads_path'].'/';
if ($HTTP_POST_FILES[$img]['size']>0) {
$data['type'] = $HTTP_POST_FILES[$img]['type'];
$data['name'] = $HTTP_POST_FILES[$img]['name'];
$data['size'] = $HTTP_POST_FILES[$img]['size'];
$data['tmp_name'] = $HTTP_POST_FILES[$img]['tmp_name'];
// get file extension
$ext = strtolower(substr(strrchr($data['name'],'.'), 1));
if (in_array($ext,$tinyMCE_valid_imgs)) {
$dir_name = $_root.$imglib;
$img_name = $data['name'];
$i = 1;
while (file_exists($dir_name.$img_name)) {
$img_name = ereg_replace('(.*)(\.[a-zA-Z]+)$', '\1_'.$i.'\2', $data['name']);
$i++;
}
if (!move_uploaded_file($data['tmp_name'], $dir_name.$img_name)) {
$errors[] = '{lang_ibrowser_errorupload}';
return false;
}
## this is change##
if (chmod($dir_name.$img_name, 0666)) $result = "OK";
else $result= "ERROR";
echo $result;
return $img_name;
## this is change##
}
else
{
$errors[] = '{$lang_ibrowser_errortype}';
}
}
return false;
}