From patchwork Thu Oct 6 17:59:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 6044 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 4MjzwG3sGdz3wgH for ; Thu, 6 Oct 2022 18:09:02 +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 4Mjzw82Rjwz2bD; Thu, 6 Oct 2022 18:08:56 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4Mjzw72nH9z301x; Thu, 6 Oct 2022 18:08:55 +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 4Mjzw62ycCz2yk8 for ; Thu, 6 Oct 2022 18:08:54 +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 4Mjzw61sLHz1Cl for ; Thu, 6 Oct 2022 18:08:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id F06824C9D3 for ; Thu, 6 Oct 2022 20:08:53 +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 Xn6qVkapGXS4 for ; Thu, 6 Oct 2022 20:08:52 +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 ED47873539; Thu, 6 Oct 2022 20:00:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1665079223; bh=WV6TmhAUoB1JEDQCFVznE9wvNfIU3cDxriR1fnKb99I=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Oy911lpdsOzvYrxHosHUJpc48Enlc9HwDXgiWSB09JxIbr3VIg3SYmDt1eCyTJw/t 7QJeKRZ85jQcrcAFGnRZgFhcSk/4P+gaSDknSnSqked23jnJaFjFRV/arwm+qaXjVR 1wnjivyiSB9kmbuQ49A8/hEWMjc0NC9F7OzGS0TnWJnyD2ma8CfdSRWiN4flN8xLwe ks+uqNfumJengOpdIVOu6CKbqiFtpczrCuOoEJQKWLjbfRCevCFVadTo9rfgbPrqv3 H5Znp14FuZK95Y31DVlwOlQEypvv/fAvOS3fydjsM6pLUpj9WAzFkISQG4pM/IGvKb NTbd6bi7HPt6w== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v2 1/5] misc-progs: addonctrl: Add support for 'Services' metadata Date: Thu, 6 Oct 2022 19:59:54 +0200 Message-Id: <20221006175958.11036-2-robin.roevens@disroot.org> In-Reply-To: <20221006175958.11036-1-robin.roevens@disroot.org> References: <20221006175958.11036-1-robin.roevens@disroot.org> Mime-Version: 1.0 X-sicho-MailScanner-ID: ED47873539.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1665684008.83121@k9GbiPT/YvuaQD0erXTyNw ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1665079734; a=rsa-sha256; cv=none; b=N7tFJo09w9FKhqRgVuo0m0Ss2HTXN+nc47w0fLE1NRIXlf0Y3hUL4z67x7dYMMIFQucVG3 5MpyxJI4pbx5Pa2qWVgGSmErstxO/UOBdokUPXgmVwk+sbD6FYo4KoCGUAJiV31pQUAohB N80+Kur6ydBMJymHGSQyb6CmqY2wlfW+cJUkzX4/+YdiZfn9jQ5B/J/Obo4jKY2APwls81 2LcH6wnJYS49a8v/pNioenVp0Tuy/zZx74L9xQ5Z7JlxsrY9BjInsw3dLTyc9WPX5r0HmZ WKA4eDMbSKMOr9SzHVNhNVYIVOvaykrlVNN6OogUSZyY1s41vKvIwPcS8MHyKQ== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=Oy911lpd; 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=1665079734; 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=1TjuutwJUcGfOMHg404O+6HgwKhv/A9yk6tNXhxSHMg=; b=iBFA7lErNDN1Di3mZb2F4uNUZSkteGsnmS5s2Bf1yfYyhtutC8OHg4/aGLIOnM+sVzUCPs tErgcb0iaZR66U9O7Tm1ezwKFa+8cpE27/iH1GeoKQD5oGva7mKyZS7aZIHeRQrl5RTDaK JErSBIlJtnMVk5YUADdEPFhUdZmdMsQllAs5B6qb2J7KJBoCNh6BCeQyiN2z7c3maF/maD JopypXSKosNyai1aq0WrNDB1+nxwy15BhesNgxhEqI4U0j22ql3KdcAQJOQFITDGAJNmso kruOIX4rW3uPctNXmih6yla/vHqFzWzA14L5rEAd0/rqbP7jj2DvAheKA1IcCg== Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=Oy911lpd; 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.10)[asn: 50673(-0.31), country: NL(-0.01), ip: 178.21.23.139(-0.78)]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-1.00)[-1.000]; DKIM_REPUTATION(-0.79)[-0.79182035360089]; SPF_REPUTATION_HAM(-0.68)[-0.68195333597372]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; R_MISSING_CHARSET(0.50)[]; MV_CASE(0.50)[]; R_DKIM_ALLOW(0.26)[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: 4Mjzw61sLHz1Cl 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 --- src/misc-progs/addonctrl.c | 397 +++++++++++++++++++++++++++++++------ 1 file changed, 336 insertions(+), 61 deletions(-) diff --git a/src/misc-progs/addonctrl.c b/src/misc-progs/addonctrl.c index 14b4b1325..1687aac19 100644 --- a/src/misc-progs/addonctrl.c +++ b/src/misc-progs/addonctrl.c @@ -10,71 +10,346 @@ #include #include #include +#include #include +#include +#include +#include #include "setuid.h" #define BUFFER_SIZE 1024 +const char *enabled_path = "/etc/rc.d/rc3.d"; +const char *disabled_path = "/etc/rc.d/rc3.d/off"; + +char errormsg[BUFFER_SIZE] = ""; +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; + + if ((dp = opendir(path)) != NULL) { + while(found == NULL && (entry = readdir(dp)) != NULL) + if (fnmatch(filepattern, entry->d_name, FNM_PATHNAME) == 0) + found = strdup(entry->d_name); + + closedir(dp); + } + + return found; +} + +// Reads Services metadata for . +// Returns pointer to array of strings containing the services for +// and sets to the number of found services +char **get_addon_services(const char *addon, int *servicescnt, const char *filter) { + 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; + + if (addon == NULL) { + errno = EINVAL; + return NULL; + } + + if (asprintf(&metafile, "%s%s", metafile_prefix, addon) == -1) { + errno = ENOMEM; + return NULL; + } + + FILE *fp = fopen(metafile,"r"); + if (fp != NULL) { + // Get initscript(s) for addon from meta-file + while (getline(&line, &line_len, fp) != -1 && services == NULL) { + // Strip newline + char *newline = strchr(line, '\n'); + if (newline) *newline = 0; + + // Parse key/value and look for required key. + token = strtok(line, keyvalue_delim); + if (token != NULL && strcmp(token, metadata_key) == 0) { + token = strtok(NULL, keyvalue_delim); + if (token != NULL) { + // Put each service in services array + service = strtok(token, service_delim); + while (service != NULL) { + // if filter is set, only select filtered service + if ((filter != NULL && strcmp(filter, service) == 0) || + filter == NULL) { + services = reallocarray(services ,i+1 ,sizeof (char *)); + if (services != NULL) + services[i++] = strdup(service); + else + break; + } + service = strtok(NULL, service_delim); + } + } + } + } + + free(line); + fclose(fp); + } else { + snprintf(errormsg, BUFFER_SIZE - 1, "Addon '%s' not found.\n\n%s", addon, usage); + } + + free(metafile); + *servicescnt = i; + return services; +} + +// Calls initscript with parameter +int initscript_action(const char *service, const char *action) { + const char *initd_path = "/etc/rc.d/init.d"; + char *initscript; + char *argv[] = { + action, + NULL + }; + int r = 0; + + if ((r = asprintf(&initscript, "%s/%s", initd_path, service)) != -1) { + r = run(initscript, argv); + free(initscript); + } else { + errno = ENOMEM; + } + + 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 = 1; + char *filename = NULL; + + if ((filename = find_file_in_dir(src_path, filepattern)) != NULL) { + if ((r = asprintf(&src, "%s/%s", src_path, filename)) != -1 && + (r = asprintf(&dest, "%s/%s", dest_path, filename) != -1)) { + // move initscript + r = rename(src, dest); + } else { + errno = ENOMEM; + } + + if (src != NULL) + free(src); + if (dest != NULL) + free(dest); + } else { + if ((filename = find_file_in_dir(dest_path, filepattern)) == NULL) + r = 2; + } + + if (filename != NULL) + free(filename); + + return r; +} + +// Enable/Disable addon service(s) by moving initscript symlink from/to disabled_path +int toggle_service(const char *service, const char *action) { + const char *src_path, *dest_path; + char *filepattern; + int r = 0; + + if (asprintf(&filepattern, "S??%s", service) == -1) { + errno = ENOMEM; + 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 + errno = 0; + if (mkdir(disabled_path, S_IRWXU + S_IRGRP + S_IXGRP + S_IROTH + S_IXOTH) == -1 && errno != EEXIST) { + r = 1; + snprintf(errormsg, BUFFER_SIZE -1, "Error creating %s. (Error: %d)", disabled_path, errno); + } else { + r = move_initscript_by_pattern(src_path, dest_path, filepattern); + if (r == -1 ) { + r = 1; + snprintf(errormsg, BUFFER_SIZE - 1, "Could not %s %s. (Error: %d)", action, service, errno); + } else if (r == 1) { + snprintf(errormsg, BUFFER_SIZE - 1, "Service %s is already %sd. Skipping...", service, action); + } else if (r == 2) { + snprintf(errormsg, BUFFER_SIZE - 1, "Unable to %s service %s. (Service has no valid symlink in %s).", action, service, src_path); + } + } + + free(filepattern); + + return r; +} + +// Print to stdout wether is enabled or disabled on boot +// Prints as Not available when initscript is not found +// in either enabled_path or disabled_path. +void print_boot_status(char *service) { + char *filepattern; + if (asprintf(&filepattern, "S??%s", service) == -1) { + errno = ENOMEM; + return; + } + + if (find_file_in_dir(enabled_path, filepattern) != NULL) + fprintf(stdout, "%s is enabled on boot.\n", service); + else if (find_file_in_dir(disabled_path, filepattern) != NULL) + fprintf(stdout, "%s is disabled on boot.\n", service); + else + fprintf(stdout, "%s is not available for boot. (Service has no valid symlink in either %s or %s).\n", service, enabled_path, disabled_path); + + free(filepattern); +} + 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); + } + + 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 + errno = 0; + services = get_addon_services(addon, &servicescnt, service_filter); + if (services == NULL || *services == 0) { + if (errno != 0) + fprintf(stderr, "\nSystem error occured. (Error: %d)\n\n", errno); + else if (strcmp(errormsg, "") != 0) + fprintf(stderr, "\n%s\n\n", errormsg); + else if (service_filter != NULL) + 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); + 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) { + + errno = 0; + for(int i = 0; i < servicescnt; i++) { + if (initscript_action(services[i], action) != 0) { + r = 1; + if (errno != 0) + fprintf(stderr, "\nSystem error occured. (Error: %d)\n\n", errno); + break; + } + } + + } else if (strcmp(action, "enable") == 0 || + strcmp(action, "disable") == 0) { + + errno = 0; + for(int i = 0; i < servicescnt; i++) { + if (toggle_service(services[i], action) == 0) { + fprintf(stdout, "%sd service %s\n", action, services[i]); + } else if (errno != 0) { + r = 1; + fprintf(stderr, "\nSystem error occured. (Error: %d)\n\n", errno); + break; + } else { + r = 1; + fprintf(stderr, "\n%s\n\n", errormsg); + } + } + + } else if (strcmp(action, "boot-status") == 0) { + errno = 0; + for(int i = 0; i < servicescnt; i++) { + print_boot_status(services[i]); + if (errno != 0) { + r = 1; + fprintf(stderr, "\nSystem error occured. (Error: %d)\n\n", errno); + break; + } + } + + } else if (strcmp(action, "list-services") == 0) { + fprintf(stdout, "\nServices for addon %s:\n", addon); + for(int i = 0; i < servicescnt; i++) { + fprintf(stdout, " %s\n", services[i]); + } + fprintf(stdout, "\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 Thu Oct 6 17:59:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 6042 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 4MjzwD5YMTz3wg5 for ; Thu, 6 Oct 2022 18:09:00 +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 4Mjzw74q79z2ZB; Thu, 6 Oct 2022 18:08:55 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4Mjzw71RrLz2yw7; Thu, 6 Oct 2022 18:08:55 +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 4Mjzw544Zjz2ySQ for ; Thu, 6 Oct 2022 18:08:53 +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 4Mjzw52vSZz1Cl for ; Thu, 6 Oct 2022 18:08:53 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 8613B4C98C for ; Thu, 6 Oct 2022 20:08:52 +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 JheK1L1we4sl for ; Thu, 6 Oct 2022 20:08:50 +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 09E777353C; Thu, 6 Oct 2022 20:00:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1665079222; bh=GM0fcuh6JCsI8ywioRsQ6Ly6B7KpqMUcdyXx5ewMjoA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gr9wfthiOxOup7Au5opKh5tX1Zo99vdf8K5PVMPDQPeszhihYCEJHlLSdLRshGWmw RScJuhChxa/DaJPX9PrEsj2Fa5uClCXYDHBgZ8IUu4Q4BMZGB6WqoZJUaDdRdS9A/R RpnLRRktNIFTxbcq+mwHnqtMdqOWEEvsDW72YrflyTLdot2M9DFBIgO4mvjkMJB+SW Bq1TQTvPWwKZxc039FQcloqTw1lTEuRkkwKljIyEKqqtb6lC03vPlM4DpmG+E6ti2v IBZ8CPD9OIBG7LSE3Q8LmjOtTEJMq7h3Tw0hOf7TC4Hd59LFEk7R3IyxH9nYiwy+/2 kuLhVU764cQxg== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v2 2/5] services.cgi: Fix status/actions on services with name != addon name Date: Thu, 6 Oct 2022 19:59:55 +0200 Message-Id: <20221006175958.11036-3-robin.roevens@disroot.org> In-Reply-To: <20221006175958.11036-1-robin.roevens@disroot.org> References: <20221006175958.11036-1-robin.roevens@disroot.org> Mime-Version: 1.0 X-sicho-MailScanner-ID: 09E777353C.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1665684008.87658@BfsdQtxqHb+yhOZmcdzpkw ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1665079733; a=rsa-sha256; cv=none; b=hzgHvttvUXi40fByxS2NzWOXBrrCo9p393k1O7/nFCQoATLg16kayfnntWncLEMGeUEVG+ lJ0kjsZ7G6BIze8sgAVySn+6iTprWY2FsIh9nRSvHvSC7Bp2SIKJTdUsX/HMmY6dR8Rlpm GdSzKwsgeIb4+T6zOC8dOX6vXWokUw5lE57SEygAMbRSKIU9nSDo582lacOW5Sj/ZtMnAx hEBsA0X10BLm0UWpJE1qjttZV8D0wU3KEtaBXPHkI64FSBvibFw2u6DVkzFR9FkDGaBH2N w12uKYGwCkF+Y0arB9zEMNxrg7rTYCc38tJegZRInwB8TAo0AH9vDoSDpAf7tA== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=gr9wfthi; 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=1665079733; 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=Z06pDpIGAZQNf9jpk9SyCHjFhCOqrLPym7t3SbPl0C1wo8GAkyaW9zR4dHeaPxGGBbUGTt DU8kuYrXW9pTYLqrgUNimuBe5WGc16Ek31kOpz4AVbDYXI9RJboAKIr2HQ0AHJaasaKp+n WX+4i0BBXqeMoIhWCZ+6zAAnpn5kjyVj2pRJzt2jV/sGzhAj41NZE+oQ4q2OrcZioPAgLO JqO/3nmsMGVkLKvdGJE8KHE0kJfzXx/ZZCDWYjqB2kwvLYnFsSvBWOONT4c3vzQfA2JWHM lxlML4r00nfs/tKm1BJAx52ZVcRch6oT/YGTXonPxnmLgfNbwYVZ4ObL4IYSew== Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=gr9wfthi; 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.10)[asn: 50673(-0.31), country: NL(-0.01), ip: 178.21.23.139(-0.78)]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-1.00)[-0.996]; DKIM_REPUTATION(-0.79)[-0.79182035360089]; SPF_REPUTATION_HAM(-0.68)[-0.68195333597372]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; MV_CASE(0.50)[]; R_DKIM_ALLOW(0.26)[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: 4Mjzw52vSZz1Cl 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 --- 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 Thu Oct 6 17:59: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: 6045 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 4MjzwJ0b80z3wg5 for ; Thu, 6 Oct 2022 18:09:04 +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 4MjzwB3nP7z1Pk; Thu, 6 Oct 2022 18:08:58 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4MjzwB3GhKz2yWP; Thu, 6 Oct 2022 18:08:58 +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 4Mjzw90ZN0z2xhl for ; Thu, 6 Oct 2022 18:08:57 +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 4Mjzw746b1z2Yw for ; Thu, 6 Oct 2022 18:08:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 160CA4CB1A for ; Thu, 6 Oct 2022 20:08:55 +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 lqz8j6i5jhQo for ; Thu, 6 Oct 2022 20:08:54 +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 0DD637353F; Thu, 6 Oct 2022 20:00:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1665079223; bh=vbDvSVGhgCO6+RtYlm/w2uMpg29aUcrnpQFLZJTdVho=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BtedIHBInE09UETl3VdQ/ISKf6FfDsCeEhx6rxLjbR9RQoTSbSj0AZTtQU6aiQTfI e1+E2BW0dLnKkpiuOq6ueNJBGJMNzVuSYFzJX9WUuf91twsXSEt0ar+JoUFNQzMPz1 pzzHp82/79WbuLltwNOQf/45RCK6qFVizFd/gEWnpXCto1JEkPNJb/o8t6pz9AduQK 9bhIVpJYueS2tLKxYf4wVMSJohw1Om6EM0+UHc5Bv+/v5c1uzMciTI7d6hjN8nf0nW TnNIuNEyybvZPW9RpnQOx2cqeMXA2uBvTzyN8JtSSg5qRbBLd/q/jQdUt1EjyUGBgM sRqTWWFvJo15g== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v2 3/5] services.cgi: minor cosmetics Date: Thu, 6 Oct 2022 19:59:56 +0200 Message-Id: <20221006175958.11036-4-robin.roevens@disroot.org> In-Reply-To: <20221006175958.11036-1-robin.roevens@disroot.org> References: <20221006175958.11036-1-robin.roevens@disroot.org> Mime-Version: 1.0 X-sicho-MailScanner-ID: 0DD637353F.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1665684008.80866@o14oBPoKcM59OZdWgqsZSA ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1665079735; a=rsa-sha256; cv=none; b=EdrsD8p+QYh52DrV890NU6tg9IQKADmqDC/a7ompAIqP4Ak3K8C3/Rj9OR4+qb3C3xFZvy yqRZv/BWYWx5YUTrzq82kKbKAYr3P3z48bnS36zf+kTienKup0Gh8tEowoIfm24VQseFYW zuraPsIbtIaZ/rp/uSYbjss5mPDGgstzTtrqSYPEluRQGtCeHX/NYhIHSx5ZmOJGAKLEac Kg2bMuPe43t/Joe5tN9L7Qj3uMP5GStYyrIOKMv+5lY4RleJZMeQgZJUbvB2e2wDva4J/N YiCibOulRfVem1cVMhciff9SYP4yZhaDUoW7mvwifVSwuLzBFCdLgS7mGeBeUw== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=BtedIHBI; 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=1665079735; 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=ME4GNtLt42V72PtRr8ItwnEvBpjtTPKcwZKCzKa5DBbpJdfUMY2Eosl5ImZ2dR2hxqz+3e 8xujb7vt6ZT8MPIuR1BYbdwSJx05Cs2w+ojfiYh6WpBX2aiPchpgx/G/+ZhnHcCfQzeKJY K7soqUY9KcwV+zFbI65X34sYwJuvo2F2as5dUihHp+UGZux+EO1Bxr1cxHe53J188zfTao 4gMVAIO2czEzUKmKrBmR8hfbiBBpg9i5BhfiVNLdvXIKmVlO+Cy7mCwkU+vhT661AAhbny aAsl6xd2DbXjSCOynqHdHJD/no0QMprLoOIC1iYzLyHkSzjqBEgAs8VnZjMmTg== Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=BtedIHBI; 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 [-7.22 / 11.00]; REPLY(-4.00)[]; BAYES_HAM(-1.10)[88.24%]; IP_REPUTATION_HAM(-1.10)[asn: 50673(-0.31), country: NL(-0.01), ip: 178.21.23.139(-0.78)]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-1.00)[-1.000]; DKIM_REPUTATION(-0.79)[-0.79182037427657]; SPF_REPUTATION_HAM(-0.68)[-0.68195341966138]; R_MISSING_CHARSET(0.50)[]; MV_CASE(0.50)[]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; R_DKIM_ALLOW(0.26)[disroot.org:s=mail]; R_SPF_ALLOW(-0.20)[+a:c]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; FROM_HAS_DN(0.00)[]; ARC_NA(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)[]; ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1]; RCVD_COUNT_THREE(0.00)[4]; 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: 4Mjzw746b1z2Yw 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: Bernhard Bitsch --- 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 Thu Oct 6 17:59: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: 6043 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 4MjzwF212Wz3wgN for ; Thu, 6 Oct 2022 18:09:01 +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 4Mjzw80DXSz2Zk; Thu, 6 Oct 2022 18:08:55 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4Mjzw728Qhz300b; Thu, 6 Oct 2022 18:08:55 +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 4Mjzw62mNgz2yfc for ; Thu, 6 Oct 2022 18:08:54 +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 4Mjzw61sTsz1GW for ; Thu, 6 Oct 2022 18:08:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id E02BF4C98C for ; Thu, 6 Oct 2022 20:08:53 +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 irrfPcoiReES for ; Thu, 6 Oct 2022 20:08:52 +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 1029D73542; Thu, 6 Oct 2022 20:00:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1665079223; bh=yyr9r7oQWZjPJ0qf+VAreyrxpn9yuyVhSrPvpR1uBpw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=T00n/VlFPpl7AWY8vwNdEWtoyS5R0dia+6+VhZxvuz1GPVW7gZ6BUEIPiCx5Qyo+4 WGL3NjacxJA/Oe8Zpl2nDGgxw8KWmC+4QjBkgAExjGnekeYbCOFkZkDfcmnlfNmEkB xG++Q+5hAcMRVloGtZF577megZ1K3ssJ1S00uVPvnL5Qhi1GgMcJMuaeAYk7hYBpLZ gne9JdBR3Dj5DJi8p1PPsy9n9BoivBLPORY6bxs1bsM4ide8f/NjCtS28VuOb1ady9 SMnQD6JYe/R7AH73IK1MdB/+xtr9X+PshAPbk68ZZeWGe/gPzqvB+vZErlMZM8pR3p UunlyOTfroyTQ== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v2 4/5] services.cgi: add restart action and restrict action usage Date: Thu, 6 Oct 2022 19:59:57 +0200 Message-Id: <20221006175958.11036-5-robin.roevens@disroot.org> In-Reply-To: <20221006175958.11036-1-robin.roevens@disroot.org> References: <20221006175958.11036-1-robin.roevens@disroot.org> Mime-Version: 1.0 X-sicho-MailScanner-ID: 1029D73542.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1665684008.85393@DBdhnaL2cYYp0pxskZM8Hg ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1665079734; a=rsa-sha256; cv=none; b=IKNMtt+1IWjqHQHxH+KDfpOi56fCAw01aGnjD27ObJNZUsnp2h9FmoEeX0lpNpYwrF7aVw m2SAmAMfPAgPDvjGcs/lYYsC8aM6n4rpaSp7b8MjAOWKf5XFr0d+3XYgXtPQ6HXR2R1b7Z ejHXIdJE8bI8w8FfzGUFk9nT6buZE5e54k9QXe1/5dP2aH0a8NdGTmPMc1GPQU5PJTGYjO BVGVa5Ua/JBuIIxqLEf6serVf4lvxMx7CK41XYzxtchy3jwAtODJOEXIL0vrY7qXDXCfac HGC7Cts+1+qdVlyTDE8GDVkFUMxKo99PnUfxVyYUP2BGsXbHp1qtTIfYpQ6lFQ== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b="T00n/VlF"; 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=1665079734; 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=n7QxEP8WQZ2Thm6s2NhCmayT8/Ewwy/ohW6SoFZoVevJPbDmbz6pMnXWeI/e7gP07T9PjY qDeUahutgjtJ+DyRyrc1fItMPE3fggymS60gA1Wkn9gAZH4Hq6H0iq5fiTQT6ALJtx7rns x1Wn4uzbJuwIrYf8AqD4fL58D0k5xjlxfPkJzOtkO4Oj40GJYPCvpdyxbO9v9GeZTT8d4z AWWqxmVnpCVUNWO+igCMBbkUXxyaeUPxu7x0L2EI9hiS46AI2t9+BiqgUqB/Z49si2fVNs 8BDKxvcB82jmcdWWDYK4AmUVoZmk6GYHnxMR9Bn84w7GU7WHs+xMdPJHx9npqQ== Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b="T00n/VlF"; 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.82 / 11.00]; BAYES_HAM(-3.00)[99.99%]; IP_REPUTATION_HAM(-1.10)[asn: 50673(-0.31), country: NL(-0.01), ip: 178.21.23.139(-0.78)]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-1.00)[-0.999]; DKIM_REPUTATION(-0.79)[-0.79182035360089]; SPF_REPUTATION_HAM(-0.68)[-0.68195333597372]; MV_CASE(0.50)[]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(0.26)[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: 4Mjzw61sTsz1GW 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 --- 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 Thu Oct 6 17:59:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Roevens X-Patchwork-Id: 6041 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 4MjzwB70Tbz3wg5 for ; Thu, 6 Oct 2022 18:08:58 +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 4Mjzw725yrz1WS; Thu, 6 Oct 2022 18:08:55 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4Mjzw708Nzz2yp1; Thu, 6 Oct 2022 18:08:55 +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 4Mjzw51NVKz2xR4 for ; Thu, 6 Oct 2022 18:08:53 +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 4Mjzw42X7Wz1GW for ; Thu, 6 Oct 2022 18:08:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 099954CA87 for ; Thu, 6 Oct 2022 20:08:52 +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 2nEJoH609Q4E for ; Thu, 6 Oct 2022 20:08:51 +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 1D7A473545; Thu, 6 Oct 2022 20:00:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1665079223; bh=dfD7zCVtF77vM74ZurVdNigaK99kVMjR5o/weXTB8fg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ajKHICakM9NK7gaRzuD2bFK5gRO4qyWFHckIv1EXd9+Ka1KMq5WUbl6eqCs0JRbqV cureGZkI92EaqGDCnFc2mUv2Pi+8BTT9j+7treMasGvely0o3Oyh9BTr02YHOPby8h KGeggYV1kic7PYQDn832QtugBcYqBRRVhhg+2n1BXDoBF3YrBtBjtbQqxlXoyqcef5 e5shJ74v8keb/C/wJ8JniKte7U/j1pVF0UJUrLuEZHgKrmiB4VDrMkhZ40P7HsyBYn 6YSS9ippM6hSYtJdMWWsYkO+pa1BpnFHP9biOCJj5m3qrJmfWlX44/lPpvow08N5lK i/TS7zVnMhRDA== From: Robin Roevens To: development@lists.ipfire.org Subject: [PATCH v2 5/5] services.cgi: add link to addon config if ui exists for it Date: Thu, 6 Oct 2022 19:59:58 +0200 Message-Id: <20221006175958.11036-6-robin.roevens@disroot.org> In-Reply-To: <20221006175958.11036-1-robin.roevens@disroot.org> References: <20221006175958.11036-1-robin.roevens@disroot.org> Mime-Version: 1.0 X-sicho-MailScanner-ID: 1D7A473545.A8A80 X-sicho-MailScanner: Found to be clean X-sicho-MailScanner-From: robin.roevens@disroot.org X-sicho-MailScanner-Watermark: 1665684008.78561@PIS90UGz+x8ss15+org15w ARC-Seal: i=1; s=202003rsa; d=lists.ipfire.org; t=1665079732; a=rsa-sha256; cv=none; b=dZbeejLWEQxV/+yAVr8cclS+3QTjPqUZhdOi5pm7DUCBjWGjeud6t+8nKaZqbCeOfQ0UyO bKSJkDRsn47Zt5yoOsk3Y9Mk9/CUqBp9cDXQtepb0Sof0K5mhhLJpNxLLqe8WVge13Uoge fcujyH5CghuIcCYVesEV/fxiy5SCL6CPV1X8jN39id1uKysDF3q7vJWYFwKtd3Tc7dkisl CdqV+Gzls7BaHY02wcvSFY71kXA+6Tv/04/BKx4g/K8LKjgcPg/p/PY5MCwQrn/njNbBdU hNNxVUo4EcCagA9wQxVv7fld5iniIespWSBQZT0I5Ve+aIzgY2ilWakhAoRXNA== ARC-Authentication-Results: i=1; mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=ajKHICak; 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=1665079732; 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=dmf24g3N3joim91QygBSs3fFmkeIpMulPzi8MwJxOx2i8+kZL08ymrRMx2BCDQsS3ZEIcx 6hm90Q0mQhP9DFW3+MN+2TUILSBqgJ661/Yvn+lcECkXFk4ABQbKd0VLS8xCydDVsCDVg/ 9f0UkddAw5RdLGX+gd927K4Km9MaOpx47XylWTwRsXCC4RyFo1BOyUjh0cI0eGfu1Q8VLa NhKFmi6kL30nXCbfavUIycTHigcYmGEydxuu5gOscz5jLR29vxN4iVGY1Y59x7E88cBAMn EHrUawBwbbqLGHCNcCq1BTEs7Bvpk5L6RQvCZ6PqanclFBsknjKSOUDmzvffcg== Authentication-Results: mail01.ipfire.org; dkim=pass header.d=disroot.org header.s=mail header.b=ajKHICak; 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(-2.99)[99.96%]; IP_REPUTATION_HAM(-1.10)[asn: 50673(-0.31), country: NL(-0.01), ip: 178.21.23.139(-0.78)]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM(-1.00)[-1.000]; DKIM_REPUTATION(-0.79)[-0.78955115065407]; SPF_REPUTATION_HAM(-0.68)[-0.67900099170085]; DMARC_POLICY_ALLOW(-0.50)[disroot.org,quarantine]; R_MISSING_CHARSET(0.50)[]; MV_CASE(0.50)[]; R_DKIM_ALLOW(0.26)[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: 4Mjzw42X7Wz1GW 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: Bernhard Bitsch --- 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