From patchwork Wed Feb 21 08:22:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1901891 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=hPXaJpgi; 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+bncbaabbqpf22xamgqehl6i7aq@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 4Tfq5M1DLHz23fC for ; Wed, 21 Feb 2024 19:22:30 +1100 (AEDT) Received: by mail-ej1-x63f.google.com with SMTP id a640c23a62f3a-a2bc65005fesf25119666b.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=OfwEFmlycIay8qyBH4NiSHnWpPyA0ky+LNQa1Wvm82s5s0ineITYPnuKpMClcG44TR /sQKFPwlV5utPDUkr9glBetpU3nsc6eElZ309XQhCM5NtJiEE7vU5tAeS+DULOkSv0LX 3IJ/0c8ektNUiQF6Bzk2xburod+glekdiOZzzST0gn0P9kYKVnn5XzJpXQiccPykPh7g OltSzV6uQ+F5Y4DPM1FUNomdL057u5jAArGpikGbiK5dvB0bx9xM3kNAj+AWlLtG3rjR 2B/G5yNmY5t3sRbgz+RrQCS06+cfyV9OiVRYZc3M2f2iobIOwphrDN8qHWOAk15SuP8B GYfg== 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 :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=Ad+gQqPiiAdFdKGUbRgRLFR58eGVy8SkG6Ie/drGCWo=; fh=3yQgyQiPRtfyyTFBfVzBtBoUR+jG/uMB7igmSloH67Q=; b=Ba40S5+OjrRRpwl1UUQjjyyoBwQdAP4u5A6stPmntTFXB5rMsO1OxCOduQ5CTddo1B 5vyeR8qBfEUsPZY3pLP7zm3eK87xE9JnJJdqf5f0mOa8jYuof2ZrOemWqYS+s9lgMlFT pg+y8BfOviO4wW4nXLKb0OBcbmStxYoO2/rD2gGt7qlC7wDCKLyRo0JCu23klCovo0NN ESxNrBCMboOYxY4EzvwBMegvnPcxdkiHSh0yyoT+dP9FsmfH3xrj2P1de9MEcDcsCCfp BdKCesvGvlxAAn+XtB0I0ZrbneQrUAJJToYExPRflnKfskRHZJJGRGzPapGnHyDL+1P4 ohaA==; 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=Whpa7Odo; 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:message-id:date :subject:cc:to:from:sender:from:to:cc:subject:date:message-id :reply-to; bh=Ad+gQqPiiAdFdKGUbRgRLFR58eGVy8SkG6Ie/drGCWo=; b=hPXaJpgiwgcn3Ea+3FrWKWVlBRCvrAEsaMHSU8bEMnH8PPpWUJ8kRZU35/J9/JPMkR vBGIuiKC2R5xWoNbU2Lc9dlh/UtPphaQaICdLOKEbN7Yuiio1xmUwkXQD77QC8utPSVP AC79vpv1LneHzvEwEcbvcguJzk0YiHmzErAglB/lOUoFlcbOAIhvV+2IxMDZXNutMtm6 yxamvQ0TAQdNa6TDRHW/YO+Ra/Mg0IcHJUnMaraKf9J11TJYDYERNpcC1Kb6WuxdJezH uOhUHnEbnEcZ5k0prClIjzimQl+iv9zqloXTvCYudqyx/VJh+hiuyAUXN9K6k/LVGrso 0oVA== 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:message-id:date:subject:cc:to:from :x-beenthere:x-gm-message-state:sender:from:to:cc:subject:date :message-id:reply-to; bh=Ad+gQqPiiAdFdKGUbRgRLFR58eGVy8SkG6Ie/drGCWo=; b=PTA5M8yp49S627GI4FTrg2AhxZVH47+/+OknX66ICG1XdQu+Gjf1oL6OrXoG4C8n4m lHHsKLPK4pz3Jmg8VgVAFhQqM8NulanyNpSLko9TDYkqn0tmvccMqDWb8I9htPsR2soz gwxqKMYhYCyfQESpCKkq/6kwIfZyBGPr8U+j27DmzVwWEwoA6jcrgY2s/VBIb+4stalp VXxILuokF3OEiKQJiErHFKv/KYrtsm64DOumdRrHaxZELR/hlPTj1pShTNXQ/j+IJ1IH /mInpT2xUnw9sVyZx3aaUIdNfMVrz6t3roj577q3wJ+bNp0TylsKz76b8KPi4zWZ3jRm ULoQ== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCWV/nklw/3G2nr2i1JcEg4UDwcAuSW5tlWv053cMyPIAie2sHYBBd5XYnNEjAcQUXn00xk6e0otwBB9fMbI6tAzOMO+0zZCWClD+sPXjA== X-Gm-Message-State: AOJu0YyLRz7vOGaJjVooPa59Mg29hLeexqzW3U3mZ+bim/2Y2t98M+2I FaDovPw/butmovskEaNFMx57gEqjuozW8Z/CMY9ha0NPbEG+4vuk X-Google-Smtp-Source: AGHT+IE7Mj0J151IqSDk74NNp50sciv3qDjeO6huh1m8HEfuFjEU19MoedR/9Rc60t67qWI8RtjCqg== X-Received: by 2002:a05:6402:1850:b0:561:f6db:2fd6 with SMTP id v16-20020a056402185000b00561f6db2fd6mr10403358edy.42.1708503746156; Wed, 21 Feb 2024 00:22:26 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6402:4494:b0:564:84d0:f1cb with SMTP id er20-20020a056402449400b0056484d0f1cbls117493edb.0.-pod-prod-06-eu; Wed, 21 Feb 2024 00:22:24 -0800 (PST) X-Received: by 2002:a50:ed96:0:b0:565:2b6:6a7 with SMTP id h22-20020a50ed96000000b0056502b606a7mr475418edr.34.1708503744264; 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=o2Ww82ENDsXzs66poMxP3mHLbFtW5PwP/ORWIIvBTXc2se8whRkbQMfz8swukCZjDi NI7RGw1gQ5N4yfVf1eUMaoV3ua2cuJzToOyMKgraAKMB1D5txSpx2LzSRmBdj7Ge5mMa pQuvh3MpWyFnUB+j9SK+xX+EmvmPtGdWQULv8ILwA77dYc8DHv7SzonxW8IN0js76T2q SInoXjcddReU6096ZVSwZw5mnnThvqnkrfq05Gyw/ua6mvHsbE7jvgcrrlnhxDT9KyWw +ULGm+W53x2oehYY5PyM5qb94EkVb6VgmII42dNbYZ4cwWkd3OQ5YD3H06PKwl9GOYTI hopA== 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:message-id :date:subject:cc:to:from:dkim-signature; bh=/nTEZJGQ2eL39vqTf/aipTd5KF5lE4L3XhLYvDj77WM=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=C4gQk9jRSSwJRqujecitSx2AwDYYIh8WSxIGIaAQ52YaZLO60jObGbMQoPDIoLKZ3C 7eEWvxevtl3HDkd777l2LHd3tahBc64MZaBDZGj5KITmmBsyHCGUA2i8uBXDjYjiIrDo Jsl8boURkfYe0JDypTyVlThjdYaPkV0vrsnCPL5Ne2XsdgiH4oE4+0v7VuMC3Q+n3zKk e6I9bjinQS8nnrybgTFmY4cu+TvF7t0eCtAPFkgb7zC2uelsFxqGCuP6sRSD90Xb/x+p nEAuxPsup4d4mARB+mNeVB9z38IoFuafyG0kmz6Kr6EVyaCLRvMsGHTy1tneLpBwC2Rn lXvA==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=Whpa7Odo; 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 x2-20020a50d602000000b00564af3e693fsi312795edi.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.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 1MjjOl-1rEcNg3O9r-00lH6P; Wed, 21 Feb 2024 09:22:23 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 00/13] Extend Lua Environemnt and post-failure scripts Date: Wed, 21 Feb 2024 09:22:08 +0100 Message-Id: <20240221082221.11997-1-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:GOqNLgG+bW+bCgTCKU7xxxcIK/A3DFVkrvSUwDBmCDrxoWcftu5 ivir3jdxUFvDuogGdk/aUVN6UwVFDrkJQyl2j5siPTy4NZ5l8kTToLse7vRKDj6LYLgFbKb rqEsbkSlXFaJn/hsgb62LySCURx/M5pPHvIkTSdV0qHl2qXwaZICNBw46i5Y+2CsuG365x9 M3sDnX8QAw7vl9XNX9I6Q== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:ifyeGegXkxw=;LBMzeGUFESKKQXh8bXb762KFpCx zlcl3BRxyuO24513uBknUhNu3l28eqqtc+ovRAisLGOYjI6F4kjk5oyJW1l1z8lNLo/USq6T6 F5FYO1CZDo3ssDjFS2vbAtdpx5RnVxtOTIJVQjexTutbNcWbbUj5x28WKE21UqlqQzf1hv1v9 io7JPu4hovPpEHzBIR+DJtxUf+kIwrJX80BQvUhRC0PANKOo4NDiueHuBZFApaAshB/bK1dFh 7/T8ZWPIWvT3Ch7hmpF6yG93XU7l5+7AFHPi1DQIfAgxm720PmqzZUxmT/oiMtqrmeQOvqGuR Ym684InGOhCIlXkc8leGlvxLSs8Ne/yR6oRiKo5Y2XsRGBEIJcUdAbnu7Lu6aBBQ0hxHwtjJf Ra2JuVN7ihCVq3ObQvvo/XZG309C0tNyFEyuyX+ZsWdPRXlqwyrf6BjK8QU/u/p4coqyVXiYi Iex+6K+ri0l/lIi0prJ2Tqojhm/QbJIuOYe4aRrWllSw4svlllYPtWS2p06eEKhW+5wlZZaA2 g0mq0udNBEkKwHjvk+UipN1/TU9iTsjWmNkJ3uKu//Q/B4DxcfY6N7TE5DF8t+VYPPA5D14jh 0BYENEZvOLpsMcKJPMWJykE/OuKelPgeShK8MnWodl/sgGjC9cr2QdFPJsIUN+YfYZCDgp0LB SNho0ATsol5X8tc0GLUP4oJp4TDr7cw4Js1R3kgQrgLjfMN/Lxf3g01F1z4SRNokKhAEHlvwG iMHIbdhDwdEoccchVA1jUiqrFpvV7ULBgXtwloPm73UZdzo1F+tvNs= 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=Whpa7Odo; 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: , This patchset introduces two big changes: - Lua life-cycle is extended to the whole update. It is still configurable, and a Lua state can still isolate a single script (as before). This is the default environment. SWUpdate sets a Lua state at the beginning of an update and frees when the update is terminated. This lets to use functions and variables defined in scripts that ran before. As example, an embedded-lua script in sw-description can set some Lua variables, that a later script can read (and modify). This is also a step for security, because no external data to transfer information is needed, and everything remains in context of the Lua state. - post-failure scripts. These are called only in case an update fails. They are usually required for cleanup and to restore to the same state before the update has begun, like restart some services, etc. Stefano Babic (13): Lua: prepare to extend Lua lifetime Lua: move out state initialization from run_lua_script image: create pointer to per install Lua state Store install Lua State in image structure Lua Script: runs with global Lua state Introduce entry for post-update failure scripts Export run_prepost_script to other modules Introduce postfailure scripts Lua Script: TRACE the name of the called function run_lua_script: check input parms Lua Script Handler: allows to run scripts globally doc: explain Lua and shell script handlers Fix warnings in case CONFIG_LUA is not set core/installer.c | 10 +++- core/stream_interface.c | 13 +++++ corelib/lua_interface.c | 55 +++++++++-------- doc/source/handlers.rst | 86 +++++++++++++++++++++++++-- doc/source/sw-description.rst | 20 ++++++- handlers/lua_scripthandler.c | 104 ++++++++++++++++++++++++++++----- handlers/shell_scripthandler.c | 3 + include/handler.h | 12 +++- include/installer.h | 1 + include/lua_util.h | 17 ++++-- include/swupdate.h | 1 + include/swupdate_image.h | 10 +++- parser/parser.c | 17 ++++-- 13 files changed, 288 insertions(+), 61 deletions(-) --- 2.34.1