I have a python script which uses requests library to connect to a device with its web-interface. It uses a url with https connection.
sess = requests.Session()
try:
resp = sess.post('https://' + device + '/url_admin/login.cgi', data=login_data, verify=False)
except Exception as e:
template = "Exception: {0}\nArguments: {1!r}"
print(template.format(type(e).__name__, e.args))
When I try to execute it from command line it works perfectly (even with apache user). However, when it is triggered with a php code (exec function) from a web-portal. it throws this error
Exception: ConnectionError
Arguments: (MaxRetryError("HTTPSConnectionPool(host='some.device.com', port=443): Max retries exceeded with url: /url_admin/login.cgi (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f55aa8e6550>: Failed to establish a new connection: [Errno 13] Permission denied',))",),)
I am not sure what is the reason because the apache user is able to execute it and make connection. Why it is not connecting when executed by php code?
setsebool -P httpd_can_network_connect on
Related
Looking for some advise on setting up Unoconv on IIS.
I am trying to run this via PHP but I get the following error.
Verbosity set to level 3
Using office base path: C:\Program Files\LibreOffice
Using office binary path: C:\Program Files\LibreOffice\program
DEBUG: Connection type: socket,host=127.0.0.1,port=2002,tcpNoDelay=1;urp;StarOffice.ComponentContext
DEBUG: Existing listener not found.
DEBUG: Launching our own listener using C:\Program Files\LibreOffice\program\soffice.exe.
LibreOffice listener arguments are ['C:\\Program Files\\LibreOffice\\program\\soffice.exe', '--headless', '--invisible', '--nocrashreport', '--nodefault', '--nofirststartwizard', '--nologo', '--norestore', '--accept=socket,host=127.0.0.1,port=2002,tcpNoDelay=1;urp;StarOffice.ComponentContext'].
LibreOffice listener successfully started. (pid=8808)
Failed to connect to C:\Program Files\LibreOffice\program\soffice.exe (pid=8808) in 6 seconds.
Connector : couldn't connect to socket (WSAECONNREFUSED, Connection refused)
Error: Unable to connect or start own listener. Aborting.
If I run the following command in CMD unoconv --listener prior to running the PHP script to convert the file everything works as expected, but I do not want to manage the listener creation process myself as unoconv should do this.
If I switch the App Pool Identity to LocalSystem everything works the listener gets created and file conversion work, but this is giving too much access.
Any Ideas as to what I need to configure to get this to work via the usual ApplicationPoolIdentity ?
Thank you
Ged
Give NAME_OF_YOUR_MACHINE\IIS_IUSRS permissions on the relevant folders and try to use AppPoolIdentity
I am trying to use/run Google Web-Starter-Kit with PHP code and surfing through internet I found gulp-connect-php which helps to run PHP files inside gulp server(we can connect gulp with our local php service). So that i installed gulp-connect-php and added the following code to gulpfile.js
code:
var connect = require('gulp-connect-php');
gulp.task('connect', function() {
connect.server({
hostname: '0.0.0.0',
bin: 'C:/wamp/bin/php/php5.5.12/php.exe',
ini: 'C:/wamp/bin/php/php5.5.12/php.ini',
port: 8000,
base: 'dev'
});
});
gulp.task('default', ['connect']);
and entered the below command to execute gulp server with gulp-conntect
>gulp connect
but it throwing some ERROR with path i specified for PHP applicatoin.
ERROR:
E:\my-project>gulp connect
[10:51:57] Using gulpfile E:\my-project\gulpfile.js
[10:51:57] Starting 'connect'...
[10:51:57] Finished 'connect' after 12 ms
events.js:85
throw er; // Unhandled 'error' event
^
Error: spawn C:/wamp/bin/php/php5.5.12/php.exe ENOENT
at exports._errnoException (util.js:746:11)
at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
at child_process.js:1144:20
at process._tickCallback (node.js:355:11)
I don't know where the issue lies on. please help on this.
An ENOENT error usually indicates that a file or directory is missing. Seeing that you are on windows, this would most likely be due to a wrong direction of slashes.
Try
bin: 'C:\\wamp\\bin\\php\\php5.5.12\\php.exe'
(same for ini) and make sure this file really exists! Other than that, if you can call php directly from your command line, you shouldn't need to point to the EXE file at all.
Using the following bits:
<?php
require('vendor/autoload.php');
$client = new Everyman\Neo4j\Client('localhost', 7474);
print_r($client->getServerInfo());
?>
If I run this as php test.php I get the expected output.
If I run this via http://server/test.php I get connection errors.
[24-Jun-2014 05:49:52] PHP Fatal error: Uncaught exception 'Everyman\Neo4j\Exception'
with message 'Can't open connection to http://localhost:7474/db/data/' in
/var/www/html/vendor/everyman/neo4jphp/lib/Everyman/Neo4j/Transport/Curl.php:91
Clearly I've monkeyed up something with either my PHP config or the installation of this library. Suggestions on where to look?
Installed per these instructions.
Running on CentOS 6.4 (x64), PHP 5.3.3
NOTE: I've made successful connections from other machines back to this server so I know the neo4j server is working. It just doesn't seem to want to let me connect locally when called via browser.
I had same issue, it was caused by SeLinux
Try disabling it by:
echo 0 >/selinux/enforce
then recheck connection.
If solved configure SeLinux permissions.
In my case httpd_can_network_connect should be on
setsebool -P httpd_can_network_connect on
echo 1 >/selinux/enforce
Helpful manual:
http://wiki.centos.org/TipsAndTricks/SelinuxBooleans
I have followed the famous michael noll tutorial http://www.michael-noll.com/tutorials/running-hadoop-on-ubuntu-linux-single-node-cluster/ to install hadoop in single node.
Now I want to execute the following command via browser through php
usr/local/hadoop/bin/hadoop jar /usr/local/hadoop/contrib/streaming/hadoop-*streaming*.jar -mapper "/usr/bin/python /var/www/DataMining/AnalysisByYear/AnalysisByYear_mapper.py 2011" -reducer "/usr/bin/python /var/www/DataMining/AnalysisByYear/AnalysisByYear_reducer.py" -input /user/hduser/dataset/final_eval.txt -output /user/hduser/dataset-outputyear
I am using the exec() command of php to execute it but it doesn't show any result.
In the tutorial the hduser is given the ownership of hadoop. However the browser logs in as the user www-data. As a result it cannot execute. I am assuming that is the error. Is it possible to execute the script in any way?
The namenode logs are given below:
2013-11-18 14:54:45,712 ERROR org.apache.hadoop.security.UserGroupInformation: PriviledgedActionException as:www-data cause:org.apache.hadoop.security.AccessControlException: Permission denied: user=www-data, access=WRITE, inode="staging":hduser:supergroup:rwxr-xr-x
2013-11-18 14:54:45,712 INFO org.apache.hadoop.ipc.Server: IPC Server handler 1 on 54310, call mkdirs(/app/hadoop/tmp/mapred/staging/www-data/.staging, rwx------) from 127.0.0.1:40876: error: org.apache.hadoop.security.AccessControlException: Permission denied: user=www-data, access=WRITE, inode="staging":hduser:supergroup:rwxr-xr-x
org.apache.hadoop.security.AccessControlException: Permission denied: user=www-data, access=WRITE, inode="staging":hduser:supergroup:rwxr-xr-x
at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.check(FSPermissionChecker.java:199)
at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.check(FSPermissionChecker.java:180)
at org.apache.hadoop.hdfs.server.namenode.FSPermissionChecker.checkPermission(FSPermissionChecker.java:128)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.checkPermission(FSNamesystem.java:5468)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.checkAncestorAccess(FSNamesystem.java:5442)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.mkdirsInternal(FSNamesystem.java:2209)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.mkdirs(FSNamesystem.java:2178)
at org.apache.hadoop.hdfs.server.namenode.NameNode.mkdirs(NameNode.java:857)
at sun.reflect.GeneratedMethodAccessor13.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:578)
at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1393)
at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1389)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:396)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1149)
at org.apache.hadoop.ipc.Server$Handler.run(Server.java:1387)
The solution I used is starting my apache server as hduser.
my cassandra is working well in CLI. and thrift also installed well. i already started apache server and cassandara..but when trying to execute php file that is not executed on browser.it shows the error as:
TException: Error: TSocket: Could not connect to localhost:9160 (Permission denied [13])
and the 12th and 13th line is:
$socket = new TSocket('localhost', 9160);
$transport = new TBufferedTransport($socket, 1024, 1024);
i gave 127.0.0.1 instead of localhost.even it is not working.
can any one please help me?
hi every one i solve the problem....
selinux is cause for that problem.....
TException: Error: TSocket: Could not connect to localhost:9160 (Permission denied [13])
To resolve it, you need to change an SELinux boolean value (which will automatically persist across reboots). You may also want to restart httpd to reset the proxy worker, although this isn't strictly required.
setsebool -P httpd_can_network_connect 1
http://wiki.apache.org/httpd/13PermissionDenied