tuxis-ie / nsedit

DNS Editor working with PowerDNS's new API
GNU General Public License v2.0
199 stars 55 forks source link

API Error: 0 #75

Closed skfigved closed 8 years ago

skfigved commented 8 years ago

Been trying to get this to work now with multiple linux distro and powerdns versions. Currently 3.4.7 but always get this message

Are there currently any issues with powerdns 3.4.7 and nsedit?

tuxis-ie commented 8 years ago

Looks like there is an issue with Curl? The error seems to come from https://github.com/tuxis-ie/nsedit/blob/master/zones.php#L80

You should be able to change that line to:

jtable_respond(null, 'error', "API Error: $code ".curl_error($ch));

Does that clarify anything?

skfigved commented 8 years ago

Now im getting following message "API Error: 0 Failed to connect to 127.0.0.1: Permission denied" Doing a curl from localhost works both getting zone list and adding zones

curl -X POST --data '{"name":"example.org", "kind": "Native", "masters": [], "nameservers": ["ns1.example.org", "ns2.example.org"]}' -v -H 'X-API-Key: 12345' http://127.0.0.1:8081/servers

curl -H 'X-API-Key: 12345' http://127.0.0.1:8081/servers/localhost/zones

tuxis-ie commented 8 years ago

Ok. Can you paste your config here?

skfigved commented 8 years ago

This is the config from config.inc.php.

<?php

$apiuser = ''; # The PowerDNS API username. Leave empty for authmethod='xapikey' (see AUTHENTICATION) $apipass = '12345'; # The PowerDNS API-user password or the PowerDNS-API key (see AUTHENTICATION) $apiip = '127.0.0.1'; # The IP of the PowerDNS API $apiport = '8081'; # The port of the PowerDNS API $apivers = 0; # The version of the PowerDNS API. 0 == experimental, 1 = v1 (pdns 4.0) $apisid = 'localhost'; # PowerDNS's :server_id $apiproto = 'http'; # http | https $apisslverify = FALSE; # Verify SSL Certificate if using https for apiproto $allowzoneadd = FALSE; # Allow normal users to add zones

tuxis-ie commented 8 years ago

I'm missing $authmethod, which should be set to 'xapikey'...

skfigved commented 8 years ago

here is the rest

$authmethod = 'xapikey';

skfigved commented 8 years ago

Just noticed that the api error message does not include the port number if this by any chance is related

API Error: 0 Failed to connect to 127.0.0.1: Permission denied

Shouldt it say something like 127.0.0.1:8081 ?

skfigved commented 8 years ago

The permission denied got me on the right track. It never were anything with powerdns or nsedit config. It was actually SElinux not permitting httpd to make network connections.

My case was solved with this command setsebool -P httpd_can_network_connect 1

Running Centos 7 Thanks for assisting me getting this solvet

tuxis-ie commented 8 years ago

Haha. Thanks for letting us know! Always good to have these kinds of commands in an archive somewhere.