u-nikos Posted December 21, 2012 Share Posted December 21, 2012 Hey all, I'm having a weird issue. Uploaded files are not visible with SFTP. The files get uploaded to the correct directories with the correct permissions and owner settings but somehow they don't show up in SFTP sessions. All thumbnails are visible; it's just the uploaded file that is not visible. The files do show up when changing the following line: Upload.php line 233: if($ajax) $success = @rename($tmp_name, $destination); to: Upload.php line 233: if($ajax) $success = @copy($tmp_name, $destination); Anybody know what is going on? Link to comment Share on other sites More sharing options...
teppo Posted December 22, 2012 Share Posted December 22, 2012 (edited) Hello there! I'm sorry but I'm not completely sure that I understand your problem, so I'm going to need to ask a bunch of hopefully clarifying questions first: You said that files get uploaded correctly but don't show up with SFTP.. exactly how did you check that they're correctly uploaded, was it with a shell access or..? Is the site you're working on public and if it is, could you perhaps provide a link to one of these files? Which SFTP client are you using? Just in case that this isn't really related to PW or OS but an error with that particular application.. Based on code changes you've made to fix the problem, my first guess would be that the user PHP is running as doesn't have required access to actually remove files from temp upload directory and that's causing strange behavior elsewhere. Could you check if anything strange shows up at Apache error log when you try uploading new files? Edit: you could also try removing "@" from @rename and see if (and what) error it outputs. Suppressing errors isn't very helpful while debugging.. Edited December 22, 2012 by teppo Link to comment Share on other sites More sharing options...
apeisa Posted December 22, 2012 Share Posted December 22, 2012 If files do get uploaded, but arent visible through sftp, then problem lies in your sftp program. Maybe your sftp program is caching the directory view and requires clicking refresh? 1 Link to comment Share on other sites More sharing options...
u-nikos Posted December 22, 2012 Author Share Posted December 22, 2012 Thanks for the quick responses! I have narrowed the problem down to SELinux. When a file is uploaded PHP stores the file in the /tmp directory and after that Upload.php moves the file with rename or move_uploaded_file to the final destination. The problem is that the file doesn't have the correct SELinux label after moving it. I dont have a solution yet but I'm working on it. Maybe someone else has encountered this problem before? Link to comment Share on other sites More sharing options...
u-nikos Posted December 22, 2012 Author Share Posted December 22, 2012 Ok, I've now set the "upload_tmp_dir" to "/home/www.domain.com/_tmp" (only accessible by the www.domain.com user) instead of the default "/tmp" directory. Apparently SELinux does not relabel files when moving/renaming them between directories, only when creating/copying files. By using a tmp directory in the home directory, the uploaded files get a "user_home_t" label, which should be enough. Does anybody know any disadvantages of this method? Link to comment Share on other sites More sharing options...
diogo Posted December 22, 2012 Share Posted December 22, 2012 I use fedora, and yep, SELinux can be annoying at times... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now