diff --git a/src/api/action.c b/src/api/action.c index f5bd23bd..5361bbf0 100644 --- a/src/api/action.c +++ b/src/api/action.c @@ -120,46 +120,6 @@ int api_action_gravity(struct ftl_conn *api) return run_and_stream_command(api, "/usr/local/bin/pihole", (const char *const []){ "pihole", "-g", NULL }); } -int api_action_poweroff(struct ftl_conn *api) -{ - if(!config.webserver.api.allow_destructive.v.b) - return send_json_error(api, 403, - "forbidden", - "Power off is not allowed", - "Check setting webserver.api.allow_destructive"); - - log_info("Received API request to power off the machine"); - // Sync filesystems and power off - sync(); - // Needs capabiliy CAP_SYS_BOOT - if(reboot(RB_POWER_OFF) != 0) - return send_json_error(api, 500, - "server_error", - "Cannot power off the system, power off has been cancelled", - strerror(errno)); - return send_json_success(api); -} - -int api_action_reboot(struct ftl_conn *api) -{ - if(!config.webserver.api.allow_destructive.v.b) - return send_json_error(api, 403, - "forbidden", - "Reboot is not allowed", - "Check setting webserver.api.allow_destructive"); - - log_info("Received API request to reboot the machine"); - // Sync filesystems and reboot - sync(); - // Needs capabiliy CAP_SYS_BOOT - if(reboot(RB_AUTOBOOT) != 0) - return send_json_error(api, 500, - "server_error", - "Cannot reboot the system, reboot has been cancelled", - strerror(errno)); - return send_json_success(api); -} - int api_action_restartDNS(struct ftl_conn *api) { if(!config.webserver.api.allow_destructive.v.b) diff --git a/src/api/api.c b/src/api/api.c index c31ce3d2..2c132fc5 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -86,8 +86,6 @@ static struct { { "/api/dhcp/leases", "", api_dhcp_leases_GET, { false, true, 0 }, true, HTTP_GET }, { "/api/dhcp/leases", "/{hwaddr}/{ip}/{clid}", api_dhcp_leases_DELETE, { false, true, 0 }, true, HTTP_DELETE }, { "/api/action/gravity", "", api_action_gravity, { false, true, 0 }, true, HTTP_POST }, - { "/api/action/reboot", "", api_action_reboot, { false, true, 0 }, true, HTTP_POST }, - { "/api/action/poweroff", "", api_action_poweroff, { false, true, 0 }, true, HTTP_POST }, { "/api/action/restartdns", "", api_action_restartDNS, { false, true, 0 }, true, HTTP_POST }, { "/api/action/flush/logs", "", api_action_flush_logs, { false, true, 0 }, true, HTTP_POST }, { "/api/action/flush/arp", "", api_action_flush_arp, { false, true, 0 }, true, HTTP_POST }, diff --git a/src/capabilities.c b/src/capabilities.c index 27d4322f..79d0532e 100644 --- a/src/capabilities.c +++ b/src/capabilities.c @@ -141,13 +141,6 @@ bool check_capabilities(void) log_warn("Required Linux capability CAP_CHOWN not available"); capabilities_okay = false; } - if (!(data->permitted & (1 << CAP_SYS_BOOT)) || - !(data->effective & (1 << CAP_SYS_BOOT))) - { - // Necessary to reboot/poweroff the system through the API - log_warn("Required Linux capability CAP_SYS_BOOT not available"); - capabilities_okay = false; - } // Free allocated memory free(hdr);