Flask, Apache, CentOS, and Permission Denied on the datastore - apache

I've setup up a flask project on a CentOS 6.4 machine, with python 2.7.6 and mod_wsgi 3.x that I built myself on the box.
The app uses a file based database for storing RDF data, and I'm getting an Error 13 on the folder containing the datastore.
from genometry import app as application
File "/opt/genometry/software/genometry.py", line 125, in <module>
db, classes, user_datastore, security = create_db(app)
File "/opt/genometry/software/genometry.py", line 101, in create_db
db.store.open(app.config['db'])
"build/bdist.linux-x86_64/egg/rdflib/plugins/sleepycat.py", line 89, in open
db_env = self._init_db_environment(homeDir, create)
File "build/bdist.linux-x86_64/egg/rdflib/plugins/sleepycat.py", line 66, in _init_db_environment
mkdir(homeDir)
OSError: [Errno 13] Permission denied: 'store.kb'
I've tried everything I can think of. Changed the /opt and everything under it to be owned by apache:apache. Changed /opt and everything under it to be 777, and yet still a permissions error. How can that be? What's the best way to setup the permission on folder "store.kb"

It turns out the problem was that Apache was looking for the store.kb in /var/www due to the rdfalchemy db uri. I updated it to:
app.config['rdfalchemy_dburi'] = 'sleepycat:////{0}/store.kb'.format(PROJECT_ROOT)
and now everything works fine

Related

Pyinstaller does not work with local files

I've made an app with PyQt5 and it works perfectly fine on my environment, and now I wan't to deploy it to .exe and .dmg with pyinstaller.
My app uses two local files certificate.yml and data.pkl which each contains certificate data for AWS and data. These are located in the same directory with main.py, which starts my app.
In my main.spec file I've added following
a.datas += [('certificate.yml', 'certificate.yml', 'DATA'),
('data.pkl', 'data.pkl', 'DATA')]
and made .app. However, when I start my .app, it does not find certificate.yml file and raise following error.
FileNotFoundError: [Errno 2] No such file or directory: 'certificate.yml'
How can I include my local files with pyinstaller?

Vagrant for web server with shared folders: Apache breaks file permissions if it tries to stat a file before it exists

I'm not sure if this is an issue with vagrant, virtualbox or a configuration issue inside the box itsef, however:
Using the following setup: Apache is running in the guest with its server root set to /srv/http, this is a synched folder which points to ./public_html on the host.
While most of the time it works as expected, the following steps causes an issue
1) Navigate to a file that doesn't exist localhost:8080/test2.css -- shows a 404 error as expected but correctly connects to the guest which is serving the error
2) Create test2.css with some content and place it in public_html
3) Reload localhost:8080/test2.css -- Still shows a 404 error even though the file now exists
4) To debug, run vagrant ssh and then ls /srv/http. Which shows:
ls: cannot access test2.css: No such file or directory
So it's seeing the file, sort of but it shows without any permissions:
-????????? ? ? ? ? test2.css
-rw-rw-r-- 1 vagrant 7 Oct 23 11:13 test3.css
If I then re-save the file as test3.css, a file that hasn't yet been accessed it works perfectly. E.g. on the host, save the file I had open as test3.css and then navigate to it, it works as expected!
Any ideas? On why this might be?
In short: If apache has tried to read a file that doesn't exist, creating that file will then cause it to have invalid permissions. If apache has never tried to read the file before, it can be created and work as expected.
Thanks for any help, I'm really confused by this!
This turned out to be a kernel bug on the guest. Upgrading to 4.2.4 using the same Vagrant/Virtualbox/Guest Modules solved the issue.

Moving Smarty website to new server

I'm moving a website to a new domain and server and I'm running into some problems. This website works with Smarty, and I've never used it before. I think I got a very basic problem, but I can't find the answer online.
I've moved all the FTP files to the new server
I've copied the database
I've edited the config file with the new database information
Now only EVERY page (even a blank test.php file with a simple echo) I get "failed to open stream" errors.
Warning: rename(/home/*websitename*/domains/*websitename*.com/public_html//skins/default/compiled/65e3d4d7349f9687ce73f56b61992749304409a2.file.index.tpl.php) [function.rename]: failed to open stream: Permission denied in /home/*websitename*/domains/*websitename*.com/public_html/external/smarty/sysplugins/smarty_internal_write_file.php on line 48
Warning: rename(/tmp/wrtPBIHNP,/home/*websitename*/domains/*websitename*.com/public_html//skins/default/compiled/65e3d4d7349f9687ce73f56b61992749304409a2.file.index.tpl.php) [function.rename]: Permission denied in /home/*websitename*/domains/*websitename*.com/public_html/external/smarty/sysplugins/smarty_internal_write_file.php on line 48
Warning: chmod() [function.chmod]: No such file or directory in /home/*websitename*/domains/*websitename*.com/public_html/external/smarty/sysplugins/smarty_internal_write_file.php on line 50
Warning: include(/home/*websitename*/domains/*websitename*.com/public_html//skins/default/compiled/65e3d4d7349f9687ce73f56b61992749304409a2.file.index.tpl.php) [function.include]: failed to open stream: No such file or directory in /home/*websitename*/domains/*websitename*.com/public_html/external/smarty/sysplugins/smarty_internal_template.php on line 432
Warning: include() [function.include]: Failed opening '/home/*websitename*/domains/*websitename*.com/public_html//skins/default/compiled/65e3d4d7349f9687ce73f56b61992749304409a2.file.index.tpl.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/*websitename*/domains/*websitename*.com/public_html/external/smarty/sysplugins/smarty_internal_template.php on line 432
It looks like a problem with premissions, but I've made EVERY file on the FTP premission 777 (to test) and this does not solve it.
There are two backslashes /public_html//skins/ which is weird.
The code is exactly the same on the "old" server, besides the config file. Only thing new is the domain name.
What am I doing wrong?
You should set for directory compiled permissions 755 or 777.
You should probably also remove all compiled and cached files (if you use cache) because it may also cause problems

reputation module installation in phpbb3

Hi i am trying to install phpbb-reputation system i followed the xml file for installation but while executing install_reputation.php i am getting this error ERROR: Could not open the file ./styles/afterburnerafterburner_config.html for reading.There are many errors in the same fashin. where i gues it is not going inside afterburner/template folder where .html file exists. where should i check this?
More error samples:
Refreshing the proFormell template
ERROR: Could not open the file ./styles/proFormellcaptcha_recaptcha.html for reading.
Sounds like it's a permissions issue; if hosting on a LAMP server, just run chmod 755 * -R in the website root directory. Alternatively you could also change file permissions using an FTP client

can't write to file in mod_wsgi app: permission denied

I have a very simple mod_wsgi python application that tries to write to a file:
tempfile = open('temp.txt', 'w')
This fails with
IOError: [Errno 13] Permission denied: 'temp.txt'
The folder with myapp.wsgi has world-writable permissions (777). I can write to a file from a simple PHP test script. This is running on Mac OSX 10.6 Snow Leopard, so as far as I know, there are no additional protection mechanisms in place (SELinux, AppArmor, etc.).
Why are write permissions denied ?
Yep, the solution to the problem is to use full paths to spcify file locations (and, just to be on the safe side, to specify shell commands you might be using in system call (or popen) calls), as the $PATH might not be what you expect it).