I have no clue in programming... Help needed in Kohana - kohana

A developer worked on a website for us where we can upload images. Everytime I try I get this error message. But not with all images. Some images are uploaded but do not appear. Am I missing something?
"Kohana_Exception [ 0 ]: Directory DOCROOT/data/clients/logos/ must be writable"
**SYSPATH/classes/kohana/upload.php [ 80 ]**
75 $directory = Upload::$default_directory;
76 }
77
78 if ( ! is_dir($directory) OR ! is_writable(realpath($directory)))
79 {
80 throw new Kohana_Exception('Directory :dir must be writable',
81 array(':dir' => Debug::path($directory)));
82 }
83
84 // Make the filename into a complete path
85 $filename = realpath($directory).DIRECTORY_SEPARATOR.$filename;

DOCROOT is the root path of your kohana application. I normally contains the following folders and files:
application/
modules/
system/
index.php
In your case there is also an data folder. The easiest way to fix your problem is to first check if all folders exist. Do the following from the root path:
cd data/clients/logos/
if it throws an error do the following commands
mkdir data/clients/logos
chmod 777 data/clients/logos
if you don't get an error do the following commands
cd ../
chmod 777 logos
I'm flying blind here so I could be wrong but this should fix your upload issues

Make sure the directory DOCROOT/data/clients/logos/ exists and is writeable. DOCROOT is most likely a configuration variable somewhere and should be the folder from where the webserver serves its files.

Related

Linux script does not work when executed using the full path

