mirror of
https://github.com/naruxde/revpipyload.git
synced 2025-11-08 23:23:52 +01:00
secure_installation will only reload settings, if daemon is running
close #3
This commit is contained in:
@@ -72,9 +72,7 @@ def save_xmlrpcacls():
|
|||||||
def print_xmlrpcacls():
|
def print_xmlrpcacls():
|
||||||
"""Print a list with all acl."""
|
"""Print a list with all acl."""
|
||||||
if xmlrpcacl.acl:
|
if xmlrpcacl.acl:
|
||||||
stdout.write(
|
stdout.write("\nThis is the actual ACL file ({0}):".format(aclxmlrpc))
|
||||||
"\nThis is the actual ACL file ({0}):".format(aclxmlrpc)
|
|
||||||
)
|
|
||||||
counter = 0
|
counter = 0
|
||||||
for acl in xmlrpcacl.acl.split():
|
for acl in xmlrpcacl.acl.split():
|
||||||
stdout.write("\n" if counter % 2 == 0 else " | ")
|
stdout.write("\n" if counter % 2 == 0 else " | ")
|
||||||
@@ -92,28 +90,20 @@ def print_xmlrpcacls():
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if not xmlrpc_only_localhost:
|
if not xmlrpc_only_localhost:
|
||||||
cmd = input(
|
cmd = input("\nDo you want to check ACL listed computers? (y/N) ").lower()
|
||||||
"\nDo you want to check ACL listed computers? (y/N) "
|
|
||||||
).lower()
|
|
||||||
if cmd == "y":
|
if cmd == "y":
|
||||||
print_xmlrpcacls()
|
print_xmlrpcacls()
|
||||||
|
|
||||||
if getuid() != 0:
|
if getuid() != 0:
|
||||||
stderr.write(
|
stderr.write("\nYou need root permissions to change values (sudo).\n")
|
||||||
"\nYou need root permissions to change values (sudo).\n"
|
|
||||||
)
|
|
||||||
exit(4)
|
exit(4)
|
||||||
|
|
||||||
cmd = input(
|
cmd = input("\nDo you want to allow connections from remote hosts? (y/N) ").lower()
|
||||||
"\nDo you want to allow connections from remote hosts? (y/N) "
|
|
||||||
).lower()
|
|
||||||
if cmd == "y":
|
if cmd == "y":
|
||||||
conf.set("XMLRPC", "xmlrpc", "1")
|
conf.set("XMLRPC", "xmlrpc", "1")
|
||||||
conf.set("XMLRPC", "bindip", "*")
|
conf.set("XMLRPC", "bindip", "*")
|
||||||
|
|
||||||
cmd = input(
|
cmd = input("Reset the ACL file to allow all private networks? (y/N) ").lower()
|
||||||
"Reset the ACL file to allow all private networks? (y/N) "
|
|
||||||
).lower()
|
|
||||||
if cmd == "y":
|
if cmd == "y":
|
||||||
xmlrpcacl.acl = "127.*.*.*,4 " \
|
xmlrpcacl.acl = "127.*.*.*,4 " \
|
||||||
"169.254.*.*,4 " \
|
"169.254.*.*,4 " \
|
||||||
@@ -126,18 +116,12 @@ try:
|
|||||||
save_xmlrpcacls()
|
save_xmlrpcacls()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
cmd = input(
|
cmd = input("Reset the ACL file by enter individual ip addresses to grant access? (y/N) ").lower()
|
||||||
"Reset the ACL file by enter individual ip addresses to "
|
|
||||||
"grant access? (y/N) "
|
|
||||||
).lower()
|
|
||||||
if cmd == "y":
|
if cmd == "y":
|
||||||
# Always set local host
|
# Always set local host
|
||||||
lst_ip = ["127.*.*.*,4 "]
|
lst_ip = ["127.*.*.*,4 "]
|
||||||
while True:
|
while True:
|
||||||
cmd = input(
|
cmd = input("Enter single IPv4 address | Press RETURN to complete: ")
|
||||||
"Enter single IPv4 address | "
|
|
||||||
"Press RETURN to complete: "
|
|
||||||
)
|
|
||||||
if not cmd:
|
if not cmd:
|
||||||
xmlrpcacl.acl = " ".join(lst_ip)
|
xmlrpcacl.acl = " ".join(lst_ip)
|
||||||
save_xmlrpcacls()
|
save_xmlrpcacls()
|
||||||
@@ -150,16 +134,12 @@ try:
|
|||||||
stderr.write("Wrong format (0.0.0.0)\n")
|
stderr.write("Wrong format (0.0.0.0)\n")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
cmd = input(
|
cmd = input("Do you want to allow connections from localhost ONLY? (y/N) ").lower()
|
||||||
"Do you want to allow connections from localhost ONLY? (y/N) "
|
|
||||||
).lower()
|
|
||||||
if cmd == "y":
|
if cmd == "y":
|
||||||
conf.set("XMLRPC", "xmlrpc", "1")
|
conf.set("XMLRPC", "xmlrpc", "1")
|
||||||
conf.set("XMLRPC", "bindip", "127.0.0.1")
|
conf.set("XMLRPC", "bindip", "127.0.0.1")
|
||||||
|
|
||||||
cmd = input(
|
cmd = input("Reset the ACL file to allow localhost connections only? (y/N) ").lower()
|
||||||
"Reset the ACL file to allow localhost connections only? (y/N) "
|
|
||||||
).lower()
|
|
||||||
if cmd == "y":
|
if cmd == "y":
|
||||||
xmlrpcacl.acl = "127.*.*.*,4 "
|
xmlrpcacl.acl = "127.*.*.*,4 "
|
||||||
save_xmlrpcacls()
|
save_xmlrpcacls()
|
||||||
@@ -188,7 +168,8 @@ except KeyboardInterrupt:
|
|||||||
stdout.write("\n\nWe did no changes!\n")
|
stdout.write("\n\nWe did no changes!\n")
|
||||||
exit(2)
|
exit(2)
|
||||||
|
|
||||||
try:
|
if system("/etc/init.d/revpipyload status > /dev/null") == 0:
|
||||||
|
try:
|
||||||
cmd = input("\nDo you want to apply the new settings now? (Y/n) ").lower()
|
cmd = input("\nDo you want to apply the new settings now? (Y/n) ").lower()
|
||||||
if cmd in ("", "y"):
|
if cmd in ("", "y"):
|
||||||
system("/etc/init.d/revpipyload reload")
|
system("/etc/init.d/revpipyload reload")
|
||||||
@@ -197,5 +178,5 @@ try:
|
|||||||
"\nYou have to activate the new settings for RevPiPyLoad!\n"
|
"\nYou have to activate the new settings for RevPiPyLoad!\n"
|
||||||
" sudo /etc/init.d/revpipyload reload\n"
|
" sudo /etc/init.d/revpipyload reload\n"
|
||||||
)
|
)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user