From patchwork Tue Oct 11 22:01:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 6056 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4Mn8tX2Hyjz3wgN for ; Tue, 11 Oct 2022 22:03:32 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4Mn8tQ1rpYz2b7; Tue, 11 Oct 2022 22:03:26 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4Mn8tP0Vnbz303n; Tue, 11 Oct 2022 22:03:25 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4Mn8tM0HQrz2xmP for ; Tue, 11 Oct 2022 22:03:23 +0000 (UTC) Received: from knopi.disroot.org (knopi.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4Mn8tL68M8z1gg for ; Tue, 11 Oct 2022 22:03:22 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 9259A4DB07 for ; Wed, 12 Oct 2022 00:03:22 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with UTF8SMTP id RFMT-Ive1Ac4 for ; Wed, 12 Oct 2022 00:03:20 +0200 (CEST) Received: from chojin.sicho.home (amaterasu.sicho.home [192.168.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (no client certificate requested) (Authenticated sender) by hachiman (MailScanner Milter) with SMTP id EC8B2751F1; Wed, 12 Oct 2022 00:02:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1665525747; bh=JBuOl8ZP3GB9iUxpKHg+3oBq+nLP4uWCgKKfjT82pdg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZmRxGNAeb90QOUOPrKiRk4LZCQMSBiWaPlw5b3ff0eBrPTFQ/cuhlyefiswfWuYOE HqsDk3cw6/zgDwa8x0FBr8h027NOChFgODzf3m2hacXJqq1TfDxJAumMXwZZg9wPvC nOiNPkj9WqYe+4BzusaEYAoH5Ay/1ziToiJsN6B7ZYcjin65dFQ/9XdEPZQ9I/YGI/ 2sg7Eio4GkVQwDmzfOhNfI0dqM5/k8xB4GpEGMm2jpeX6gXH/KjYDR35cUCrVeyRBf lu9qavtHRKqGBSpruaOjwlF9p1xPCk0+mdQc30/J1Pf1pFFZvr2chw+1G2kXfEUXDr FlobTj/bGN0Aw== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v3 1/5] misc-progs: addonctrl: Add support for 'Services' metadata Date: Wed, 12 Oct 2022 00:01:53 +0200 Message-Id: <20221011220157.17385-2-robin.roevens@disroot.org> In-Reply-To: <20221011220157.17385-1-robin.roevens@disroot.org> References: <20221011220157.17385-1-robin.roevens@disroot.org> Mime-Version: 1.0 X-sicho-MailScanner-ID: EC8B2751F1.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1666130530.86395@lQ9s3VYNF9d/XxtsoUqnqg ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1665525802; a=rsa-sha256; cv=none; b=A/06Tu/+oMshsLwvSm15V0yMk2bhy95qC+qbPwGFcWy/n/nmaliYOx/Y3vBLlKoxBhMDCK 2KMYSZBSzrwP0U+TSu0PhR265cOXjio0sLVEREZAm+w7hHH98sheOMEHuWF9DQuhOgFTJ1 4MDh9HpM4dtWIY9NKPB9n9AlcvYrlqy6V7dsQXOWAoRY7zWYbQ9tym97qhx4zrvuMOJYAF Hgo9aj+ItCLhmzU5jHdCEhJI6CNybfe2GZrK6kRSbfBQqOZFhsYu0LQQhgW49RjwLqBmH6 xWJbWO8jImXanpVUeeIndB31FtMIkmzjHG/eR58ZJ+p1RQgWIiKPctcTKX30lw== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=ZmRxGNAe; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org; dmarc=pass (policy=quarantine) header.from=disroot.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1665525802; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WLN1tSKJSumT03FBdxv0mO1cWXaKEpWzg2cVK/xo/H4=; b=VhUu1VmwcIkxW6Bych9VcNng/RRrbZooEY1cT07dzAPUD/bbJDhjn/helyuO19J0OR18oZ OOLfqoJ+8OuaDudDDsNgDLXOLNvptiBDj/R62aY8SLKx4cU2bb4DYyVZWYO/GNGYpuOL90 c7GiMUONmQ28nFGYg6KIe6KWzdLYU3Hd/C40tLRpmTI8Z54C8ztfOdBmZ8shvTkE4DwPG6 tiXINIP+jI/xi2s1KEqeXUrTd06n1qvEpaVOUKe/Z/EG1YvVeWGIcCp1a40BnHAjPLa8/4 Sx4vxITE/JwkUxXOIEoyIPd+1JFKWTySlMzGJQ0tQODpIoNBCzh7cqATEu+c1Q== Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=ZmRxGNAe; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org; dmarc=pass (policy=quarantine) header.from=disroot.org X-Rspamd-Server: mail01.haj.ipfire.org X-Spamd-Result: default: False [-5.11 / 11.00]; BAYES_HAM(-3.00)[99.99%]; IP_REPUTATION_HAM(-1.13)[asn: 50673(-0.32), country: NL(-0.01), ip: 178.21.23.139(-0.81)]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-1.00)[-1.000]; DKIM_REPUTATION(-0.82)[-0.81568261952269]; SPF_REPUTATION_HAM(-0.61)[-0.61451727240354]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; R_MISSING_CHARSET(0.50)[]; MV_CASE(0.50)[]; R_DKIM_ALLOW(0.27)[disroot.org:s=mail]; R_SPF_ALLOW(-0.20)[+a:c]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[development@lists.ipfire.org]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; ASN(0.00)[asn:50673, ipnet:178.21.23.0/24, country:NL]; DKIM_TRACE(0.00)[disroot.org:+]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_TWO(0.00)[2]; TO_DN_SOME(0.00)[] X-Rspamd-Queue-Id: 4Mn8tL68M8z1gg X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" * Addonctrl will now check in addon metadata for the exact initscript names (Services). If more than one initscript is defined for an addon, the requested action will be performed on all listed initscripts. * Added posibility to perform action on a specific initscript of an addon instead of on all initscripts of the addon. * New action 'list-services' to display a list of services related to an addon. * New action 'boot-status' to display wether service(s) are enabled to start on boot or not. * More error checking and cleaner error reporting to user * General cleanup and code restructuring to avoid code duplication * Updated and made usage instructions more verbose. Fixes: Bug#12935 Signed-off-by: Robin Roevens Reviewed-by: Michael Tremer --- src/misc-progs/addonctrl.c | 459 ++++++++++++++++++++++++++++++++----- 1 file changed, 398 insertions(+), 61 deletions(-) diff --git a/src/misc-progs/addonctrl.c b/src/misc-progs/addonctrl.c index 14b4b1325..8eb7fbfa5 100644 --- a/src/misc-progs/addonctrl.c +++ b/src/misc-progs/addonctrl.c @@ -10,71 +10,408 @@ #include #include #include +#include #include +#include +#include +#include #include "setuid.h" #define BUFFER_SIZE 1024 +const char *initd_path = "/etc/rc.d/init.d"; +const char *enabled_path = "/etc/rc.d/rc3.d"; +const char *disabled_path = "/etc/rc.d/rc3.d/off"; + +const char *usage = + "Usage\n" + " addonctrl (start|stop|restart|reload|enable|disable|status|boot-status|list-services) []\n" + "\n" + "Options:\n" + " \t\tName of the addon to control\n" + " \t\tSpecific service of the addon to control (optional)\n" + " \t\t\tBy default the requested action is performed on all related services. See also 'list-services'.\n" + " start\t\t\tStart service(s) of the addon\n" + " stop\t\t\tStop service(s) of the addon\n" + " restart\t\tRestart service(s) of the addon\n" + " enable\t\tEnable service(s) of the addon to start at boot\n" + " disable\t\tDisable service(s) of the addon to start at boot\n" + " status\t\tDisplay current state of addon service(s)\n" + " boot-status\t\tDisplay wether service(s) is enabled on boot or not\n" + " list-services\t\tDisplay a list of services related to the addon"; + +// Find a file using as glob pattern. +// Returns the found filename or NULL if not found +char *find_file_in_dir(const char *path, const char *filepattern) +{ + struct dirent *entry; + DIR *dp; + char *found = NULL; + + dp = opendir(path); + if (dp) { + entry = readdir(dp); + while(!found && entry) { + if (fnmatch(filepattern, entry->d_name, FNM_PATHNAME) == 0) + found = strdup(entry->d_name); + else + entry = readdir(dp); + } + + closedir(dp); + } + + return found; +} + +// Reads Services metadata for . +// Returns pointer to array of strings containing the services for , +// sets to the number of found services and +// sets to +// -1 - system error occured, check errno +// 0 - success - if returned array is NULL, there are no services for +// 1 - addon was not found +char **get_addon_services(const char *addon, int *servicescnt, const char *filter, int *returncode) { + const char *metafile_prefix = "/opt/pakfire/db/installed/meta-"; + const char *metadata_key = "Services"; + const char *keyvalue_delim = ":"; + const char *service_delim = " "; + char *token; + char **services = NULL; + char *service; + char *line = NULL; + size_t line_len = 0; + int i = 0; + char *metafile = NULL; + + *returncode = 0; + + if (!addon) { + errno = EINVAL; + *returncode = 1; + return NULL; + } + + *returncode = asprintf(&metafile, "%s%s", metafile_prefix, addon); + if (*returncode == -1) + return NULL; + + FILE *fp = fopen(metafile,"r"); + if (!fp) { + if (errno == ENOENT) { + *returncode = 1; + } else { + *returncode = -1; + } + return NULL; + } + + // Get initscript(s) for addon from meta-file + while (getline(&line, &line_len, fp) != -1 && !services) { + // Strip newline + char *newline = strchr(line, '\n'); + if (newline) *newline = 0; + + // Split line in key and values; Check for required key. + token = strtok(line, keyvalue_delim); + if (!token || strcmp(token, metadata_key) != 0) + continue; + + // Get values for matched key. Stop if no values are present. + token = strtok(NULL, keyvalue_delim); + if (!token) + break; + + // Split values and put each service in services array + service = strtok(token, service_delim); + while (service) { + if (!filter || strcmp(filter, service) == 0) { + services = reallocarray(services, i+1 ,sizeof (char *)); + if (!services) { + *returncode = -1; + break; + } + + services[i] = strdup(service); + if (!services[i++]) { + *returncode = -1; + break; + } + } + + service = strtok(NULL, service_delim); + } + } + + if (line) free(line); + fclose(fp); + free(metafile); + + *servicescnt = i; + + return services; +} + +// Calls initscript with parameter +int initscript_action(const char *service, const char *action) { + char *initscript = NULL; + char *argv[] = { + action, + NULL + }; + int r = 0; + + r = asprintf(&initscript, "%s/%s", initd_path, service); + if (r != -1) + r = run(initscript, argv); + + if (initscript) free(initscript); + + return r; +} + +// Move an initscript with filepattern from to +// Returns: +// -1: Error during move or memory allocation. Details in errno +// 0: Success +// 1: file was not moved, but is already in +// 2: file does not exist in either in or +int move_initscript_by_pattern(const char *src_path, const char *dest_path, const char *filepattern) { + char *src = NULL; + char *dest = NULL; + int r = 2; + char *filename = NULL; + + filename = find_file_in_dir(src_path, filepattern); + if (filename) { + // Move file + r = asprintf(&src, "%s/%s", src_path, filename); + if (r != -1) { + r = asprintf(&dest, "%s/%s", dest_path, filename); + if (r != -1) + r = rename(src, dest); + } + + if (src) free(src); + if (dest) free(dest); + } else { + // check if file is already in dest + filename = find_file_in_dir(dest_path, filepattern); + if (filename) + r = 1; + } + + if (filename) free(filename); + + return r; +} + +// Enable/Disable addon service(s) by moving initscript symlink from/to disabled_path +// Returns: +// -1 - System error occured. Check errno. +// 0 - Success +// 1 - Service was already enabled/disabled +// 2 - Service has no valid runlevel symlink +int toggle_service(const char *service, const char *action) { + const char *src_path, *dest_path; + char *filepattern = NULL; + int r = 0; + + if (asprintf(&filepattern, "S??%s", service) == -1) + return -1; + + if (strcmp(action, "enable") == 0) { + src_path = disabled_path; + dest_path = enabled_path; + } else { + src_path = enabled_path; + dest_path = disabled_path; + } + + // Ensure disabled_path exists + r = mkdir(disabled_path, S_IRWXU + S_IRGRP + S_IXGRP + S_IROTH + S_IXOTH); + if (r != -1 || errno == EEXIST) + r = move_initscript_by_pattern(src_path, dest_path, filepattern); + + free(filepattern); + + return r; +} + +// Return whether is enabled or disabled on boot +// Returns: +// -1 - System error occured. Check errno. +// 0 - is disabled on boot +// 1 - is enabled on boot +// 2 - Runlevel suymlink for was not found +int get_boot_status(char *service) { + char *filepattern = NULL; + char *filename = NULL; + int r = 2; + + if (asprintf(&filepattern, "S??%s", service) == -1) + return -1; + + filename = find_file_in_dir(enabled_path, filepattern); + if (filename) + r = 1; + else { + filename = find_file_in_dir(disabled_path, filepattern); + if (filename) + r = 0; + else + r = 2; + } + + if (filename) free(filename); + free(filepattern); + + return r; +} + int main(int argc, char *argv[]) { - char command[BUFFER_SIZE]; - - if (!(initsetuid())) - exit(1); - - if (argc < 3) { - fprintf(stderr, "\nMissing arguments.\n\naddonctrl addon (start|stop|restart|reload|enable|disable)\n\n"); - exit(1); - } - - const char* name = argv[1]; - - if (strlen(name) > 32) { - fprintf(stderr, "\nString to large.\n\naddonctrl addon (start|stop|restart|reload|enable|disable)\n\n"); - exit(1); - } - - // Check if the input argument is valid - if (!is_valid_argument_alnum(name)) { - fprintf(stderr, "Invalid add-on name: %s\n", name); - exit(2); - } - - sprintf(command, "/opt/pakfire/db/installed/meta-%s", name); - FILE *fp = fopen(command,"r"); - if ( fp ) { - fclose(fp); - } else { - fprintf(stderr, "\nAddon '%s' not found.\n\naddonctrl addon (start|stop|restart|reload|status|enable|disable)\n\n", name); - exit(1); - } - - if (strcmp(argv[2], "start") == 0) { - snprintf(command, BUFFER_SIZE - 1, "/etc/rc.d/init.d/%s start", name); - safe_system(command); - } else if (strcmp(argv[2], "stop") == 0) { - snprintf(command, BUFFER_SIZE - 1, "/etc/rc.d/init.d/%s stop", name); - safe_system(command); - } else if (strcmp(argv[2], "restart") == 0) { - snprintf(command, BUFFER_SIZE - 1, "/etc/rc.d/init.d/%s restart", name); - safe_system(command); - } else if (strcmp(argv[2], "reload") == 0) { - snprintf(command, BUFFER_SIZE - 1, "/etc/rc.d/init.d/%s reload", name); - safe_system(command); - } else if (strcmp(argv[2], "status") == 0) { - snprintf(command, BUFFER_SIZE - 1, "/etc/rc.d/init.d/%s status", name); - safe_system(command); - } else if (strcmp(argv[2], "enable") == 0) { - snprintf(command, BUFFER_SIZE - 1, "mv -f /etc/rc.d/rc3.d/off/S??%s /etc/rc.d/rc3.d" , name); - safe_system(command); - } else if (strcmp(argv[2], "disable") == 0) { - snprintf(command, BUFFER_SIZE - 1, "mkdir -p /etc/rc.d/rc3.d/off"); - safe_system(command); - snprintf(command, BUFFER_SIZE - 1, "mv -f /etc/rc.d/rc3.d/S??%s /etc/rc.d/rc3.d/off" , name); - safe_system(command); - } else { - fprintf(stderr, "\nBad argument given.\n\naddonctrl addon (start|stop|restart|reload|enable|disable)\n\n"); - exit(1); - } - - return 0; + char **services = NULL; + int servicescnt = 0; + char *addon = argv[1]; + char *action = argv[2]; + char *service_filter = NULL; + int r = 0; + + if (!(initsetuid())) + exit(1); + + if (argc < 3) { + fprintf(stderr, "\nMissing arguments.\n\n%s\n\n", usage); + exit(1); + } + + // Ignore filter when list of services is requested + if (argc == 4 && strcmp(action, "list-services") != 0) + service_filter = argv[3]; + + if (strlen(addon) > 32) { + fprintf(stderr, "\nString too large.\n\n%s\n\n", usage); + exit(1); + } + + // Check if the input argument is valid + if (!is_valid_argument_alnum(addon)) { + fprintf(stderr, "Invalid add-on name: %s.\n", addon); + exit(2); + } + + // Get initscript name(s) from addon metadata + int rc = 0; + services = get_addon_services(addon, &servicescnt, service_filter, &rc); + if (!services) { + switch (rc) { + case -1: + fprintf(stderr, "\nSystem error occured. (Error: %m)\n\n"); + break; + + case 0: + if (service_filter) + fprintf(stderr, "\nNo service '%s' found for addon '%s'. Use 'list-services' to get a list of available services\n\n%s\n\n", service_filter, addon, usage); + else + fprintf(stderr, "\nAddon '%s' has no services.\n\n", addon); + break; + + case 1: + fprintf(stderr, "\nAddon '%s' not found.\n\n%s\n\n", addon, usage); + break; + } + exit(1); + } + + // Handle requested action + if (strcmp(action, "start") == 0 || + strcmp(action, "stop") == 0 || + strcmp(action, "restart") == 0 || + strcmp(action, "reload") == 0 || + strcmp(action, "status") == 0) { + + for(int i = 0; i < servicescnt; i++) { + if (initscript_action(services[i], action) < 0) { + r = 1; + fprintf(stderr, "\nSystem error occured. (Error: %m)\n\n"); + break; + } + } + + } else if (strcmp(action, "enable") == 0 || + strcmp(action, "disable") == 0) { + + for(int i = 0; i < servicescnt; i++) { + switch (r = toggle_service(services[i], action)) { + case -1: + fprintf(stderr, "\nSystem error occured. (Error: %m)\n\n"); + break; + + case 0: + printf("%sd service %s\n", action, services[i]); + break; + + case 1: + fprintf(stderr, "Service %s is already %sd. Skipping...\n", services[i], action); + break; + + case 2: + fprintf(stderr, "\nUnable to %s service %s. (Service has no valid runlevel symlink).\n\n", action, services[i]); + break; + } + + // Break from for loop in case of a system error. + if (r == -1) { + r = 1; + break; + } + } + + } else if (strcmp(action, "boot-status") == 0) { + // Print boot status for each service + for(int i = 0; i < servicescnt; i++) { + switch (get_boot_status(services[i])) { + case -1: + r = 1; + fprintf(stderr, "\nSystem error occured. (Error: %m)\n\n"); + break; + + case 0: + printf("%s is disabled on boot.\n", services[i]); + break; + + case 1: + printf("%s is enabled on boot.\n", services[i]); + break; + + case 2: + printf("%s is not available for boot. (Service has no valid symlink in either %s or %s).\n", services[i], enabled_path, disabled_path); + break; + } + + // Break from for loop in case of an error + if (r == 1) { + break; + } + } + + } else if (strcmp(action, "list-services") == 0) { + // List all services for addon + printf("\nServices for addon %s:\n", addon); + for(int i = 0; i < servicescnt; i++) { + printf(" %s\n", services[i]); + } + printf("\n"); + + } else { + fprintf(stderr, "\nBad argument given.\n\n%s\n\n", usage); + r = 1; + } + + // Cleanup + for(int i = 0; i < servicescnt; i++) + free(services[i]); + free(services); + + return r; } From patchwork Tue Oct 11 22:01:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 6054 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4Mn8tT4qdGz3wgN for ; Tue, 11 Oct 2022 22:03:29 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4Mn8tP4JnDz2ZG; Tue, 11 Oct 2022 22:03:25 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4Mn8tN6zDsz2yl8; Tue, 11 Oct 2022 22:03:24 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4Mn8tL5xJXz2xmP for ; Tue, 11 Oct 2022 22:03:22 +0000 (UTC) Received: from knopi.disroot.org (knopi.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4Mn8tK72b1z2Mm for ; Tue, 11 Oct 2022 22:03:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 8C5444DB02 for ; Wed, 12 Oct 2022 00:03:21 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with UTF8SMTP id RHjHDbx8xx43 for ; Wed, 12 Oct 2022 00:03:20 +0200 (CEST) Received: from chojin.sicho.home (amaterasu.sicho.home [192.168.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (no client certificate requested) (Authenticated sender) by hachiman (MailScanner Milter) with SMTP id F2C81751F4; Wed, 12 Oct 2022 00:02:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1665525746; bh=GM0fcuh6JCsI8ywioRsQ6Ly6B7KpqMUcdyXx5ewMjoA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=h1OnDxXF9izQanATMUTcUqUbHCk89Ej/cMFbi6j/4pJyBIT73AljWs4IQ0YPs+0sf OMH2pRAOIF+NdQ3nui7+UOdn0u24rCBAkr4p+xrITUe5Psf4ObtcQewPCTLriFFXtQ V9WFaAcjEY+qLADavNjowhZR0PssbtAPYVoO4fBUuYoU4c7GtiLiVlaCQO+/x+LwpA 2UAkYcKAvZmDi36npb2P3uK9kKxN5zdT+QsTd6QEbh92KqOnzTtnwqq18zyaADkatn 7iGd9YF0gVDbcO5Ft/ngxzUx7xI/Lq9nFduwtjbWuMB3CrTeciG4GzoMJ/KbIk444m UqYUpwtJ11OpA== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v3 2/5] services.cgi: Fix status/actions on services with name != addon name Date: Wed, 12 Oct 2022 00:01:54 +0200 Message-Id: <20221011220157.17385-3-robin.roevens@disroot.org> In-Reply-To: <20221011220157.17385-1-robin.roevens@disroot.org> References: <20221011220157.17385-1-robin.roevens@disroot.org> Mime-Version: 1.0 X-sicho-MailScanner-ID: F2C81751F4.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1666130530.91022@YqXNQAJJcSA960NnnXQ+Vg ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1665525802; a=rsa-sha256; cv=none; b=o+XZ7Yb2cWHyzeF0aIJKzXK53GhJQwQJDnmEastSw5h7wqORAMDLB00fF6kd578rl+d/1Y IW/wrPgoORGXBQq+5hHYUUwtcXq6qpaOe44w4/80qHae9NOaPZa0/kvQDPUZAMCPLIFaqq YaIEVsFtqhFr1MnlWYFXriaUsUsJ7xKDslmu+8uEQpOQM/V78Wu6/4QSSX3V3S9afg9vHT EIgSgjF9px6NGGTjrMs7TeEpXaA7BGcvupamJZ9N0C7PD7Gtn8wPQzVQkhZua0z13SjOXN FZXIpKt6ubCXrVODnuZDxj94WK4aOmlynBj1vVJMkWreboPMi/3Z71Ym18rvmg== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=h1OnDxXF; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org; dmarc=pass (policy=quarantine) header.from=disroot.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1665525802; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Ac48KXQ5M8yw6OVWDjJcLBVLTpyM7FeRFwTNgLoSLbg=; b=Z9ONjetXhne0IMSasMD2MjBuIHAEMKxQrvlKBJnEZF2ktsoiGwJVYWyRWOlrxjAu/MiLSJ GUCd6o88xW9TrnlMWL92pvYl8Vid45uUU89iNF8leOzlSRuK1f+uYCkzi4FmUJ+owcYBX/ Sy1CBF0ttewQn4fwmpAh3JPTgUn9hiU8++DY/X4/osOw8W0AF95Zmcy4WVq4yVZgYJe3OX zb3tDg8QBHtdLqDAp3A8SuOai9J2SqGqYlHOi5TDjJIYYCOkz2Q3KmlEO61pWSsnnwdg+Z PDO2L8zT1FgZxjm23tMOK/8oW9b0X0ks8Gqn7K9DA+J4eYYbiJifwYYSLoCNRQ== Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=h1OnDxXF; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org; dmarc=pass (policy=quarantine) header.from=disroot.org X-Rspamd-Server: mail01.haj.ipfire.org X-Spamd-Result: default: False [-5.32 / 11.00]; BAYES_HAM(-3.00)[99.99%]; IP_REPUTATION_HAM(-1.14)[asn: 50673(-0.32), country: NL(-0.01), ip: 178.21.23.139(-0.81)]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-1.00)[-1.000]; DKIM_REPUTATION(-0.82)[-0.82134715129011]; SPF_REPUTATION_HAM(-0.61)[-0.61440594065069]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; MV_CASE(0.50)[]; R_DKIM_ALLOW(0.27)[disroot.org:s=mail]; MIME_HTML_ONLY(0.20)[]; R_SPF_ALLOW(-0.20)[+a:c]; MX_GOOD(-0.01)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; ARC_NA(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[development@lists.ipfire.org]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; ASN(0.00)[asn:50673, ipnet:178.21.23.0/24, country:NL]; DKIM_TRACE(0.00)[disroot.org:+]; RCPT_COUNT_TWO(0.00)[2]; SUBJECT_HAS_EXCLAIM(0.00)[]; MIME_TRACE(0.00)[0:~]; TO_DN_SOME(0.00)[] X-Rspamd-Queue-Id: 4Mn8tK72b1z2Mm X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" * addonctrl's new functionality to control explicit addon services was implemented. * Change 'Addon' column header to 'Addon Service' to be clear that it's not addons but services listed here. * Services not matching the name of the addon now display the addon name between parentheses, so the user knows where the service comes from. * When no valid runlevel symlink is found by addonctrl for a service, the 'enable on boot' checkbox is replaced by a small exclamation point with alt-text "No valid runlevel symlink was found for the initscript of this service." to inform user why a service can't be enabled. * Added German and Dutch translation for above message. Fixes: Bug#12935 Signed-off-by: Robin Roevens Reviewed-by: Michael Tremer --- html/cgi-bin/services.cgi | 114 ++++++++++++++++---------------------- langs/de/cgi-bin/de.pl | 1 + langs/en/cgi-bin/en.pl | 1 + langs/nl/cgi-bin/nl.pl | 1 + 4 files changed, 51 insertions(+), 66 deletions(-) diff --git a/html/cgi-bin/services.cgi b/html/cgi-bin/services.cgi index 29926ecc3..de946d755 100644 --- a/html/cgi-bin/services.cgi +++ b/html/cgi-bin/services.cgi @@ -20,7 +20,7 @@ ############################################################################### use strict; - +use feature "switch"; # enable only the following on debugging purpose #use warnings; #use CGI::Carp 'fatalsToBrowser'; @@ -141,15 +141,22 @@ END &Header::openbox('100%', 'left', "Addon - $Lang::tr{services}"); my $paramstr=$ENV{QUERY_STRING}; my @param=split(/!/, $paramstr); - if ($param[1] ne ''){ - &General::system("/usr/local/bin/addonctrl", "$param[0]", "$param[1]"); + # Make sure action parameter is actually one of the allowed service actions + given ($param[1]) { + when ( ['start', 'stop', 'enable', 'disable'] ) { + # Make sure pak-name and service name don't contain any illegal character + if ( $param[0] !~ /[^a-zA-Z_0-9\-]/ && + $param[2] !~ /[^a-zA-Z_0-9\-]/ ) { + &General::system("/usr/local/bin/addonctrl", "$param[0]", "$param[1]", "$param[2]"); + } + } } print < - + @@ -170,33 +177,35 @@ END foreach my $pak (keys %paklist) { my %metadata = &Pakfire::getmetadata($pak, "installed"); + my $service; + if ("$metadata{'Services'}") { - foreach my $service (split(/ /, "$metadata{'Services'}")) { - push(@addon_services, $service); - } - } - } + foreach $service (split(/ /, "$metadata{'Services'}")) { + $lines++; + if ($lines % 2) { + print ""; + $col="bgcolor='$color{'color22'}'"; + } else { + print ""; + $col="bgcolor='$color{'color20'}'"; + } - foreach (@addon_services) { - $lines++; - if ($lines % 2){ - print ""; - $col="bgcolor='$color{'color22'}'"; - }else{ - print ""; - $col="bgcolor='$color{'color20'}'"; + # Add addon name to displayname of service if servicename differs from addon + my $displayname = ($pak ne $service) ? "$service ($pak)" : $service; + print " "; + + my $status = isautorun($pak,$service,$col); + print "$status "; + print ""; + print " "; + my $status = isrunningaddon($pak,$service,$col); + $status =~ s/\\[[0-1]\;[0-9]+m//g; + + chomp($status); + print "$status"; + print ""; + } } - print " "; - my $status = isautorun($_,$col); - print "$status "; - print ""; - print " "; - my $status = isrunningaddon($_,$col); - $status =~ s/\\[[0-1]\;[0-9]+m//g; - - chomp($status); - print "$status"; - print ""; } print "
AddonAddon $Lang::tr{service} Boot $Lang::tr{'action'} $Lang::tr{'status'}
$displayname$Lang::tr{$Lang::tr{
$_$Lang::tr{$Lang::tr{
\n"; @@ -215,51 +224,24 @@ END } sub isautorun (@) { - my ($cmd, $col) = @_; - - # Init directory. - my $initdir = "/etc/rc.d/rc3.d/"; - - my $status = ""; + my ($pak, $service, $col) = @_; + my @testcmd = &General::system_output("/usr/local/bin/addonctrl", "$pak", "boot-status", "$service"); + my $testcmd = @testcmd[0]; + my $status = "$Lang::tr{"; - # Check if autorun for the given cmd is enabled. - if ( &find_init("$cmd", "$initdir") ) { + # Check if autorun for the given service is enabled. + if ( $testcmd =~ /enabled\ on\ boot/ ) { # Adjust status. - $status = "$Lang::tr{"; - } else { + $status = "$Lang::tr{"; + } elsif ( $testcmd =~ /disabled\ on\ boot/ ) { # Adjust status. - $status = "$Lang::tr{"; + $status = "$Lang::tr{"; } # Return the status. return $status; } -sub find_init (@) { - my ($cmd, $dir) = @_; - - # Open given init directory. - opendir (INITDIR, "$dir") || die "Cannot opendir $dir: $!"; - - # Read-in init files from directory. - my @inits = readdir(INITDIR); - - # Close directory handle. - closedir(INITDIR); - - # Loop through the directory. - foreach my $init (@inits) { - # Check if the current processed file belongs to the given command. - if ($init =~ /S\d+\d+$cmd\z/) { - # Found, return "1" - True. - return "1"; - } - } - - # Nothing found, return nothing. - return; -} - sub isrunning (@) { my ($cmd, $col) = @_; my $status = "$Lang::tr{'stopped'}"; @@ -313,7 +295,7 @@ sub isrunning (@) { } sub isrunningaddon (@) { - my ($cmd, $col) = @_; + my ($pak, $service, $col) = @_; my $status = "$Lang::tr{'stopped'}"; my $pid = ''; @@ -321,7 +303,7 @@ sub isrunningaddon (@) { my $exename; my @memory; - my @testcmd = &General::system_output("/usr/local/bin/addonctrl", "$cmd", "status"); + my @testcmd = &General::system_output("/usr/local/bin/addonctrl", "$pak", "status", "$service"); my $testcmd = @testcmd[0]; if ( $testcmd =~ /is\ running/ && $testcmd !~ /is\ not\ running/){ diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl index 798abcffc..db7d117b0 100644 --- a/langs/de/cgi-bin/de.pl +++ b/langs/de/cgi-bin/de.pl @@ -2251,6 +2251,7 @@ 'server string' => 'Server String', 'service' => 'Dienst', 'service added' => 'Benutzerdefinierter Netzwerkdienst wurde hinzugefügt', +'service boot setting unavailable' => 'Für das Initscript dieses Dienstes wurde kein gültiger Runlevel-Symlink gefunden.', 'service name' => 'Name des Dienstes:', 'service removed' => 'Benutzerdefinierter Netzwerkdienst wurde entfernt', 'service updated' => 'Benutzerdefinierter Netzwerkdienst wurde aktualisiert', diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index f770e7cd9..60dca5be4 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -2306,6 +2306,7 @@ 'server string' => 'Server String', 'service' => 'Service', 'service added' => 'Custom network service added', +'service boot setting unavailable' => 'No valid runlevel symlink was found for the initscript of this service.', 'service name' => 'Service name:', 'service removed' => 'Custom network service removed', 'service updated' => 'Custom network service updated', diff --git a/langs/nl/cgi-bin/nl.pl b/langs/nl/cgi-bin/nl.pl index 49dabec99..4fd6955cc 100644 --- a/langs/nl/cgi-bin/nl.pl +++ b/langs/nl/cgi-bin/nl.pl @@ -1899,6 +1899,7 @@ 'server string' => 'Server String', 'service' => 'Dienst', 'service added' => 'Aangepaste netwerkdienst toegevoegd', +'service boot setting unavailable' => 'Er werd voor het initscript van deze service geen geldige runlevel symlink gevonden.', 'service name' => 'Dienstennaam:', 'service removed' => 'Aangepaste netwerkdienst verwijderd', 'service updated' => 'Aangepaste netwerkdienst bijgewerkt', From patchwork Tue Oct 11 22:01:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 6055 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4Mn8tW3xyZz3wgL for ; Tue, 11 Oct 2022 22:03:31 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4Mn8tP6t8Rz2RV; Tue, 11 Oct 2022 22:03:25 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4Mn8tP09fVz302f; Tue, 11 Oct 2022 22:03:25 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4Mn8tM04s6z2xfn for ; Tue, 11 Oct 2022 22:03:23 +0000 (UTC) Received: from knopi.disroot.org (knopi.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4Mn8tL65XPzyn for ; Tue, 11 Oct 2022 22:03:22 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 9AE434DAF4 for ; Wed, 12 Oct 2022 00:03:22 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with UTF8SMTP id 6HixwdkJf82d for ; Wed, 12 Oct 2022 00:03:21 +0200 (CEST) Received: from chojin.sicho.home (amaterasu.sicho.home [192.168.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (no client certificate requested) (Authenticated sender) by hachiman (MailScanner Milter) with SMTP id 0D29A751F7; Wed, 12 Oct 2022 00:02:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1665525747; bh=vbDvSVGhgCO6+RtYlm/w2uMpg29aUcrnpQFLZJTdVho=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=OrxlLqc3bW5OIZPfST0nzZmhqn6YxI72qNJbbz8CV4ONhe0HiRgBKLjiZ+ImimmZv /M4uo4LXpEXprXRsEhnNsQo9i4aGbdHXCxjOiupRWUjNPHrB4ngM7yMH6hcRB3LkHN 4ldd9uapW7u4ow+Kku2vUZUBCecNULFJWxRRk78J4eLEGRrmw9z4HIjAk8qFP8HKFS Jn4YACOSzNu281EMFZZXcIF+Ik8crOtp0UORosBcsQmZjYYbuWYV+3rDeQhTuyKTZ9 ltPJncxKT8riA/PLy6KtW5MpRVooAnp4dkzpR2yVDM1/qEYYlU/J6+e4oNecsJLONg 73ExljrTbBWmw== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v3 3/5] services.cgi: minor cosmetics Date: Wed, 12 Oct 2022 00:01:55 +0200 Message-Id: <20221011220157.17385-4-robin.roevens@disroot.org> In-Reply-To: <20221011220157.17385-1-robin.roevens@disroot.org> References: <20221011220157.17385-1-robin.roevens@disroot.org> Mime-Version: 1.0 X-sicho-MailScanner-ID: 0D29A751F7.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1666130530.96056@f98+IXgoBH6OtFxrZ6r2ZA ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1665525802; a=rsa-sha256; cv=none; b=xvYOD+oSBvw/AwMwNokEM3YNKxIEVKJGTlOy/Ay8VqfX2zhPP+rhcnumYFmitWeXILUbJR Jax++3jUxCQ/S8TxYhu/RsS2GjOY9lviq1QEtnl7BHi9CO+MjWqrgC5rVHjxzA+pRLOlAy uvUxe+sOQH9sEdW6Npj8kPnOZVeO2G6lCjuK8S76XedTfG6fXcoHvcuJF1egkrS4JiEJ7E Ragqi0OWCqVvMLXKC7iJEXuBodL+ewjqh0OVnz9WWCwXY3r+DRb3LtO9QmBP7ZTb0ZbJTK EFzbfyY/LiB6QDIrzqAvogzRzukICxxivwwMrmZ3KdQfcv9MiCzpS32wvtGizg== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=OrxlLqc3; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org; dmarc=pass (policy=quarantine) header.from=disroot.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1665525802; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=kv4X7Ldg++5HyH98neE3Ar4qsUNU6YeUaIoFM7DSOko=; b=EPUPZ0ZcWjRxDXyVRBthmcfDsbgpaQG/Z0jCL5mP7FfvG1iQkjZ9oOXuRuOAoXGk3U6oG7 zPZ2o2mV65/ci726ZNeSFvJc/cutznCEx9U7HsCy1+ILCgeAIry1UNDZThtcLMB2y9nmC2 XwHljwMdh/CqOuSyCOA3pI7/XUwGJKKnpEFbCr9/kajTorXvLFLTELQ0IVygBz7UQKUD4F gkiIC7f1snPNWWdXXq4Km5nORidb5/MB/qykOnQg1vE+r/yVNYihF+7J1Wru2geEG5wVrh ZGcqe/Cr6u0LzmpaUH0mI2+n7gaDVEKbI35a61eC8Kvu0tyqSril79np2ZI/eA== Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=OrxlLqc3; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org; dmarc=pass (policy=quarantine) header.from=disroot.org X-Rspamd-Server: mail01.haj.ipfire.org X-Spamd-Result: default: False [-3.58 / 11.00]; BAYES_HAM(-1.47)[91.49%]; IP_REPUTATION_HAM(-1.13)[asn: 50673(-0.32), country: NL(-0.01), ip: 178.21.23.139(-0.81)]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-1.00)[-1.000]; DKIM_REPUTATION(-0.82)[-0.81568261952269]; SPF_REPUTATION_HAM(-0.61)[-0.61451727240354]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; R_MISSING_CHARSET(0.50)[]; MV_CASE(0.50)[]; R_DKIM_ALLOW(0.27)[disroot.org:s=mail]; R_SPF_ALLOW(-0.20)[+a:c]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[development@lists.ipfire.org]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; ASN(0.00)[asn:50673, ipnet:178.21.23.0/24, country:NL]; DKIM_TRACE(0.00)[disroot.org:+]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_TWO(0.00)[2]; TO_DN_SOME(0.00)[] X-Rspamd-Queue-Id: 4Mn8tL65XPzyn X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" * Singular 'Service' instead of plural 'Services' as column header of services table * Sort list of services Signed-off-by: Robin Roevens Reviewed-by: Michael Tremer --- html/cgi-bin/services.cgi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/cgi-bin/services.cgi b/html/cgi-bin/services.cgi index de946d755..e35b04cae 100644 --- a/html/cgi-bin/services.cgi +++ b/html/cgi-bin/services.cgi @@ -105,7 +105,7 @@ if ( $querry[0] =~ "processescpu"){
- + @@ -174,7 +174,7 @@ END # Generate list of installed addon pak services my %paklist = &Pakfire::dblist("installed"); - foreach my $pak (keys %paklist) { + foreach my $pak (sort keys %paklist) { my %metadata = &Pakfire::getmetadata($pak, "installed"); my $service; From patchwork Tue Oct 11 22:01:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 6057 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4Mn8tY56kTz3whg for ; Tue, 11 Oct 2022 22:03:33 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4Mn8tR2NSLz2b9; Tue, 11 Oct 2022 22:03:27 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4Mn8tR15yGz2yXK; Tue, 11 Oct 2022 22:03:27 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4Mn8tN1njXz2xfn for ; Tue, 11 Oct 2022 22:03:24 +0000 (UTC) Received: from knopi.disroot.org (knopi.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4Mn8tN0jcKzyn for ; Tue, 11 Oct 2022 22:03:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id D0ADB4DAF4 for ; Wed, 12 Oct 2022 00:03:23 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with UTF8SMTP id v8SLBqb9_J3b for ; Wed, 12 Oct 2022 00:03:22 +0200 (CEST) Received: from chojin.sicho.home (amaterasu.sicho.home [192.168.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (no client certificate requested) (Authenticated sender) by hachiman (MailScanner Milter) with SMTP id 0F654751FA; Wed, 12 Oct 2022 00:02:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1665525747; bh=yyr9r7oQWZjPJ0qf+VAreyrxpn9yuyVhSrPvpR1uBpw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=SjDjVtKnCUZf5aOqGRAdVSUxYskPRu7tqtaud+XWB0oaC14JacFd+i2InjgnBgNuw FBKE4o95QqMOD8i6uqqvyf268jxYP463vGSaQQAOa+TlWozTnuiACDJxaQ3f+oBe34 H8iD9+hdAK7TkKVN+g42fzy57kO8tWzqYI5ApKbHDhqm/ahXtzjhIKK8b1l0mt7UIm Kj6FQKzty4xaxhVDBPUXo/C6cbiNjzabFIF/7KX2zerSOkO1xSajt8dLYBwbVqWhgX BZ4FrmSbpyM52bDvC5wi96IQokj3w+0JecpgUj2UW52h5HeLJLdlYQg/Nbt6SobACH kQRRFI5GjOUmQ== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v3 4/5] services.cgi: add restart action and restrict action usage Date: Wed, 12 Oct 2022 00:01:56 +0200 Message-Id: <20221011220157.17385-5-robin.roevens@disroot.org> In-Reply-To: <20221011220157.17385-1-robin.roevens@disroot.org> References: <20221011220157.17385-1-robin.roevens@disroot.org> Mime-Version: 1.0 X-sicho-MailScanner-ID: 0F654751FA.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1666130530.93361@K3jXsvk5+T8AqQH71/2duQ ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1665525804; a=rsa-sha256; cv=none; b=Z6tCeqPB4Rg7k1ZI5Lwon4L+tiZ0jklAirGNbxf9BbOFJcOj3xf3pkizvVKjDahQ2B9B6K Fo8orqpDDGy0vnY+VAZvaWnX/3sLMlh3A8kDwtHerCIu1BVnJOgIAZVPF60Uu7yfDGziwj x9vypr+qnRdr0HQtLI5cI/HsNU5lsEcts7GKeJWo+R6vaQv8wCOuHD1Kw5ZkbdhB5Vo9Xn CmCFKlF3xsGQfczTQUZlZGiTuBc/Bl/I2m9wa8yHaIWGRlTWDtyb7L5c123rupqVO23WnB XVqT+PmFMuxtIK3rk6RTVbbiOPnVzRdDrwJxfb0kGvwwrXThbpD+lVZ+L9puGg== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=SjDjVtKn; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org; dmarc=pass (policy=quarantine) header.from=disroot.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1665525804; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WXYia0IMeOLf9Pntkzycp729WzHUkkazpFm452MZ0fw=; b=wREJIsWqZiuzUr+H4QwEgiluFi1iITpWmRl9RrEsl12uZ+kyuKVEeYyGlBKdrqEZRpw7Mj coKVrRxFiVfsllF8LQ0KF9DBdDiyM1dimx+SPCsQp4dJXHlj20RYWywY+F7UQ1Y0mMiIDD YswRjROKa54vrSMlP7QG602Lzhkw+JL5w+a4QCDuqZVGldu5F1NpSBcn1fdFxWYp64gHD/ ZCc/P+xxP21CmcvsCDG2naUVGM92hh6qmX7mGHfZQf73+ps4suYEPI2pCmmDoVe/quNnZy isyHDYWng9zIqWOQ5NruQ5fk1OstIUQ0Hz2Xr+Xd3styqIjmDKKYfA+J/dH5aQ== Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=SjDjVtKn; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org; dmarc=pass (policy=quarantine) header.from=disroot.org X-Rspamd-Server: mail01.haj.ipfire.org X-Spamd-Result: default: False [-4.81 / 11.00]; BAYES_HAM(-3.00)[99.99%]; IP_REPUTATION_HAM(-1.13)[asn: 50673(-0.32), country: NL(-0.01), ip: 178.21.23.139(-0.81)]; NEURAL_HAM(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; DKIM_REPUTATION(-0.82)[-0.81568261952269]; SPF_REPUTATION_HAM(-0.61)[-0.61451727240354]; R_MISSING_CHARSET(0.50)[]; MV_CASE(0.50)[]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; R_DKIM_ALLOW(0.27)[disroot.org:s=mail]; MIME_HTML_ONLY(0.20)[]; R_SPF_ALLOW(-0.20)[+a:c]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[development@lists.ipfire.org]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; ASN(0.00)[asn:50673, ipnet:178.21.23.0/24, country:NL]; DKIM_TRACE(0.00)[disroot.org:+]; MIME_TRACE(0.00)[0:~]; RCPT_COUNT_TWO(0.00)[2]; TO_DN_SOME(0.00)[] X-Rspamd-Queue-Id: 4Mn8tN0jcKzyn X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" * Add restart action to services. * Only display available actions for a service: Start when service is stopped or Stop and Restart when a service is running. Signed-off-by: Robin Roevens Reviewed-by: Michael Tremer --- html/cgi-bin/services.cgi | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/html/cgi-bin/services.cgi b/html/cgi-bin/services.cgi index e35b04cae..4b379251e 100644 --- a/html/cgi-bin/services.cgi +++ b/html/cgi-bin/services.cgi @@ -143,7 +143,7 @@ END my @param=split(/!/, $paramstr); # Make sure action parameter is actually one of the allowed service actions given ($param[1]) { - when ( ['start', 'stop', 'enable', 'disable'] ) { + when ( ['start', 'stop', 'restart', 'enable', 'disable'] ) { # Make sure pak-name and service name don't contain any illegal character if ( $param[0] !~ /[^a-zA-Z_0-9\-]/ && $param[2] !~ /[^a-zA-Z_0-9\-]/ ) { @@ -196,8 +196,6 @@ END my $status = isautorun($pak,$service,$col); print "$status "; - print ""; - print " "; my $status = isrunningaddon($pak,$service,$col); $status =~ s/\\[[0-1]\;[0-9]+m//g; @@ -307,7 +305,9 @@ sub isrunningaddon (@) { my $testcmd = @testcmd[0]; if ( $testcmd =~ /is\ running/ && $testcmd !~ /is\ not\ running/){ - $status = ""; + $status = " "; + $status .= " "; + $status .= ""; $testcmd =~ s/.* //gi; $testcmd =~ s/[a-z_]//gi; $testcmd =~ s/\[[0-1]\;[0-9]+//gi; @@ -330,7 +330,8 @@ sub isrunningaddon (@) { } $status .=""; }else{ - $status = ""; + $status = ""; + $status .= ""; } return $status; } From patchwork Tue Oct 11 22:01:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 6053 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4Mn8tS6sP5z3wgL for ; Tue, 11 Oct 2022 22:03:28 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4Mn8tP05hBz1gg; Tue, 11 Oct 2022 22:03:25 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4Mn8tN5qFHz2yrV; Tue, 11 Oct 2022 22:03:24 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4Mn8tL5vHrz2xfn for ; Tue, 11 Oct 2022 22:03:22 +0000 (UTC) Received: from knopi.disroot.org (knopi.disroot.org [178.21.23.139]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPS id 4Mn8tK4v7Gzyn for ; Tue, 11 Oct 2022 22:03:21 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 246B04DAF4 for ; Wed, 12 Oct 2022 00:03:20 +0200 (CEST) X-Virus-Scanned: SPAM Filter at disroot.org Received: from knopi.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with UTF8SMTP id 2txdvFuDDzPg for ; Wed, 12 Oct 2022 00:03:19 +0200 (CEST) Received: from chojin.sicho.home (amaterasu.sicho.home [192.168.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (no client certificate requested) (Authenticated sender) by hachiman (MailScanner Milter) with SMTP id 11A53751FD; Wed, 12 Oct 2022 00:02:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1665525746; bh=dfD7zCVtF77vM74ZurVdNigaK99kVMjR5o/weXTB8fg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=l3jyIgneAtiBh+0DjXmbdDnN1worEHdbiFRwNXSxHm88ba49VCgDesQBSiu0ryQye EppBlae7Si22lHsLI7xCmBw/j3rKZWc8xfqc9PBvBtHRXkX6kzLqgHpqc7Wnwd9tFc ufW1C2VCxvQbFg+mL7CDQqSIlwqI5+T/cfOGkU5kbF6Pg9tvY7UTGutUjI9gIdWCYD Vh+ACYqNC6r0axkaHHHzn/jbpsCdtpxflLUUEWuOugkw4aQZW8v1fcgYF8AJOyeKev UNZ5mxeTfqFIeP0F5BV95MDuzhpgY7nSrCLeLyZMoX3dEGUc+rCA6x/FzPXOJxfjcI 3Xb59+MFUxAHg== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v3 5/5] services.cgi: add link to addon config if ui exists for it Date: Wed, 12 Oct 2022 00:01:57 +0200 Message-Id: <20221011220157.17385-6-robin.roevens@disroot.org> In-Reply-To: <20221011220157.17385-1-robin.roevens@disroot.org> References: <20221011220157.17385-1-robin.roevens@disroot.org> Mime-Version: 1.0 X-sicho-MailScanner-ID: 11A53751FD.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1666130530.88704@5siYQs3ni2+1f7AHBEm8wQ ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1665525801; a=rsa-sha256; cv=none; b=Xh/Fk8dVhNS5Nv2cUx9xeBTJNHrabSjT7z3oeAs5oo7LXcqg9AyIbgbxEE+qnx06C+M8jV UO+e/CFplBnyQchaNuTwqNbABP3YMBl5DCuPhMAruPZUS4z3oa7ulwUjjclu3dibWpbD7y zZ9iPZqgZT5+5hokGR7ww83Hb7wa0XeZe72k8ve/PYFVV1vQjbtaD5uTuk3Dw4UNhoWzo/ l5Wj2JndVqaTOHoZR7gkPFf9tn9yLPhDi9/0c87Wg8uhQe+F6MtCUvPd4uRzW19y+cxJFB HaDvMSRSINUHnw2r3h05XsSwA9ISJjsmbYwk+R/KbnGxbTjAdoQHVHF7o78wvg== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=l3jyIgne; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org; dmarc=pass (policy=quarantine) header.from=disroot.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.ipfire.org; s=202003rsa; t=1665525801; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=G9YnD2y3kDrDXmCNmhWrnFpcknqM6D2HqhXaGVvKHmY=; b=xpbF1/qmE8b2ecyh/I2i3ek2JIDmYRiavue3AM8qvEOf18wn5KRNzvoJukj+Qn8BFoDzAB BhzlDyUjWERSxxXiS3/a4IhIHKWqb+ENp/V9If8Dy+v8lIbXcnHeRZX7NoM1nML/13iw8a t7+zUaMtZSHXOmMlDJbDfDZF4ms/AJoQGLsy+4+RMLnQLIx5LMgqvbSaL+HunZCnHMgxU6 vs7IHzlf2bAHNI29MeG8ws9vQpVQdWdI6LG9SMTE4Kdg+du3R7Ogk6TlVWrOjnZetjHIdC uYKvFhdspxvsA65XC6qXzGASwZ/D08DdkVg4ebaDZaYtxSptN6I8Mc1GsuaAfA== Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=l3jyIgne; spf=pass (mail01.ipfire.org: domain of robin.roevens@disroot.org designates 178.21.23.139 as permitted sender) smtp.mailfrom=robin.roevens@disroot.org; dmarc=pass (policy=quarantine) header.from=disroot.org X-Rspamd-Server: mail01.haj.ipfire.org X-Spamd-Result: default: False [-5.12 / 11.00]; BAYES_HAM(-3.00)[99.99%]; IP_REPUTATION_HAM(-1.14)[asn: 50673(-0.32), country: NL(-0.01), ip: 178.21.23.139(-0.81)]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-1.00)[-1.000]; DKIM_REPUTATION(-0.82)[-0.82134715129011]; SPF_REPUTATION_HAM(-0.61)[-0.61440594065069]; MV_CASE(0.50)[]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(0.27)[disroot.org:s=mail]; R_SPF_ALLOW(-0.20)[+a]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[development@lists.ipfire.org]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; ASN(0.00)[asn:50673, ipnet:178.21.23.0/24, country:NL]; DKIM_TRACE(0.00)[disroot.org:+]; MIME_TRACE(0.00)[0:+]; RCPT_COUNT_TWO(0.00)[2]; TO_DN_SOME(0.00)[] X-Rspamd-Queue-Id: 4Mn8tK4v7Gzyn X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" * If a cgi file exists with the same name as an addon, the displayed service will be a link to that cgi file. Signed-off-by: Robin Roevens Reviewed-by: Michael Tremer --- html/cgi-bin/services.cgi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/html/cgi-bin/services.cgi b/html/cgi-bin/services.cgi index 4b379251e..14ed01c50 100644 --- a/html/cgi-bin/services.cgi +++ b/html/cgi-bin/services.cgi @@ -192,6 +192,10 @@ END # Add addon name to displayname of service if servicename differs from addon my $displayname = ($pak ne $service) ? "$service ($pak)" : $service; + if ( -e "/srv/web/ipfire/cgi-bin/$pak.cgi" ) { + $displayname = ($pak ne $service) ? "$service ($pak)" : "$service"; + } + print " "; my $status = isautorun($pak,$service,$col);
$Lang::tr{'services'}$Lang::tr{'service'} $Lang::tr{'status'} PID $Lang::tr{'memory'}$Lang::tr{$Lang::tr{$Lang::tr{'running'}$Lang::tr{$Lang::tr{$Lang::tr{'running'}$memory KB$Lang::tr{'stopped'}$Lang::tr{$Lang::tr{'stopped'}$displayname