I have an issue executing a script from another directory using a full path.
For example, user jnh has the script in its home directory(/home/jnh):
# ls -l
total 4
-rwxr-x--- 1 jnh tstgrp 120 Mar 12 16:39 test.run
Now, when I log in as jnh and go to another directory such as /apps and execute the script using the full path, I got an error message:
# /home/jnh/test.run
touch: cannot touch `test.txt': Permission denied
Any idea? Thank you in advance!
Joie
I think your problem is a permissions problem not a scripting problem. Does user jnh have write permission on the directory /apps? Because you are running the script from /apps it's the working directory, and thats where it is trying to create the file, so the user that is running the script must have permissions to do so.

How come my Apache can only access root owned files?

Running apache on centos 6.4 and my web server can't see any files unless the root user creates or copies them.
ps aux | grep apache shows that apache is running as apache user, not root.
I tried chown apache:apache on the files.
I even set chmod 777 on the files.
-rwxrwxrwx. 1 apache apache 2300 May 15 17:46 example.php
I still get an http 500 error, what else could be wrong?
also even if I chown the file to root:root, it will not work, I need to actually cp file.php file.php as root before it will work. I don't get it!
chcon -t httpd_sys_content_t example.php gets me there! - thanks Chris.
Does this mean I need to change my FTP user's Security Context settings so they can upload files like this or do I need to change a rule in SELinux to allow a wider range of files to execute?
SELinux might here be a problem.
Please do ls -lZ example.php
To rule out SELinux you can:
getenforce
then
setenforce 0
And try accessing this file again...
That will temporarily put SELinux in permissive mode.
You might have to change a context of the file! Let us know how it goes and we will take it from there.
Update:
As expected, SELinux was stopping apache from accessing that file. If you trust this file, you can change it's context:
chcon -v --type=httpd_sys_content_t example.php
If there is more than one file, you could use -R flag, so:
chcon -vR --type=httpd_sys_content_t /html/
As you have noticed, with ls you have -Z flag to show SELlinux context. You can try using this flag with other programs like ps for example.
To troubleshoot SELinux problems I recommend sealert - part of setroubleshoot-server.
How did I know that you are most likely using SELinux? Your filesystem is labeled.
How did i know that your fs is labeled? -rwxrwxrwx**.** - dot at the end of permissions tells that fs is labeled.
Don't forget to change the permissions! You really don't want 777...
Hope that helps.
If you have enabled suphp then files with 777 permissions will not work fine and give 500 error, change the permissions 644.
Also check error log for the same if you are still facing same issue.
Why are you trying 'cp file.php file.php' with same name, to copy use other name as below or copy to another location where file.php not exists.
cp file.php file.php-bak
or
cp file.php another-dir/file.php

Chmod 777 to a folder and all contents [duplicate]

This question already has answers here:
How do I change permissions for a folder and its subfolders/files? [closed]
(19 answers)
Closed 4 years ago.
I have a web directory /www and a folder in that directory called store.
Within store are several files and folders. I want to give the folder store and all files and folders within the store folder all permissions.
How do I do this? I am guessing via .htaccess.
If you are going for a console command it would be:
chmod -R 777 /www/store. The -R (or --recursive) options make it recursive.
Or if you want to make all the files in the current directory have all permissions type:
chmod -R 777 ./
If you need more info about chmod command see: File permission
If by all permissions you mean 777
Navigate to folder and
chmod -R 777 .
You can give permission to folder and all its contents using option -R i.e Recursive permissions.
But I would suggest not to give 777 permission to all folder and it's all contents. You should give specific permission to each sub-folder in www directory folders.
Ideally, give 755 permission for security reasons to the web folder.
sudo chmod -R 755 /www/store
Each number has meaning in permission. Do not give full permission.
N Description ls binary
0 No permissions at all --- 000
1 Only execute --x 001
2 Only write -w- 010
3 Write and execute -wx 011
4 Only read r-- 100
5 Read and execute r-x 101
6 Read and write rw- 110
7 Read, write, and execute rwx 111
First Number 7 - Read, write, and execute for the user.
Second Number 5 - Read and execute for the group.
Third Number 5 - Read and execute for others.
If your production web folder has multiple users, then you can set permissions and user groups accordingly.
More info :
Understanding File Permissions: What Does “Chmod 777″ Mean?
What file permissions should I set on web root?
Why shouldn't /var/www have chmod 777
You can also use chmod 777 *
This will give permissions to all files currently in the folder and files added in the future without giving permissions to the directory itself.
NOTE: This should be done in the folder where the files are located. For me it was an images that had an issue so I went to my images folder and did this.
Yes, very right that the -R option in chmod command makes the files/sub-directories under the given directory will get 777 permission. But generally, it's not a good practice to give 777 to all files and dirs as it can lead to data insecurity. Try to be very specific on giving all rights to all files and directories. And to answer your question:
chmod -R 777 your_directory_name
... will work
for mac, should be a ‘superuser do’;
so first :
sudo -s
password:
and then
chmod -R 777 directory_path
This didn't work for me.
sudo chmod -R 777 /path/to/your/file/or/directory
I used -f also.
sudo chmod -R -f 777 /path/to/your/file/or/directory

Undeletable file in cygwin

A command I executed in cygwin hosed up a bunch of files. Now I cannot delete them. Omitting most of the 'ls' output, here is what I'm dealing with:
% ls -l
ls: cannot access WSERV001.txt: No such file or directory
-rw-r--r-- 1 mccppk mkgroup-l-d 50 Sep 17 16:57 WSERV001.text
??????????? ? ? ? ? ? WSERV001.txt
% rm WSERV001.txt
rm: cannot remove `WSERV001.txt': No such file or directory
% touch WSERV001.txt
touch: cannot touch `WSERV001.txt': Permission denied
The .text file is normal. The .txt file (directory entry anyway) is obviously hosed. Any ideas on how to get the .txt file deleted?
I had the same problem and fixed it as follow (under Win7):
Open a cmd windows (run as Administrator)
takeown /r /f DRIVE:\PATH
icacls DRIVE:\PATH /grant USERNAME:F /T
where USERNAME is your win7 username under which you are running this.
Also make sure cron.exe is NOT running for user USERNAME or SYSTEM (can be checked from the TaskManager) and that no programs from cygwin are running.
Once all has been checked and done, you should be able to delete your files.
Hope this helps,
Jean
I have a reproducible case and none of what is suggested here helps because of permissions restrictions.
Under sygwin:
[Sakis#t0000000000]$ ll
total 0
drwxr-x--- 1 ???????? ???????? 0 Jul 4 02:51 t0000000000_1.db/
[Sakis#t0000000000]$
Trying to take the owner from an admin cmd console:
c:\t000000000
0>takeown /r /f t0000000000_1.db
ERROR: Access is denied.
Trying to delete from an admin cmd console:
c:\t000000000
0>rmdir /S t0000000000_1.db
t0000000000_1.db, Are you sure (Y/N)? Y
Access is denied.
Cannot also change the owner from the windows GUI. It complains that you should have read permissions.
--- RESOLVED ---
Finally, I have managed to delete it by entering a cmd command with administration privileges and execute:
rm -r <dir>
TIP: You have to make sure that the directory in not used at all. You can use the procmon to find you who locks that directory.
Attempts to use chown and chmod, even as root, failed (I don't recall the error).
I'm pretty sure my disk is fine. I run DiskCheckup daily for a strong history of SMART settings, and checked it this morning. No worries there.
Since the original problem and post, I got busy, and just now got back to that same local shell window. Those files were gone. This was a local cygwin shell on my laptop, so I know that no one else "helped". Strange. Those .txt files were just not there anymore.
I'm still curious what would cause ls to output all question-marks like that for all of the file metadata, except for the filename. But the main issue is resolved.
As admin, this should fix:
chown <yourusername> WSERV001.txt
chmod 666 WSERV001.txt
rm -f WSERV001.txt
If not, you might have disk errors.

Getting error that the database is locked when refreshing the page

I am running apache with mod mono and my asp.net app is using mono sqlite as its db. When i refresh the page twice i get the DB is locked error. The folder it is in is chmod 777. The webapp is creating sqlite.db and sqlite.db-journal but it doesnt seem to be able to delete the journal. Also it has problems when i load the page once. It definitely seems to be a permission problem.
i'm confused. What permissions do i need to set these? i tried precreating the files using 777 and had no luck.
-edit- I didnt find a solution however i thought how silly i was being since i was planning to use mysql for my webapp. So i just ported the code and i no longer had issues.
When creating/deleting a file the directory permission matter.
So, if you really want that, you have to set the containing directory's permissions to 777.
Sample:
$ ls -la
total 21
dr-xr-xr-x 2 me me 1024 May 22 19:19 . #no write permissions to directory
drwxrwxrwt 21 root root 19456 May 22 19:19 ..
-rwxrwxrwx 1 me me 0 May 22 19:19 abc #all permissions to file abc
$ rm abc
rm: cannot remove `abc': Permission denied #abc has 777, but deleting doesn't work
$ chmod 777 . #change directoy's permissions
$ rm abc #now removing works
$ ls #file abc is gone
The reason is that when you delete a file, you actually modify the directory and not the file itself.
Think of a hard link: The file itself will not change when you delete one hardlink to it, but the directory changes.
Sounds more like one instance of the session in apache is blocking the other session, i.e. has the db file open exclusively. Try to let the database(model) run as a singleton (or similar) which all sessions access.

Resources