From patchwork Wed Feb 21 08:22:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1901888 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=JogFI5lQ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::53a; helo=mail-ed1-x53a.google.com; envelope-from=swupdate+bncbaabbqpf22xamgqehl6i7aq@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-ed1-x53a.google.com (mail-ed1-x53a.google.com [IPv6:2a00:1450:4864:20::53a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tfq5M05lnz23d4 for ; Wed, 21 Feb 2024 19:22:30 +1100 (AEDT) Received: by mail-ed1-x53a.google.com with SMTP id 4fb4d7f45d1cf-5640681bc11sf2772827a12.2 for ; Wed, 21 Feb 2024 00:22:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708503747; cv=pass; d=google.com; s=arc-20160816; b=MerH0Ify/HCDD9xyVFN34x7XUPONFGKy0lE3UBGx4Ktxeud+dLNhsJtkhQXBuUASx7 VRd1F7pjngijbT2YjDNiqNKLjwctnmYHRDOhdG6mLFfOcdHGL2Lu4BHXE+2lylKsG8XY KpH2XBVeB/pH8A17GG5wniYDd2gvzZu0rXIfXWulmWnENy1zzU4juZbKT8jVR5hErCH5 Vc+RiDRfX6KF08THRwYs6FvmqxR44cBXXijvmOxyMhUR1qTRmAPn7YIFqcLx6AN41r43 JPqK/s4ov+mOC530/0+2wK0zHfCu3HB1cZxQ4A077QdHx3bDgAmy5jtrk6LVDCjIlenC VUDg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=wWEzEYhBP9NlK0L+Ide0mW6Ad6R8IrCHI88E/XOA+Vw=; fh=wm3wGdgSyShPTWuQFANL7TxLJYbI9U8+GZxFCehkarE=; b=rGIif7W9XfD2qhXw7sxcILBuA9qN1iTERn5kLy0U0mfBVPO+1mFKsbkGAduimjRLJS 3BPGpVoo+1SwM4jiSHicsLIxcj9xhOiBq5eBZuKroFlhYj/A2C2/siPX0DIexqNe18b4 dCkLXb4MPCvu3fdZ/H67BC7WbASWEdCxk4okRDGXK+wQYMJy3wWmReSlxdAwpV5HI1K+ fFhGdENAUVdT5+I5K6sRmcb5Uwa6/RCiafz97cDwKctYlzHW11VHH8NJM2w31iXHEBHL 6q3UQzSAaS9NAPynvGr5bCzUYeEL796+v5muuN1VwJ66YdtDJxDBLmctoh20J7M5BjY1 ha4A==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b="R/3XsAie"; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.134 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1708503747; x=1709108547; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=wWEzEYhBP9NlK0L+Ide0mW6Ad6R8IrCHI88E/XOA+Vw=; b=JogFI5lQDjDeAjQYr87VKLWSIQwVQMdQyGucz09CAzTK88iyN0PSN/XIje0jJ6HFCL 68GFCeemFbNi+Tj/8WTSnL345K5gYZXG3RdMBZ64KgRMDHBJyPbnJZoktF4IVrFT53hq Ss+mqLy6Hpla5MqFH9HeTB/iXhD19X5Eroc8gG17q+fcDer/gRJEa7/HGRECo5NgKMcC IDUyltlvgC6TBEOcxsjUV38J0wcLyzT6pmmBS+cIG4XDX640K2kkp1ZPc83EyNO56XNU jwnFPgAlj/FLo9kHkM8BA/0D7drpP3ddMjpVQ42RitPIaSL2RFmMi3IcbAf11BSmxECf zl/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708503747; x=1709108547; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=wWEzEYhBP9NlK0L+Ide0mW6Ad6R8IrCHI88E/XOA+Vw=; b=SdVEE3EtKVTnduxHlrM6iW4vK2TvKn2+yNVT0LVH/WAaYfBsxE+Iy+izLJbC+WmhWn S/Eqk8uJY4Ft12O3VvZ2tqzRNFm5o+ZzZV7fVuKnwmHBhNV7zXKppDvhNA00m5qmnO56 J+fjNZ1Z2CzctgjKrlVjOJ0vAWD2/WUivC5NwgyZ0JQJjdKFaZIpuiy4WjaAM6IloJhz 1i0exvQROfrISCvuIC3RKuhLFIOWXdLXP0vGDA018cdK2leJ8Mn3saFO8DilN7mmMaQm BX+7BSfaVIaEQYm1613+TgJfAtCkIN7lu3vRwak4FfwfwYmLVQCeg9NKCJOOytlmwB/E 2kkw== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCVx4Q1lo2I0SCV6w0SmfHIajXracT2d3PuznrbSlnStp2Tu7YGCqL+JwmwhivapRoGalHqWY4BzeSVJXtmpOKQ9d0DCSaQIRD0yXavb6g== X-Gm-Message-State: AOJu0YyNJ15BNySpU6nwW/rIYwzkX8YO6g2lXFK8FxpqJpEkXyDnRIYc EnFEqxxw2WtClrgJYuCwdSOtMgfc7yF6DLJsiC8xMl+n5aNmPJog X-Google-Smtp-Source: AGHT+IEGvb1V/44J7ReJ8SdpBgZYVbvSZbCrCRmhDlumzJCd4+nc5aDjV5e8NEW0K7aAccKu1oia5w== X-Received: by 2002:a05:6402:134d:b0:564:a4e9:3683 with SMTP id y13-20020a056402134d00b00564a4e93683mr6105685edw.16.1708503746213; Wed, 21 Feb 2024 00:22:26 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6402:4018:b0:562:c01:57f9 with SMTP id d24-20020a056402401800b005620c0157f9ls576819eda.1.-pod-prod-01-eu; Wed, 21 Feb 2024 00:22:24 -0800 (PST) X-Received: by 2002:aa7:db53:0:b0:565:dff:cd4d with SMTP id n19-20020aa7db53000000b005650dffcd4dmr181354edt.13.1708503744413; Wed, 21 Feb 2024 00:22:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708503744; cv=none; d=google.com; s=arc-20160816; b=aU6Dir2cieHrVsXBYZryYU1+ywMM7XTbvZ++rjH2OzI4QkAhRu79u5AMHd3puPQ9N7 5RbjBptFVNVSSWksDslVHCAYoHoEvkv8Mo/JAVoEVOevFJw6ao14z0Kh0y5PVrOimvoE v1Z+Cfodj4t3JSkcJsuKTIeti5aLhIcLiYG245WSup4kYv+94SBD+zVK60eI1vtnxXVg D/9OCytgNuuQ2/uyla2k/wmCrUr/EHCJeObBUk6AxBC3qxdEr+zUWYFaET0Ghwo77XCQ vrjkcAZczPLLzAD385LfJT6BdfpTOMo0fbkp27jXKGUMJgvLa7uuQT6N+SNcEe3YQZqD PgmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=qGHtzsUmj5bw/HTTeGC+H46S8D3k6rtbw9/35TkPi00=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=nIq8yG/doKTpyA7vIK1wohsrl9oHPBpqpxJYwL88bak5llVh1c5dnfNRxqqjB84I6R +nnJkH+Z51sYgilfDLSLTrzwAtuYL/t1bkLHGneDLSHCDRKpaqcvKumHMRi+LF/wtxwb +63ULznWU4MuySQiAY3Ih9InK743UZ9puSS6Kf1plpLg5F1jT6lm/+eZ64wgZlrEBcTO 9a76nX+zVE3ghej+TiR5RgST88sU1/9Da1ghbLZqxaM42+YFMvW8ZFDUy66t8DHp47lF MYSr2j+ulP5rzpH+FTXO+h/vTDrujWv7DePMnl6oJ2lodnGzDEJrvQ9FTjkU3tiqxJKK guyw==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b="R/3XsAie"; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.134 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.126.134]) by gmr-mx.google.com with ESMTPS id x2-20020a50d602000000b00564af3e693fsi312796edi.5.2024.02.21.00.22.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 00:22:24 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.134 as permitted sender) client-ip=212.227.126.134; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue011 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MoOMq-1r9vXz3wrI-00os02; Wed, 21 Feb 2024 09:22:23 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 01/13] Lua: prepare to extend Lua lifetime Date: Wed, 21 Feb 2024 09:22:09 +0100 Message-Id: <20240221082221.11997-2-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240221082221.11997-1-stefano.babic@swupdate.org> References: <20240221082221.11997-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:yeR8HTZfXZPZB7743lk+cL94olCLq+WHmOZglm9QjyyUt9T9cOq sOb+ebwenKaMVggPmv6BgaiRRwGu9TLo7hbpW6ReFNUeltDSkNnafPpBidxNoc5crZzwvJC JAaY5Ojei1xcc0R7comFi8x6WmUa/cqEqQv6eni5PLn8NSs1+zM63MGh9JKzQjTkFrdpiQa m2ws1SQD3bMJteoD6hYRA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:QPqUIUtWqCY=;se8axlseEphiNpiO12JL8C8Lxf+ N3/PGxDUU+zBr9UnM9dWU73IjUF6kXExSoSr4PBgebjV8RW8nqCtXf5zu+UNsAPlMbNv+UmMI bCmzy0ucAkW049iqNZDvpedozFf6cK2w8g5TO75sjXlyWEOqKmzBdXMXNZteWkVSnesn9KSLD VaBr1D1ENb6gLkQnSZ2+7PPgg8sRt14pDHLNJo4pv1/nyHgKBf1+6RMSiU8LVUWeuK9uC5KZR YQiqZaFg2EJmHQIfjdazNd7WQcS2tOjPA5fEJHEUDtL7Eq+NmxvSViV4fv9guWk40Ei8CgCzT 6hKhMeg871JXhKzKGb90IkHUJn2SyYCCxyijn+t85CmczFtFstD4VQBdd6XvoxpyVYdCEyjJ2 UcJnbOQPQgZZxH5+oMM87KL0YQ9Xfw5xW6PPFszqkEyV2efDJHRCb7MQ9ubCwE50+BXU9SQD/ 3dfdRpsOR2sWPWgjBsCVT6Jo4vUB2oER1Rja/neSKVl7TUR3ylTx3mN29spcOUw3iN+u9wmBZ uGgtbDvtrPYvd66kXGjf6UiB7b3LQrKNGdEpUrM3t+qe14pI+QcAPoh5drouV5EEmhZPCy9Ao 6iodoilfmVQ8ms9Dwa0lpAyuRg3/ApnlPIuTOqAlVLFC9Um9iWCz+u7vtPDQZ+CXF8IGICgra xUCLxM4JPvEFyhOh4CViU/WdNd9N5E3uu27OTsCgOedG1NZ1d7d7qiHYMfre09gZzcUUNN1cd UgoBTrPxC94noRp8eADWhRwd9j7wfNfm2ETX740BqBbjNxeR18FSQo= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b="R/3XsAie"; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.134 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , A Lua context is created and destroyed for each Lua scriptthat should run. This isolates each script, but it does not allow that a later script can benefit and load a function previously defined. It was decided that so high isolation is not necessary - instead of having a context for each script, create a Lua context for each installation request. The Lua context is then initialized when sw-description is parsed and removed when the installation has finished, independently from the state. Signed-off-by: Stefano Babic --- core/installer.c | 8 ++++++++ corelib/lua_interface.c | 14 +++++++++----- include/lua_util.h | 12 +++++++----- include/swupdate.h | 1 + parser/parser.c | 16 +++++++++++----- 5 files changed, 36 insertions(+), 15 deletions(-) -- 2.34.1 diff --git a/core/installer.c b/core/installer.c index 20b5b51e..2b85a6e7 100644 --- a/core/installer.c +++ b/core/installer.c @@ -33,6 +33,7 @@ #include "progress.h" #include "pctl.h" #include "swupdate_vars.h" +#include "lua_util.h" /* * function returns: @@ -478,6 +479,13 @@ void cleanup_files(struct swupdate_cfg *software) { dict_drop_db(&software->bootloader); dict_drop_db(&software->vars); + /* + * Drop Lua State if instantiated + */ + if (software->lua_state) { + lua_exit(software->lua_state); + software->lua_state = NULL; + } if (asprintf(&fn, "%s%s", TMPDIR, BOOT_SCRIPT_SUFFIX) != ENOMEM_ASPRINTF) { remove_sw_file(fn); free(fn); diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index 2bd8e6cf..33be8d3b 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -1517,7 +1517,7 @@ int lua_handlers_init(void) return ret; } -lua_State *lua_parser_init(const char *buf, struct dict *bootenv) +lua_State *lua_init(struct dict *bootenv) { lua_State *L = luaL_newstate(); /* opens Lua */ @@ -1533,14 +1533,18 @@ lua_State *lua_parser_init(const char *buf, struct dict *bootenv) luaL_setfuncs(L, l_swupdate_bootenv, 1); lua_pop(L, 1); /* remove unused copy left on stack */ + return L; +} + +int lua_load_buffer(lua_State *L, const char *buf) +{ if (luaL_loadstring(L, buf) || lua_pcall(L, 0, 0, 0)) { LUAstackDump(L); - ERROR("ERROR preparing Lua embedded script in parser"); - lua_close(L); - return NULL; + ERROR("ERROR loading Lua code"); + return 1; } - return L; + return 0; } int lua_parser_fn(lua_State *L, const char *fcn, struct img_type *img) diff --git a/include/lua_util.h b/include/lua_util.h index 1d00bf82..5f5e67a7 100644 --- a/include/lua_util.h +++ b/include/lua_util.h @@ -21,7 +21,8 @@ typedef enum { void LUAstackDump (lua_State *L); int run_lua_script(const char *script, const char *function, char *parms); -lua_State *lua_parser_init(const char *buf, struct dict *bootenv); +lua_State *lua_init(struct dict *bootenv); +int lua_load_buffer(lua_State *L, const char *buf); int lua_parser_fn(lua_State *L, const char *fcn, struct img_type *img); int lua_handlers_init(void); @@ -34,7 +35,7 @@ int lua_notify_progress(lua_State *L); int lua_get_swupdate_version(lua_State *L); -#define lua_parser_exit(L) lua_close((lua_State *)L) +#define lua_exit(L) lua_close((lua_State *)L) #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM == 501 #define LUA_OK 0 @@ -81,9 +82,10 @@ void luaL_pushresult(luaL_Buffer_52 *B); #else #define lua_State void -#define lua_parser_exit(L) -static inline lua_State *lua_parser_init(const char __attribute__ ((__unused__)) *buf, - struct dict __attribute__ ((__unused__)) *bootenv) { return NULL;} +#define lua_exit(L) +static inline lua_State *lua_init(struct dict __attribute__ ((__unused__)) *bootenv) { return NULL;} +static inline int lua_load_buffer(lua_State __attribute__ ((__unused__)) *L, + const char __attribute__ ((__unused__)) *buf) {return 1;} static inline int lua_parser_fn(lua_State __attribute__ ((__unused__)) *L, const char __attribute__ ((__unused__)) *fcn, struct img_type __attribute__ ((__unused__)) *img) { return -1; } diff --git a/include/swupdate.h b/include/swupdate.h index 883bad51..e18de8d3 100644 --- a/include/swupdate.h +++ b/include/swupdate.h @@ -59,6 +59,7 @@ struct swupdate_cfg { char mtdblacklist[SWUPDATE_GENERAL_STRING_SIZE]; char forced_signer_name[SWUPDATE_GENERAL_STRING_SIZE]; char namespace_for_vars[SWUPDATE_GENERAL_STRING_SIZE]; + void *lua_state; bool syslog_enabled; bool no_downgrading; bool no_reinstalling; diff --git a/parser/parser.c b/parser/parser.c index 1d9a38db..3944de64 100644 --- a/parser/parser.c +++ b/parser/parser.c @@ -1022,15 +1022,24 @@ static int parser(parsertype p, void *cfg, struct swupdate_cfg *swcfg) swcfg->embscript = get_field_string(p, scriptnode, NULL); } + L = lua_init(&swcfg->bootloader); + if (swcfg->embscript) { + if (!L) { + ERROR("Required embedded script but no Lua not available"); + return -1; + } if (loglevel >= DEBUGLEVEL) TRACE("Found Lua Software:\n%s", swcfg->embscript); - L = lua_parser_init(swcfg->embscript, &swcfg->bootloader); - if (!L) { + if (lua_load_buffer(L, swcfg->embscript)) { ERROR("Required embedded script that cannot be loaded"); + lua_close(L); return -1; } } + + swcfg->lua_state = L; + if (get_hw_revision(&swcfg->hw) < 0) { TRACE("Hardware compatibility not found"); } @@ -1049,9 +1058,6 @@ static int parser(parsertype p, void *cfg, struct swupdate_cfg *swcfg) */ parse_partitions(p, cfg, swcfg, L); - if (L) - lua_parser_exit(L); - if (LIST_EMPTY(&swcfg->images) && LIST_EMPTY(&swcfg->scripts) && LIST_EMPTY(&swcfg->bootloader)) { From patchwork Wed Feb 21 08:22:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1901898 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=VgfydtnG; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::240; helo=mail-lj1-x240.google.com; envelope-from=swupdate+bncbaabbqxf22xamgqewpny2jy@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lj1-x240.google.com (mail-lj1-x240.google.com [IPv6:2a00:1450:4864:20::240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tfq5M6hmfz23l1 for ; Wed, 21 Feb 2024 19:22:31 +1100 (AEDT) Received: by mail-lj1-x240.google.com with SMTP id 38308e7fff4ca-2d24466f7e3sf2932961fa.2 for ; Wed, 21 Feb 2024 00:22:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708503748; cv=pass; d=google.com; s=arc-20160816; b=w6Jyau8ECJu3I5WclTOMtFnwOB1e0velHz9Sp+iHBC/3AdQ2yWsDy/CWOdyFXl7YRi 3VDnmrkmelYBVt49leGFabm88ERDabuqDV8x8ONoZxApbX5/ggnTfT90pvRJO8Dl5hQp xJMqtEGDd0pnmQUjytSLTbpyn0eIZoXzlzcfbd2fdWiaKLPBrAaRAOeDGNhXAB8AGtcs zpCydvpUcpShj79JFlb7qR+l075kJzW+Bmkxe/RuEQAK2+9hifLDlXxSKazIznh8Q7l9 O+6eCal2m1FhREDtr2UDPJquisTTOG4iCrcHdywNgo2r0N7+UIDI7gjCeJCr9vcWSkqw eNyA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=NbqzaMjynr9UFZHqSaUNRraGLqPrwOsKf7uCrV1fJ90=; fh=SS7vhwH3umT5xhgpnVcpPEx0oA4IQdL+Y3wlPvzWl3s=; b=mlycYlvIPXIgTpqx+hhkIuq7lHH4zNBanFkqNww8GL7g67KXckfqlHOH7QWzTD8BUL iozaS/9HCFY0UCL0TPuTS2j/4eaCIUNJFLOZcYQ46yGwjt45r4YJPp/tI/4KwunS+dm9 4Ty5oSAUxcqT0q4wL0AdKKV/HjCXhw7Opvg8+x05TBq84EbdKNywKNS3+LuUP3uSc40i IkxjWWIJJhN8dLJ7iTQCBv9lkydn+yKo48k+UQATP4Maw2b4IcJcB/MGkR6pPNt/YH7n lmYTpfwI0MGX2U/cWc7syefHPeNdBTp9FAqfV5vbzbqFtofUhaJZYeEE4wz+6VIGBBzI 0TjA==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=ZOuG3dXA; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.134 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1708503748; x=1709108548; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=NbqzaMjynr9UFZHqSaUNRraGLqPrwOsKf7uCrV1fJ90=; b=VgfydtnGihTMIdNa1OqPj4vuxLOYBAeCiuJatoSsxrrJWScHOVOhF0CP4gg/a13a2d IcsQt/gfM43HntwXIgQ7Cb4c1bWdP7lnDgw5IqCNlBM4xZTPAt5qudhCy/f1DdyKzIMa PtXcMvA2HYcCjP5JsmQP3H2djxHZHhLUom1JEjWykQLLFhF+7Q44t6SsLlfT6lRCpv2D X0RJkjc2czWppufi5jw5JFOnxe58LkVXm987UxjB1ITRLw+S1l/rkRCV2YMwh7n/HZpy z+6WORetnFtawS0jP9PsrwOGFnVblm9TYCWpGqeThf/UwO+fxqht7GGtFjSZAoJBZb3V eg5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708503748; x=1709108548; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=NbqzaMjynr9UFZHqSaUNRraGLqPrwOsKf7uCrV1fJ90=; b=Fj6G4IObmvI7kg9JH7CnJxAp3B/ieBnndqc6lLpnoq8pX5GVbBH0U49e6HuyEqe69S ldKH32IVlFFZAjtk/91sqT7VAEZa0+wwWlpscredSEoRFzDMm1FStoID1R2vyeqNj9Op pBqSFnrgpoAVYCltcJSb18vDviIwx9gMJ03dVSv7foJLxfGs+y7fXk1kuDbaYiS4yGs0 2lh2FC58UYxBZ/1SCLtxO9nh9QF2mwTEmreK5c+AgNhr/wJ/hpQWqg524cdzGt7dq5T5 cg56UeAR6hgwvgLBhB9VGTM/1MIAjMXh0hY9yiiZIWwhK5vYOg+y11Y0NX66CBF8NLf+ sRcg== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCVe6FD/D/uMXDv8JSf3sV46iGXUL8gZo35QLuSemAE55/sAxWerML9qYSwBb+DIP9PXIUmzQtKENhRrxZmVCCmelbDYp5W9jkv2GTQThg== X-Gm-Message-State: AOJu0YzXj94dy5x9XNvkfm8qRMKgeFGoaM7wlHqZjwLCz22y/SMkIS/O ngOZjTkQPsHsCpnF0c7HiwXHeOh+UHjwe+QvaXNEiH7FijG6H0ii X-Google-Smtp-Source: AGHT+IEbNStZ+BO0TOVXTakm0BMYm5PP7TqdOytQg0gmOWPvXLWXdemt8uvOSz56bUcr4W8Pm3Rg7Q== X-Received: by 2002:a05:651c:217:b0:2d2:4054:2fab with SMTP id y23-20020a05651c021700b002d240542fabmr4693733ljn.37.1708503747155; Wed, 21 Feb 2024 00:22:27 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a2e:a495:0:b0:2d2:47b8:fc28 with SMTP id h21-20020a2ea495000000b002d247b8fc28ls383280lji.0.-pod-prod-05-eu; Wed, 21 Feb 2024 00:22:25 -0800 (PST) X-Received: by 2002:a05:6512:96f:b0:511:4ee3:dc1c with SMTP id v15-20020a056512096f00b005114ee3dc1cmr10573055lft.33.1708503745059; Wed, 21 Feb 2024 00:22:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708503745; cv=none; d=google.com; s=arc-20160816; b=dmVw9aYYJEyWlQ5fLVA7hW69sR0uiFUpnnEJNihchZ1ABXBzRJ2Akd0dk42LJuTTkz ISMTQqufZ+kc+4N6iStEfAdG5WPI4bw4capzbOra3cpOUqAckxNnRCzHPTzhM3MZYu58 BWH/77iLMpubV9tVIS1ZB2Sb9ATSgsBpO/M3StGPCmpksc9x3t+3Tbniw+dYhKTkhw5i 8ap+p9NTv+bjfd/UL7JcFeG0i3lra1xJQ3vWvMlt4J1Eux+zec5Hm5gVDWasSy42ZOIG TBZlpm31lOoJR0lx4RwG9xrvnR4Z5Hbz7V2E23foG9+hS+ROqKx2nsByDFh7mjCEZC4E qFcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=NDeGLSnxGUSvl3yjIHBoVNE1CZ1PPpEo4u/65E92t04=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=QeACnlaRb1PwIjZukveBby0nR1dkqfkKC5AalwQH6EScuD5mF7ktZ3xTIErAYpYlki 6CxNUG2WwyObcOA8asLMONoybc0BSaT5heAecq3tNt2EwcftFl1xcAzOjGVYqhg5pTbl 6KnAnongBerUgobyek1rQvvK+mubJIurondjzImjRDWJbffTxbYkGCyYDhuQ9/bg6JRN 89Ic4kBVMYv16ik2Jrnci9GEbC7xOz1MreS9cMSqPUT+x06uhFFZwyTAImNw0gGnX4Zq f6HzhKscZUfcLz1dD1lwEFV9KkvMpGdL3E1xubN7/NI8ozEl5ikuAoSxg2xjv2u6GBWT oJmA==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=ZOuG3dXA; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.134 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.126.134]) by gmr-mx.google.com with ESMTPS id bp15-20020a056512158f00b00511539e222esi447029lfb.5.2024.02.21.00.22.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 00:22:24 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.134 as permitted sender) client-ip=212.227.126.134; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue011 [213.165.67.97]) with ESMTPSA (Nemesis) id 1N6bTa-1qrqjG0FFW-0182kG; Wed, 21 Feb 2024 09:22:24 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 02/13] Lua: move out state initialization from run_lua_script Date: Wed, 21 Feb 2024 09:22:10 +0100 Message-Id: <20240221082221.11997-3-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240221082221.11997-1-stefano.babic@swupdate.org> References: <20240221082221.11997-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:kGLCkPuAjiBWGaSD1B+0XoYGjpNAUyYsrmnStSFWBu4HjSh1Efn Bjuc2eBGbAB9zqAn61roPTRjgq+ZWY0fqXKFrJGKQLeOspEvm20orVLCM0eSe+m/BIo2fvF bT70JkVcARkO6JTADCz6xwWb4dP7D2VD+6skoS+S6u2gvRaA6HiD14CBsYC2TBBZeIPw0iL VcPFVIrF4puSG4OT+/98g== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:oemHgrscDI0=;CGIniezQbdH2b9v0n+Di6iyASO4 mf68bR78rVBxwt44jr96nMs3IgUiJTc8AVABnTy9emiF/N9ARwSswo+rP64oTbQdCDm3vjidR CsnXNB0hEwBYP/bhPcnQ0vgdMAo27P6UgLVfw1AiLVMb/fD103h4ntJLVBX5j6iCau8DGWaeR 95pMelAgL7Rj/9d7/Iuh7nVajun6E+pJqJ4IJvDIRW/gUGJoYxVsKsnN0kjw12YlLmTLZp7Pk 50OM2lDUmj+c5oePp7W2wasC2Q81Vwi6+NuAqWV948X/JbOqgPuMTRqBS7F35WOt30RTx6Uel xzfMypjL5A+VzxigDQfl7Z0l8kpV+bkN2RmTfVAKFOvIkrEAFxAtTMPChHiN0fTNTI1i/nvB8 s+AtTLBB0j0QOurO0U2FOAgtZSjvXlihmA1HIsxrBfYHIJ5548A6wpkg66gJ87qDdeCNRQtZC iND5Yk88zoImVbMyM41bsLSCcyNZvDvPCeNafmzbgcsrERHViPV54aemk58jBd8o3llIqmoNX EK8MfA6dvvu7GopEqvdsk7kQ99rB+siEt+lfz7hx3/ql0imhPAgjhy/zQQlJymqHfMAlRopAw Cg0RDxbZXznbA4LHVYMbht+ACMpy77awD7FafcxA3qkdkIulZzKoSBGytksOOoQ8AON5t7uWj ZBvm/u37VwG3CSC360j12CcInaEJ+LruNiXAdpETFV3rgAs/uN4aZ+sQAAB7rlra5sOpWu5aU JUdYW0WEokj+j9LGEXk8veT00mZ2sXiJ/n92VcnWAc8kyO3W77w0AU= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=ZOuG3dXA; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.134 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , This is in preparation for using global state. Do not create the state in the run_lua_script(), but accepts a L state as parameter. It is duty of the caller to provide a valid state. Change accordingly the Lua script handler. Signed-off-by: Stefano Babic --- corelib/lua_interface.c | 12 +----------- handlers/lua_scripthandler.c | 14 +++++++++++--- include/lua_util.h | 2 +- 3 files changed, 13 insertions(+), 15 deletions(-) -- 2.34.1 diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index 33be8d3b..72190383 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -204,18 +204,13 @@ static void lua_report_exception(lua_State *L) } while (*s++); } -int run_lua_script(const char *script, const char *function, char *parms) +int run_lua_script(lua_State *L, const char *script, const char *function, char *parms) { int ret; const char *output; - lua_State *L = luaL_newstate(); /* opens Lua */ - luaL_openlibs(L); /* opens the standard libraries */ - luaL_requiref(L, "swupdate", luaopen_swupdate, 1 ); - if (luaL_loadfile(L, script)) { ERROR("ERROR loading %s", script); - lua_close(L); return -1; } @@ -224,13 +219,11 @@ int run_lua_script(const char *script, const char *function, char *parms) LUAstackDump(L); ERROR("ERROR preparing Lua script %s %d", script, ret); - lua_close(L); return -1; } lua_getglobal(L, function); if(!lua_isfunction(L,lua_gettop(L))) { - lua_close(L); TRACE("Script : no %s in %s script, exiting", function, script); return 0; } @@ -241,7 +234,6 @@ int run_lua_script(const char *script, const char *function, char *parms) if (lua_pcall(L, 1, 2, 0)) { LUAstackDump(L); ERROR("ERROR Calling Lua script %s", script); - lua_close(L); return -1; } @@ -257,8 +249,6 @@ int run_lua_script(const char *script, const char *function, char *parms) TRACE("Script output: %s script end", output); } - lua_close(L); - return ret; } diff --git a/handlers/lua_scripthandler.c b/handlers/lua_scripthandler.c index 509b360d..d4ac421e 100644 --- a/handlers/lua_scripthandler.c +++ b/handlers/lua_scripthandler.c @@ -29,13 +29,20 @@ static int start_lua_script(struct img_type *img, void *data) int ret; const char *fnname; struct script_handler_data *script_data; - + lua_State *L; const char* tmp = get_tmpdirscripts(); char filename[MAX_IMAGE_FNAME + strlen(tmp) + 2 + strlen(img->type_data)]; if (!data) return -1; + L = lua_init(img->bootloader); + + if (!L) { + ERROR("Lua state cannot be instantiated"); + return -1; + } + script_data = data; switch (script_data->scriptfn) { @@ -54,10 +61,11 @@ static int start_lua_script(struct img_type *img, void *data) "%s%s", tmp, img->fname); TRACE("Calling Lua %s", filename); - ret = run_lua_script(filename, fnname, img->type_data); + ret = run_lua_script(L, filename, fnname, img->type_data); - return ret; + lua_close(L); + return ret; } __attribute__((constructor)) diff --git a/include/lua_util.h b/include/lua_util.h index 5f5e67a7..ff603b5c 100644 --- a/include/lua_util.h +++ b/include/lua_util.h @@ -20,7 +20,7 @@ typedef enum { } root_dev_type; void LUAstackDump (lua_State *L); -int run_lua_script(const char *script, const char *function, char *parms); +int run_lua_script(lua_State *L, const char *script, const char *function, char *parms); lua_State *lua_init(struct dict *bootenv); int lua_load_buffer(lua_State *L, const char *buf); int lua_parser_fn(lua_State *L, const char *fcn, struct img_type *img); From patchwork Wed Feb 21 08:22:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1901892 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=IFNV52AD; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::53f; helo=mail-ed1-x53f.google.com; envelope-from=swupdate+bncbaabbqpf22xamgqehl6i7aq@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-ed1-x53f.google.com (mail-ed1-x53f.google.com [IPv6:2a00:1450:4864:20::53f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tfq5M1rx6z23hR for ; Wed, 21 Feb 2024 19:22:30 +1100 (AEDT) Received: by mail-ed1-x53f.google.com with SMTP id 4fb4d7f45d1cf-564901924f4sf1616999a12.0 for ; Wed, 21 Feb 2024 00:22:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708503747; cv=pass; d=google.com; s=arc-20160816; b=bbhfaBD5kQNsA/MVLP4ZM9Crb+6RJ/m+3pc57cxNoA3rnY7Z86QrmmyElzEKuPzXE/ I+HHaWctlPijGeoto9jtn8c+H5rAI8nsC1mKBrPaKndTvoz+zOr59E+xZPzOFYmq8C4E /v6ICffBTkAQY+l2MhZHcgjZaOK4e4hfshIfGfZEjs4R9oySaMuPElSj2W4V5VeeArXo tJRgCs57tj6A7NV+SJKVpbnlhl+JHP22UdrM26dYGHrpjGow5C+4lfBditOBPQ+D5LXL uOMNkG/hpEavLSJw3UKW3dzvyidVLg7oT3+tHCvxHb711bole20BTvotvPNNZoJg70gp ClHA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=fiXR+IrhTdNopWc0Vq1FhhnOfw5dJin/A720IaimDv0=; fh=g5VdsSTeITmfFGmzFM31+wmYi4mUj7PfLQQGHH3hJYo=; b=iDJECtekpuF3Mw7aw7YFx6dqWrP+nkJSUFkD04kO/rKuG3j1NwWIuwv3yp49//kP9l t9A5UZ34G1DrwcIPbkYpfyS9zHs17AkN5d8Ri3hR4Fz+G7uBd7mLZ49pwBydMyWZUxyJ lVtaIBqyk55oPxRvjkw3cDLd3GZOjWVZSwbwvUVy9Xo9fun8mMkRqO1VAGy6q+Y0+Lwn GYvJHUFG9F8ZeTUpqpahWHju8hRAc0CbaWEkno9NSd9RCuLzxDyqjc3URLxSJkuSBeKP z+xPgdu5DKc4TPduegTtGQ0f4Gyflxlw2Btmkz8he4JoTEl4qwAQ9eSKWFvlA8tZglxg eqLQ==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=toQB9Sd1; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.135 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1708503747; x=1709108547; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=fiXR+IrhTdNopWc0Vq1FhhnOfw5dJin/A720IaimDv0=; b=IFNV52ADVMq2bIVZYDD8JYAdxuMyg/trfFvnkUjssxpBdGIpe2/nhjSfJGptON0ZzH COBEC2XP202+7bQMZSekdJN9bmw7cEZj9xORnvaayQv+BzyABdCEv2DO8EW1ftyb16AG R9whQrWqMu+Y5uo44tmnPwxw7Lz3obLcPrLx8brSzWKc/3+xdR06tSJaQc8pIIUJuaVo qShRhOaBOycdLg0jn0QOx7LkFsZ0F4j+BzoL9b3Qtr1lNQ0Ab++2vXtGPKX0xG46krmt dZ25jafeJp2Z83J4pW7QFhSTMTT/JzHN0I2ehCVB/k99M+ln1hiJgLs8m/L/DvGU8z12 TUbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708503747; x=1709108547; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=fiXR+IrhTdNopWc0Vq1FhhnOfw5dJin/A720IaimDv0=; b=nwpaPQBnT37n7mUZkdhMZqvzq32xQ7GYm0Zine4rvARc/piI1eqularCgQuV73qGz2 G2fzWOIEUVuEBhknmBHiOw4E/X3b5p7VDx7bEqY3XPmf6ehMAUcixqDgkk7NZyI5JPVI bhG5YoY4bkYmQREUN6lHRR9eS8/itfScbVx2Wmy9Ezh8Rtcx5kEHm5TbvI4NyL3NYY+M ejHp/UxKHm1emdzpE/rgQC8tpjbNHP89QGsSHNQScpyGgsqORThUECYIqse4480ipfw2 rfuXansUilBkpzBe+ghG5ypEPzEN1jln0K7aVDt/+fegzIxvVDNP/keFgc04ThSvZp0T 62wQ== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCXy8RxEo+pt7QihhU9HN5b5hPwbSk9q0C0ZYtabtPejQQ0L7O0pap5ydqTlZIZ2o2IWPv1CtKo3CB19gv1YKQ4bIYbkYXsti2NG0RROeQ== X-Gm-Message-State: AOJu0Yw3tih7AMtvWiLXBuWuyzBtRwR5UIyrhbP2V4kk3nOb7/k8sHDk 9yrASctJWJKbAfhqIf87r21+NuW7Afh/lockF2HCEtl8qPkOb57l X-Google-Smtp-Source: AGHT+IGr15ez5/fl06n7bC6jDdn1hlXZvJ7FGuxOucWEjp4MBw931FCdIRivUaB1g6unJEg5xdMirQ== X-Received: by 2002:aa7:d44c:0:b0:561:a18e:e1b with SMTP id q12-20020aa7d44c000000b00561a18e0e1bmr11001988edr.5.1708503746498; Wed, 21 Feb 2024 00:22:26 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6402:3811:b0:563:7dc3:bec8 with SMTP id es17-20020a056402381100b005637dc3bec8ls1137416edb.2.-pod-prod-08-eu; Wed, 21 Feb 2024 00:22:24 -0800 (PST) X-Received: by 2002:a05:6402:8d6:b0:564:813f:7af3 with SMTP id d22-20020a05640208d600b00564813f7af3mr4014875edz.18.1708503744581; Wed, 21 Feb 2024 00:22:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708503744; cv=none; d=google.com; s=arc-20160816; b=SZzacR5z70s3wRKTWlp93gjqkvAlA1ZfSv6AWrXtIGtHjui8+bWzt3NEwPUte3CYGs 6YxgDngpjqglkOduxr0zexIyl7ECcx4Q74CdLplazWEEcPrdbkJ+Upda49FW9d80rZMw DzTFassGPXAcSCjBVWb/lCr6fSGceWPV3oFblsW0DeYHIJOoB00TYhlENN1zG9OO3h/c dOXno5gpcOmq9v7NBWFliGgtGZqnix/rE+u1UAtF63aAeps+W5eoAQkcGPO5UPBkoYQg NF9qkEYDI1OHtHNuYlyjPZ6fCt0sz6KPeVf9xs9rvMD4TPpoDF48howA1cQPFgWcAoq3 YhXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=8gmCup5IR0j8lJbE+d7lpC4ClDUITS1Uyu+cympBB34=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=Rxtti8JRpGSJD8LdWJ9V7MT82CxuGLWuZMZODwo6JJmjNGhFxnM7TotPyu5mcRP6Eb KkHdlM9eH18CSYgQWCAiiOXXDpN3k+TPr94/os86v6EFZGJPBaGBKEBKUIuhLMpqhwgn f+t9gpxyj7F52QEgQof6cm1g9dN9FKnT6aKVcBIiIvsnRS3pas1qfn2zYjZVs1+99eql UBitr/hKwcQcsIGXOrfsNWEbZ6IhWhyWVU7mcPB0XEpXWWgHGzpn/irrCrDXBMFLe29r iHE/K3ahC0l2ymiO4cBNJBLrDmOa7ORIZ7PdGlI5ardRrRPInz+OLKtf5IYn31ChZgR5 jyRA==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=toQB9Sd1; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.135 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.126.135]) by gmr-mx.google.com with ESMTPS id m20-20020a50d7d4000000b00563fcbe92aasi690733edj.0.2024.02.21.00.22.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 00:22:24 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.135 as permitted sender) client-ip=212.227.126.135; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue011 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MiaHf-1qy8GN0kFz-00fkGL; Wed, 21 Feb 2024 09:22:24 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 03/13] image: create pointer to per install Lua state Date: Wed, 21 Feb 2024 09:22:11 +0100 Message-Id: <20240221082221.11997-4-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240221082221.11997-1-stefano.babic@swupdate.org> References: <20240221082221.11997-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:nYcC4oXrJGd2ap+c/uRPc0OtFoma7711g0xseh30eLaMs/AelCe BeUAxIML2QgaE/hM0Pd+dah4t35fL19vW9S8NQI2OoC58moiHDYcSJAtA4jrN1xc7cFpiSQ r1y5vSUhwNAKjmKONrn9I14f0rs9c0EOeCrs/2RyF7DsPU/s6DB3X56r6rCBtUWMNNUosKI vFmPcIEEN2IChJw9bnfwQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:nFPOpfGsXmk=;bWIX9U2rp208fKInW93y7iE6e1x DRu1rrsDSRE42fCXo5ZDspf3MYQjmdhl+Wo6L8pjepeiMNSACYu5gVUfD7kB5+9R7MDYLnYJk UOjoScj9hQlolxIT2bkEHNmf79duwwysg+TImRh/XclQ95YWPdEitEyZ68rTCZN7X+m9JiRVm rqUP2X2Oh+F+oJkdqEeXtnPQfFkOln7R/86ynN0jsLTfSjRmlwNj8gkgSB4v9i6loHYmGerlj HUajvHtEjw/V4A1QZks5qpa3nfsG3Kx7W4bljnuxWlaArxeeBYgCr/IqCwoFxCuuzxwdcVFbO ukAxLV9u33t3CAF/uc/mRRBu2u0GDW0y4AFrYtBolgJP5YtDlT+LntpTmFR4Um76K55vrrR5o qQ6KLtSPLHfSpUSemQqX351gP/QKnVIbwMe5Ujj0bjqn1MsA4VMAMsLD9m4BQt6A6dcIGBZHQ okXxSaF+v4Ll5FlOB3hH82lvJU2JCEC5k53WF3Q6pjyFMYub1VBSEJX/ezj0LAFQDnPRYgYVn xwuPLd5iWJdVIwiwVaruIZJCj6X4PQ59DglSWBDBSH9jtBV3GxWo3JWRZjePImMz7d2A+86eS wG/6GuWEZgy1tKG3QvYGyg5CbX8c1GYMAC56lUVyRmjch8lpBcY3xviubCY8WminVYT1Wtcnd T9mD3g1HKSBnI9RpJfOuS2EcuMfdaRrUUyL98y0rJEmzcw1q02Comgv9p+wLDfgBfHHuSYoT5 T2iyspRrssUZHJDN7lxBzJuMhr3W3pG3ykxVRpjYlWC8l9hwoMCtYg= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=toQB9Sd1; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.135 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Add pointer to image structure to the global Lua state to allow handlers to use it instead of creating a new one. This allows to call Lua functions that were previously loaded by the parser or by scripts, or loaded at the startup. Signed-off-by: Stefano Babic --- include/swupdate_image.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) -- 2.34.1 diff --git a/include/swupdate_image.h b/include/swupdate_image.h index 592a886b..68d97a02 100644 --- a/include/swupdate_image.h +++ b/include/swupdate_image.h @@ -12,6 +12,7 @@ #include "bsdqueue.h" #include "globals.h" #include "swupdate_dict.h" +#include "lua_util.h" typedef enum { FLASH, @@ -60,7 +61,14 @@ struct img_type { int is_script; int is_partitioner; struct dict properties; - struct dict *bootloader; /* pointer to swupdate_cfg's bootloader dict for handlers to modify */ + + /* + * Pointers to global structures + * that are alive during an installation. They can be used by handlers + */ + struct dict *bootloader;/* pointer to swupdate_cfg's bootloader dict for handlers to modify */ + lua_State *L; /* pointer to swupdate_cfg's LUa state created by parser */ + long long partsize; int fdin; /* Used for streaming file */ off_t offset; /* offset in cpio file */ From patchwork Wed Feb 21 08:22:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1901893 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=mYalXAdY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::140; helo=mail-lf1-x140.google.com; envelope-from=swupdate+bncbaabbqxf22xamgqewpny2jy@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lf1-x140.google.com (mail-lf1-x140.google.com [IPv6:2a00:1450:4864:20::140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tfq5M3npxz23hc for ; Wed, 21 Feb 2024 19:22:31 +1100 (AEDT) Received: by mail-lf1-x140.google.com with SMTP id 2adb3069b0e04-512a3aedf22sf648777e87.0 for ; Wed, 21 Feb 2024 00:22:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708503748; cv=pass; d=google.com; s=arc-20160816; b=gvckHk0ZS9GhMbRoItfHITeTSTcFiFV2q6Z0QoWd+E/F5NY9Snm8Wf+wMxKrXRJWUN 2QbWSdMNZt4Qk8wjfAlCy7LZSb8YL1Q7A77YQmLCU/B8WAYDgsmqIAnsZKh1yET5FKdJ yA1GLi/+0MsyCGLRBu95GFKH22BeHHc52kOzkN1SlJh3p9oagu9PuKP4InNXl1fkL+Qy Q2YBP0OwjM6yDIdFV26/lh3A4dYjLoENr22u4DWXGLwOl9M9I0v2rwI8GEr9RIEAyV64 UcYOc96RWQlntbu8RoPJQHyoOBCzw9hf+Y+ulbcR3k28bjf5ugf8MW/ptejWB/RmvJGH wQWw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=/dQ+qt5xJIJS561Ag4BPLw57SRv/NiJxnXps0smzMPs=; fh=+Fly/4D4U3VDhC7/cDs6sg0K+JSyMP/z3la+PIdPHWo=; b=JJMsmdT3utN4Rg3Vl8AQ8z+E6PSvDJr4eaLTlO69ZXM5yga4MM2urczMO9ZKJXiJ5l ihcz/dUTPz4TUIw7jJdDWoVQxz+etjErfo4QLbBnFMYEp/FPobOST2nEs9R64uYeu4F4 LkN85WIVzlBbS+uO1on+qsjx9p6GxXHgqhjfqoOUVclOXspt6kZdkSjdV9z2R1WIts+B PZ0GexM09lTEsvq8QbEyFw/oDAOIu/9GvPDobAx3LCfwSvoNUCyoUWPIabf8KFRfAwOi L7Uqjo71LYgASqwWaq7KiM1xZoSALraZRLzRjqjnJWJ3IDltx6n5VciSK/u7c/aRDp3g JBDw==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=Lr0Hwtha; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.131 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1708503748; x=1709108548; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=/dQ+qt5xJIJS561Ag4BPLw57SRv/NiJxnXps0smzMPs=; b=mYalXAdYtSH9alA4+P5iT9wmuuz54hK3hpn5uZflwjHtlLILOeWW8iawkxUyNmfkGr vUC3XCATSuZ++iwvSMJ0bLUfSjBYLGR9XRBCZIStKp1goHKQLdO4sMQclOvUUD3oFX3i uNwx4aJNm9XdrB+iDXEKHGyw57Lgf2GS1MQWAe+92k6vEbkS0vcc5aUqFXkWXkByoCd9 yjOoCAq+qGxIoqdj0yr5ybBItDHrw164bQ6mHxcRgAxVPpRvHNHppQmg+8WGin/Pbx34 DhE+SGW0TOkxzA16ec1ZetXqkyEkc8Spj3Yne1968PMQfYPZXDixUPRsR7WRVHyJ7S51 f5bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708503748; x=1709108548; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=/dQ+qt5xJIJS561Ag4BPLw57SRv/NiJxnXps0smzMPs=; b=EqdW8wKi8ZtoaTTvU5GQXtBLNnJzjnOadQ8RAL69oZhnY81VVxY5v31nDVwSOHg5NK kzJx84jArdMVWjnkODTzfqUL+qApFcNuWWxhEyMicdY7pWGH5dFVwharVC52Kvb819Z7 ZecTY0/8EXVo4VG9M95LXZNXJ2X/cDMYz5GseYwOcikLu55iJhOAB57N3WLzIjt+380/ GuDE0AbbwK0lB/kBOlDaD1923gc0pKIQfl2VGobcLcPnn2JATMHHmyfB9AEksysNbuYJ aMVpLvhHFgX8G85RhU/GoZv0xLRY/o4H+2gIzyvuJAlL4RGMqkjGmrkSCSz2vmYbP3aK iDwg== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCV3mQbDhtcT0WRGzBiu/5w1nrX9cV+mvJsC4eeEqHhqalkOhuwOLQjSJj1ugO7OxGVog5uC1I/4Cx2zgwB5hvZX+QpSbnnFMHrsnR21Fw== X-Gm-Message-State: AOJu0YwL/SgejNr+uqkda+cokNRMbpJf9j+FlMmbeFez3DFk4M+j4T/Y WCsp57VJ1mjo+/sDS79QvayWBG2hrFAOwjb/J7+KyIOAvF8jAxj9 X-Google-Smtp-Source: AGHT+IFUG7asSNMc3osLZqkdx6ZIHMiJVvJuPj6a8Ef43A/Bbq4mhFWEWSIUvBUr+y7NuB28AHIiVg== X-Received: by 2002:ac2:514a:0:b0:512:bc0e:27fe with SMTP id q10-20020ac2514a000000b00512bc0e27femr3606497lfd.1.1708503747022; Wed, 21 Feb 2024 00:22:27 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:3248:b0:511:4a70:6ac4 with SMTP id c8-20020a056512324800b005114a706ac4ls113459lfr.0.-pod-prod-05-eu; Wed, 21 Feb 2024 00:22:25 -0800 (PST) X-Received: by 2002:ac2:4a63:0:b0:512:d251:afcd with SMTP id q3-20020ac24a63000000b00512d251afcdmr576796lfp.27.1708503745091; Wed, 21 Feb 2024 00:22:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708503745; cv=none; d=google.com; s=arc-20160816; b=tTKCRoqFa6O1rmULk/wnQzlyqzNUt0D/UqS13E0G4k4l9EBvkSmjBtl/MHEf8cCMez j9K2f/sGVGCW2Wq46Lg/gwlHINbj6FvHxmuji14fIFLpX0qc9+0hs+AybrTglOU0jOrN iNT5VTCR6bUOVOk9v5Lzu3IH0ziRAxdj5DO/iUmYAvU/xRY79MPm0U3QDjNFZXDuu9JP QTOvE6sNVZ2BVTpIrDepyZpxUE6hvTEWWA5n7j8An1Ns9tG55tz254GVk1IbDyhOitPP fXgbukmjWIBAfkSPJ87vDVhCb4zfShPNScqo3Cm+g0cqJZJBQk8oO0C/z0alDDkTsG6i rrWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=KyRc4r7Mb9trc+qouCsPi/me1UtUg2wjG2d9UVulu10=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=Cfb+7pAbq8YqVK3cDWehyFxzrgoonrq2f0OVZtye/8TB0Jm8d03Bf4k1/Tu6QRsHVV 53yguzj49t4LgBKJYZdme/6oCdkHnwfXFb70D/46tlnidKMJJewVilsedKp4us4RF56/ X9mICL9NjJcDSji1iZB/7TD48s7gbNs+PpMuLF/QlbbbVGDy1yRAMH71896BQY+w8Bil VW/yYEcCNwpIdWG2WQUSHV/yaRv3f/ckm4HirM6ux+bKiu1qkwJKCqW4SnOPYUB5uLJT ce1oJR+77WDZ2xjwB8JZHDoXlhLsmplhDxJ2SSn3bbWFt8HJvXxR8HqDsETddpzLRZ58 WjfQ==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=Lr0Hwtha; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.131 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.126.131]) by gmr-mx.google.com with ESMTPS id be7-20020a056512250700b00512d743677bsi2417lfb.0.2024.02.21.00.22.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 00:22:25 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.131 as permitted sender) client-ip=212.227.126.131; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue011 [213.165.67.97]) with ESMTPSA (Nemesis) id 1My2lr-1qioIx1DuZ-00zU2X; Wed, 21 Feb 2024 09:22:24 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 04/13] Store install Lua State in image structure Date: Wed, 21 Feb 2024 09:22:12 +0100 Message-Id: <20240221082221.11997-5-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240221082221.11997-1-stefano.babic@swupdate.org> References: <20240221082221.11997-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:yP9fiAlXVuo5xkt91mPqJQ2DdrLr8JFrLdZfRR9DIPsjTw890aX CBSTLMDigvSvQu6ut5dIetowafYxmLfNaSOVFGvQ70vvl4HTnQODehYqkT64Zg9U1EZXZwU 7JBcFG1wQEm3igQwD/6jmSj5SPR27zvO1AA1eb8UToBsamUWsdvhkkCHXipPp52bHjfpTv+ v0B/qwKytrbnLtNl6D5oQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:SgY/faFHJ08=;Z7p388CqJo9yHF5BaNV15cFRi9P Yl1OwmwYYsWnFW21xBm62V6Uag0REuduSOOyTXDvGbRLucCnnrg8rQBZAn0RTPoxAv3Rjqc5Z OhJPjg5lEYyvFEk/Zt+SMOl7Ohvv05PfxxA9q6SAUHveNqgfnVDaA83fakzmwT1ldvcI5scgr Su38yL1molHJ6TYgkHTOs59NI1RsfDE8Bwh3ildCJaMJNADKmyF9HGEzrzXaGjbmOFMDAWKaE zaUW7ujH/+LPmxcovxjBd6hIXmuVYxmXLmqw1p1Y6Sh+uaZ0ROQgFG7oQkQD2gLHuHHbxxyDN kPfxWPTxFHVeI3rrL6oO9fFchVQVU7A49reqxrc6vWT+EgwHfbvL7hTCWHWAvVvL2Gxwaw2WN uTcbBqwB7eIf2s4Q9ChRs7wF1HIQ2kvYNUDEGineO/8vqA/VbsasuJh5xOYBl+iqg3ArMemcq e2AdrancOPRvE+CINLNEaiJ0S5Clhx+ikhBItgTFE6ORT2Qx55cFl5aSSRGYxkzbPjt+1NsGO DlO+jdNAJvTmNRXqkq+ERlb12d0w3rnyJV/VmqznIJCdWrFAqXT98foJUeXW0/5jH0d4yt9Q4 YiA7CLkFfwd4wT3qaToIzzPqqKwxow6+1edHFaI96rHC5Ketbg/eYkzs+PJ1h2OzEzBdM6wbn hjG3KOCOV3+49ID8AlJprdGoHafV/JlcOXnhmlD9nGdbCCigGcFNcVtXBWzLnUXCI49cqAwy6 rjZT/UlebkZqvpQbPITzFDmx4eoHwy7P/3Zpb55TAilf/0NaOe03eU= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=Lr0Hwtha; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.131 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Each installation will have its own Lua state. Save it into image structures to allow the handlers to access it. Signed-off-by: Stefano Babic --- parser/parser.c | 1 + 1 file changed, 1 insertion(+) -- 2.34.1 diff --git a/parser/parser.c b/parser/parser.c index 3944de64..5502e34a 100644 --- a/parser/parser.c +++ b/parser/parser.c @@ -384,6 +384,7 @@ static int is_image_higher(struct swver *sw_ver_list, static void set_img_globals(struct img_type *img, struct swupdate_cfg *sw) { img->bootloader = &sw->bootloader; + img->L = sw->lua_state; } static int run_embscript(parsertype p, void *elem, struct img_type *img, From patchwork Wed Feb 21 08:22:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1901890 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=hO6NBkMZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::537; helo=mail-ed1-x537.google.com; envelope-from=swupdate+bncbaabbqxf22xamgqewpny2jy@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-ed1-x537.google.com (mail-ed1-x537.google.com [IPv6:2a00:1450:4864:20::537]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tfq5M13ckz23f7 for ; Wed, 21 Feb 2024 19:22:30 +1100 (AEDT) Received: by mail-ed1-x537.google.com with SMTP id 4fb4d7f45d1cf-564a038057esf1452752a12.3 for ; Wed, 21 Feb 2024 00:22:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708503747; cv=pass; d=google.com; s=arc-20160816; b=KRkajm9c1xFe4mr/uORz7On0YwNSwGiJhEwJOuQ9z3dGgp8KyD6dcJzwnmAnVmMDL6 FnLglQrjCHmbIEaPTgXNxpusp3q1NhwV3WIz+bJKcrzVyO+iBR15IkzU57gq/paHfHZS 3jpKyd7E5FMwjf8071ylmfNqNX4Z/WUBuB+B7+PbIT7wGJqgllIoAyB3UvCfHA4Q8A4b L2y64vrcP4ZGaD8dzqPVBGIfMoKVto4y7mNnqnl9z7Dyn0lR75XC35a1rJqUdHf+qNP6 1wXxbTPf9zEVa63Oevr/OE64ql5WfEvBfndp0Qypaw46jUiOQFz0XzhVqFp3t7x7EgyZ oHag== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=3yqSzdFwEDtgJigw4g1OESe0i9MdMzMhhczoKM1z55s=; fh=CoanefZyb5Tgm+XwoDneXi31t3k/R9Mdx5vEiRUkxSg=; b=hKKPCvFWaokkXbWztL1XjXxXtZO9I0nmtQRJXG9gN/0rdulBChilUVE8wkcHqYZ0Hq 7oYMRaYp062NHFjbTQijH0QnMWOK26XSsgPJ8dvy0JBkJm9QE8WrYc8Is4CnWQ9C7P1L UpKZDSOSe8z/FGs4pti6gD63KJ7SEOWTup6TuUL85J0XjUqfhjvAV5SJnEzXIhV2oolH 1gOQv0yoLcvxSZAzZ/BEbMlM1XFFpuk4mWaknajvKhC2D/zmNcmX43bWaxwVAhMO8NKI FE/gnggugFT2kpthnKKEoaJLx74KnOpZBRsO+mazTZqapNwJjVvaGI4A9jn7MuusKmHI 6Fkw==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=tIH5jX6u; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.130 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1708503747; x=1709108547; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=3yqSzdFwEDtgJigw4g1OESe0i9MdMzMhhczoKM1z55s=; b=hO6NBkMZdI4zK1Li3J2e1OisTA/T/saYBHBNy5rNlSuz56KOWykHAbeEhAw4nOmRyd o33ivBGN540zP6hFyuzJkKGbVE1Y7kOPg6gqBBcks0EsqzBz9vf3UZAU7kb7BRA3e31P LO6APU3JK7qUzGP8aV5mFvLoNPaUwq0/Y9AMSwNbI1uSIDyFsjKSxTaVlP+9rr/blVx0 /jLsGZTwoboaFH6vEM7b6Z+Tx38lv6ZIQu5yv1a61d/Bph2bagkZ4OaRdwGDJ80Mra3r 5EseOJ4kn9mZg0LtCsc9ZTxr6ZkokiGK87PkXTOk/8UHWkKfdPxLWP3Bx/GNWCzN33Ds 5AgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708503747; x=1709108547; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=3yqSzdFwEDtgJigw4g1OESe0i9MdMzMhhczoKM1z55s=; b=fWtIE96KAyGHxYBce03AbztKzYyuKbfz6qEf4aFqiMGiEAOLnqkho2bx1xLk03q3RI xrhmHvidLotjtEhYyI5rmbkfAJ2FthVfjFrkmV5R0wgjoHNm05VEthvL7GKVBWFgmpTd Mb8rE652z7WBqBap5+XE6IniSdBHYlJ0mpmIMJIaAL5E2sE0nDdfm/gxt+x4yX/YqoTl NSVv2Pi4HYwBA5ltv3QjlmzsIhiciiLgyZa6oXW2PrRCJ04gXvz7TV2YKR+HyRNMxjLy WX6W/2FhQuBqJqIKWEMP5GILBPmBv5TJJpxMcBdXIgH+uFMvHRF++nNM7GovsHh+UJjS +XQA== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCUhD3mUf3kQtCuHdpk85a4iywSFvD5MpiNdKRQG7AJkfdew25kkGXYg+GTvJ9BiL9j8+0VGRfrUuXbNwnpRdfgQKZMnVMVdtpdKAPj9YQ== X-Gm-Message-State: AOJu0YzO9DsFJ/u25WG6UO/Zh1j7NMUJ3tLhkGcarEJy3rENjh4LLURH vwkaj7GO4Hwz0Thz0OjkjezVCT4rvNcHHCMwIn6FBGXf7w06GbZu X-Google-Smtp-Source: AGHT+IHA3fhjpNmrGt4DetdjXDXLLWA/RG+onTGj3CA4VwzXKcAsFyuI/9cUnzGoYyC2xNVJgNxvKg== X-Received: by 2002:aa7:d899:0:b0:564:4028:e2cf with SMTP id u25-20020aa7d899000000b005644028e2cfmr5481146edq.24.1708503746638; Wed, 21 Feb 2024 00:22:26 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6402:3705:b0:561:f0f1:15bb with SMTP id ek5-20020a056402370500b00561f0f115bbls762039edb.2.-pod-prod-02-eu; Wed, 21 Feb 2024 00:22:25 -0800 (PST) X-Received: by 2002:a17:907:76d4:b0:a3e:791d:afe6 with SMTP id kf20-20020a17090776d400b00a3e791dafe6mr5446280ejc.44.1708503744905; Wed, 21 Feb 2024 00:22:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708503744; cv=none; d=google.com; s=arc-20160816; b=0uz1Y4Syzo8Tf4eN7zxXcG2hQnohmJj6/dkW/KqxnyWEBptfLL8InMCGYXCM1BKqPD zp2oHzglYJ/qNKmigW9QZtzdxGUVhWLb5Pw70vdsi+pIkFmjFe7xfsEmKQ7bCgbFs9PX JWMUFdRGRUrQDVhBODSKdl3o94UwESltZwGHz2W2Brhsz4XsjIwklkJaOwVngEwiQuQT SL0h6vnZCj51zMi6Nn+qM3FkFV+9jAwREAuH3fPQBHJEqoL3hed7z4ZT3oegpkDEqRFB hik2dV75rAtoUHwuhlnh7FazT+dqIRiFX1TsePFLCMmGwo0Px0kkSMcuoCnu0cr0c5XQ dMhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=pNM9e1o5Y66ZZm6BNUKi7ShJ7JKJqADMU0rCnOJne5o=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=zCmzQUY4u01DhevGVF/K0n0F2BzFtaxXMNWQ/LlyWPkGTLshY1bIyCnqUHW4ujamxL 8xncH/LIY2Au1/fy1n6+W6tFQSqC6UrSlDlxt/XUb/64UPoH1sdhPnw4e5+DSrxDRCYu Vog0BmwD7RnEXQmbCEJWpzJRndVHbEsSyzzTZxokmeUw4WLM9Ly9CK9vm+v2XDNaHG2e SrsNZxW++ej5gzGsDysoO23XQhIprD3mQvEMWv7HdkE/CCVoPHk9zrC8ORrlKKMkmxdp L4A3NG0ISqAsYkLzLJwRJvoGyeZ38thSok99Ua2dqwcg6mjuRMTO161tkjjlhbndUDO5 rGTw==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=tIH5jX6u; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.130 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.126.130]) by gmr-mx.google.com with ESMTPS id fx6-20020a170906b74600b00a3e643fea3fsi427840ejb.0.2024.02.21.00.22.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 00:22:24 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.130 as permitted sender) client-ip=212.227.126.130; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue011 [213.165.67.97]) with ESMTPSA (Nemesis) id 1Mt7Ll-1qnm6z1sb3-00tQIl; Wed, 21 Feb 2024 09:22:24 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 05/13] Lua Script: runs with global Lua state Date: Wed, 21 Feb 2024 09:22:13 +0100 Message-Id: <20240221082221.11997-6-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240221082221.11997-1-stefano.babic@swupdate.org> References: <20240221082221.11997-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:WHYJO+tJjCIpKLiyDEkHZkUsVgTUHVmhBMA4kPh9/aUskdOrhaG 7+y1Bmv5dl6rfaV1MJNnIGj5ltlWRuEMbMRGUlpgqRYx0lEl/GLESUGQ2p8LJU3rnqIqF0C Q+eLPEnuBxjBnkx2ZDNp/IVKZieHBsPUJwRFrioBaXp5MqkpkPnGatt5z4MkGdRgdoFaaHK /kwfWxVn5BRzQgHWUgFMQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:ZyZUgeRvCK4=;LG8dKSDq6tc+34m7CxHYYIElnlY v0Ho3NyxWGQqMWYHVno9nQUl4xVJrKpVtIegDu5lIoAYI/qNe77S8Qk+rivuWIH66r1GrVSmL a9FPz9zcBItGXdAXnPG1Z5CP76q3/H/lSPTMmKagHsH9b4FiURbmvSA3duQoI+r7uJkN9JeMi 0ERzkVD4bf6GMfpoKmbRmgDwBMG8bwS/nxyeW3ksn9uf7hEDYPT7UObsVgJ16R+Zypftqf4+2 3rVkxeiSjpK4zONfFru9/WylBcM0us/zKZ104fofdSwYH0tuarJZuDXB2lviZktuX08wKGQDm 1qwl1TlEyyzZwbHrvLOpd9QP61LZ5A2AaXUTyIUatELLjfm6dCoMhfoaTJ+2QU8vTGQyCMZTU cg3IIWjyxn9sD6fkExINMWwW153SRLCV+RLGRgPCbL4DrklfNlmxQlzInCCfUZPa51fDjklZW Iws96OvYF2Rs29CMDw+1owTNcNV4URoVCKpkn+aIdBORt4gn6zxkWFhrAlZ+SWanDR/oyIVQ6 0rXXWPypNyViKiQQoQpibvgbt0XYj/dW59QGXyUMkvSchgRM6rFcKgWrPPDplfwfZBl+bV8bD CITpt3iySuyAdDhPWYdrSSUnahYNulr8ly1OYUaQofsrWuJEFLjoWhhQkjgdDTVoZ3QAiKV6K soL5+5pMlF6e0+UYXcZhzV3lGCcbAvoTeW4ZutOekI1dj3z2Htl8jEn5J3oSy05xVMtvkkoP5 64qKXEbklgpL/qOuqqk6MMyaKdYrk208nqTBaxgJGFvtvmCQjH5EQ8= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=tIH5jX6u; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.130 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Add a property "global-state" to run the script with a per installation Lua state or creating a new local as in the past. If global-state = "true" (as property, value is always a string), Lua state is reused and the script can call any Lua function that was loaded before during the installation. Signed-off-by: Stefano Babic --- handlers/lua_scripthandler.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.34.1 diff --git a/handlers/lua_scripthandler.c b/handlers/lua_scripthandler.c index d4ac421e..213099de 100644 --- a/handlers/lua_scripthandler.c +++ b/handlers/lua_scripthandler.c @@ -36,7 +36,14 @@ static int start_lua_script(struct img_type *img, void *data) if (!data) return -1; - L = lua_init(img->bootloader); + bool global = strtobool(dict_get_value(&img->properties, "global-state")); + + if (global) { + TRACE("Executing with global state"); + L = img->L; + } else { + L = lua_init(img->bootloader); + } if (!L) { ERROR("Lua state cannot be instantiated"); @@ -63,7 +70,8 @@ static int start_lua_script(struct img_type *img, void *data) ret = run_lua_script(L, filename, fnname, img->type_data); - lua_close(L); + if (!global) + lua_close(L); return ret; } From patchwork Wed Feb 21 08:22:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1901886 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=H+YqP/Wt; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::537; helo=mail-ed1-x537.google.com; envelope-from=swupdate+bncbaabbqxf22xamgqewpny2jy@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-ed1-x537.google.com (mail-ed1-x537.google.com [IPv6:2a00:1450:4864:20::537]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tfq5M0ffTz23d5 for ; Wed, 21 Feb 2024 19:22:30 +1100 (AEDT) Received: by mail-ed1-x537.google.com with SMTP id 4fb4d7f45d1cf-564d6955fc4sf680899a12.2 for ; Wed, 21 Feb 2024 00:22:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708503748; cv=pass; d=google.com; s=arc-20160816; b=EEJ47GKelx5yUC5QmGVzeu7oWDVV6Mb+Xow2Q6lfYt76kremqFgTZjMmAJ8kYYrD3v mqrIw+B2bkd6KKQInhplfBr4i6E2oX9BlnUQCuky0AVrXPQBc8s6uCTfLLrJNtDFLB5q VhZeDhSTLceuylv4Zfrza9amw3eM5EoTWwJPIMuMJ/Jt2JYLdp3ficbTC7S/jt6ubgUY nc+uyP1sGZv0s4fVBM30aPHR3rB4nIJioNtjg14XtXxYfPDMwETjK7v1Qtp5a0KzMqyX CGVUtEL1XsIlmlI38VhGHfw+ZwNAMi0M99M7B33letaRaaMJsyV2aMCTys1n/Fd5mme3 bjNQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=YSOpoEsvxZBr/Jln1NJlN09m6LNCxzmH+5sqKtSrskI=; fh=n2ru78EJ1bDUXoy4Vb2Xz1PfShCQ3UwJNrX1BVS8780=; b=H6y32rZ7uK1nBtOOJadX3zH/qx5uub+rdHaNi07B19kKP9z5MkFcIvWlxlDCZbO74m i7fNlMNwWXq3BvIwtDxImiOcCZxUdgDwX+CTgfSdFTOfoTFBxbwiGiCdbNSvWwfU467s xcFYWp63OVSRWPf05vNTjEUY1sXIHgHZKNroyTaBvCHBvyLgN1j15N9qldN7SyiDDcof 0Dc00O7mkzcPBk6CbS8qQOsBSCwyBdkyOXDhqT608WayVL0+adbG3w811adaa+QVHLjp KUeIGyboI2jOtPOtflXNXrPheobUXVxiXhsF3at4ZbWA5w2M12rYxYHQXwosRV6S7KRW DdYw==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=c4aZd+Kd; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.133 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1708503748; x=1709108548; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=YSOpoEsvxZBr/Jln1NJlN09m6LNCxzmH+5sqKtSrskI=; b=H+YqP/WteXDv31u1rUnfjHxN+biMIHpIa2F3T+LdjOtaZ/ShmVsAYlaVgAUJhU4o72 NeTKbg8C6L6XqFXe0vcPY3d/+kVsdD2Nj+WIBZ4vSz1KudvFFIDmPy87vVUShXnS/JEC l1q6IoXicV/RB6mIpt3kNG6LH5FIcyMPyA5QNXC1wDt6XMK0m3R1Swk0DmU9DuaCu8O4 khIrL23gaCNbtiKt+sVLQBL4CVLppkRzkFZLvX+GOIk9K3HbTSPAwbjuh7U+jfBrzJZe nMsaBxtMUHa+0T8e8xcpYgx9pEmLvMYagI+vpzpL7xogVcmflYcqlZOsY02BTsmYCY7p pTag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708503748; x=1709108548; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=YSOpoEsvxZBr/Jln1NJlN09m6LNCxzmH+5sqKtSrskI=; b=osHjKKnMz/81a8cS4SxCAm4zTwcVn3qCztJUZrBKUrTlHYzFxflB1zKCR49HhjC8mL UlMa9lfydgKPIgeLm+le2BsLk98TF2HJieW1laOw/LIHwizND8CCZsWmGDDlkVGpgShv OyKul9R6+ByfFmT6Q9vNwreS1MqUuPVqwHaC+snva3SkBshY+A05ckKTkgjdmkwlSSFF 7LjwsTzDBxCuv5mvkNEXv5+7PVCw3bc4zvNpmwt4CFOXaTRHocsPFXY5EhmkjVe/z1q8 Myn/lVPt9ugE8W/0HYIPFQExZmU7zaIRa9T1xkZxR+7Vwetot04EBj0ef9aEcAFTSH9d hBTQ== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCUF0Mec4NxAPxwOFOFXdsSTYJ1lnopOKqvJODygsXS72CgOoFF8B2davvOLHihwqyCBa01RkKr2LeMas2u2rZc5UXsQnaHg/OL0/140sA== X-Gm-Message-State: AOJu0Yw8aWJejl2XKzBhnQONbiA9PqZqW8CRok/xcIFcFCx5NVO0pVAS HaKB9QRzJj/yd7y74NVXDmJXhVcrVv45c5iI+Fip259JPiPum5zw X-Google-Smtp-Source: AGHT+IEIS+iHv/ub92YE1birfByuvNGM1PYG4Te4tTgWqjNBOfOJpg4fxqSAkcYwy/OonOZch/e6uw== X-Received: by 2002:aa7:d74c:0:b0:564:20f5:6926 with SMTP id a12-20020aa7d74c000000b0056420f56926mr7763999eds.14.1708503746851; Wed, 21 Feb 2024 00:22:26 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6402:5293:b0:561:2701:7e02 with SMTP id en19-20020a056402529300b0056127017e02ls956594edb.0.-pod-prod-07-eu; Wed, 21 Feb 2024 00:22:25 -0800 (PST) X-Received: by 2002:a05:6402:31e1:b0:564:bcb1:45f6 with SMTP id dy1-20020a05640231e100b00564bcb145f6mr3162318edb.15.1708503745026; Wed, 21 Feb 2024 00:22:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708503745; cv=none; d=google.com; s=arc-20160816; b=BdZe+keMRhyEIDrsLLevhSCDCkx+Bxm3tKHwt6U+d4mh4HSNO9dpg5HZklWdBXxA0+ wttbaP12IMk1FhEkUOCslWDmGYzN5GCbjdQP3p7OQDdH7oCYCIWidSdKsfwysXcFnV5f r9hzp7orVN/F7vAyBTSo63qry2yp/nmd2Ke6BPfvOSQGBsQaJoAq6WTKDqoCGFJOsGuU FSrnfTh/OXLVqMPX4bYfa3o1r1NuBaV5SHUaXLjEbpIe2yEWH+mE0oLmea52tSLhmoTj BLuIU+QKM/MgSjURkxlBsSAoc1xDTbWETNHxRcYWnwsljcy4iv2iwzznpZLHN3RP4S97 j4Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=AUNqii4CA9Ah2ZBmCu3MNvpI+O/AmsnpwFxC37T0rCA=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=l6wtGPFmtNkx3LCz9+/FkZCkIoBB6JZMp6Qw6ciM0/ZeJA2pPg338m5xOQW8cjwzKN 1+0cu1R8S+aJGiEBWk2RO+VeOlBkyFG0a5uxLcd1sc8uE84Kx7AK6MfU0HzyQZj7tr7H ss7kbC7eDLSJVbgB9HJDcKKYn97Q8TbhYyrnIo4IhMkgH8JJ/CKTDxhUclrIgyUVq9hj D/e2zdFqUldoq1XSlRpMiB2/RXJfBxJ1/ijXV3MYfncvmKDoxJvZmDdB2kQkBWeiOapD EeYi+EFx+t4qobu00eI+ZH/Wx9afHY62djY1oBqMWLoFLJWjF1Pq814slWL25wfY3oRF kVlw==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=c4aZd+Kd; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.133 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.126.133]) by gmr-mx.google.com with ESMTPS id x2-20020a50d602000000b00564af3e693fsi312797edi.5.2024.02.21.00.22.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 00:22:25 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.133 as permitted sender) client-ip=212.227.126.133; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue011 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MIdNt-1rfgYf2MWj-00EhEd; Wed, 21 Feb 2024 09:22:24 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 06/13] Introduce entry for post-update failure scripts Date: Wed, 21 Feb 2024 09:22:14 +0100 Message-Id: <20240221082221.11997-7-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240221082221.11997-1-stefano.babic@swupdate.org> References: <20240221082221.11997-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:vVvsyVNTK5AxvV3qxoYYLP8AYAfbkni7F+wuceyKw5thaJWFuqE WfFTaVtIDCm8+Qs2PRZ0JE0xRCZZ413j8EoAeIZ7QoICVtCv2g/QxXnjMCw1CQThtTwMS5Y OtLQUlva67tls9FOmZtMZcBvy+la4HaUJEimXF8KfgihVs7UVrRBOUMBjEoXYJ6a8ODUQaH JtwOfsEgsC1GkL9YW0ZFg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:CzPKjlRBDXY=;kHeTVxp3PkY/+bPyDvyH9PZ+oCf rzWuiYYfsC0and1+oNqKLWlRFNOmvumrw/pzXo9MtZH9A2iqtzIxxQwuD7tTjI2zA6WKYftbp AxefbaEwYt3/MlKxJrbH0SByAoRH0fDag46SSCJfBzqlKY+1AN1tC2C+/J6wq/0IkFysNg/zP BnwkMFj8nJVa2Hu3j08qjM0WYw1FZiRQ2Nq2RBTQOSrdVrrFZhTtxyvn2aUbwg3aJi11z5Ai7 TElfJWRT9c/fjbDKVXJJSKl+Om62WLSUc8Va16tOJjmwLCTE/FTfpGRte0Def9Blxoq27/szz eci9alQqk2qz5dtgtsPAwCClSqZuriEAeP11IaDIGp1INWWD9fq0n9R3oLwiOcE5BztU0OxZn jtQP8w4ImPSNMsWDSgYOaQfjXlThlfFLHBaSf7r5X2sinR+7bO4aENHkth2hnnrjJK3hSiB/b zwlcazVQzm1U4xKA8NfQ81E0jR+Fk7GhaSeQej5JdxRVsVTUf+kuq703FofLykDrRS3vnpBmy 1qEdOEclgZNgj0H5ACrB/0Zm4Kqom4iplnpTF+0RpBIoHDDwIWs3mxnJek+JxCYY4QWjjXzVn e8E4akTz4+XdAnl7XXZswLdIPdCx9n4atfm6D/PDnBOaMmzcXZ7sdmf7yC6lh0pXTRr+WV1M9 1dUjjJO469LNrkLx0eKDQ/FoLMD+mUdv+fTlwrgO5/2w9w1WGG+kGbVJi37vRCSBGobx/M6gY iPaqjXKfwQelU/ns6UZ9dhuq/wpv8WCggmgAWmo4q4xX06Z56rxNvE= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=c4aZd+Kd; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.133 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , There are cases where an update fails, and some glue logic must be added to restore the system before update has begun. To help this, introduce FAILURE scripts, that should be called only in case an update fails (and they are in alternative to POSTINSTALL). Signed-off-by: Stefano Babic --- include/handler.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.34.1 diff --git a/include/handler.h b/include/handler.h index 36e860b3..509a89ac 100644 --- a/include/handler.h +++ b/include/handler.h @@ -11,10 +11,18 @@ #include struct img_type; + +/* + * Identify the type of a script + * A script can contain functions for several of these + * entries. For example, it can contain both a pre- and post- + * install functions. + */ typedef enum { NONE, - PREINSTALL, - POSTINSTALL + PREINSTALL, /* Script runs as preinstall */ + POSTINSTALL, /* Script runs a postinstall */ + POSTFAILURE /* Script called in case update fails */ } script_fn ; /* From patchwork Wed Feb 21 08:22:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1901899 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=gf9Pjvka; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23d; helo=mail-lj1-x23d.google.com; envelope-from=swupdate+bncbaabbq7f22xamgqe35sp7hi@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lj1-x23d.google.com (mail-lj1-x23d.google.com [IPv6:2a00:1450:4864:20::23d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tfq5N5q9Jz20RF for ; Wed, 21 Feb 2024 19:22:32 +1100 (AEDT) Received: by mail-lj1-x23d.google.com with SMTP id 38308e7fff4ca-2d240155a45sf24450041fa.0 for ; Wed, 21 Feb 2024 00:22:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708503748; cv=pass; d=google.com; s=arc-20160816; b=fYMBgtkJ89XTGi8FZOF64qc/jr6NZ1irt8dWvJL0V+Yh1eAtYwjzsNydlZAcYdmaw7 h8cpaQWBRlA//ut6cd37poZuazy4ZL0mo57fDjUOarMpZKtB8w5YcVJ6mud22NrnRN9x C5RSO0xzHchmsjIc993UXr6B4g/AKb7V076ntwR7WGdXd/8wLTkiW/r/I+PE5b4v9rzQ ZKN0Ffl23zLJgef7vf5QQBH8h7f7LouUv1H+PalZ1VLHws972EWVWTp8tq2vQO1tAR5W NwXbRZV4UgcBOauD8DHqWFXWnock/98GZx1G2pQhY6F1L9NKe5+/XQwmJP9KCD2FiLTQ oXug== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=eVj2aIq0VORYVvy4lwH3AEwZCsiPVRrcgYj/OZukpkE=; fh=DOgogxXHJvco6HWvvB9SIltY//GnDnlYyIeSU6aYky0=; b=Zv8sdvybuKwRINB3seaH1TWcHWuCVmb3c7fCZikg51LwRwABxHJ3PRMysYA61Q9/pR ag0hRlE6KS6twBk1VSzOi1H01PTBb08fpLD0klWuSneVrTfYP6vm7jrtfcZgshAaGrfP 1kMI86ZfKgYifZoxhH+RLTDUewp4b5STaQ6862D+xkG5trGnP2ZdNLGPsDt9euVKq+PQ t7BdqpRThYT9rVsfnv4hR8I+m5avhZ4NmKrr+xiyGo9tQp3jbslfDCt7B+igFetEF8tr lfZTyMnuQL8QHe68aXyX06uVULYf+w0t8dckymd0cTwWOpNvuLx6dB8E+CVkUJ1oBT7q FBiA==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=VFuHxN0W; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.134 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1708503748; x=1709108548; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=eVj2aIq0VORYVvy4lwH3AEwZCsiPVRrcgYj/OZukpkE=; b=gf9PjvkaDTKUPw+jIlISMWDA3AHqTCj3g9zhrcVulyoif0WNBAMXWfuL5pdbR4JUde 0EFQgPZw4tVDElTFdYUQ7a/mOZUkqcDLVLxrov34ohq4Lk+gUmM9T4Ms2EI/PczWCAc1 jVF8pvvnzGuiJR+Ts+OsyKnNR3yVpTgPRdTkQVe7onTog7Giv9TBiRHUhIN2mj1i/ArW RtYbKWhxsVWLXYwdwmnyNkJC2TS5z3U1Let8ji3OypVehAf7JoCOeMkJ3ySLZWualo7v gFLTOo5vWrIqAWpsxQSZp/1b+YIinLIypP3YsH9Kp1OotuNOBZBtg2BxGeoQiqVaJpO1 9/+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708503748; x=1709108548; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=eVj2aIq0VORYVvy4lwH3AEwZCsiPVRrcgYj/OZukpkE=; b=eCLqocmEaA+brL0YvoLfs0fyH42QOvrhFhaeNdgyRj/UVx2IrVcmUn8GxESSF9DEko bDywuLwrahPPEzs5hoPytTJJjlJLkSfEVMiGbPQk+O64I4aqrZdV124zzENoulDys2IA +PG6+/wnMAJMaE86fai5LIsxHQIvuaS1vPraLtBysbW0t5GPcYdPuJPLoct78u6IePWo /YN9frZnre6Y45p4iGOkqU4Rs5DVfWp0kbU/9yJUV6n+liX6vEe3LV3beluifFM+Eott ytZLiM5xiNUh8nRJ3b5TaZVHww3FDF/D5toWPrSb2/ASgHA1ouhcwGJpX7aYTdzGl2g2 R4vA== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCV1Da09MOTvyr5d35DRDCGa3X/rnUDI7vpWsRFHQfFH2LrBMsLmAEcHY04GPvIz1fKjAvHS37zLCo9mkW8HsIsUE3VSQRnCtN4zNdubOQ== X-Gm-Message-State: AOJu0YzVhJgmMUQQ35xqrq3KuH68FKCxInWQbYAXGD67J6LVKUSgrnkh O+cU7ZXJ441qUmDyRb+ZMTLvfbddFIqHZFl6nRkCn1/bn30bFoAp X-Google-Smtp-Source: AGHT+IHy60LvodUll21HF7wqQD/BTTyh0Zkk2HAVJlxb5fCishySuUmvJwHNHH0NA7ET0aNiKavSVQ== X-Received: by 2002:a05:6512:3dab:b0:512:bce9:11af with SMTP id k43-20020a0565123dab00b00512bce911afmr5512552lfv.3.1708503747680; Wed, 21 Feb 2024 00:22:27 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:3d18:b0:512:c39e:3a7c with SMTP id d24-20020a0565123d1800b00512c39e3a7cls41814lfv.0.-pod-prod-08-eu; Wed, 21 Feb 2024 00:22:25 -0800 (PST) X-Received: by 2002:ac2:4244:0:b0:512:b066:be25 with SMTP id m4-20020ac24244000000b00512b066be25mr5787207lfl.37.1708503745341; Wed, 21 Feb 2024 00:22:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708503745; cv=none; d=google.com; s=arc-20160816; b=stS2PZnYD/QL3Mn/ltXsuz7+DoLsgCOgfsWXUL5/AoRYW24JEBkI3smYA1Cyrh7mrk LRo62lcdbPLVrNPWGmHGgs1Q+8CZ9Nc0PoRi8/NaHaT8O5dug+K0xUPO70HDl2bPhh66 wh2UMrc7BDS97ldasumPZfUS9tkEs50z7FBgpRuxFlZ7vPzNJ9reblL4sGQ2ATJRLAQO 17eV+caq+bnGGgWH8T6GjCladdQg/XYT5w2Y+vygXuRM8eY54bHHmd6Wdr5wNUQEMvbf qRsYdfMJ3714wcX0BlkDhNolygwTK2jevCmoZzCQPx9EBYK7pEe5ZDZ8tKcD28gTz8wq 4MGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=05SLQ0uwI4HLjWMnCMl/FNkneBKHHBykVevoNDzFFdQ=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=L9BO4JDEFr0rAKCMWLPhKlYPlhM8rg97Uoc+O1CD0HzSmKUIELQU94roSXhYy9qxL1 gP6Gd63UdYGMnaDlhUtXzU9UU/9xYajEa6IVH/uciYHh70MMIdGEeQEiUcrKAoT4k60V R0MsSu/+j9aydqxXqlAfFKun5Y9oKWKLzgKsN812AL3D2WUszOx37HV7xSfZrUiqUwyW iSGnIA/QbC3qJoUBeftkdp3TGzcGbiwRg9ZxvktD03xvxbCeNgY793QyVhF42i1+WaU0 YtPt9iZNnw7JsIJvqkKPOuXby25vUOmJb6KaWJSgvuaGy21zFLGZRAD3/LHa7rN15Plf jMwg==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=VFuHxN0W; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.134 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.126.134]) by gmr-mx.google.com with ESMTPS id k21-20020ac24f15000000b00511a71805a8si466344lfr.8.2024.02.21.00.22.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 00:22:25 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.134 as permitted sender) client-ip=212.227.126.134; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue011 [213.165.67.97]) with ESMTPSA (Nemesis) id 1N1Oo7-1qx5WF2so7-012nxB; Wed, 21 Feb 2024 09:22:24 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 07/13] Export run_prepost_script to other modules Date: Wed, 21 Feb 2024 09:22:15 +0100 Message-Id: <20240221082221.11997-8-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240221082221.11997-1-stefano.babic@swupdate.org> References: <20240221082221.11997-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:jEOifenDCPHrfVZqd0x7P3J8gEZq1hQS1OepEZ6oVrR7aLvnCAb r0W1/r/U85qrqxzz4EhIK+xo3tmD18DzMY+McQwZXSAdiXMlT5186jGntGq+L4g6gntQDJ+ DBWpRD2o9vu0fjRvaWoVt3lklQj1NqUv2ukF3tv71cFN7YXg6S8yng0BSlc0j04Jo5WUosC KnZdda2Cf6gYzmSCT7Cmw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:8L9gqnIpX+I=;gfUCJS3dHOYUnZmZe1ZTed3jWAr 9JgXuI/LT7R3lI1bjJ8SmbSEtrNnYt3NlHPVccgHAowKQph3A/5xjCoyED7ft1SZadf+ft/yH XHaaii13xQh4zvS5u1i+1uxICSbJhzf0yav0XULeEe06zotlq0f3F5XK7YXV/YeMW38lqL9Nv 8hB7KRY0GOPgQnBjt9G2aMDEXsxcq192+E2PU7XNcuBUw6knQUaClT6qoWfMV2cEGWduUvkWq k2QTKgq0U1e7yUrjEiI3Y6Gl5yhXfFprw4Wf5/nECiabF3akd7z2mq/8og5QaVeM3mF/5D10D a5+s9TdtgqSo2E9qjjneVosfwOk9Yy2out4jGGHEzG/IVTvO0IEQQqYltjbIgZLKIBWyDkZpc /HlovSjLZvmwSQ6ff/RQLGYptZ2zggaA6Uz6scduMpWZ8ptuBDEA5q1y+myCjQzyOgAtDKeWa xSTAN+Id6l5qJ50WjvupAuMzM5+iXCaw8Bx66JsmVrKqX3AdDJhVO5tmh5jxvZ4DfWnvW/YHG mEF3Xudho8pk7T5+jwNQ12ccZTABa8l0+KRLdm7FH+zA2FbJ9lQUbUUZK570OcBLp7Pn4QtDT 8WnpHeeItBKv/QtPVS5UG9eRQBjLKDkHdcCLOTMGiGfG3qk8mvKBredUp7nRXRtBPj8nLWfse GNMcc0ygsJHi/icN7/k/suV5EHZyk5zGaQsEh94OQSYDZeQkwvNAVjkZW74q4gTSCy3IducAC hy3nEU4r3YwZteHj4bZSh86mPUpKwmUF0/yDqyisVcJSppVuU8DRXU= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=VFuHxN0W; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.134 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Function is generic and just accept a list of scripts. Export it to let be called outside the install_images() function. Signed-off-by: Stefano Babic --- core/installer.c | 2 +- include/installer.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) -- 2.34.1 diff --git a/core/installer.c b/core/installer.c index 2b85a6e7..f2fbbcab 100644 --- a/core/installer.c +++ b/core/installer.c @@ -216,7 +216,7 @@ static int update_swupdate_vars(struct swupdate_cfg *cfg, const char *script) return ret; } -static int run_prepost_scripts(struct imglist *list, script_fn type) +int run_prepost_scripts(struct imglist *list, script_fn type) { int ret; struct img_type *img; diff --git a/include/installer.h b/include/installer.h index 613ecc71..aad77097 100644 --- a/include/installer.h +++ b/include/installer.h @@ -21,4 +21,5 @@ int install_single_image(struct img_type *img, bool dry_run); int install_from_file(const char *filename, bool check); int postupdate(struct swupdate_cfg *swcfg, const char *info); int preupdatecmd(struct swupdate_cfg *swcfg); +int run_prepost_scripts(struct imglist *list, script_fn type); void cleanup_files(struct swupdate_cfg *software); From patchwork Wed Feb 21 08:22:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1901897 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=p+gMmw0D; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::13e; helo=mail-lf1-x13e.google.com; envelope-from=swupdate+bncbaabbq7f22xamgqe35sp7hi@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lf1-x13e.google.com (mail-lf1-x13e.google.com [IPv6:2a00:1450:4864:20::13e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tfq5N0HpXz23l3 for ; Wed, 21 Feb 2024 19:22:31 +1100 (AEDT) Received: by mail-lf1-x13e.google.com with SMTP id 2adb3069b0e04-512b43132f4sf276074e87.0 for ; Wed, 21 Feb 2024 00:22:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708503748; cv=pass; d=google.com; s=arc-20160816; b=fNGDZQ03Hh28NjEAY7QixYKiGAooFda30uGzo5vYkXGoZYAcIdByfAxUVdvpmIdSSd h+qVvTosm2Y59oQV0XK3yGZx7vDZtWA+Q8VmKP7HaJltxzqYH37qDSS0jSFD5QJI0zaC 3bjV0lnJXK+0bKshmGjTGQPM0CLD4emvoGHpbXVkQ/azqTS/a1XBXGBkZm322E0ysS0y bUj5xhtV1wyB0G6SVddHGLiF6mtIyGhfNxlWItLv4bj+tzoUaHgOKztIRlVxPW9q9ruV IPEk/LVIWLgqmJH4NWRqQ+jEvY8WnBn2nam8EIhlDqnG0D6AjKpcHbravmD65chNtw8h f9Uw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=JELIIk9py8YRPDnooMi4aEIW/8ydpXhk/HgkllUfYkM=; fh=bORm+4fD+KHtOwqzYRgr7W1ms/QwBSkBWb9OYZ6AsYE=; b=Y4UOWZWxJiyj7x1nqBBYlLsoaUIt/BHaWSnraBRHhQCpZsgalJrJIwC2vBJB6OHc+c rjeveusxePKRQ8x3pF6QCT4E4tCiwS6KHy2DDK78f8KTH3yEf/c06Sjqkm47Q4xluwgE 7wyuunPyZ19APhWORNtHFZJtIqUgnCKlSxiNFPG2GIGFCnxcSqNqwbCiC6xaWA5u7vH2 HDURvEWNz9i7xfIZTk5mNX/ht9NogVBfS/Iua2h7KdkXoiL0akzqnrs4nrwp5KWrOZCh cWbZ3ryx/wmzHjTWAIF0ftQWC76spFmRee8Tp8nHo/9q9nQNc8fYmHR8BCmLJAwwS2Bv XIKg==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=ogMjpp6E; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.133 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1708503748; x=1709108548; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=JELIIk9py8YRPDnooMi4aEIW/8ydpXhk/HgkllUfYkM=; b=p+gMmw0DGnGszrBBjIJxTPADE0M4dOB6ahLv+6uB2A9rSWPQHPmifoVVZ3hxVZaA7K I+EfSO/xcGz80YqNa6FJCCMNydWyiM44dvkHh2LcoZYG5zfMWPHfWM5LUPUg7HUER6Pu p3uJ/DBtzu4kTuOyZHig1j+bhgC866bXEPrpeZRYQpTt5SdzOkTGXDX0543u0fHi9D/D +bsQ7ivDm9JGFsKxDpiCssrEQQHs7W516xPM7oGbqnw/hkt8o5ruWWAIIITJbv3PjwPr dOICQ2Hc7fExpHXmh87HYvxdY9ziNGbr/quI6pJJ0RW7V5KNuTR+yYQEUzzc9yTQF/dI 0tVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708503748; x=1709108548; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=JELIIk9py8YRPDnooMi4aEIW/8ydpXhk/HgkllUfYkM=; b=OKG3mPnouhpqrppSGRxWFnUFmETPUTyyDzgokbeDNqgF6hRt6cF49gY4QsJzymptC6 hRkeADv2xHXN8OlJZSvjajhHjCCuNQkQGrKU2mz7Hr5mrHYbk0NEsr3dd/sZTSE9dS9B aweojQ/UeiQRIZh2dqkd5gByU6LWmu84AVsnjd4pXIQhJft0cKrp5v7msFNkKhGqG+pD ILwCw7M3w3LjNUvI/uxOBxCnGwQdyeS0j8aoIfby/gjqLk/xK8kKXhD27HIpJUOdi/Wm CXuA5Y84eUSQunsmx2h9+7jhpfgVEw0xpnAGviJ0so0lPehagi6FShjERPJytKrWsPyS 5yXg== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCXG8UpmkGl5MBwzZTT36K6DeW5lxVKcSnKPvELxm9SwcZnyhsZtSP5QefH7S3YmqE0qibWZ2MvmyJqbE7RpFXV/AMZrC4oHri2+xkQQdA== X-Gm-Message-State: AOJu0YywQZZC8By6Q5zxfoiLqP8eZMFEvKoT4nOP+VPGa4Y0V8yweDK2 cLOLJjN1pVT6gOTX6xj9MQvDjT+96JGXbdF+crIxIvNymUGRaTmE X-Google-Smtp-Source: AGHT+IFs4N5mvV4ikH8SWARmliekVwt1fi5jvwVo9/IwMeXN5V7G+roYPjxexIAZ5vDJUKGBj0Fh/g== X-Received: by 2002:a05:6512:714:b0:512:9e56:7fda with SMTP id b20-20020a056512071400b005129e567fdamr6386888lfs.3.1708503747571; Wed, 21 Feb 2024 00:22:27 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:39ca:b0:512:d048:cb15 with SMTP id k10-20020a05651239ca00b00512d048cb15ls289663lfu.1.-pod-prod-09-eu; Wed, 21 Feb 2024 00:22:25 -0800 (PST) X-Received: by 2002:a2e:8290:0:b0:2d2:1fed:a679 with SMTP id y16-20020a2e8290000000b002d21feda679mr8258302ljg.7.1708503745574; Wed, 21 Feb 2024 00:22:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708503745; cv=none; d=google.com; s=arc-20160816; b=AUbfRSWNeVCtuEpJ2vN0wJeOKWoTsXHjMUTrVgzRY4ZH1J3QHo7nfD8oGWa1qkecrt 3+m26CA1VWBniW5eKf7BshgAmHWcY2hikHsWY18gsPiQ24MOHDggshzdp7PwveinXeD3 J12LdUV9VmYz0yLh8kl6k04PG4088+CkX/ZAR50zV/QMCwVqBBKVq4w/hYpH66BuNeOn hpkpiOxULVlEgVMo7W1vU/qNl+2NEe6tc6C4tjJkOa1Ut28cNWd8hVPtt5qbCfNY+b7M RUHsWIxy8wnRxt+7bGH/TcVjuTI7sAQDu9YFojJKvbljw0Ga17vIeTRhvIrJpQukDTsm CTSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=UsAdfwbrOq4kyjhaDAf5rK145I614uBkDEjeEyBNjts=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=SYXIw5aKuHlVJKyxVRElLQABLwFsgZ6YWVEzcGv5tWHWhIJneM6OjAEtZK6yZZwUPP Xvec/Ht0Lss7dbL/7+k/6p4tM33BLOPehalpu+czJbUm51RezNhpwmHPcfsFRr5izSK9 dlqEYGiB60L5OH0pSZc6RirmWMkmquuKV9V3QaPAXAfyVODl8+tAs6xvLPSoY93xp8J3 lE6lq7TBZueWpiHKxmkutghDgOzaQViJ0xLHovmZnkyNMv0YPnFwUZsGNd8TafAdKV4W hh3CZrK0UMx6TO6mlRZQ2R0vEQnvVqUOdJa0hu+G3EBhAoOlGRj/ujMHPN2wmdh6KTVm vTnw==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=ogMjpp6E; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.133 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.126.133]) by gmr-mx.google.com with ESMTPS id b24-20020a2e8958000000b002d230e90c7fsi405092ljk.5.2024.02.21.00.22.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 00:22:25 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.133 as permitted sender) client-ip=212.227.126.133; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue011 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MDQRy-1rkvLi3NOI-00AYNA; Wed, 21 Feb 2024 09:22:24 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 08/13] Introduce postfailure scripts Date: Wed, 21 Feb 2024 09:22:16 +0100 Message-Id: <20240221082221.11997-9-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240221082221.11997-1-stefano.babic@swupdate.org> References: <20240221082221.11997-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:I8IqnRZV76MCWEf5dyH+T3SVem5wh8DLwYzdETjYqxZmpliTjZF YqWXVOdj/4zgi/9UhP2C6cp4ODWXkyySVM9SJLjyJd/pVzPPRlPVPV8x8AjhSaHnqOWy3HZ tLkeNLD2P0DMuWIt7h72pLP6ScHggXD1FEd2NKsNRx1LVx7OjsFk09r0tiH51JgxBv5Mn6a D3LqfmjTTencOJyxWXomQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:C+xm8TVMBfA=;SMTZpT6DQ5Luwjey0iCUIEeln58 WR2WEFXMhComfdZEiCPs0MvXNIs9oUfykS4wnXyZL+cKXM5GtpC1drNZm6gxqxFWvglAwVj/9 Sc/PSX3PNO+BqglSLpwnJNRRbNBwQm77cRvWvfydR3RnQor69zJwQkh9BOOY921XWRF/B+KCn iAeepnlGuTaPjUWgSRwnnG776sbJ5WZJ0R872T/ym9nC4mBXIjXff25tMMZ7tyTYbpZ6CBpX8 M2e9ETdF5/8UM/SJKmewBT59FYJMnwnVBjCQAj2uqMP15lOGrVOAI/fMehnnWc/1wWK+4dVxu SmpiICrIBDiV/MSeYtn8EEpJ97ywTO9UBcT+8vUYnPYLe/vpN+8YtOTeNlHe0ngHz/Z4nYjd1 0XA9r2n02Fu0kE3aCI+08idRMn53Afx09rkb6zs0huHYgnkqcXsSn9pbCBIGDZyFMOGlbSoAD rafos7gVu14XL5TcvXsogi57a+/k3VL8OPaRlvPq6O5RT8gJCYQVcYurRrTuUm/EuKNpWQGgl Iob9NTKrsSD7Tbt/p//YMWjdDa1ra/WxglW/R0C5+7Yfv3B/Rc/OfPKOt1pHyyalyPA6s7ud5 je2Jj3JDp4nEjWCjthg/QR1TGDmRjAl7HRZtoyUMMmQgABEXwtZ/nC39br4ab+zB4CjHJeWKJ gtpTR0Kw7pbqD8IP+oQzr2KCvhSLqpWWlyzpIykpmeW54uLWbw24YmuHgL8c1RCksHv/5wVfW FHge+Ks0p7KY62yo6QxUZj9wbvYWqj+kBac1mALau8fHErB7o+mr4o= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=ogMjpp6E; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.133 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , These scripts run afet ran update fails. They can be used to restore the system to a previous state before the Update was initiated. All scripts will be executed, as it makes no sense to stop if one of them fails, because the update state is already FAILURE. Signed-off-by: Stefano Babic --- core/stream_interface.c | 13 +++++++++++++ doc/source/sw-description.rst | 20 +++++++++++++++++--- handlers/lua_scripthandler.c | 13 +++++++++++-- handlers/shell_scripthandler.c | 3 +++ 4 files changed, 44 insertions(+), 5 deletions(-) -- 2.34.1 diff --git a/core/stream_interface.c b/core/stream_interface.c index b9bce6d7..5ebaca68 100644 --- a/core/stream_interface.c +++ b/core/stream_interface.c @@ -674,6 +674,19 @@ void *network_initializer(void *data) update_transaction_state(software, STATE_FAILED); notify(FAILURE, RECOVERY_ERROR, ERRORLEVEL, "Installation failed !"); inst.last_install = FAILURE; + + /* + * Try to run all POSTFAILURE scripts, + * their result does not change the state that remains FAILURE + * Goal is to restore to the state before update was started + * if this is needed. This is a best case attempt, ERRORs + * are just logged. + */ + if (!software->parms.dry_run) { + if (run_prepost_scripts(&software->scripts, POSTFAILURE)) { + WARN("execute POST FAILURE scripts return error, ignoring.."); + } + } } else { /* * Clear the recovery variable to indicate to bootloader diff --git a/doc/source/sw-description.rst b/doc/source/sw-description.rst index b0363359..d4cb8971 100644 --- a/doc/source/sw-description.rst +++ b/doc/source/sw-description.rst @@ -759,7 +759,9 @@ with an error if the result is <> 0. They are copied into a temporary directory before execution and their name must be unique inside the same cpio archive. -If no type is given, SWUpdate default to "lua". +If no type is given, SWUpdate default to "lua". Please note that running a shell script +opens a set of different security issues, check also chapter "Best practise". + Lua ... @@ -790,12 +792,24 @@ called before installing the images. function postinst() + SWUpdate scans for all scripts and check for a postinst function. It is called after installing the images. +:: + + function postfailure() + +Only in case an update fails, SWUpdate scans for all scripts and check +for a postfailure function. This could be useful in case it is necessary +to restore a previous state, for example, in case the application was +stop, it should run again. + shellscript ........... +SWUpdate will run the binary shell "/bin/sh" to execute the script. + :: scripts: ( @@ -805,9 +819,9 @@ shellscript } ); -Shell scripts are called via system command. +Shell scripts are called by forking the process and running the shell as /bin/sh. SWUpdate scans for all scripts and calls them before and after installing -the images. SWUpdate passes 'preinst' or 'postinst' as first argument to +the images. SWUpdate passes 'preinst', 'postinst' or 'postfailure' as first argument to the script. If the data attribute is defined, its value is passed as the last argument(s) to the script. diff --git a/handlers/lua_scripthandler.c b/handlers/lua_scripthandler.c index 213099de..08479ef4 100644 --- a/handlers/lua_scripthandler.c +++ b/handlers/lua_scripthandler.c @@ -54,10 +54,19 @@ static int start_lua_script(struct img_type *img, void *data) switch (script_data->scriptfn) { case PREINSTALL: - fnname="preinst"; + fnname = dict_get_value(&img->properties, "preinstall"); + if (!fnname) + fnname="preinst"; break; case POSTINSTALL: - fnname="postinst"; + fnname = dict_get_value(&img->properties, "postinstall"); + if (!fnname) + fnname="postinst"; + break; + case POSTFAILURE: + fnname = dict_get_value(&img->properties, "postfailure"); + if (!fnname) + fnname="postfailure"; break; default: /* no error, simply no call */ diff --git a/handlers/shell_scripthandler.c b/handlers/shell_scripthandler.c index a85e8bb9..5602b98b 100644 --- a/handlers/shell_scripthandler.c +++ b/handlers/shell_scripthandler.c @@ -63,6 +63,9 @@ static int start_shell_script(struct img_type *img, void *data) case POSTINSTALL: fnname="postinst"; break; + case POSTFAILURE: + fnname="failure"; + break; default: /* no error, simply no call */ return 0; From patchwork Wed Feb 21 08:22:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1901889 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=egXVfTdp; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::53a; helo=mail-ed1-x53a.google.com; envelope-from=swupdate+bncbaabbqxf22xamgqewpny2jy@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-ed1-x53a.google.com (mail-ed1-x53a.google.com [IPv6:2a00:1450:4864:20::53a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tfq5M0j6nz23d6 for ; Wed, 21 Feb 2024 19:22:30 +1100 (AEDT) Received: by mail-ed1-x53a.google.com with SMTP id 4fb4d7f45d1cf-55fee28d93dsf3024496a12.2 for ; Wed, 21 Feb 2024 00:22:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708503747; cv=pass; d=google.com; s=arc-20160816; b=cj+10FYbiPJDBQOHQoMNEi1zH8RzFDS0gHli69FIDZfBW3sxTDTaN9Gj989FcYPEKg BZ2Ww/tcG2qUXZsoud3sM72+xLdO7vV8WlEJEnCTlklUUAVCHtGNwtzxX1ejqWDg2nLH kuGXOfmsT6gAeEGZwpR/hJSKF+tcIpW/FXGiL3VCHbq7y1WN0HXVwghCrdofI8AOkCDM tTRhVlcLKyh4+MA4ONUxwh0JhsbhhaUnGP4pbLnmooDsyXIzdMzA3JpXi5BA8x0TNh7B 6ylRl2zlwWu0wirO3i71G5QCKK9qMc/ZoVourkzS6cK1XbkkeNp/osCJ1gHGLU0s2u8t KErw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=PoMT3R9BX3zm6E68gCjq/AR8DGoGXLi3qflA3hn9d5c=; fh=W+MFsc32Kz6g25JRijxBwa/aGRGkOLgVTGK+lSqSOkI=; b=lvW3IPdf9roVuHcs1LeU9yvCvz6E8IBpddu2HxWFe//B6AlmJVvGVUEKPpeGDt8E7a +4hnac12v8Awo/ZsLSrbm5YCJRlM09Zhe9n68FyOeAgpCjYs2mJfQ3q5UJmqJjgTDDiG cjV3qL55ZMwEq22HqbXscrK0gwePzDTJCbubMwwRHTdUV1awPwvCchSvEFUjHASCX1sI JnexmVZyDIOgbgX2QQB4i2/cQBaMhO5zqbij8jojJ1a+JDDzhkY4tqwSPPttfEq0XWhI 7XiwuD2F2lRhgMsgj9MANvLtVeCwY7+gmVi3uxX2wLOx9kt5Ptr/mW41NiYzFvIk6FlE PCfA==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=UFgAzgk3; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.135 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1708503747; x=1709108547; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=PoMT3R9BX3zm6E68gCjq/AR8DGoGXLi3qflA3hn9d5c=; b=egXVfTdp1FFRggA9KBgPAgjZ1ZqHaPgZz20CtMKCJSjIA1RiyRLDL1WzmHVW27ZZRV MnyMWjZr5g8BEclc18RtrR6LCNM/v1L3FJJo0VYOqqQHxZkLg4EAwIgaxi0r62tJxav0 TiuZn+SUtIgb0mDYItMrawGzZ0BlvoDrJEVxo4nOClInD/04D6+jPA/82TNbgAZG2xKS LQG1aAcwlVlQtq/iIThIXTkO+QdUWPpGglrFYDCGYLXVlshDPiXJkMc9T7QucswcCO94 zEyM1tyvpPED3n7+hibc4050MXWs0Ty7s1NeQzFUUm+ueMtNwHJzwGMSXadDNHIRQ+oF 2EdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708503747; x=1709108547; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=PoMT3R9BX3zm6E68gCjq/AR8DGoGXLi3qflA3hn9d5c=; b=DVA683J7+gRURt+MtQCF+tC1h+vtVRwGGw2ilctOitaHVsAnO+eyoYStlyaML78ONu Fx5PIuibdkH1KIj2VjCfAZW+//6+A0COSxLe6nDDmN8dY7+nDZDLp33DKijllqQemLDJ GPNJwXRdyN3oHsR4XNyIHZWvmqCJq32+QOcIAefiv4ynX1n7pS66b4BY8MpJiupfu+Vm +LagqNHIG75Sdwq6kPu2xPhSLknAFH0LeRDrIaXy0m92D7kYmj7c17En/mHgUlqekWQ6 z5u/Mz57exz+WBkm8m3MBMzCO1V1QPBcgBodOh9DYfhy3CG8TDHmOzXDR1SoIGsDwW+g Qfvw== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCWGwOp2FVneh3B+CPNjGSPTKi/sb/kuAkdHLnR9mSx+JtQZ9/2FGhHSiPhfXlDV0EGHeNWHxiWxe968tmspQ7eKnu0xLBGk1i3NhGKFQA== X-Gm-Message-State: AOJu0YzXngQXtFas700U8/NYLyxwRxnjuJqO9Bpd2oxLGkU58TLteNAr tDY9qQ95TFRA9sh26BC/Kc56QTjSdtmNyszJZJXhNh/Br0PKtMH6 X-Google-Smtp-Source: AGHT+IFJz1cPbdU8+fA3Aj4s3SZVBgYGKv4kUmiipVbKVMLGF2iYRZyPm+nyVgqGv1rOcC2FjsF1rw== X-Received: by 2002:aa7:d382:0:b0:564:69be:6e86 with SMTP id x2-20020aa7d382000000b0056469be6e86mr6123646edq.0.1708503747350; Wed, 21 Feb 2024 00:22:27 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6402:5293:b0:561:2701:7e00 with SMTP id en19-20020a056402529300b0056127017e00ls113826edb.0.-pod-prod-03-eu; Wed, 21 Feb 2024 00:22:25 -0800 (PST) X-Received: by 2002:a05:6402:b39:b0:564:a9ca:d6d5 with SMTP id bo25-20020a0564020b3900b00564a9cad6d5mr3911744edb.11.1708503745376; Wed, 21 Feb 2024 00:22:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708503745; cv=none; d=google.com; s=arc-20160816; b=fn1XfsK1xyf7yZ3wSdOWoq3L/Oxr84p5/TJSm1LzFI76cgYVM5OR9zOOEjFZ+aKOuN DEQ5P8nLVAxqEtFCBn7s5Hmrr57PRn87ktl4DfArD+66yG4ElvM70gMyol790B8LtGJ9 0GYIsnGqUvq19jf7hzIMJiENExGRugzOGYE+5N4/fDI2C4IoUtc2jtLB8vAaYdUnTr2i DJ6BigrhH9GP2j5GkMOguF5snOvpuTjBPc2mTdAtzZNfOcQNeMs7odNohATenojdGmDR VPbkfRIVYRZf+xEab8gLBaBWod4e2W5QHx6R1f5e6FczGlvwckna1AkSlxnmnDrOi4xE bsnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=FA2HAx18aliocJLuEtCsnCZPpnogiNZu40yZCk3xFf4=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=HNhARu56so2XWHtY3uOaAZpQmIN9yRrSw4wfUolHdMPsHxtLYiYY7DEaonhX34NwaI gjzAyCbOZ52FLCWs/3oOv1Q+rFw361AwT6+gkSV/BEY6MGWmMbCpukpsy2yrY6cB8jQc drYlZ3Z9OrzSMWzQLmnHd/xf0kLkWz7gSubw9O6N4aIssmFMXHfop1vmZ4fqJzDTaZnx 8x0jWRGxOLMol9veWh1/NIbOnkoF2j3qM5y/H3topSpBN4vff10w91fgkr5po+EUIN7m R1Ha1FHsOwDaLHkgZG9WvmtNtq1/RBKntTleOwHdfmp3DLsdgRR5Mkd4yl8G30gT96g4 oG5w==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=UFgAzgk3; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.135 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.126.135]) by gmr-mx.google.com with ESMTPS id m20-20020a50d7d4000000b00563fcbe92aasi690734edj.0.2024.02.21.00.22.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 00:22:25 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.135 as permitted sender) client-ip=212.227.126.135; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue011 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MV5rK-1rTOSs3rVe-00S5Dw; Wed, 21 Feb 2024 09:22:25 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 09/13] Lua Script: TRACE the name of the called function Date: Wed, 21 Feb 2024 09:22:17 +0100 Message-Id: <20240221082221.11997-10-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240221082221.11997-1-stefano.babic@swupdate.org> References: <20240221082221.11997-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:hCzwDfQjtfVpB78bgvgYt9au6Xg1O1H//r4Qeyr3/+N6XW6o1yK ORaMmhxst5fSXDgGHL/boWnW0ssufW002vimkisvOo8dzL1bF3nGiFZNn37Zosk4pjg8JQd 3oR5jG5N+THWpitzeEALfBOgIQfSkq/4yLApz8zamfO2Jbmw/WztEmgo42SDOJyemH2tobU y074w8ZkwNPBgMRl7+DLw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:ZsOlIg0Rhu0=;B2HIrQoVFty1MbLYoDTtGlAKITB lYeXs5GiMH2ffmLg0jCmwlTeo8CUPF8PCuW0mClBP9pnefk3SY1kOYElaZW3tH++W2jlpyouG 89XmQ9RbDsDZgrW89BHw0JWl7GLEdLH2SkwXLCZGw8/7VPd4hg9LackmcnuP5S9j6AmC0Rh4H GWKkX6QZF2OX5F4MnEo41Xq22OfUkz4lk7biy5KD+E5fACGYpfG0KZUIyB3/GN7gnJzASVhQg pXdlbgH7qTBxHZlWVMvkADyh4uZFbKQOWkqqTKuujgxh9nyGYBkpWlkHhI6CvAs3zrXY7GiDn QixNIXLY6uj5fteNXH0VRCq4HWmAtVeGnsIObwCVSvaAeADlJ4iPoYQuV6j7CpV202ImxfXn2 CFEOS54/JvQSotcF3L3ZDojGsTmTh6M2DU3hzURsI1yOl+aCpKsBWESU923NrFAGVdhicWjVw 88zZu0Tb7WIwmsEEoVrnMwFt7wyeD+3xrfeXNJR1xaxacwocrrN5z9hpfS+G4AXdk4M3LSxri bY/24eMgx9Y7WoZp/tuDaVG6MIqw4D7L+2zJIE+VnsrwZq0y4U+J7Ki61X0swHzIhQrjGUDWy nL/qvT3oPF+h8qDtDfsh4LfT8EY8JAhC1mWYL64G2BnkOvSJ5oq2m/4+3POf9GusGxXIEBuEB Wpt7m4K505Jv/r4k06xI4huNgXSvfYCImpjDp240A/9GAcmr6iy8KYTPosaWVZr0GAa+2GYsN yrCSIDF92ESZ8jPjS7wsHA3RABjLCwawN98yCfq5znOb7PKsFrtZKY= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=UFgAzgk3; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.135 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Signed-off-by: Stefano Babic --- handlers/lua_scripthandler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.34.1 diff --git a/handlers/lua_scripthandler.c b/handlers/lua_scripthandler.c index 08479ef4..83440e81 100644 --- a/handlers/lua_scripthandler.c +++ b/handlers/lua_scripthandler.c @@ -75,7 +75,7 @@ static int start_lua_script(struct img_type *img, void *data) snprintf(filename, sizeof(filename), "%s%s", tmp, img->fname); - TRACE("Calling Lua %s", filename); + TRACE("Calling Lua %s with %s", filename, fnname); ret = run_lua_script(L, filename, fnname, img->type_data); From patchwork Wed Feb 21 08:22:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1901887 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=S+TLWRA5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::63f; helo=mail-ej1-x63f.google.com; envelope-from=swupdate+bncbaabbqxf22xamgqewpny2jy@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-ej1-x63f.google.com (mail-ej1-x63f.google.com [IPv6:2a00:1450:4864:20::63f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tfq5M01hZz20RF for ; Wed, 21 Feb 2024 19:22:30 +1100 (AEDT) Received: by mail-ej1-x63f.google.com with SMTP id a640c23a62f3a-a3f3c382ba9sf21370666b.2 for ; Wed, 21 Feb 2024 00:22:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708503747; cv=pass; d=google.com; s=arc-20160816; b=Xyjxbr0Rm60EhmAt57nSFwLmpsVPZhx8IySwIjumWcit/3S35kSLphAwaOD1Gwcg5F M3AStPmlhUigUgqhgOmT3QIdEBi8+/8AmboFjn3tQyABTmtT/klRdnQdYaXTxCWSO9uc Nq8eYQPPmifg/LM8uwwZmwAc8s+WSVyEJBCn4aRE++dAD+ntRFdxaMULFHcBn+LUYNV7 YhWRB6Si+gM6mAPylXNwKBRURFgiFp63R35Em0eR1DgM6aWXWgmY1i6EE+oZEuF40E3q so4vxkhM0ljAHh8cSlQbC2a9WqxIZxaNiCj7sSaRyhKLcD9rCtF3RHm305nnfUMYm8v5 VXBA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=MqsjraVN6EbWQhPsDpyms9ZAdh168x6QQZhZf2JGW+Y=; fh=Qy58wvZaopHRpLNZQ/jUkoU6AsXMPi5ZIrP75nxx0Ws=; b=Q+E5dQkd/C70LT3b1iu9G/8DZs3Vpwt6tGRq9kfPxfnPYhy6i/EmDAhophyrO1RNlz hO7b+XlCpIMaKXaIjEx4CGR4YuefJakxZzv3VEQ6bNrN11KWN4QOBUQRnups67g4RSZ6 GS4NctrRvFDQ4IVkpLXODjynh6Lb06IWIBLbxZjZIgRaaxz4ZSqYpukLQxYOjbqHAVx1 8DdbVHWrNC20JnDkQomEMihGE/Gld0k4kR1Ue3lL6+g4yINkFr2fFlyhkSM9H/ovw49L iCmGTjOQvKwNDsQKADjEcwhvApK9FkphBcLNlRb/qcSwzOMVdRfWdO/P1Bxyo6FXwdGF L6nw==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=e+0UpzY2; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.131 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1708503747; x=1709108547; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=MqsjraVN6EbWQhPsDpyms9ZAdh168x6QQZhZf2JGW+Y=; b=S+TLWRA5TeUg5BQcSv1q8m4U8XZAuLv9oBjhXLste5O2/LqYcrU2//lPQ/6rx8GuOT W1HrkxAtHRFINiaXX/L7cYA1jyM0VbMlbueDjf1las7zx/r40lHupnIQ2i3pT4ha1L9b PKxgTHoYrIZ16N5f39LSVT1oljG9o6uelXSRNeTJOGZlCTXDKCHxKJUHf/fp7VC2oTxa QWc5Bb132zoUx5u5lbtEqtd0lPfXJO5I2RYlYKyTbwdMyAkqflYgxaHhGL1la+kO6eaL /DRS/0Sdu40Bz68zU1oo2xlBuFJkYYRVWQFM/leWsw+Lomt3PDnC2+aslB4To4FFSUwy j2XA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708503747; x=1709108547; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=MqsjraVN6EbWQhPsDpyms9ZAdh168x6QQZhZf2JGW+Y=; b=dEZ+nA4OazML1XXuy4Y8lgN+VXKRz4p86L1EFOzQCDg6NUkkVcDWf13Gvntzcv+S35 9cjC9yqJ5YAPSetj7Hp9d/A4+hZZpJF25lB8tzLw1NarRAtiQ8ncFEOXa7mL3BbTRmf+ Sv+6Pbalb90QJHPawSDqsfo+NDanr0cpSa90UjFsA7TsU9d3EeYa5YZcpn1U/c3tAVQb Cu2XdnEXgC4a5R/0T58WYR4Z97W4sHW1j8daYbWcemifl0/OlTZ0ZjbEggh4Ot3iH03d 5WBWo/27OKoDbd2dLtUDbrDjNOdzIZztqQ/EBLO4wM6fqI/4Wzc7IND7lRX//tg+vGSk ZHgQ== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCWQ5CCXMRGP58E6XSngDCaHb0++3RyBOco80ytT98FtCq9cEzhEhcVnnIlspGvNEK52tnHg17XiofBfo483n7F72J0IKSdJYG7ElZ03bQ== X-Gm-Message-State: AOJu0YzEmRWKUoEq0vJkUBfC/nsd+qxujzo4ItbfyrS0M9uJ6oi/zdMG p0/Zr2XMnyP6+pTg3OQahfGMI9rH+VbKGKiznmy8h/z2teo21Sre X-Google-Smtp-Source: AGHT+IEvQHpRU+u2i9ak3yWUW4/Yb1BKCzMJ8DSVwhrIkXB+/25oeXSAOEVTO1yT5TaVeY4vTg2p9A== X-Received: by 2002:a17:906:b0d9:b0:a38:63d4:2273 with SMTP id bk25-20020a170906b0d900b00a3863d42273mr12445879ejb.35.1708503747101; Wed, 21 Feb 2024 00:22:27 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6402:4494:b0:564:84d0:f1cb with SMTP id er20-20020a056402449400b0056484d0f1cbls117524edb.0.-pod-prod-06-eu; Wed, 21 Feb 2024 00:22:25 -0800 (PST) X-Received: by 2002:a17:906:d285:b0:a3f:4b56:b9ab with SMTP id ay5-20020a170906d28500b00a3f4b56b9abmr388494ejb.8.1708503745534; Wed, 21 Feb 2024 00:22:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708503745; cv=none; d=google.com; s=arc-20160816; b=jRcT8/6CsqtLc5vElvYUFK6aUofAk0ef+undiSDSsVrZ6wGyiY5aJq0MiwCDFC9TbR Ls0LM+i+/8IxUUR5HlOSJstyjCCayhFdj25vBU6BX/e9zYzl5zZGwTOmKa6UWmgXeHJS XwyPZh+9CPH4Pr+7yQlRgUmLLlz/BIj0R3J/QWBxo2edNq+zITHvU8DxAAlvnKz6QyCD WufdiAatsqgJHs7FX7wfl0+TE/HVffYeSTOR9rCCpVqCf/qS4QEnfv2XHO23yTx7wach DDrUaQZg5yyvoiSboXlAo+EOZpfJSwgTpzjFYBiiUC0IQGCkJvUbk4QS9s4HMH/XFPbK Iy3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=h9zma5dTn1xIJiHsMtkg3SzTq6b1e4bpwbte5GZXOq4=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=l+P/YOgGHc5syMZ9UAY3q7jYegH8xvagKhitOpFzLrJkP9cE7kiGE0Qc8lvU5rg+Fu qtoqpXJzStf7Y+S8CRNUw5vKHonp69UVN7o3IsEXJQyaUJzDazVsvIR13H/5dUrsLWB6 xaO6bhPfVkdBA61eQwaXuznslIni4WxV8OpsPyj248Qub/6fPDM7/vc4hI+E3Vq7xYzv umFVs+l5+bO30dLPAVCAv8aL/2Deq2nrx9s4asYo3aibFtXdKnoNsyNvR1+Cz+fOABho dSCuGEBvyzqUyuqD3oBvv70guFbscioLHpHIHU7D+EpaB0zBJcsrb2Ig+97phDpr/8Uv nzVA==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=e+0UpzY2; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.131 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.126.131]) by gmr-mx.google.com with ESMTPS id p1-20020a05600c1d8100b0040ff8f0e6acsi55640wms.0.2024.02.21.00.22.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 00:22:25 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.131 as permitted sender) client-ip=212.227.126.131; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue011 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MeToK-1r2H7l0Kc0-00aVTK; Wed, 21 Feb 2024 09:22:25 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 10/13] run_lua_script: check input parms Date: Wed, 21 Feb 2024 09:22:18 +0100 Message-Id: <20240221082221.11997-11-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240221082221.11997-1-stefano.babic@swupdate.org> References: <20240221082221.11997-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:MK3d+UfLqYyx3wteZQrnZ+Io5W+p40aR/l/Yk0FRgWe9ybFomWR 2KFNefarvoVq9QJ0kqex+uttK99+XNPju8CnYovdF4q70P6GYSr3mb4RcMk04rDCR4XM7WL 7HUTGeGAwb29HL+TxnoPv54rc84auxwXYRf31HVDUvp0f63bDcMJJKAKX1VmvYR+Q0+d05s TefibmRmXBydNhyn1oXFA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:yW8ra3w74Y4=;K2KvSea8aowNZByMAcJ5B3VNQ5e 0hfehWPvt9XTIB7LVROMRK6DyAkb0uht2pr9OyUKO4dB8vs/nBR1zwyBliNKC0Gt22C3XAXD7 CvO0PxoOBg2UdeD9vCG/GvcD5vYtiA/c2k7s/H6hu2IFcq8H+yH1KaE8n0XdHxbPFSrUWRbtW 2G1TVf8WJJRH99iTRPPeWI2X5mtawLqVeCR6r7GnLrlAQM8XKyBDEYyyogMTDSAk232jFANm0 hrVD3UBMiNRl+8SlR72eTjl6/uXmR98PDEP/FYI9dR8ahpR0OEmnNELg/AKkvWfvq/AN7Zm+U cXMYN2mXowA4Hh2P5NpsF/IMDv7Ffw/4b/RY4mWyrfifx3HfNrK75g2Aq5BcL+eIKAWXrWtcb xjKHX1mvZFAlt4Yii2Arvvv3vyU+nn4kaLZ/jlIYPHjUnhLINYHwsRM6Xe0kwe3EJhmZHKhyn w1IL2wKDgbh3rzT+Y22uyuvu3rhHwNJY5ADWCRHTOwTk0KiPIZ6Al4KbdQpoq6wOOv0IlXVZZ rgc1spBmTs/tlW80voFtw1OxlVwMjsVkXw/Keh3yftYONDaPv1MvNIwR0J3d1bHJFZyGXOSLC FoyjbA/PiD9kQ9PaOt0otHy73ZQ8ZZqj9NBOFU0cyNjkEZs4bOjFB1jwFcVI6o6k4jRG/gjVY 1tN5naV9t3vK+S829ePno1uXOFGRJCPQqso4Qeg2JR4BqcpWHEecU5qTcO5nEvW6x0SxhPzz1 dC8Qx3ZFkz5rtrrWKvb5asS76JmXES+2MkEOQB7PUX4PRihWPvsqus= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=e+0UpzY2; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.131 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Moving the Lua state outside the function, parameters must be checked for consistency. Signed-off-by: Stefano Babic --- corelib/lua_interface.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) -- 2.34.1 diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index 72190383..78e27576 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -209,9 +209,14 @@ int run_lua_script(lua_State *L, const char *script, const char *function, char int ret; const char *output; - if (luaL_loadfile(L, script)) { - ERROR("ERROR loading %s", script); - return -1; + if (!function || !L) + return -EINVAL; + + if (script) { + if (luaL_loadfile(L, script)) { + ERROR("ERROR loading %s", script); + return -1; + } } ret = lua_pcall(L, 0, 0, 0); From patchwork Wed Feb 21 08:22:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1901894 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=XeqHRae+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::140; helo=mail-lf1-x140.google.com; envelope-from=swupdate+bncbaabbq7f22xamgqe35sp7hi@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lf1-x140.google.com (mail-lf1-x140.google.com [IPv6:2a00:1450:4864:20::140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tfq5M4YQTz23hw for ; Wed, 21 Feb 2024 19:22:31 +1100 (AEDT) Received: by mail-lf1-x140.google.com with SMTP id 2adb3069b0e04-512bde6ba39sf2428711e87.0 for ; Wed, 21 Feb 2024 00:22:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708503748; cv=pass; d=google.com; s=arc-20160816; b=fQy7HFJUFCT13L7Pc59uDvxWYguFuRJHITeviOaaS+sk6c7V5kAV5Wkg75L61ewDN5 NOU9vCATwFOJLlGRuDHcm453H9k1L1BeFTpTWBD1bxIQAbGd5VUEy8IjgYJAkgj0nwuw IMX2t2jekFi9ugEUNSV02kD1kJaJiKHlUXGWR3W5l6ioofY6q+WTlaJUgfsVI704SM3h 034XSW57YL0Um2Vn7kwfxFNnk0hubzcewtUT7pFBeqPNhl10fYo39PBGrca/UPrVDOAc femGQpl6EuefoFRn25i83T4IF1NLm5ef58/PThWIXbhMSdQlz9ruIMRDf2iTMQeJPHpb 5Pfg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=KlzdfbnHhFPceSyKy9hZe7I1SORLTS26qMdgwKJHbFE=; fh=Sunj1N57skZOa/kqe7r/hImvzLc1n8z/gzJOupGjXCw=; b=U5H2sZY9bgmSnhRng8RjZjGuBgWzqYKzup2jN1iwlfewWmCcPNejTyjXzi/8GVvgik Q1U3v0wZVNU9OrrMc9Q4Nm4XtRI4gwhIxbjdh95MFuquF51K1ic+lytl4PwQ5Li4dQ9u HtH3O/0CH+AoT5q8uh9S+ib3eQLm3cKR9C3G7+Rsbp9cFSe0FVqnioPHu2K/fvyl9VHc UB4jm2+2cR9qhutob4kBlhVSRZLbjezRCNCDkHwf2aEenS2ybKo/hdnzbnH394WN2cjj aCiJtwyidEoMvHFiljN3QnuK+1sHWcm5Be4X/bT++emAq0Zl/RMPWhjcOaGATVmISA1/ 0Sfg==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=m8se4137; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.187 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1708503748; x=1709108548; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=KlzdfbnHhFPceSyKy9hZe7I1SORLTS26qMdgwKJHbFE=; b=XeqHRae+IoLSSv5Us9RzIKV7xVWm5Vsa6kP6b4SExD4kKf2fVwVTRzu6yGygct4g2T wcrQZTT/36+ESdREGDK0TAGw+/HcEgEUkBM8QTpkU3/AVBoZmlHG8jJ34XvzEgG7tzPy ro7SS5VSfGwQZ0D4yUv5g3GIYc7+MK6gxqTaRFbyzGqB0bkSEz0C7uKfRiHD3M2jN4wj jUySLTFU70UiEt/xceJ4fHK6GEmlJ/se81wp8JsOoK7g0lCnGEpo4SsSuX9h09n4i2j9 H5O5/Au24idgpn4E/qUf3QJzpPwYbrS1feLrLomdpaHa37AJpxrWw9VFaz1z4WLFssuv PGKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708503748; x=1709108548; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=KlzdfbnHhFPceSyKy9hZe7I1SORLTS26qMdgwKJHbFE=; b=Gi0MvszPWXhbqrMUBnKQjWTfjefCjkzryqwx3YpFwAPO3y8bNmAGTLZQwJj5SITZhG ETmlW4NYNn9r0oc+uzAxuJiR6pWUIedC9VlCm1pvFklrZ/Lby/WE1Jd3fpNxYfnZTVe5 AnDU6uXGVicHbAhYk65MEtqul3zRcW0jk+aUF8ao4D6eUIg+UP+MZ7jcTF4d0dUQdGyZ Q1pLrkFdvK2cl/XyHX/8cjJQZSt9TbScP3FLQxKY/PZ6P7koMFV3pdCYFPqxCHsCsLEF 4X+5k/3EBvr/AbxKTG8KW9QPzxhdO7cfCYaNrkGeyJbSi32zVZrVcfjFzx7osnBzeVYu peCg== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCVHkGAhksatDkIfCuC44T3HptL2QTyxFy8lYLP539aGWLcHaztscbMF+IO5XzlBQndF8q8H6IzQr15g0MseYu7BdNiWTkTVYd0G8SRDIw== X-Gm-Message-State: AOJu0Yxm5qvHz2/3gNwdl1MAcn6fj9I5tWicKVUGrlbuHPRQCt2Flbk1 5rEO3VXxqRVdSPS6Yxza96jcCjpjUFZq5XJSCcIU9V9eYUQIB4ra X-Google-Smtp-Source: AGHT+IHblJrsNjrTeYMqMFE3PBVAVL0TJviiKVpob49o2KIjHNZMF8NARmZ2aHPVjbyNKq8fvpJgcw== X-Received: by 2002:a05:6512:31c5:b0:512:b773:2800 with SMTP id j5-20020a05651231c500b00512b7732800mr6129330lfe.34.1708503748059; Wed, 21 Feb 2024 00:22:28 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:3b07:b0:512:bda3:91c6 with SMTP id f7-20020a0565123b0700b00512bda391c6ls27262lfv.1.-pod-prod-08-eu; Wed, 21 Feb 2024 00:22:26 -0800 (PST) X-Received: by 2002:a19:7404:0:b0:512:9d0e:2ca5 with SMTP id v4-20020a197404000000b005129d0e2ca5mr7973470lfe.39.1708503745932; Wed, 21 Feb 2024 00:22:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708503745; cv=none; d=google.com; s=arc-20160816; b=H49kSRjx44fggyGFkmvchwc5Jbsxxf+ba/6WTleLAdotxqnXVmAOXnPA9s1RuM4RUS B1/Duj+ASvAIouB9lpWD0jdeHAl7nCpJwWmM7zDeAUQ9Ai/CRN2y2DsHOhqb76fBEIQn Gtb01QucClGt3GGNAXpIFt5VfO2XI70H9522GmLrkrZeA43RckKvC8PqNMIGrAo7GVSQ kJyf9vDgeGyTBq6DPS/Q15/ZUeE85CmCITwQBUIAxtdkByIKQ1Do0dIasEMpAU2UmoxD 3evQIouRuJ4dsltvGtLdXYm7Vcvk7sJ5YeLBXehdeLKmLUoRsGOp3yWHdkensgS1ySY4 ao9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=DXEkNzDKkIDEhwcekOQETtrRMk1DHGDxN9tVM3AAd6U=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=UkkizXeYgulZXT0I3nUOv4jZoGpSdfhmjCIOxjumQk5Ol+p/KacNkcZXopEBagQW1R dbbfmM7WloK4Jo8ytlkVuPsSi5mDqLFERRkaU/oIn5pnpvXtqGj6pO0/gMtaSG6jdFCh 5zlxrz7/Pb4nI9DfEgDkgXTNHXdrUvM/9YpliNws7CldERK5+8KvpBtrdlR6LL0LmJrI rFYEHpOUJqMXPOz2CbiPDa7OaRnA8ObvKom1Qb14PnDN4d16Z76ct8B8Egat69FlaGpa zrJiSQxNUAYzWT+mNW2M8Hk8ULsP0iirfXiPhtaoj3cooZq29DN+QFGcfX6knwuT07y9 CP+g==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=m8se4137; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.187 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.126.187]) by gmr-mx.google.com with ESMTPS id k21-20020ac24f15000000b00511a71805a8si466345lfr.8.2024.02.21.00.22.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 00:22:25 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.187 as permitted sender) client-ip=212.227.126.187; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue011 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MD9jV-1rlCKW0pDl-009BSd; Wed, 21 Feb 2024 09:22:25 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 11/13] Lua Script Handler: allows to run scripts globally Date: Wed, 21 Feb 2024 09:22:19 +0100 Message-Id: <20240221082221.11997-12-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240221082221.11997-1-stefano.babic@swupdate.org> References: <20240221082221.11997-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:Zl/IbtvW5fRFyZtPvXxSbFGjixxAcU3L9mcCmELcuoWjlsSWJpa xcbaAuI3FMo9kyDGU9V5D89/SjQIEEFvoogz+G8NwBSSlFmMuUX/8u/DXsnlfq7zT0L+ukx +Mn8LsLCXLSZ+QNIP4V5S0xitHCgoe07Ah5kJtQF3eDUvFM/xl/BDl7wMgdr123ETf18nqd IAawT/G05vIt+dY128f1A== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:xF9auli3NgM=;BL358p0rnh4JlXJjTcP1m6MIQCk jNkwPe/eNcLdSe1DLqnBms5wK7iEj81ykwURRbK5lLSvR1D0aU4dia1H/253MInkgDmREFr9m VVjlnmjdT18sTG++1dIRPj5OhHkAB2rsokWt9SywxeZQaZQeC7c9BD+BpRWrjhz1LFkwecebb QW2HZOzB/JbdknAIHqVPj1YTGKIEK6EXog1HdzPBVq97eJrvAN3ukkE9rs4+mrDhsKG+wd5Do X1htRBOcjfnE2dRALFhki4aCpS8nVctLcEYudiFuhKIhEyodXMT9u9YqPy+MVWZCDG09x8Mxf UCFUas7ojNP/duGEDrugJcVmzc8laGxwc/eXQOa4QuYM8fpo+9BOy+OCfJPPm6fUETfJrwk8W t37ARMhj5l5iKGXg3vHW+LLqqLe6+tHOHHGiXSJPcU8BNm1Ui4nTG/ziigvITiFECVe88aepF ZahQZ95bUkdvJ99jEOLsGa/ZOgzkIQl0FZLRt7FsTfX4edFt3x73PQR6ul8HLfHQxkVjcpM7n 5lWTGbkdFx9UEaoZpp00BWROg8tBHuM4sr+1pWO+Tp8oYgaz78PmqeGnsMQWsj4bLU3PuJzGe op9OknrdUuMmAKX/9PEwnDEuOovEzuGBFJlae7ZV6eUDEaEiSk5rKQKvbbx4EjX8n8Qw8/vJ1 ae2bzgNQs5JiEq1pXRbagN/rofOeHaDR4LJGZLuAE/+TBjOECaVK/a4YMNXvOYbK+WDSYd7of /sXUGJMqNif6zAeU7dHbmeUkjFLY7iZZrusQV3m5+JWt68o5Pp2e1A= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=m8se4137; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.187 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Up now, scripts have run in isolated context: SWUpdate allocates a new Lua state, and import the basic libraries before loading the script. A script is then isolated, but it cannot access to function already loaded, or it is not possible to reuse functions from 2 or more scripts. With the introduction of a per installation Lua state, Lua scripts can call functions already defined in previous scripts, or defined in sw-description. Because when a script is loaded, it could overwrite existing functions with the same name, it was decided that functions in scripts must be unique, that is each function should be declared just once during an installation process. This means that for global state, sw-description should contain the name of the function for each step (pre- , postinstall or postfailure) that should be called: the names preinst, postinst and postfailure are still valid in case the script runs with isolated state. This allows also to load a script without executing if no functions are defined, and functions in the script can be called by later scripts. Note that the handler will load the script in case of global state just once during the "preinstall" call. Later, it is assumed that functions will be already available. Signed-off-by: Stefano Babic --- corelib/lua_interface.c | 26 ++++++---- handlers/lua_scripthandler.c | 95 +++++++++++++++++++++++++++--------- include/lua_util.h | 2 +- 3 files changed, 90 insertions(+), 33 deletions(-) -- 2.34.1 diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index 78e27576..747cd96b 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -204,27 +204,35 @@ static void lua_report_exception(lua_State *L) } while (*s++); } -int run_lua_script(lua_State *L, const char *script, const char *function, char *parms) +int run_lua_script(lua_State *L, const char *script, bool load, const char *function, char *parms) { int ret; const char *output; - if (!function || !L) + if (!L) { + ERROR("Lua script must be executed, but no valid Lua state was set"); return -EINVAL; + } - if (script) { + if (load) { + TRACE("Loading Lua %s script", script); if (luaL_loadfile(L, script)) { ERROR("ERROR loading %s", script); return -1; } + + ret = lua_pcall(L, 0, 0, 0); + if (ret) { + LUAstackDump(L); + ERROR("ERROR preparing Lua script %s %d", + script, ret); + return -1; + } } - ret = lua_pcall(L, 0, 0, 0); - if (ret) { - LUAstackDump(L); - ERROR("ERROR preparing Lua script %s %d", - script, ret); - return -1; + if (!function) { + WARN("Script was loaded, no function was set to be executed !"); + return 0; } lua_getglobal(L, function); diff --git a/handlers/lua_scripthandler.c b/handlers/lua_scripthandler.c index 83440e81..009c0557 100644 --- a/handlers/lua_scripthandler.c +++ b/handlers/lua_scripthandler.c @@ -24,10 +24,21 @@ static void lua_handler(void); +struct fn_names { + const char *property_name; /* Name of property in sw-description */ + const char *def_fn; /* Default name function if property is not set */ +}; + +const struct fn_names fn_property_names[] = { + [PREINSTALL] = {"preinstall", "preinst"}, + [POSTINSTALL] = {"postinstall", "postinst"}, + [POSTFAILURE] = {"postfailure", "postfailure"} +}; + static int start_lua_script(struct img_type *img, void *data) { int ret; - const char *fnname; + const char *fnname = NULL; struct script_handler_data *script_data; lua_State *L; const char* tmp = get_tmpdirscripts(); @@ -36,8 +47,29 @@ static int start_lua_script(struct img_type *img, void *data) if (!data) return -1; + script_data = data; + + /* + * A little paranoid, thios shouln't happen + */ + if (script_data->scriptfn < PREINSTALL || script_data->scriptfn > POSTFAILURE) + return -EINVAL; + bool global = strtobool(dict_get_value(&img->properties, "global-state")); + /* + * Note: if global is set, functions should be unique + * The name of function should be set inside the script + */ + fnname = dict_get_value(&img->properties, fn_property_names[script_data->scriptfn].property_name); + + if (!fnname && !global) { + fnname = fn_property_names[script_data->scriptfn].def_fn; + } + + /* + * Assign the Lua state + */ if (global) { TRACE("Executing with global state"); L = img->L; @@ -50,34 +82,51 @@ static int start_lua_script(struct img_type *img, void *data) return -1; } - script_data = data; + /* + * In case of global, loads the script just once. Check if a function is already + * present. An Overwrite is excluded by design. All functions should be unique. + */ - switch (script_data->scriptfn) { - case PREINSTALL: - fnname = dict_get_value(&img->properties, "preinstall"); - if (!fnname) - fnname="preinst"; - break; - case POSTINSTALL: - fnname = dict_get_value(&img->properties, "postinstall"); - if (!fnname) - fnname="postinst"; - break; - case POSTFAILURE: - fnname = dict_get_value(&img->properties, "postfailure"); - if (!fnname) - fnname="postfailure"; - break; - default: - /* no error, simply no call */ - return 0; + bool load_script = true; + + if (global) { + if (script_data->scriptfn == PREINSTALL) { + for (int i = PREINSTALL; i <= POSTINSTALL; i++) { + const char *fn = fn_property_names[script_data->scriptfn].property_name; + if (!fn) + continue; + lua_getglobal(L, fn); + if(lua_isfunction(L,lua_gettop(L))) { + ERROR("Function %s already defined, functions must be unique", fn); + return -1; + } + } + } else { + /* + * Script was already loaded, skip it + */ + load_script = false; + } } + /* + * Trace what should be done + */ snprintf(filename, sizeof(filename), "%s%s", tmp, img->fname); - TRACE("Calling Lua %s with %s", filename, fnname); + TRACE("%s: Calling Lua %s with %s", + fn_property_names[script_data->scriptfn].property_name, + filename, + fnname ? fnname : "no function, just loaded"); + + /* + * In case no function is selected and we run in global, + * script was already loaded and there is nothing to do + */ + if (global && !fnname && !load_script) + return 0; - ret = run_lua_script(L, filename, fnname, img->type_data); + ret = run_lua_script(L, filename, load_script, fnname, img->type_data); if (!global) lua_close(L); diff --git a/include/lua_util.h b/include/lua_util.h index ff603b5c..7b34eb89 100644 --- a/include/lua_util.h +++ b/include/lua_util.h @@ -20,7 +20,7 @@ typedef enum { } root_dev_type; void LUAstackDump (lua_State *L); -int run_lua_script(lua_State *L, const char *script, const char *function, char *parms); +int run_lua_script(lua_State *L, const char *script, bool load, const char *function, char *parms); lua_State *lua_init(struct dict *bootenv); int lua_load_buffer(lua_State *L, const char *buf); int lua_parser_fn(lua_State *L, const char *fcn, struct img_type *img); From patchwork Wed Feb 21 08:22:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1901895 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=AYtCbd/q; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::63a; helo=mail-ej1-x63a.google.com; envelope-from=swupdate+bncbaabbq7f22xamgqe35sp7hi@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-ej1-x63a.google.com (mail-ej1-x63a.google.com [IPv6:2a00:1450:4864:20::63a]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tfq5M6S1pz23l0 for ; Wed, 21 Feb 2024 19:22:31 +1100 (AEDT) Received: by mail-ej1-x63a.google.com with SMTP id a640c23a62f3a-a2b6c2a5fddsf423055066b.1 for ; Wed, 21 Feb 2024 00:22:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708503748; cv=pass; d=google.com; s=arc-20160816; b=SSrAQaAnpWyKSX+zKbIfRcRPQPhvRuuc5iQ5Js4Gg7Q66xVG0w/osijPVzzPw3B2Ln NXkmw8gLSgUFvcvukdJeiH6wslWRp7HmxFG4dBhZnis/PfhDmt1QNpMNGQ3b8GKTwxG+ aWHg6UFLYNgc7AAV43u6PwrwlG79xwSJiVW4cqKya/rkxO9mnl5ipLI0lqLJVcPOCz2q bOqJn2PRAEdbOnh25WEYfExUfC25kTnAmyseT0q3nSul4qy6I1Hk/no1Mariu1qby3Cx A4Fe2hMgA6Z4aTkuqfddA0rU2vIIfkutZRDPvJ+2UtdS2VyTFl3rv3TVaOTu/V6XizQz iDqg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=CVAowEz/yuMjTFbzYh5/ZLa56QYTyepZ8ScbSbeB+xY=; fh=f98PhOZ9MAOwkQ0frCtLaJO62PtH7frSltCcn+HKI4o=; b=Wz5nFOQFVfwchWAYY+eEWAJlLRtHaSaD/ddaUcBlfhg5c14R7/BuugYPUCNs2tVLXl NpX16sQV8n7W7fpU/Ra3fOjKQwrIjLLggRU82v8uvlKoxWQWgMNam5qTLS3ZwZUzMl2n jvi7W1PjNN96ObnccgWhRetdvzXIkvouEVmYzYIuQRBLVP8XfRzz36VXU7pm7/HF/sbH 1FryYKi4zGn7C/vIUxdCsDRAMqv9wyKo3JIzMR0mGXVFZOKFxrbu4w1gxHBqBY2WmP9O qdYuKFDvnWXz+lslAQ0OJLK7F8lT1QGNzHJXOOpDHLCKgvuJs1LczArLXPB9wLWtff2G zZLw==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=yjwHw7dV; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.131 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1708503748; x=1709108548; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=CVAowEz/yuMjTFbzYh5/ZLa56QYTyepZ8ScbSbeB+xY=; b=AYtCbd/qc//BwwogKaw1xhdVVmndY5X44Gt85hygnvd2oebFwTIJSIt/xciXXXEaDH +HygEejC3Rtiba3LQNkl/OwgIs7ZLAaLqvA6PkXns8EQWKWdYaIHebWDUkfN+bWfGnSI zMNbiKm4DAkHiE8jixI2e2VoRrYe2iwtZxz9ywKZ3R20aiDeI+Ab5VVNTIByhTSNeoPv AYxzUUZtjnBOa/0X5zenVOR8TcRTcRkXvKSw9hFENlHdN4DKFxK+1ayDenaHO6nOwe66 XE8+YElH5jEYjKlr7bMI+grqaarMBuzDT+GV+27vfzCJOyX+omlmCOj43HzVYXqaaVTw B8jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708503748; x=1709108548; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=CVAowEz/yuMjTFbzYh5/ZLa56QYTyepZ8ScbSbeB+xY=; b=wpsWt2XPEietmqnezOOniEys9O92UMqO9ksgftcw7HS1qOLWPFvF+GlkPGmyr1RZ2K dctENFX5qat/2omZHz+uESI7cbdSQ8+NhInL5jxULx3IOP3zBzeF7GWidotqNYBQJC02 3lGs9JxiKmgCGx7bi6sMbUiiaUc9aiKfZe4daz9g+aE2jMwSgR3kWhG8Z1CejW7uoawu potdNQu7ASKx32JWk9+Ocdfp1UWRa581Xty0fbUNpb2VkF1pqma+t0e80Q/XRiU6sX73 iiPfcezfzaqz9lliRE9Kwd7YjLh5OnR1z9bVvWQPt8yw3NYZW83OnhnwxGu9aB1oN5Yp +asw== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCW0+PT2+lfV2j3aeZ52SwqmzE9axcMMwyjWCr7Wr6DKc2+D4vsLtOux3jM+0cZyD/vXn1kAHwonscV8weTHgKHUyGUGN95Vx2Vq0D1/2g== X-Gm-Message-State: AOJu0Yy7KNYW041XsUYsa5w+r6UHFllStvcjVZ+2EPlqumgoF6X0hv4o /e2uySLwifStDSN24JfZlgD5vlZsGFY4RHTFvzRqV5sT7jSzlKzD X-Google-Smtp-Source: AGHT+IEwfY4GS6C+/UdHbuE7v3l2g1q/fW7TFdmHcW3xsHMs4+XtHMjqYuYgkOicp2yUTsq4LCirog== X-Received: by 2002:aa7:cad4:0:b0:564:5f40:e11a with SMTP id l20-20020aa7cad4000000b005645f40e11amr6686646edt.16.1708503747536; Wed, 21 Feb 2024 00:22:27 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6402:5293:b0:561:2701:7e02 with SMTP id en19-20020a056402529300b0056127017e02ls956599edb.0.-pod-prod-07-eu; Wed, 21 Feb 2024 00:22:26 -0800 (PST) X-Received: by 2002:a05:6402:3457:b0:564:a62e:dad with SMTP id l23-20020a056402345700b00564a62e0dadmr4466656edc.34.1708503745791; Wed, 21 Feb 2024 00:22:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708503745; cv=none; d=google.com; s=arc-20160816; b=mVzlZdLCe3KMb5LxK8fDwtFqpSvbMxfZjCGXBe32kiW4i0qed3JRwg+N19rXgJXo44 3geeC/29qlhEpppgu9dmVyI6oPJlu97ONIrL5BNLuPLHeWNSmsPH3izf5z/INNiqrqLW +iE9hrt04bDgqqI2RwFt4G1ejbymFTsFYDOmkYZDnLGcWFwgFwcgqbj+0TknkuObuUmQ XEh8nCqFMeM9oTixjTYhWXIXPPP80sMG7tEjPUjfDrS4HpVaM6OV+LeZK/h8TuZNcRcL oxfRAPi9P0Lm5fWjVTGNSoyMvnZVen2S6XFH9ZQf1Z4KHX6sdGZgafjmGcjLd30YfuZk jYCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=N4Fk12mSL1boQ5SZkymm2gDhBtTRxq/GhTgTXSWtP14=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=drTcebOi3Jtx5n8NysU4hV0FlaSjFDhiIWnABPoRdAzLFCGYRS+8OyyjDPrGJLw1vX wLKQOugMk9/Wam3epoARxT930fARAdQ8syeZnt0PxJoaCf+vEpG8Q3kgg6yxWcOIuDfV QNfU8e/LSyogVle/Bew8hfOxwlOYMyORW2XyU+dz112/2GR6llDZ0eWxBrYcKualkGip 8sqEMi+izkwwCe75/rwMzqx9tBm/RP5vwXDUN1NqsCqx0mWFUk+dX5wcoyTEt7QMNpTK IFCHgpv1mOYiuWY3URKcadbCdKFl/ev/WyieWgRC6IjOymHfa1cFRBfV+jrPe4KNyKG+ uyZw==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=yjwHw7dV; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.131 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.126.131]) by gmr-mx.google.com with ESMTPS id bl5-20020a056402210500b00564647bdc98si209626edb.1.2024.02.21.00.22.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 00:22:25 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.131 as permitted sender) client-ip=212.227.126.131; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue011 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MF3Y8-1rjGOX1Jvc-00FXFS; Wed, 21 Feb 2024 09:22:25 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 12/13] doc: explain Lua and shell script handlers Date: Wed, 21 Feb 2024 09:22:20 +0100 Message-Id: <20240221082221.11997-13-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240221082221.11997-1-stefano.babic@swupdate.org> References: <20240221082221.11997-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:H1g/QBIvYHzZ0PJJrpNSZthFQ//F9g4BWbsaOfXgALhLlpXVQLO hRXjTO+HTh+oniRu9Itb7wmC6YjKDMhNbXPVclgaWtCqDR/6d/d86cc1CNXtipmK/ho50+R f8qhjKW/Vr4zGTd3SA4SI3Y/MRdx04lwq2xWoJLwp5NcZfIAC3TMjR66EXZvk/M2os0g/fq I/ijOfwOgdvsfQjEcoq0g== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:6IU1mLCs7kI=;2Cp06qh3oDyMKAike3nSQgTErA+ ORjPNbfsOWE9mRAzMAVHfWb4CMuf+WUZeb1XYM+rjvVJskMFMmaVqhdvGNMwtOvKxuQhy/btB AZ+l16bYtkk7/fjrs4dlPm1jb+CTGHUpPlZSUEgkZFnLsjXVqyEv88Jnjh9QVJGT9MhUTbdkJ avrmIdNdjSPGo5sPxjr3nntzAnjy4WpH0Yc5si60dN362v+fZg2yM147F/vJbeVmPE7FS7PQB XWJrPVEoMiBjv+PilpMWC3zfJoaGMjxZzUadbBBN6puqmFeXzA5M2DHMU+72o6uMB3X7WepTC e/G5Uk0lowJh5ccuExLE8Z1jk54TVZVWR5DS2nahqjrhxWk9JdkN6DVBJGb0EWY7NOk8wLTkV qCWO1oWgWPeEnRjRJG4VaD/EHCklsMsftvmlMPxgUbjUNZgaPaSg8eYkOUnA9Ra0gvYegDoa7 8UXBYv0l4HweKH1PWakyGrFlaNhOsh8rxtog9EsVpLJDdb8ryOssL/u7hKFfUHiv54/SO8ZCh jcwQ1+Tl5U+oTnbn2L1uscy+hjsCY/jgYwFFnNKtGo5szb8AgdxExbUvMDqxELyFJOzQKCBDT YYZypDC09oIHf28Y3T41wAHVpIxWzJEw/w1HTxiCjsQ1/p965xprWEczBIDJ4G/InbjlwHxKD LU82FQQQLDxaR3pDMx5e3is9l2ADIpDdJTBPYMjWu6zWhsmoVY7HY8gMABq5snQ7rrs5ZBFxr R7vrejQDznwjEW1GPYVYlmeDisASDSicRZQMI7aYDdUBne1Bt+9pxA= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=yjwHw7dV; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.131 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Signed-off-by: Stefano Babic --- doc/source/handlers.rst | 86 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 82 insertions(+), 4 deletions(-) -- 2.34.1 diff --git a/doc/source/handlers.rst b/doc/source/handlers.rst index 1a1988f0..da0bbeb8 100644 --- a/doc/source/handlers.rst +++ b/doc/source/handlers.rst @@ -457,6 +457,84 @@ image, this is not implemented as it carries some security implications since the behavior of SWUpdate is changed dynamically. +Shell script handler +-------------------- + +This handler allows to run a shell script thta is packed into the SWU. Please note +that running a shell script opens a set of different security issues. Shell scripts +are supported due to their large acceptance, but you should prefer Lua Scripts. + +SWUpdate will run the binary shell "/bin/sh" to execute the script. + +Lua script handler +------------------ + +A Lua Script handler runs a script in Lua language. There are two possible ways to run the +script: + + - local: the script runs in own (isolated) Lua state that is created for the script. + The script has access only to function defined inside the script or functions + provided by external libraries, like the internal swupdate library called via + "require(swupdate)". + - global: SWUpdate create a Lua state at the beginning of an Update and this is + valid until the update is terminated. In this case, the script has access to any function + and structure that was defined during the update. For example, a function + can be defined inside sw-description, and the script can call it. + +As default, each script runs in isolated / local Lua state. If the property "global-state" is set, +then the common LUa state used for each Update transaction is taken. + +Scripts ran in isolated context in previous versions. SWUpdate allocates a new +Lua state, and import the basic libraries before loading the script. A +script is then isolated, but it cannot access to function already +loaded, or it is not possible to reuse functions from 2 or more scripts. + +With the introduction of a per installation Lua state, Lua scripts can +call functions already defined in previous scripts, or defined in +sw-description. Because when a script is loaded, existing functions with the same name are overwritten, +it was decided that functions in scripts must be unique, that is each function should be declared just +once during an installation process. + +This means that for global state, sw-description should contain the name of the function for each step +(pre- , postinstall or postfailure) that should be called: the names preinst, postinst and postfailure are +still valid in case the script runs with isolated state. + +This allows also to load a script without executing if no functions are defined, and functions in the script +can be called by later scripts. + +Note that the handler will load the script in case of global state just once during the "preinstall" call. +Later, it is assumed that functions will be already available. + + +Example: + +:: + + scripts: ( + { + filename = "testscript.lua"; + type = "lua"; + properties: { + global-state = "true"; + preinstall = "pretest1"; + } + }, + { + filename = "test2script.lua"; + type = "lua"; + properties: { + global-state = "true"; + postinstall = "posttest2"; + postfailure = "failure"; + } + } + +Two scripts are defined. Both are using the global Lua state. +Functions in test2script can find and run functions defined in testscript.lua, +because both are belonging to the same context. When preinstall scripts are called, only the function +"pretest1" from the first script is called, because no function name is defined for this step with +the following scripts. + Remote handler -------------- @@ -1326,7 +1404,7 @@ passed to the daemon: Docker Remove Image ------------------- -It is implemented as script (post install). +It is implemented as script (post install). Example: :: @@ -1341,7 +1419,7 @@ Example: Docker Delete Unused Images --------------------------- -It is implemented as script (post install). +It is implemented as script (post install). Example: :: @@ -1386,7 +1464,7 @@ Creating the container can be done in sw-description with: Docker Remove Container ----------------------- -It is implemented as script (post install). +It is implemented as script (post install). Example: :: @@ -1411,7 +1489,7 @@ Examples: name = "helloworld"; }; }); - + :: scripts: ( { From patchwork Wed Feb 21 08:22:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1901896 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20230601 header.b=G46m2IOI; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::53b; helo=mail-ed1-x53b.google.com; envelope-from=swupdate+bncbaabbq7f22xamgqe35sp7hi@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-ed1-x53b.google.com (mail-ed1-x53b.google.com [IPv6:2a00:1450:4864:20::53b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tfq5N0FC7z23l2 for ; Wed, 21 Feb 2024 19:22:31 +1100 (AEDT) Received: by mail-ed1-x53b.google.com with SMTP id 4fb4d7f45d1cf-563df53b566sf2817675a12.2 for ; Wed, 21 Feb 2024 00:22:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708503748; cv=pass; d=google.com; s=arc-20160816; b=RPwHfpd7akF2MHYohYvw0FE9yNuxOFo0GT9yuqu0o54OvPrxdwiMaw8zbOXt4o9rZb Bv7+VocNciAQ3DlMYiGbogmGAhFDLHlLdYZHZAIC7FAotdsFYJed/je7ZpW6SbQQa9Nx 3P6MZ7FNvFkr5ChExy18KR+9cE4LY4w84GLE740KY0kDvoNnTztehaZ0p7KyjUK8yFOv 7UXivzZ6EBDa5fRtc9ODFwdPOA4GqTJ4H75dYC2QLkyNAWDVMMwc6tXS6Q3CZ1sgX720 /DMy4tDPLp6V6AToMGAfZXC8FcydEpfrx0I6uKSnhkWSDlh/OGgZdFk19KmIa6GnxR4t nHRA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:ui-outboundreport:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=EjZv+sZErwk3EN1DRqkfntuKX2MneJxXFGdhFvzwjr8=; fh=AChex0vxhShVZXxw17q3qITk/FLmOHdMnGVglkOpkjg=; b=unbQyYavjk8fqHKtQpPwrvhc/zidzHWup1VxFsBve106v+qnPolvK7o0yCZGugxShF dEtIVCSXOKKGImpf4nLvMcTyyGVKI7VzBBN+iKrbOOr7n5cNSsD6XiHeNOQqsafUsqLl anRwFlF/JF7jiK80SXdDAXolxyqH/Vj9faz/BdeymLfu3RHASOEgzKdgzgFUSKol52T9 4cI6e0qbdFynySne3mI7WyvYWXYKsBANh3XMS+Iblja41ka9Wn7FC9iQU/SftQbzzUK2 1cLwdRHM07KJsJxG/HzPW4K5niH97LUMmqXARX++kIZSB/octUqacBIpyeHXiq/BB8Y1 Nusg==; darn=patchwork.ozlabs.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=FaZnHGw3; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.187 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1708503748; x=1709108548; darn=patchwork.ozlabs.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:ui-outboundreport:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:sender:from:to:cc :subject:date:message-id:reply-to; bh=EjZv+sZErwk3EN1DRqkfntuKX2MneJxXFGdhFvzwjr8=; b=G46m2IOIPW1Dh4VNkRrmUE6oxe/T6HM/C7nUXt+MNc33AEKVDcV/FGD7QuAjW7w/fr eQMnIMn8ZloC8wUfaBYxh/h6LhI0taQO4N3PqUNfibS0OZzsX83uzKrRO74Z6IxbtQ/4 k9JovxPZGiFeVwB1MRVO60I5Wr8L6hLGnQ8b9pgpaLSOj0y10HZ1iz0JjZRnRZ8zeJ6y zGhASpVfqWLCXqJfNqLKyJgiu48nuMgE3sgqLc6S6ravismMD0cIC5C+9b3Q4Eg1Ytw5 Cd/zEvTLXhX9C0DIMn1fSYGvPoNUDqC800JB3cBhcujXYv6rW7KaHh6ueX0njPaGluZp /meA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708503748; x=1709108548; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender :ui-outboundreport:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:x-beenthere:x-gm-message-state:sender:from :to:cc:subject:date:message-id:reply-to; bh=EjZv+sZErwk3EN1DRqkfntuKX2MneJxXFGdhFvzwjr8=; b=rX6KrCXOhSKy5VxX9k3ikHJ4XZwPRdF0RkPhVkuQ90kIEn8sKQ9kq2VKXZ/+i3mzEg fQWEr8DhiZZ1BoPX0xgVqI5d2wsSY9KlCoXfNp6OxIXz9OZINVSLUiMGo1Sor8PNXFCq MfUhNHbRQvpLmm6Ae4OguqmW11BEdCcK+CR4GFhpJ6XJueD3k66kFglJBs20pw4QKtXR Cn1isqq4H2K6iTdZSJku9jgo1/ex0T9aEkaC3g6C8DmPf/pAIvylvmFMch7ZvGbF0w4X DY3ha4qbGk8kjaMUTl0WNFjtZDqTWMek/J2OZ66RFab44DrKAqS9ozID9+q6SF+GxHwg irZw== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCUJ6Swzaptu+7Jo14t9JMo4gO38T6XGxavpvTWLpbWh+p4jXnsqZZoQ3hCLI+B5lGs0yB2lsC1Muj1cC+IcBi6Vq0K8FuM6nsfKAw1Yog== X-Gm-Message-State: AOJu0YxZDnOaWO9ZWtRpD/zDjEsl7F+Uron5WVz2CzIFWov+wz/cXiXU M4hea8T7Y1cYoJ8/cVa91IOlTuKQWoSUdx2YvtjUuMiqSicOX9/5 X-Google-Smtp-Source: AGHT+IHQQgY0MLwct02sZv8Yd+Bxmy1oKddiZuxT1gKaszghAuT8LEyASSpmt0wQr+rSsSuILMNxsw== X-Received: by 2002:aa7:c2d5:0:b0:565:813:b39e with SMTP id m21-20020aa7c2d5000000b005650813b39emr296969edp.40.1708503747796; Wed, 21 Feb 2024 00:22:27 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6402:3811:b0:563:7f13:d25b with SMTP id es17-20020a056402381100b005637f13d25bls549343edb.1.-pod-prod-09-eu; Wed, 21 Feb 2024 00:22:26 -0800 (PST) X-Received: by 2002:a05:6402:430a:b0:564:f9e1:5864 with SMTP id m10-20020a056402430a00b00564f9e15864mr811072edc.42.1708503746010; Wed, 21 Feb 2024 00:22:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1708503745; cv=none; d=google.com; s=arc-20160816; b=LpBiiQE0qVygVUDNw9lrf5La61Wf8gtbLeDWdVHvYtr1eeFgB5um2YKbPsEG4csVZo N6UTt//K41li5qKoBfF4D376dsJvs3JlrX5jrDzyh+xLS9ET8RRlcMeaBZA1BDUEqzrk GrhJ0GIIotP36bw+wq/0qOex0r33Dy0hyy26oZKOKKbGAKunaH613HItgCf3jMWiOt7a tGpP980GxO4ittXr6sQnUBXrO3JXBWTyf2qXXZdpFz3/iFp7lGFIIT7ytEOdWrQqxmqo nuIViQLlHKDJv91X6sjW1QIWZwGdaHNFJPrr906MOJ4/CNk5qZle70pnUf4GOz1kkjTq I8VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=ui-outboundreport:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=izO37pjK+gyo6ppGKz073VVMKVWZdCWS+1iofzIiRlM=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=nESCXtdCSna5FSltjyuT55w3dISSQBXBLd9c5gRr6fAjQ8A+rPyohHEJtU2SsQW0Gb Pn6aPLHyd/afhWoHJKaxoR2B3AbDl5CQL2rgmdqD93QAagNS9bRBgZ1wQ5iievWuSo5D fMZEIEGGgVaugOSsNbwDxY1W9+kue4D0BhlHw75f5xv9Wbl4Zndk6GplbsLqqm/Yd1J4 DacZ1KEaBXf/SuBSmHxNhZG1s3+10LhmEE9J1qFGWDHssh63ygwXcd//Umk3WEZ/fOo/ s+1E7GL/QF7oKbdBZDgVviG68nRzLv2xqKIFa9l6q+vVp8pa6pC7CCEWXkURwgGTi4eJ gW0w==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=FaZnHGw3; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.187 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.126.187]) by gmr-mx.google.com with ESMTPS id e15-20020a056402190f00b005617c6b0e51si245430edz.4.2024.02.21.00.22.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 00:22:25 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.187 as permitted sender) client-ip=212.227.126.187; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue011 [213.165.67.97]) with ESMTPSA (Nemesis) id 1MjSPq-1rEtNz1orK-00l07U; Wed, 21 Feb 2024 09:22:25 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 13/13] Fix warnings in case CONFIG_LUA is not set Date: Wed, 21 Feb 2024 09:22:21 +0100 Message-Id: <20240221082221.11997-14-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240221082221.11997-1-stefano.babic@swupdate.org> References: <20240221082221.11997-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:4AUIjPRTzI9QMVnzdmWTH75twX24a4uD/GY/po2FxyD/yo/I/0O /22tjo8UqgKeu4tEn8yCnqwe9rRigyqMe/6Yf7ItObMATsROZjovc7R+XpphDY8QlMFUtOu bvGhepwSQNkOOylHr9DuYrbdrYbuebc7C1I0Id14Fft2n/jJEDWZnf+OM+ja7xq9Fil3qRw qDLqz4IiCRV8DKjwEgp7w== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:304XQPpWBl8=;zoFjxxPR/K6nXkHiMgYS+ECThBm sBOAzlWIGAjVM19fOme+KwIX5yZHb3zjTOUThfYF3oWW/6r49KKpnIjtsCH0+lH6dztaqTpUU kIfltG8hpbgzBliag0b6vxs6oVrDQ7zm7OxNkRuV2N79ybL02mgm8VY6hNxV7JvM6oKu8Eeud GBv7FkcWQAuetZs6b7eeuPaNlCb2HzYhlGuWmyHkEbgLTCd8AYack62hsYc8PtO4rjqWeOGL8 R0WeT7T1ZKgqGqlS8fGzMMDxMA80TfdYwhEghYrZeSne5iVLoFKDTk1G5Rp2anBA8U7yVFyGm Hr3ybv+PQAD+gnYg5+8zk2m8weSDbcL2A9O/lOR8GbyRa97PVTxj6SELeknd1bO8t7UOTuWE2 yitqUD49q38pWYCcCyOHOE2VmR2/pG/Vgr0lPdabKwaZfHR6q3oFeL2iROAUgK76gwwvhRnbp r/hVWjRXW29xOQhV5EzeMYpukl5zFv74817/kUlacKLvEboKbr+abvsyLgPFpGw2qj2k/Dzbr Jux2p0GsASz+7g6/E58bVGRyI+LIjHH8haRijVzqx2wS+AIBosEK1G0IG6ud9m7gJcAUxxh1O LX1NbqAZyiG0e01bSQujCaWmh2Vo7fpJwxnyLyiGxATR1BS4FToBTCFqVQgiA5WMCoEvONJzn 9CYtagFewLkjyr7j/MpzqPqlunlXy3Vgdqx8nvolUgX0UakbxMJ4J5GR1z8oaWNP3AlDqEwSK w4uaCYOm0edWsXMpc7Cgi0g/IxYWTGAKoelqlgtrszv1gb7YE9Y3XQ= X-Original-Sender: stefano.babic@swupdate.org X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=FaZnHGw3; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.126.187 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Add dummy lua_close() to avoid warnings in the parser. Signed-off-by: Stefano Babic --- include/lua_util.h | 3 +++ 1 file changed, 3 insertions(+) -- 2.34.1 diff --git a/include/lua_util.h b/include/lua_util.h index 7b34eb89..bf8d2b0e 100644 --- a/include/lua_util.h +++ b/include/lua_util.h @@ -81,8 +81,11 @@ void luaL_pushresult(luaL_Buffer_52 *B); #else +struct img_type; + #define lua_State void #define lua_exit(L) +#define lua_close(L) static inline lua_State *lua_init(struct dict __attribute__ ((__unused__)) *bootenv) { return NULL;} static inline int lua_load_buffer(lua_State __attribute__ ((__unused__)) *L, const char __attribute__ ((__unused__)) *buf) {return 1;}