From patchwork Thu Jul 4 10:24:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1956791 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=ovqy4nWZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::138; helo=mail-lf1-x138.google.com; envelope-from=swupdate+bncbd2zdgn6sekrb5hqtg2amgqewwddfey@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lf1-x138.google.com (mail-lf1-x138.google.com [IPv6:2a00:1450:4864:20::138]) (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 4WFCSp2c1Sz1xqq for ; Thu, 4 Jul 2024 20:24:57 +1000 (AEST) Received: by mail-lf1-x138.google.com with SMTP id 2adb3069b0e04-52d174e26basf590295e87.2 for ; Thu, 04 Jul 2024 03:24:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1720088694; cv=pass; d=google.com; s=arc-20160816; b=o9gWNwKSOk05rKZIAOd/o8qodRhcPjsFZNX4IYE89R3wpoEqKpAnTUTOyZ0Uufg48n smYp9vP/PkREsfJFCI9BiuG6s4KnfGbKm3VhNVp5m5xNdUwkxG6YVdn5zrmVyuoQMlLH RmtAjN5CZyy+Fg+DYUdW3h52vl1O4uiNXyaQ4+m3eMMkXstye5KILxXACGTTAtsPbo7P vJ8jvZJB0lu/6/6JobconkiYoXLpUY/9rZH0sCftznksFn12ra+DZTq8KiUSmRlGv1AJ JfAhJGpyzSz6htFFRCPb38D92WA3XLiWrg/wN5H5r3bLpbFuwwr5PADg88OluJTdQ0h0 AQDg== 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=kZ7Tzyl9uQHlVLH2N/dovus9h94k+us8ddAnNJA6aJ0=; fh=84i/gk3alQqvcURLJGOngxmwyYqL+Q+YhAjr5M8/3xk=; b=aaqOm+LMc+RCsn0P2bODrJSarHOH2xFZI0TpLAcGkgAEB+JjHdRmbdC156u//pfuBx Jzu9QJ7FM3UO4WbVEQEd10MwPfBC8P8R3eFjSEE79Iqv5tCpyaesURM+w5mAhSfn3Tib El/P1qjmxooJuE3NpaObT5JxcakMk09vbGZDktB+bHcd27aoRr7RfLM4+642sR+HZt4E q8/tSwOCq3R2YBBXhEPuP9VBwSrZjzjmJeuBP3pR+3SpqHgg8K9eHqCSvbQtadsRcEe9 11CkjLNARJziERI/vnCfaj0RUfZ8tVhS4mJzjCqdTr2c790bfkC5UIPzs4dszcvPvxKQ xNyQ==; 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=xNDHR35P; 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=1720088694; x=1720693494; 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=kZ7Tzyl9uQHlVLH2N/dovus9h94k+us8ddAnNJA6aJ0=; b=ovqy4nWZl+8GidCHXzFTQeonTx7VJs1TRlU0XKR66Pn0ZV77Pw8b7/74erSvXAZVDf tCnbbqYP1IrfuZNzcr8ewkrcPH8tsjDTZy/b2mveecygHvRn/CPCvywKVSml99EbLvZe QYiWLJk255meF8Rc5XL+MwyIYRIqxtAigdYZOU0CKfHlK0yc9Ry7SYIXkcz9ExsGGJXY 5eHYS7L78Q69FUIGdqW+HPpcMtPMyS4RfTeJm/uuqQdaNR2Ih3tuSKJ3LFsX/6nAtN6T JjXkomrjrlKkD2BkV4BxJwZteoZdq7sy9gE96sRrc8kOLQHAn2gTKMihl1h3SFyMj1Cv UGKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720088694; x=1720693494; 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=kZ7Tzyl9uQHlVLH2N/dovus9h94k+us8ddAnNJA6aJ0=; b=Rb6kHVIgZ8ltLa8vAex7Sq259lgut8ykAFhKAifeto22T5Md+npH9C56AGG24Jw3bF nL7DvGiqxugpzygWYrf5SWve6wX3di1fNiFExjoyhRL1XX1p6hE4r2WRP3ekCTn9zOnS P1TBgXXjN/ALJNsulcwEnumeRezxbqZsNY2jRr2PXJpTzw++P/FSNUJRbiLR1Ml6839l vkpRRLJHN555uJqwVOAW8OZLfL1r3fBdrmWiYVGHak+kjVHLUnyeeXTAei8sXphGS/65 PRsWjR/uMkmtiDoiq+t155wl0byR1h6e3LaKHQVJ49vor+NV+q2kmuI4UTTWwNvPdUgj CHlw== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCWHMmJ4dEQpR+KQDyOeFjbYJ+YaB1Xt2JPcT0JQCHTmUrAr3zjgRxoCRwka8ezvNbh3tFtuQfUcwrR0A4jX5jTj1JT24VD3W3ZiqlgKfw== X-Gm-Message-State: AOJu0Yxo7MliPDISy9tzGGVWy/kko2cXuDZXEL0SQ1Hv3GS2b5sWUpRn xhwM3DSfYwHHc9Ae7Fv/nCAhaihRP44bW8iC4ndWH2Wq3bLzcuCG X-Google-Smtp-Source: AGHT+IHnPenl2HDnCStLY3vLFy80g93ZKKuTJneccW20rfjK6P6rTLZUrdPEKKjJnXQYOcrSRo5SHQ== X-Received: by 2002:a19:a417:0:b0:52c:d657:8322 with SMTP id 2adb3069b0e04-52ea062e4e8mr945499e87.23.1720088693433; Thu, 04 Jul 2024 03:24:53 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:6512:147:b0:52c:e130:476e with SMTP id 2adb3069b0e04-52e9f34b8bcls259722e87.2.-pod-prod-07-eu; Thu, 04 Jul 2024 03:24:50 -0700 (PDT) X-Received: by 2002:a19:5e5d:0:b0:52c:c9d3:a30c with SMTP id 2adb3069b0e04-52ea063d221mr712313e87.29.1720088689873; Thu, 04 Jul 2024 03:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1720088689; cv=none; d=google.com; s=arc-20160816; b=FkhRs+chScexowUILzHTY/IKWWmRpuYZIP/uSqipjj5i8g6S/RkSPSJXUwGRuEnMgS MpnhwQVwjeYMGQ8Er3tMxXXec6LPfHnmW7fgz2bJoKooSWFPx08TU33yJbfCYt8LbKI2 f0XXlGKcu2VW0SRCXwlJxH2r7Q3541CJyX1F9n88pdzvbXkMKEClPOpvEQ5Rbf2Eexvl FCeTunBd1gL/F6oOmN6+rKS7F5TAgmj3sBdpF4x/p+f5FOv1di8THw5qzMmwmJXZy1BY HXbe4QGJFw+g+gxh8jaLVsfOWkyeYVXqc30WjSW3CWBVVlgyt48xN0AVwZvVb3Qv2kQm bemw== 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=g49jXyPcqzJfkcoSQnE5gKyOyQdaqs+GQIvJHki5UXg=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=xPkqsunH+yptCwsuOFJy602Y0SAlle5j0/mbkYWDqP14ZT2Pk69n7I+LHfwhdv79Mq 4vyaisFQVPv7iHo34I5pLC15revfK6r5FP0lODZ1eSPJ1Ot6G+foRL5cZI0+Mx+Jyzqj UvPdeey3iXGicUoXCbivDroSWfeUKrFH+scS//mrkrZXN2jxCpB7oyju9wlZDqWrZsnu PiLvK4D2llmBcZa5SvexfTAPfYT12+x2azauOkETNtM0iwv5WPiUJV0M8MG+2t9uKUBc 6h7NoDkv9tiUrW/grZQlN/E8KtWT1yi2modf1aoDkjuWb6iY2znNuXNGLa3j+B599qsb 6BOA==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=xNDHR35P; 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 2adb3069b0e04-52e7ab2d702si262767e87.11.2024.07.04.03.24.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jul 2024 03:24:49 -0700 (PDT) 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 1Mq33i-1s2r7D0KxO-00hMiG; Thu, 04 Jul 2024 12:24:49 +0200 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH V2] BUG: bootenv functions not available Date: Thu, 4 Jul 2024 12:24:46 +0200 Message-Id: <20240704102446.54870-1-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:qCtmJ+EXzKBkdpMEyqyTroqfSchHBOILZ/Bx0mKZWJX/Z/tQrAz li4lWebn7xdYav3FUyJf3t4s41KOw5zBPIAqRdD9GWopk2aXBGEKPlEn7ejq2kP7v9NHd4S mkQDsavL3DCCA/uyA188zqKOili0Ol2G6ZhZIR/2hubqcE8Z3Fv6NykcQwL/lIPiSSF9h0p Kx7N7yparUI9scS0Hi92A== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:Ib18r4bDwFU=;BQOIVwcGcTV1SUNLjV9xeQETbHg /juURdSoocsyjXh+I23aEnyOsODeOhG13iqVpuCBmQ5x1NGoDOn+XaoO2qYL0ShU+xxAnsSkr aH5OluKrtIoRO7Frz8ZClO3/LtVAloB8UVMteWHrqyezA/g78/7SNe1ghblOSnystF3ErEXFY Cpwrr+rIYfYjoK+1nTGalOApahxLK/YUJeCDisyQ+Nvyko9h0OfggTGkHLPt/t3JgiodB0Jnz /T3AonRCakF7F4lNVBnF8C0c0GwJGIyKquiO9hald2qk6lOXK9seOX0UHhxWhPTYpcCcaPPmh iLtraF2U+kksyppybHcukzmQAVL1boSXKaHhDFjK+2tE1J58KEH7utue2U1tMwsj9bzWwksNM vVIScooKZ6B7IAjXZp8z3Mpj7DI5TJ7gZlbWDqHYLU3V3r0IlXKdc/R0pFWZ0Hq7Ens/1RPob duLBpDa4cnIZqTuktfqqp6rTNVteR4xsLOfLATs1MLeuVoXk0+4Ab2/ZMWA6RUefVdu42VBRb vzjAwah3Pc6e8dtmcZztllfvlTQrx/B2OjOETqy+J3G4+M3UqzuJ//kxOaAr9io3enk7Wzz6B LJJIkaze9m4jXESlHofX9gnzXEM6oIpyAS8rTj2E2/PaOpbdzLWtQ3bB98//MJZ7Pp3gIJBwn O4fQeTGjcHufFb0Lm2zistZ+cQ+r9zJ26soZFREzgmLUMaJGUKUf0LQub7CXB7mHmDYfw17k7 JU2HJ4Hxz4Gz7ODAw6ml1i3c1N4e7I8VZoGjWyzNLRUQnlM2Hdw+is= 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=xNDHR35P; 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: , commit f8153 introduced a regression bug. The bootenv functions are not registered anymore and they cannot be called from scripts. They were handled separately, but after switching to a Lua Session State, there is no need for this and the function can be added together with the rest of the interface. Signed-off-by: Stefano Babic --- corelib/lua_interface.c | 17 ++++++++++------- include/lua_util.h | 1 - 2 files changed, 10 insertions(+), 8 deletions(-) - Changes in V2: push bootenv initialization in lua_handlers_init as suggested by C. Storm -- 2.34.1 diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index 74590ab6..f2ef849f 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -1489,7 +1489,7 @@ call_handler_exit: return 2; } -int lua_handlers_init(lua_State *L) +static int lua_handlers_init(lua_State *L, struct dict *bootenv) { static const char location[] = #if defined(CONFIG_EMBEDDED_LUA_HANDLER) @@ -1514,6 +1514,12 @@ int lua_handlers_init(lua_State *L) lua_settable(L, -3); lua_pop(L, 2); luaL_requiref(L, "swupdate", luaopen_swupdate, 1 ); + if (bootenv) { + struct dict **udbootenv = lua_newuserdata(L, sizeof(struct dict*)); + *udbootenv = bootenv; + luaL_setfuncs(L, l_swupdate_bootenv, 1); + lua_pop(L, 1); /* remove unused copy left on stack */ + } lua_pop(L, 1); /* remove unused copy left on stack */ /* try to load Lua handlers for the swupdate system */ #if defined(CONFIG_EMBEDDED_LUA_HANDLER) @@ -1547,12 +1553,9 @@ lua_State *lua_session_init(struct dict *bootenv) lua_setglobal(L, "SWUPDATE_LUA_TYPE"); /* prime L as LUA_TYPE_PEMBSCR */ luaL_openlibs(L); /* opens the standard libraries */ luaL_requiref(L, "swupdate", luaopen_swupdate, 1 ); - struct dict **udbootenv = lua_newuserdata(L, sizeof(struct dict*)); - *udbootenv = bootenv; - luaL_setfuncs(L, l_swupdate_bootenv, 1); - lua_pop(L, 1); /* remove unused copy left on stack */ - lua_handlers_init(L); + lua_handlers_init(L, bootenv); + return L; } @@ -1560,7 +1563,7 @@ lua_State *lua_session_init(struct dict *bootenv) int lua_init(void) { lua_State *L = luaL_newstate(); - int res = lua_handlers_init(L); + int res = lua_handlers_init(L, NULL); print_registered_handlers(false); unregister_session_handlers(); lua_close(L); diff --git a/include/lua_util.h b/include/lua_util.h index d3dd1cd8..d82a76d2 100644 --- a/include/lua_util.h +++ b/include/lua_util.h @@ -26,7 +26,6 @@ int lua_init(void); 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_handler_fn(lua_State *L, const char *fcn, const char *parms); -int lua_handlers_init(lua_State *L); int lua_notify_trace(lua_State *L); int lua_notify_error(lua_State *L);