From patchwork Sat Mar 9 15:11:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1909983 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=Ow/V7VOS; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23b; helo=mail-lj1-x23b.google.com; envelope-from=swupdate+bncbaabbr7ywgxqmgqesp3tvji@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lj1-x23b.google.com (mail-lj1-x23b.google.com [IPv6:2a00:1450:4864:20::23b]) (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 4TsRNF2JWMz23qq for ; Sun, 10 Mar 2024 02:12:12 +1100 (AEDT) Received: by mail-lj1-x23b.google.com with SMTP id 38308e7fff4ca-2d2e4ea0f63sf12523301fa.2 for ; Sat, 09 Mar 2024 07:12:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709997128; cv=pass; d=google.com; s=arc-20160816; b=uVLdS8z6+RVRALY0PWGz8Y90N/lTMu+TnrWKqSc5ZIY50ZxUrpX/NspeEQLSvzuLs5 N7M2XAHl/d7cmitUadn8Iro0GApmprf4T8EMZqeIHjl6VcMei6qc2Cspxv5NwqDflpIO Bl+2ROhRWgiwMrFkIeWljNWVXu8ji8MDuvMlFxWDD+t4zbdrI8pp1GY/V7ZNhN60ouA8 CpNXZLO6OzDxt/QtTa4IasfaCSj67s2oQp1cYC5BK3WGblZ8bhrQdgCN52MgCnInWdi0 tYF8tGwVUMSeqHW2KX0uwngh2UV5rDW9RV5/ubtK7j8+xbiiV/WTpbL3OGxwR2+zlYXo RP0A== 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=oa74gS+kaTrRcgxajCdrgPVX2pgB/KAJyJSZI9rj5Ec=; fh=IOwOWn7rcuUODfxx3ROVYN1ea3hpiW1hWs4eajbSq30=; b=m76Ta6FQXUAsolBqoFYSGzBtLECyTLDbwdsHCdtDAGmneqTd6DYH3JYYtmREoeieNw yhRN21OAawY97MV8oe1Hh2Yc7wr2tqk4Ab43mjMFAvA8kqVWXO9biEE2Bfp4rTNHtlYz v5P+mkQNVdP/l3oNWquIn0soh2OhbANoWKma5ztnDn53XmvpaS/k3t3w2C0UbW8rCcnZ +X3NYGTqTwPmmGPkrLql3XdSEmdSSm62pTpQj9ZZtN7qQ/Us14qPsggeld34a3Onz5xn hswyVtJIxKsusuUR8De/tKVaBSM/VrhTShcB3aKspzJjCpAHj4tj7hsuKEAMGJTKmxPh QO4w==; 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=TeoDqkdK; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 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=1709997128; x=1710601928; 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=oa74gS+kaTrRcgxajCdrgPVX2pgB/KAJyJSZI9rj5Ec=; b=Ow/V7VOShMY22goMuBJprKhmZbi3LJbwXix6qQXQ+U1vrF+YgcHb20bMgaPLvxAqC2 uRi+yg7y/Fbhg6RzmBx5/d/DKaaRK+OVJWeDq0IzDLp6/tAWRJuIrbn28Y6vl1D/kmzE D/DWcBgXPJD4hPaIpsjN5TVaE9Jolx+Ru/QT7wn0UrCbWi17o7IxLOdnVkK7lXBd8A5V ZJbSLSexS3OMJP1SKd98tdUK8/MfQFvtF72lc2zyY6+FNEAbNlIAz62g6zyP3imvalya 7NrTTsUWPwczpIME61n0/VvctqDeQuYr50tirhzb5WWfconGKVPCmPxH5wco+G74vkLs U/2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709997128; x=1710601928; 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=oa74gS+kaTrRcgxajCdrgPVX2pgB/KAJyJSZI9rj5Ec=; b=J31CSS0deFz4QLKgpHY3y2gLkIjXSrn7NsHs5g7XOdIE3NDEUEg45EQBUYkP0EZGLU 8QbcDY4vY0LJO1FX3+IakIrMl6S2wwmeFDmEDGLRlUnCYLu4nJAxup632nFq1cpxixyF +snnVcdV4noDt8Fe875Dnv+iqjQAQvtp4NFXWtPt/mFC9+8Zw6yTAEI/f6rozQJqC3Fy lxzYOn+oObKQ8tVrVXAmJQb2kzB0hCly47LAk1hXwwZXkSi9H5a5o21Te6vFYA7nwfAu WdQlHL83DM7p0meEXTz3nI88UqZYvvtKrjksw9+5H9dbtZuGJN/8VMP5A3yUHOA9SdN8 ASWg== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCUCHltc2Xohb+1Lud7lWVHuRW9zmeQNX+GHGJZvY/j2zC/s+nVu0AQeRASjj0MdzstdKChT7hetpIZ0YjqTbU2RTbyJ88Tr2Z3T/23jWg== X-Gm-Message-State: AOJu0YyhtgmV50we6aVfiC8dj/GpDHLoWfpn/j2XFhLybm4Zh0QYWWp+ OUrYrQHJ3oTp9LWVZ7MUvwFnE5BeW1WZL5SndYoWWTOOPiOVw6TN X-Google-Smtp-Source: AGHT+IETFavSN8fwwbEAPM3y82ESzl10zGoVyW0JwCqAxO9Y3X4YVMYnl1jJuOnnfF4o+DabPT/IHQ== X-Received: by 2002:a2e:9252:0:b0:2d3:93dd:c54b with SMTP id v18-20020a2e9252000000b002d393ddc54bmr1243966ljg.25.1709997127768; Sat, 09 Mar 2024 07:12:07 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:651c:b23:b0:2d2:7b2e:c2c1 with SMTP id b35-20020a05651c0b2300b002d27b2ec2c1ls240404ljr.0.-pod-prod-05-eu; Sat, 09 Mar 2024 07:12:05 -0800 (PST) X-Received: by 2002:a2e:9ace:0:b0:2d3:f830:54ec with SMTP id p14-20020a2e9ace000000b002d3f83054ecmr1289117ljj.43.1709997125551; Sat, 09 Mar 2024 07:12:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709997125; cv=none; d=google.com; s=arc-20160816; b=PW4oaE1h3kjfnHLoqNErv+EbcXEZQJWC5ZtJfKQ0VOTQOGXhqPMUW75xOF79UUrKMO gjn5gdgJPGVlWN4sMeieg7ImF2dl7T9oCj+W43pwXLWy4LVljIDilRFIwDm2NUsJqHZe J1GrdsuDW9j7QAx9rfJhptv5Zml7TRcSAyEoy7pq310VW4ku3uzwjn2/hOHzyED8t7gd 2bAsZUzL1AEoR4/t3bx8k2ZeMvUc2x0iVH/nwOKm3nXduywUx4FD/Ozjdr6pJDrFYNWr SrFuYqmnhlOiU88VG8GHmcrTh1ICnO0q365cRZpdk/kIHk0lvYD6PRiZFVd2YoaHDzvq xIrQ== 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=NN9eiMzV2eo+7TIdOLozwALuD0LO4m5/o8ZNPdBRDd0=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=VrmTG61GoFFD0HAgpI+GzTwHxyPuqdg1XBTYzhSS8mECElHnbHISprjvcfYtzQGMmX CMTdaoEY9l3dwPDohysjZioYnjQzsD6GYtAm/cB9xXzyJeMarq895IJLVkpfIZDjmMUV FjRq/JI6y9RnfBm+I+83ENyDNXS1dAnXvT97ZzKgUbULoOIoncgDLr8wDBSy+tZS5YF/ w+J2hH1uJQGw/rG0x5inoYK84rP3QsnL1PJLqG4q0ohMV7EGy0UIOQYg93q/CCozEXUp pyGdJvpmGK69i2OAQ6IFKRvDo8zlFeeSnN9YjrC8pV1zYGMrNmtI+CWJmoAfOiK4Khyq L1rw==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=TeoDqkdK; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.17.24]) by gmr-mx.google.com with ESMTPS id q5-20020a2e2a05000000b002d2da2ffee4si113738ljq.2.2024.03.09.07.12.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 07:12:05 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 as permitted sender) client-ip=212.227.17.24; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1M9Frd-1rn4yJ31D5-006M86; Sat, 09 Mar 2024 16:12:04 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 1/5] lua: add wrapper for handlers Date: Sat, 9 Mar 2024 16:11:55 +0100 Message-Id: <20240309151159.8426-2-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240309151159.8426-1-stefano.babic@swupdate.org> References: <20240309151159.8426-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:XiJWEMp+naVQttKTHz5RdRIbxkDfwPuG5sx0HlwgkfwNOPvHVtL O1m3Z1qZ+DdwSJGakx6kIy1O+iSJhfA//cD8BtO9ZuRYuNnKuzvHnMRFFPnR1UT+gmD97VT ZQzwSxO4X4NXGsp6rD6OUlAPjjWFcJlxVyCKu7uVxjRf2wJHR/hhM7Z1HHf69j3M1K0LqGn LnRYKRLldApk09ZFcP1Xw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:eoc1Flb4ask=;hY+ihVe0nkw5wL+PUVYBvXGkSfS t5vhNC81g9kBXEy4tZqaRG7UAoVp8qk1q0B6pmz+tdU8fKntMDTsPnujbvnahwY7ekoZIAory xxcCwQGE7/MdyR4NJ09FezNC+Ri+U56G8gomo/sV29M2cbgH6NdLMn/eBtqav9Z6iC1bO1uj9 cKEL+iKQMhXATyioh4/UlpJUBuYVJEg9HBVaFuQbSvdetrmP14lJNmS6xI8y3Swga5hZzc/27 38fHXdjCsNZlaurtLo5df5xt+76dGj1aZ9+b33c9PH/OdhFfP4PpIPkXW7FEQ1KxCwUpcdPqi l0fxErZ/cQrVnQv8vYrQOzaRP8abUcoTOhj6kRuqW9BD2l5Toc195lh+mfYhHxeQP4egWmOQM LupCM8Uv4yoyXb9IkiqAS9d0uJF0BTTVcm2psvzylC1B3tRescS7pAb9trCqyisXAEBBrVgYb cwZ4KVJbFd6ynznYw5ZijmMrsBvWLf9unjVOExt633rDbCUXX49V3qMBr0ZIxmocix6+gGinI l72exKpXhMp4qSSRcY49WoZWklnvqKskA0SriYb4Ig6pNuR/0zVwIG+2AuXF/ovaTzkZpMpo3 DfzYNDy+13KQzmZVXmV8Q4Y4aAKpiObX8jvn9K6U3xm3TjEXqfoFn6UdsKqIj/lxkRB48xZnN y0MYW5FJxNkj9Ff20q4Iw25dNCvjvDsdT105ZQOhuoj4aSZgz4X3X3gT1P+lV2dMX9Bc3V9pA iPfs/8m4TlGuO0pb2det7jxHJHKrszaxSB5PdVPksSdHHGjJwaOKHI= 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=TeoDqkdK; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.24 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 way to call a custom Lua function that can be used by handlers to check some results. The function receives a string as parameter, and if multiple paramters are required they must be combined into a string. The function returns a swupdate_status result, for example: return swupdate.swupdate.RECOVERY_STATUS.RUN Signed-off-by: Stefano Babic --- corelib/lua_interface.c | 36 ++++++++++++++++++++++++++++++++++++ include/lua_util.h | 17 +++++++++++++++++ 2 files changed, 53 insertions(+) -- 2.34.1 diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index d785cdb5..fbdb7d05 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -1597,3 +1597,39 @@ int lua_parser_fn(lua_State *L, const char *fcn, struct img_type *img) return ret; } + +int lua_handler_fn(lua_State *L, const char *fcn, const char *parms) +{ + int ret = -1; + + lua_getglobal(L, fcn); + if(!lua_isfunction(L, lua_gettop(L))) { + lua_pop(L, 1); + TRACE("Script : no %s in script, exiting", fcn); + return -1; + } + TRACE("Prepared to run %s", fcn); + + /* + * passing arguments + */ + lua_pushstring(L, parms); + + ret = lua_pcall(L, 1, 1, 0); + if (ret || !lua_isinteger(L, -1)) { + LUAstackDump(L); + ERROR("ERROR Calling Lua %s", fcn); + return -1; + } + + if (loglevel >= DEBUGLEVEL) + LUAstackDump(L); + + ret = lua_tointeger(L, -1); + + lua_pop(L, 1); /* clear stack */ + + TRACE("Script returns %d", ret); + + return ret; +} diff --git a/include/lua_util.h b/include/lua_util.h index bf8d2b0e..67c5c47a 100644 --- a/include/lua_util.h +++ b/include/lua_util.h @@ -24,6 +24,7 @@ int run_lua_script(lua_State *L, const char *script, bool load, const char *func 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_handler_fn(lua_State *L, const char *fcn, const char *parms); int lua_handlers_init(void); int lua_notify_trace(lua_State *L); @@ -37,11 +38,24 @@ int lua_get_swupdate_version(lua_State *L); #define lua_exit(L) lua_close((lua_State *)L) +#if !defined(lua_isinteger) +static inline int lua_isinteger (lua_State *L, int index) { + if (lua_type(L, index) == LUA_TNUMBER) { + lua_Number n = lua_tonumber(L, index); + lua_Integer i = lua_tointeger(L, index); + if (i == n) + return 1; + } + return 0; +} +#endif + #if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM == 501 #define LUA_OK 0 #if !defined(luaL_newlib) #define luaL_newlib(L, l) (lua_newtable((L)),luaL_setfuncs((L), (l), 0)) #endif + void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup); void luaL_requiref(lua_State *L, char const* modname, lua_CFunction openf, int glb); @@ -92,5 +106,8 @@ static inline int lua_load_buffer(lua_State __attribute__ ((__unused__)) *L, static inline int lua_parser_fn(lua_State __attribute__ ((__unused__)) *L, const char __attribute__ ((__unused__)) *fcn, struct img_type __attribute__ ((__unused__)) *img) { return -1; } +static inline int lua_handler_fn(lua_State __attribute__ ((__unused__)) *L, + const char __attribute__ ((__unused__)) *fcn, + const char __attribute__ ((__unused__)) *parms) { return -1; } static inline int lua_handlers_init(void) { return 0; } #endif From patchwork Sat Mar 9 15:11:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1909981 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=TSS6yUtq; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::43d; helo=mail-wr1-x43d.google.com; envelope-from=swupdate+bncbaabbrxywgxqmgqebdhy5ly@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-wr1-x43d.google.com (mail-wr1-x43d.google.com [IPv6:2a00:1450:4864:20::43d]) (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 4TsRNF2TcSz23qt for ; Sun, 10 Mar 2024 02:12:12 +1100 (AEDT) Received: by mail-wr1-x43d.google.com with SMTP id ffacd0b85a97d-33e705fb2absf1024839f8f.3 for ; Sat, 09 Mar 2024 07:12:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709997128; cv=pass; d=google.com; s=arc-20160816; b=0C/0aQlBIhfgelQrQrPFRJlt3hq0XDJ/iVMKadmlvZphSBGxbVf9+Q+096I4P3wYYo u0V/Up0m/w6qngrdLYiMRzWvEMsi+h409yoIMxnNtS2MquoDGqmBvEesQebDx0mFi9DJ yc9RPBvVLzWPu6+LMB4w0WyEmltlMBb+/bu0Bd+lnLo/bq5S7o8pJH5vw/PQYFVRMwYP 2VO+mEiHePLj2DsDiJHbeBcpo9oX2Pmgi6+Ahg/pp6hhuoaKVqz2IdrzP1+998M7AqYR anVXZdI++L0aV6LgpDYK9g91lq4EBYQtl3Y1PHbAIy6mPEKSMYfXZ7g+X/79VZwj1A18 3oZw== 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=VK2T5h+0NQwxmVXXHHtHmDsKbfngSl0q3bW4NK0C/NU=; fh=PJzymT4/1yU4FSc0+AizGJgxdHtkL19N5yWOl1qXNXg=; b=QHkho1PLwpmQUr2gUjxYu9neHxmVvSgJH5isIY7PjQejff8Y8xwpnE3vEeJ+t42k/C svuCq4OXs14hgkxVv3XPMvehas+XAI8OX8PncgFQDIcXNMB2IxndhSpZPkLvPhXQKzMX 5qPPYfqueKiwzHGqveUmSG8AjZ4fNVHGWa/z85tg3pQ0qsL0z2zMhK65L5KucE0KZ8E/ Zq+N+yUTAe6jlqtiZS48b2WEAB0wzEznpnzcrCmKIDCDZcwWY2J0jfkQDEeb6UQG6aR6 YHiunzGTMMBhq3T9IdpjbKpBYYFuLrV1AGUtbt0LkEgWTyn92xO4FkphHQUsst6v444u 6JLg==; 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=lwhPHdya; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.74 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=1709997128; x=1710601928; 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=VK2T5h+0NQwxmVXXHHtHmDsKbfngSl0q3bW4NK0C/NU=; b=TSS6yUtqfFxAZ/3R5haCN/AxbCFyq3wsaPWiwHbus996rNTkpK4itr63s/HEefFsiB 6D/P3mimHS85ftmIPbaN/fjj1R7XNPIe9lv6X5O7VyQf/GRA54Ep+m24u4k5T/pRj9SF bO83PMcCyosCFk7gnJKVwb/zo3TBaJUyC9ehRtKpzuqyQO2GhQvonZZYIaXHWrfSmtOb sgw90UOzM9FUQqGWKxUTxycIFS4X/MQM9aKT8Ei7xcojK5Jjg244ztEjQ5IlS2emOM5V 8zda0sDMVxyjwDUQx1Y/JtZv4T9bP7lYtlQ2OZ2XHHJj5b0WiQR7eRIcgvFOto6sc8KF d7Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709997128; x=1710601928; 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=VK2T5h+0NQwxmVXXHHtHmDsKbfngSl0q3bW4NK0C/NU=; b=OwAmDqfmvxg4BqF/gyNg+Rw4Lge4FYPwT1krL31RtFIrOHBzU1rwKvnu/pUziPV/dz xd6wNK+n9at3L279grJaxEo1bTtSnBk84YxpWDyHeDipIIBetfuhnQQg87Qg0oQnBTSm oNEls1aE6W1TSYs1whR4Op2SND0Db6RqvvQTgtDeUjNt6bXKni3sfnqoul28lf3U5caq JFGya6iHepe5XK4iMAQge54tSygk60T5kj5QtXn2mQjooglNqoaxEG8H/WMZCYWXgMGP xnL18Ubq9dSTYG/1+CILnySl3HsabmRvZsNnvrUsSbYhigh6GRoGSrQ0d50t661pK95x rC0g== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCVrY7iMj1BFfLndeY5EK+7K5a9WgSl/4rARKyD0cEHd33dkhPGt6XuV9qXtCZDAjS8dTQVsW/Hu2BP92LwmCiW7WSw7jzPVjy+DkRhVKg== X-Gm-Message-State: AOJu0YxuAXhab9x/1tgjN+XT9YTR+/GTQGXSxoHyp8MdJaOSbzt+4I0L 3rhVCx+JhynWHP1rP+7JhlqyUMVMnaTK9+ThwnJdzlyGQb0VQraG X-Google-Smtp-Source: AGHT+IFW3l2AR5MjrMIYu5BDGvfx3M6f1VJKQaUsXBBH4P34K0SVQ8cGIlWzsL7IPKS6ceUt6vyUpQ== X-Received: by 2002:adf:f00a:0:b0:33e:7b70:a114 with SMTP id j10-20020adff00a000000b0033e7b70a114mr1537288wro.33.1709997127518; Sat, 09 Mar 2024 07:12:07 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:600c:1c04:b0:413:1986:5865 with SMTP id j4-20020a05600c1c0400b0041319865865ls680888wms.1.-pod-prod-05-eu; Sat, 09 Mar 2024 07:12:05 -0800 (PST) X-Received: by 2002:a05:600c:3149:b0:413:19ac:2a06 with SMTP id h9-20020a05600c314900b0041319ac2a06mr1533420wmo.28.1709997125481; Sat, 09 Mar 2024 07:12:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709997125; cv=none; d=google.com; s=arc-20160816; b=Z6dWX9oJ/VVdzT9vj2IZAG3D+T4qerBF4RZr6Hnu6alkWorJppTGmvKdSmF2b+/7Yb cXjPHtPu3VPCFbAaflpZmjbVr5PSH60BpDHxioev/ZmXY2NzV8u+b2nwNwYRd+FxnpYv 0rp447F94g+ecRhlysrLXnsdionYTWs96FlMdkt8CT1lcY67beJG7jyTlLTWDCN2Jgzr Krxpp2DCHPr2icwwr9Kl7YToLvUawmxoEmqy2SfH9MGAhhgLWQjB0D3yJfS6GQXcyvdS y2ii34R6OsvTqUqo/2NRt4OqOPWfSAi4+E4k2thwNoyxgbW5hd5+FyIjhK1I+exIxgP/ rPzg== 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=9U8zUT+koIf0MRDPrbIGoe0V+7WrRWT21hNdGMuJ7oc=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=S+TtAPpERIgmBME2FWrF5QKCPN3lTuRFpgOooj9SbIC1QiORuezSjL//SH+B26CH/2 4YRDnWkoxryEzx+STn5RordEMjgyEMT45/4Inkrp0zbcW3UcSxGLQNyp3/edckvGIGlc sl7I6DW879mLFgPMQ9eO0gxB8Oao7bHh31ieh9NsRax39HyCkAN5vcCVHvVJlMtrKcwb Sf/ZdkeQWKHrh+Kbsmf1ao64fMGhce0Gd9RLxgjvzwEDP5tUrebLw73L22YYfPIHcbeG o0gp71eM/Y1MFU5gqYwie5nR/kgea5sWrYXpxptpKWSIs37/JJKIcseVMV3qkMas2xyE Dc2A==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=lwhPHdya; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.74 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [217.72.192.74]) by gmr-mx.google.com with ESMTPS id iv7-20020a05600c548700b004131654decasi213286wmb.0.2024.03.09.07.12.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 07:12:05 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.74 as permitted sender) client-ip=217.72.192.74; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MVNEv-1rIC9b3b7v-00SROI; Sat, 09 Mar 2024 16:12:04 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 2/5] swuforwarder: fix return error Date: Sat, 9 Mar 2024 16:11:56 +0100 Message-Id: <20240309151159.8426-3-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240309151159.8426-1-stefano.babic@swupdate.org> References: <20240309151159.8426-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:jVlnigU/M1wzlavaOQv8VQgFeEmKcw0otOrHlGxBDy/dFPJRHE4 sfDq97jNWyh7eAtOOnzqv8WvLX1Z+pvJO/UIc2NOkh5qiZnQ007E/S61eg2ZcchzvC9wC63 9C6SPdjA1bpT0L/u0wgj6QsGgJzoZJHy7bI+oFl4Ee+MHpN1oPIE/7X0mlKMpzX3i54Zl4q uVyM/VxIUE0SB+pSw8/MQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:j85iP5sIUZs=;fUsc1GhQMwLNKWvqUIw/sKpdzL0 kqi6TExMIwaqJydUqZwbBLnj2Dsph+W2fYcGYfxDEf+jbCEfiaSrlxdtdIekxtUB/rGFoBrJ5 zRf71O7HlOaogFQobZVwGHzK4WDQ90ewZHq4GBHCFqILOP7FBcZsJH5Db5+I2qF0GjcLfn4Du 0Ccsa0xYeUN1czKkYWsgfnnmCxI8jXUG9s+6kQSxIP7kWAvtsQzGkt1gc3y6K3Jdg1KyElcJl XzQEqBngfV8oqqi32O+ebuq7Qj0siDq3SCDXVHpJ/p+gxf+mLK1s9Iq+KMqxR2EIGim/hYDcB 51B2+s3yo9cx1xE6Gix9e3tXmtACbMByb3ViX9g0BuI3SXcM0aLj6gPpTGGNWJJfD+HL5NfXV hc8vaU+nUYQ6xxMMWlO0qVO7XF5OxSxmzbiVtbtwv7hOhKQSa0VjdK4Lf7ReAKVxQaruI7ikL 9vLtkNoFSw2ISNMEORcakPRARuCA1OzljpE/OTQNMXuT6IZd1Yf+IPVw+Aj7C2a3O4K0qInIK V9/eSKTYgnF5FWhc/BqOeiOT8USSzSF3raMEdH1jYgKQsuqN/cfEsb/OK7fr3EI3Ps5SeDeHZ nidtZV3iFmzbdw/OiLEdBwIKdP55z/sbWGFV4vGRxCffIPRz7DBo1BVhu5Od3xA7PEIQtAKKn apSHf29XxEfgJhcP03bxdA0NGBbnUDRKOQbXyeIAYUa+ddLyPxYittZ6DFZIG9RGJz2/5gxIO Ja3Cu7g9d+8ExbnN3YV+F4EeHBwThcEAluXwnYc5K3U+RrLC3HOrqc= 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=lwhPHdya; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.74 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/swuforward-ws.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.34.1 diff --git a/handlers/swuforward-ws.c b/handlers/swuforward-ws.c index 3b835dbd..0c4d6fff 100644 --- a/handlers/swuforward-ws.c +++ b/handlers/swuforward-ws.c @@ -143,7 +143,7 @@ int swuforward_ws_connect(struct curlconn *conn) { if (!ws->context) { free(ws); ERROR("lws init failed"); - return EFAULT; + return -EFAULT; } memset(&i, 0, sizeof i); From patchwork Sat Mar 9 15:11:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1909980 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=QaN7RH1q; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::23c; helo=mail-lj1-x23c.google.com; envelope-from=swupdate+bncbaabbr7ywgxqmgqesp3tvji@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-lj1-x23c.google.com (mail-lj1-x23c.google.com [IPv6:2a00:1450:4864:20::23c]) (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 4TsRNF2DLXz23hc for ; Sun, 10 Mar 2024 02:12:13 +1100 (AEDT) Received: by mail-lj1-x23c.google.com with SMTP id 38308e7fff4ca-2d33a42c1f9sf19258611fa.2 for ; Sat, 09 Mar 2024 07:12:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709997129; cv=pass; d=google.com; s=arc-20160816; b=rwgPLZotAYTGKQehGKZfwMkFcUUULxz2pch4pF2a6kS9xGUG+xjVU2cTD4ejWoEUNv J4b2Q6FEg3lfXNzD7eeEMnmWdLMrvFqcU5+gR926BXRkOeyV8Q1GNZR+IK81oEmsGBlB ydDC2DXC7VKCo8cI7Xd1q2sqCewTTlXcz1x9P8cIx7I+Arf+WGGshMptlThYv1jDJHdV 7Eq/MEofdRGeViLRMgmVZpDBwGhW0zUT4j79T3HIbLw7TKc98dMKZpEOXK817dpyoobd RAIm6LBOzfaVPO507m7U81GEP09fuqJcsF+f3bulhoJ7l2ama9w1Q6L0qL08Akhg4A1I urLA== 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=B5TwR5COvPT760SOA6Ay0oJAn7jOmxlMmoPduZfJB6M=; fh=JatissZ1qnklmIWIHKhaXeNGlLF6osdndn24MZZjc3w=; b=nDZIf6pUe8vcYWGiSVkRwv+0Y/3V8d3ss8ZWf86doXLSk7yv4Y9zVyudlyT2rAeTYU 8C5X51RCpYz+8rzvpFDhgTd/fkwyR8XS8hkF1A0ag6GmI6maZvYyYvpjqCJnE866LOa1 IDD4Ymo5jQs4I4x8ZZ2mY7bsukKqZXk1/69s1XLglCPsLJrYMlnxYQwhI+71W8kZoL9P eoStz00ssxPU/pgxbTFMSdBxR61oxoZdjLGVbplSVsevPFYQ32AmP3ho3Ghb6CO5+SND AcG7ZC/5LaT3dXJPXcmD//kyc770FlqWVQTomaL4KNjwCA3Hidgjlak3g4u3tk72qja/ 9RTw==; 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=IF4c6ilg; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.73 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=1709997129; x=1710601929; 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=B5TwR5COvPT760SOA6Ay0oJAn7jOmxlMmoPduZfJB6M=; b=QaN7RH1qBPyuhS3JFbnu/nihTIyJFlcPVfIGOIg0eZQjOXlj+C2aQSVwUD3dnLXLik p7NiUGuDJIIF7e2hGPPWkJDs30ddqaIHn1mY668R6arUs7M5XZYhr8q1QyJD6HYBAzWa WSG4AEfJz7M+udw8Nj82uTOfYD5PIXT4JGKtvU8rGpa5TTFlsKwOgwbdRoTziW4+byra 8YeIq7u5cghHAQA7nsEM5GipGJ6ZLkDR/Qfse/lmoc5Rc6xMHROFQiBH0wQncwhinf8J iPwAbTs8qUvMiclgupcGuETtky4gOHp3JD3CxgTPPot9nwanxYM2psdVfJU2B5PUzrF3 QbSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709997129; x=1710601929; 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=B5TwR5COvPT760SOA6Ay0oJAn7jOmxlMmoPduZfJB6M=; b=L9yYtEoI8bpLgBWs0f0thHyqq8O68v4b/vsQxsmhL66AJ4cj39pu0PVnCFQYEn8kQu bW9mAVM3XLdHl+RRdrS8LH2GGSgSsxv1+dx7Hg8JXEpKHDNO4DPIXt9rKtqIjcRb+tZx BRKA9q7pQEZPXAfeyQbm+slyoJWzaxtuoUO+qr1n838CDGudxxB45KV/QJBum19Nv7sy WLcQuw9P4qWx6WyDLCwPPOYF39nfK7ieaupFL5kydUCNqWq0dJrUlikfcZSL+qWLuGoT gUdER3RPUbBrZ+V1MjHs13DJ91iXOs0MKp9/QIj82qcx3XNMsOZztvQAVJhfsrViYID4 +j5w== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCVhJdoFj51W2zSPo6ixabgdOaDZqqw8oB64bidAtCAEf1xGUKEz8raBUU1paiX+WwG1XwNx9OQeaj6OV0Z54FLMq1b6UVI51iQdSOOKCQ== X-Gm-Message-State: AOJu0YxckTZhJK441CWX0uAbQoThjWxxIc1KmME13mFgsX8J7YpbR3s0 vyJrOzLN9vOizuhulWrZxsve4zRBEmpwgPGuq1vWP+4IK9v1ycv6 X-Google-Smtp-Source: AGHT+IFlBPsTc8ekN2JmZZUkoOR5pinsVrs4hV1jtYLUs/6XKzchGDQsORdHn0BsyDj67iNKMoNU4g== X-Received: by 2002:a05:651c:221b:b0:2d2:a53d:bbb9 with SMTP id y27-20020a05651c221b00b002d2a53dbbb9mr1547104ljq.50.1709997127859; Sat, 09 Mar 2024 07:12:07 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:651c:b23:b0:2d3:95f6:b8ee with SMTP id b35-20020a05651c0b2300b002d395f6b8eels1123539ljr.0.-pod-prod-02-eu; Sat, 09 Mar 2024 07:12:06 -0800 (PST) X-Received: by 2002:a2e:8551:0:b0:2d4:6e5:2cd6 with SMTP id u17-20020a2e8551000000b002d406e52cd6mr1199716ljj.25.1709997125807; Sat, 09 Mar 2024 07:12:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709997125; cv=none; d=google.com; s=arc-20160816; b=X/38hjjFeu0mQHc8XVjxfk8JdvEFmY4wSFq3N9fsQqQ0QucRw70iuQuGjBGBJPhc3T MScxLzPq0CI/EAEqfNXSot3GkuZ/sWYb5XOhADEpXWLICKYGzSvo9fHC0P8z5Wl2lWK3 AkNxqLNNjUo/5TVi8QUKX+0BVQu9/nbwTP4l0mlRYRR3M2Z+kvQVpOFl5cEpInfBH4bm Bir6XgYIqH424u2OsqLYb0459pnAP4ZIsMamJh9AZmmBVVE4t6IQiMxly0SHf5rlqwEq rl592bJvt3bvgqv4HQ1qH7p/QKumf2CQ9QaYUlKtU2sqJPra0OPJ0o1bKdK38Byy0xcn 1Xcw== 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=l0eEp0jlS5KdkGwNSK5iApzC8EDCxZT8ZZchcT0S1aY=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=MBtSu/1bhYm6caq/9uLXqNZyM34uO87oOPfibGJLdg8ClAXzjeJSRIYf3+y/WM4X62 IaZytQ2UW1EN0WGNCbt5Tbq8TEy51/Sj/1gyrDR3qHVVxIGKBl7P8RGlwwoWObJiJ3bm ZHT/N2u6KM0iTbjbcdylxGlUin4wghheHR+/JH8ECdYr9DYhVBT1BYEN8Vz6D3jGbOBj OZcqhnb65teiO1a/7ASicaS3EH1HOmHoQMfvHI5er/kMVujtovcO2gQ7tbmQGVEli+Hp 7ArQydENwNwP1Qwp/Lrn7RFLU3+u3YigySuicKh4AZcB20Uj0+aMdyrnml7mlVbKpYyu zPYA==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=IF4c6ilg; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.73 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [217.72.192.73]) by gmr-mx.google.com with ESMTPS id z4-20020a2e8844000000b002d32d63a68asi107199ljj.6.2024.03.09.07.12.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 07:12:05 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.73 as permitted sender) client-ip=217.72.192.73; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1MXp1O-1rJXbd0AcW-00YDsz; Sat, 09 Mar 2024 16:12:05 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 3/5] BUG: swuforwarder: SEGV for malformed URL Date: Sat, 9 Mar 2024 16:11:57 +0100 Message-Id: <20240309151159.8426-4-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240309151159.8426-1-stefano.babic@swupdate.org> References: <20240309151159.8426-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:tVcDeE7yJjX142J6PyCLdd8nizcpSBlWGR9EKSvX8y48Av3hMRs MpuCtysi3WnSY5SDmSRQ4lxx1oisVMPqOU5BRUDz24Z5os3CqJEBtJncT/g+kvmxe8LQd2m qeZzHr8iTOIJaqehYC8v+55DDwlqEIIQL2gcYrDTPp5T2O7RKOauYGUfgn350jSu9k2P2nB soBdgnZodBWIEaHSXHFbw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:NTaJw4n6Yvo=;7xGPEMBwUTODdgO34ASekesHJtw 1EffawizmbcCKLvUWSdIbl+mMtvmQCQGqCIHvPO189fHzmEOV/KcMM6+QUVKdmM4Di6vs8Iuz jsorKjtdCSHiioGCR9VGYA1WzpA8djcDA0G8uiPOqz1YO2g5jlvvMg287sOTgs9zU5kvg551V 2vhhm7MXjqwXCnJVeLE4l23fqJynQ8OGaOJf/xQ7pqVhXnmQ6JXIX39pVy5VvLkKvF7YEO9pv l4vP8JNqejIhAhNEvwSdFwL/nD+lzeEv8Y1K46dJ0Pjf0qexuDdqN+u2bHGOXvTJM7WzSRYIH OjXJXKoAhzxTRa9mj9a7JKxlr+n15Y9QlmTrgyEDBKJRDGkm0EGSbxdC6an3Sa7KmX31ZVt1J sO6rPxkWn8MltANV+hGGJ2csFuiit9H1hkWkayGORRuG5H7XFpTxov5ATOjrmGvXcRN9CxsDU euBiXVWGp3uWtjc+7khnsewLC6R+LIIB/Fd69vNVD5wHpUIX3Am5zJp8+gTfLWwqZfVzFZJ3j Y1IhocWepLvmDIt48PlsZRcdUx46CpOlc/FermSr6k5u9UuIHTx6i8XRw2dx7rp1p1X5mrHbX jGWiqj4AWIzYTg7t/N1GPG43HiSv1zttaN2K3T6nWg7pVuiJiaJeDMOOdgP0Jiv8KH9qt1RCu bgpQ/vkMq86oE0/DBHxBeXAj+lsXivZdv6Qm1/eNFKRU/bY/F2WQyoWvsBsHmlYBXXQKbhSBJ YrAgJ2/MYY3gxNFC4y0Ku3Jl7jnJv6SYXVk92YuSyJXcrVHCa2zVwE= 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=IF4c6ilg; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.73 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 malformed URL is not detected by the URI parser. TEXTRANGE_TO_STR does not return any valid string for the address, resulting a SEGV when a connection is initiated. Check for address before starting a connection. Signed-off-by: Stefano Babic --- handlers/swuforward-ws.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) -- 2.34.1 diff --git a/handlers/swuforward-ws.c b/handlers/swuforward-ws.c index 0c4d6fff..2cd98002 100644 --- a/handlers/swuforward-ws.c +++ b/handlers/swuforward-ws.c @@ -160,11 +160,19 @@ int swuforward_ws_connect(struct curlconn *conn) { i.port = strtoul(tmp, NULL, 10); free(tmp); } + + /* + * Check for a valid address before ask for + * connection + */ + if (!i.address) { + ERROR("Malformed URL, exiting: %s", posturl); + return -EINVAL; + } + lws_client_connect_via_info(&i); free((void *)i.address); - //uriFreeUriMembersA(&uri); - return 0; } From patchwork Sat Mar 9 15:11:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1909979 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=w7YzKHQF; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::440; helo=mail-wr1-x440.google.com; envelope-from=swupdate+bncbaabbr7ywgxqmgqesp3tvji@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-wr1-x440.google.com (mail-wr1-x440.google.com [IPv6:2a00:1450:4864:20::440]) (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 4TsRNF1nPqz1yX8 for ; Sun, 10 Mar 2024 02:12:12 +1100 (AEDT) Received: by mail-wr1-x440.google.com with SMTP id ffacd0b85a97d-33e7ffdf5c1sf511070f8f.3 for ; Sat, 09 Mar 2024 07:12:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709997129; cv=pass; d=google.com; s=arc-20160816; b=Y+0a+9uaDW9u+jN6+F8KDC6uXTPnTMCLcmPpZr0zmeov/3C5kip+jlZKahFYRz6F+F xmSzRzWzAyZvyc0v9IHRmUSyGOvea6+5E9eET78jaTSFoQU/AgqHvY96LRzlW3SZMb2o id5a53Fi6AwI8DoJMWL5zwwlXJBadhl7oPavUK06/KiEWcnOArfW6HgXP0YtblVodoeD 13fe0pvyiby/341oOsJvRvWtheOxNtId5YoQEK6VFveScDax1zaFrAU5bn5Cq88UYdcE TA16maZZEMC3PRYE8FKf+QpAIllvKiwnMZvipFI+6pENcqd0s48HS6PFCZRtqO8RvGFC uqDw== 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=3d30IhqySL6c0x9RUNnj4fACUTWcM5AWoNS0D3OfSTI=; fh=2L4pW+j31QCh5V2ZvJpt9vFBYWC8YGcwyhsE9qFoL3s=; b=0LdoajdW7t9F9V95YQCwSmn4yRVZynfAheTRuhQg4LWl4JNdXwNjzX2LNHJqqtUmpX S6vzNHmejWpxOFz25U4vPhel4Wu6MlzkxSPWF8HvkJXU/KO49Casgyyjy9uqNZJqgnRZ d9xm3phdiyIqbCyEz4qDN3ItEitE7s7up0ZPeIIxtVkbUwtF8drLjovISTbTkIAa+4e2 e5Bh17B4D/f25dX0A/3d+dsUi7se9EezwaSFWPWDkSjGwEcTw5dWNzOH2YOqZi6DEvOl UFUVS7EO0QAKkGLq1ZMZ4tjy/9uytX/uYa2mcU0iNht5j5IqrzOvfHE/HfXRKxtOcCED JQyQ==; 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="s/4YiFPp"; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.74 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=1709997129; x=1710601929; 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=3d30IhqySL6c0x9RUNnj4fACUTWcM5AWoNS0D3OfSTI=; b=w7YzKHQFjYJEqnPmrAw13l06otT/xnQwfklilBrlRGmxt7s1LfS7Dbi+kiECp1DC0Y hlzfXCnPVKp49Wsclu4g07EnjID+Jf1FaloQqvnyvFXHRrJhhxHD0coiC6fiaI7piT/9 ArU10zJUxiVx6i8xmHjzx5HvF4D9w0RwwQQo2Df25RtHJIac1a+D35TYevqs9FqC5F7A o33XDA3/tLmKQfmBR6RJBS8o2yFbTSsd+NpCiKzhurO89+DMaXl4HfHnvXdxfFozLDQl riEuxCrcixuXXZTCM2RTjByZ/MF6iW8hsjCHU1qshhl+/5c5EiV8qhoY6E2ZGlgrVE9n lstw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709997129; x=1710601929; 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=3d30IhqySL6c0x9RUNnj4fACUTWcM5AWoNS0D3OfSTI=; b=UnCtztLZ332QAgT7zzJgUIFhn7O7tOa1XhTaJg9JVhmq5lZw0Ad48SvCaOPC7YP47L J5dCJq2hte+I55mVlBwI+4+XWhtFBM4wklpQhfPkq5SAaA4JThMhQqXjFNDuXAisi+xM VeS6THDHli87CbWvKAAaFat/A9TNYRAUPQqM42lr5sM+oqel/7w7opyDe1idfiWk2ArA ucIsbu/aktRIn+ObmNu8H8ygnlbfHz9Wb7Ps5JEnRUes93DHnisGR9u/LoMXdB8DPs10 sUOGczKfjdThUKzvkquK2Y8eaYMV1Hg43Fa9gts41bIjSQu9u2UYkiMk/zWLqVRzOJiQ T44Q== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCV5pRaOy2tmQ+FfqmjyNdlN4oEbkFtqENTKMBkaq3Y5EqAhZ5/gsQxwHU1Rb7X+9j24ZwgkVmL4CTo/WaGPBZpeANI2B0IFZ46olI4dBg== X-Gm-Message-State: AOJu0Yyo0I0U1sOV9lPgKTDFdhJ5QGq6eQLXkF7ZuAlryIsbhcJvmDA8 HjIPieVcvWWr+sdSxpqEwuvBpC2JC+4NsjGfl1VFBloyuqPeJcZk X-Google-Smtp-Source: AGHT+IFgvAe1gqzJke46TYqiFEb5lbxch9SDb0uR0a3MuZlRGYHl536LJB/4vqh/B2vi30yAXUwukg== X-Received: by 2002:adf:ed85:0:b0:33e:47d3:a6cd with SMTP id c5-20020adfed85000000b0033e47d3a6cdmr1526074wro.68.1709997127657; Sat, 09 Mar 2024 07:12:07 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:adf:f50a:0:b0:33e:4c3f:9f8c with SMTP id q10-20020adff50a000000b0033e4c3f9f8cls1098311wro.0.-pod-prod-04-eu; Sat, 09 Mar 2024 07:12:06 -0800 (PST) X-Received: by 2002:a5d:55cf:0:b0:33d:c3e6:109d with SMTP id i15-20020a5d55cf000000b0033dc3e6109dmr1580010wrw.61.1709997125617; Sat, 09 Mar 2024 07:12:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709997125; cv=none; d=google.com; s=arc-20160816; b=wsrqSvNMCD87aFcGGbieBADXvG4COiUl+WwE3DPNEC8lc37YL3B7832+nqd0CsjySD B1vaAi7ljhLMmu0Xv/P8ac0TJYmdNsEmZ/IOyi9u5a8ZgVFHb137bCqJEgvbQMePj0dH 8GfnjUdC50Jy8uBxXfDuLvz/QMmxQ9yTgVVVmc80gVu0U22GbDQHDI8nVCufGCqy6G7e g5eD2pzbnLnoLJCCQDi4oB7OtXT6jssr4m/SA6pHdALDBSJ8bybNnHoYGEyB1yv4um8F MMfEwm+fTVVDBeRE8NRObRuP3WK4hkGJVmxnwKCjpijX9QHTjvBsQKgmhc2k3u2fQQxa USnw== 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=+D8C72s/kVOlj8mUzh61RSEWgdRF8Q8NZlNdtZgrki0=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=Q7LlER6xEv/MMO21fvahKtHaor5zOCsCDw2EmMJePzsiUDqJngK7eDVufOK/Xro9vO vC4Ar0hzOAIOgdiEVTLplyJuhR7DIFQlnRD1XW3dREAYWe8u5KSJZR6KV+Kb+/c172Ew 9kE6ST2+Qq3FVWmUBS55dBq+RgzlwgL5Xg8AWXW788n3OAFog2wCjx20PFn63aZqhDY+ 13t/yubCb/cp2fH0DWGa2qQpqrwDFpUk3WrsdOK3CKcOG4/CRhBcUIkl9EhHJYfBfrEz Prbcu751JYyANfOe52Lvb/XoWUGpcWIIBrG1N8ln7Dfx+67BOY0W67pXKDCnDXFCWxJ4 NjMQ==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b="s/4YiFPp"; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.74 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [217.72.192.74]) by gmr-mx.google.com with ESMTPS id fx12-20020a0560002d0c00b0033e7e5930b9si85292wrb.8.2024.03.09.07.12.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 07:12:05 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.74 as permitted sender) client-ip=217.72.192.74; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1Mgek6-1rAz050k3g-00h3af; Sat, 09 Mar 2024 16:12:05 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 4/5] swuforward: add generic uploader Date: Sat, 9 Mar 2024 16:11:58 +0100 Message-Id: <20240309151159.8426-5-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240309151159.8426-1-stefano.babic@swupdate.org> References: <20240309151159.8426-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:QPOY0L4OpHcuXQ3TDWU6uDz5d1+nwyYnf6wiarFV/XYBMQooKu/ wQ0gJAe+hGaL7KK0REpRBYPZ6rZ03eGD3u+0y+LtSs5BmzI5HqMhKX4yli25rWpA/Nlay3p xwbp0OPRKbAJ9y2aPArs7mhBU/VbCeyLYBupOXuwCt1lbFrdvGqskUUYgBJltPI0fl6H7JE PrsZkFk/uphGo0GDK26oA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:rB0VCCtdycs=;bwPDRpyEvasdwpHg2dB0LnskjDI C9iWaoLy6jglzR/QrXXXzA5Ow7eaBWMqdMwZL1k/tepE8zpRR7a3Jd0gXkoc84OEHhnaRcA9P 7yIC4wQTVG2ftjXRoE+NeknA4TW/BNWUT8jvLRRO5mlS6z9XZSTRQpxYZfjiDm9kOgbwyL4/Z LDJT0Dq7VvMfRzcLuex1G//ld5UoHp2sV5zToxcJqmQlIIZ+LDnkNw2+vfapup08z7lPg9wjo sPIicLrJLs5p8ANMGd9X6Cc3EZNO7IGgwSRxFyDdGOMs98hOAnUsV5o+HPGDF1aJAv3HKw5r9 kanvS0N1/2lK+hCrj+Cp+Tzu+2PobG3A17y5ZeXqVEAHYFa1NPSkYyMyWcRJLB60I0ReWqoHX IKj/k3Xyl7LYr+76MPk6rioWckEsmCMLAb/B7Nv1sHR+sS7v3whmIKBYZakuQMZsgM64QbKVy yFt1mwg2X2oRG9IDxH76xDKFqBJtI/F6EQaCNIbPUtMaVcgRJvWAw0gTT7SE+HVwWWI0pIxdb iQ8UxIe80yIHVnBmeAf5J6T2bqzDsgUgpQo8vm0gXnOeWBaZToGU5KXGZRkgRRW5/KUqPGv+3 qH1ueO8rqJOTjtB+nt0HajxHw47YXwNGDsSxmN0jBDNUW4Mlkf1UffhK3W/HhbL72XwcPwdJx SQbm9WkcQhU7V4uWkNMsyIp1PNF8nhYQTLM4AVITjGzmxqHxrC5b9dvDJX5bMfqp2MfRcK97k VAFB8sPfe5v4gb5ubun199ezmP/g5aqxUGzaLXhXSpwGiO12zVNkw4= 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="s/4YiFPp"; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 217.72.192.74 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: , The handler is used to push a SWU to other systems running SWUpdate. This patch introduce the concept of generic uploader, and the handler can upload an artifact (not only a SWU) to a URL. The handler will still connect via Websocket to the webserver, and it will parse the answer. To make it generic, the answer can be parsed by a custom Lua function, that should be loaded previously via embedded-script or via a script, or even via swupdate_handlers.lua at the startup. Signed-off-by: Stefano Babic --- corelib/lua_interface.c | 4 +- handlers/swuforward-ws.c | 97 +++++++++++++++++++++++++---------- handlers/swuforward_handler.c | 17 ++++++ handlers/swuforward_handler.h | 3 ++ 4 files changed, 92 insertions(+), 29 deletions(-) -- 2.34.1 diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index fbdb7d05..90aba6eb 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -1608,7 +1608,6 @@ int lua_handler_fn(lua_State *L, const char *fcn, const char *parms) TRACE("Script : no %s in script, exiting", fcn); return -1; } - TRACE("Prepared to run %s", fcn); /* * passing arguments @@ -1629,7 +1628,8 @@ int lua_handler_fn(lua_State *L, const char *fcn, const char *parms) lua_pop(L, 1); /* clear stack */ - TRACE("Script returns %d", ret); + if (loglevel >= DEBUGLEVEL) + TRACE("Script returns %d", ret); return ret; } diff --git a/handlers/swuforward-ws.c b/handlers/swuforward-ws.c index 2cd98002..ed881fad 100644 --- a/handlers/swuforward-ws.c +++ b/handlers/swuforward-ws.c @@ -35,16 +35,47 @@ struct wsconn { #define TEXTRANGE_TO_STR(f) (f.first == NULL ? NULL : substring(f.first, 0, f.afterLast - f.first)) -static int callback_ws_swupdate(struct lws *wsi, enum lws_callback_reasons reason, - void *user, void *in, size_t len) +static void swupdate_web_answer(struct wsconn *ws, void *in, size_t len) { - struct wsconn *ws = (struct wsconn *)user; struct json_tokener *json_tokenizer; enum json_tokener_error json_res; struct json_object *json_root; - switch (reason) { + json_tokenizer = json_tokener_new(); + + do { + json_root = json_tokener_parse_ex( + json_tokenizer, in, len); + } while ((json_res = json_tokener_get_error(json_tokenizer)) == + json_tokener_continue); + if (json_res != json_tokener_success) { + ERROR("Error while parsing answer from %s returned JSON data: %s", + ws ? ws->conn->url : "", json_tokener_error_desc(json_res)); + } else { + const char *reply_result = json_get_value(json_root, "type"); + if (reply_result && !strcmp(reply_result, "status")) { + const char *status = json_get_value(json_root, "status"); + if (!strcmp(status, "SUCCESS")) + ws->conn->SWUpdateStatus = SUCCESS; + if (!strcmp(status, "FAILURE")) + ws->conn->SWUpdateStatus = FAILURE; + TRACE("Change status on %s : %s", ws->conn->url, + status); + } + if (reply_result && !strcmp(reply_result, "message")) { + const char *text = json_get_value(json_root, "text"); + TRACE("%s : %s", ws->conn->url, text); + } + } + json_tokener_free(json_tokenizer); +} + +static int callback_ws_swupdate(struct lws *wsi, enum lws_callback_reasons reason, + void *user, void *in, size_t len) +{ + struct wsconn *ws = (struct wsconn *)user; + switch (reason) { /* because we are protocols[0] ... */ case LWS_CALLBACK_CLIENT_CONNECTION_ERROR: ERROR("WS Client Connection Error to : %s", ws->conn->url); @@ -58,33 +89,45 @@ static int callback_ws_swupdate(struct lws *wsi, enum lws_callback_reasons reaso break; case LWS_CALLBACK_CLIENT_RECEIVE: - json_tokenizer = json_tokener_new(); - - do { - json_root = json_tokener_parse_ex( - json_tokenizer, in, len); - } while ((json_res = json_tokener_get_error(json_tokenizer)) == - json_tokener_continue); - if (json_res != json_tokener_success) { - ERROR("Error while parsing answer from %s returned JSON data: %s", - ws ? ws->conn->url : "", json_tokener_error_desc(json_res)); - } else { - const char *reply_result = json_get_value(json_root, "type"); - if (reply_result && !strcmp(reply_result, "status")) { - const char *status = json_get_value(json_root, "status"); - if (!strcmp(status, "SUCCESS")) + /* + * If it is not connected to SWUpdate's Webserver + * call a custom Lua function that should be loaded + * in advance + */ + if (ws->conn->fnparser && strlen(ws->conn->fnparser)) { + /* + * First convert the incoming data + * to a "data" stucture (string) + * that is passed to the script. + * Raw / Binary data aren't supported + */ + char *data = (char *) calloc(1, len + 1); + if (!data) { + ERROR("OOM when allocating buffer for Lua Custom Script"); + ws->conn->SWUpdateStatus = FAILURE; + } else { + int ret; + memcpy(data, in, len); + ret = lua_handler_fn(ws->conn->L, ws->conn->fnparser, data); + switch (ret) { + case RUN: + break; + case FAILURE: + ws->conn->SWUpdateStatus = FAILURE; + break; + case SUCCESS: ws->conn->SWUpdateStatus = SUCCESS; - if (!strcmp(status, "FAILURE")) + break; + default: + WARN("Error parsing answer from Webserver, %d", ret); ws->conn->SWUpdateStatus = FAILURE; - TRACE("Change status on %s : %s", ws->conn->url, - status); - } - if (reply_result && !strcmp(reply_result, "message")) { - const char *text = json_get_value(json_root, "text"); - TRACE("%s : %s", ws->conn->url, text); + break; + } + free(data); } + } else { + swupdate_web_answer(ws, in, len); } - json_tokener_free(json_tokenizer); break; case LWS_CALLBACK_CLIENT_CLOSED: diff --git a/handlers/swuforward_handler.c b/handlers/swuforward_handler.c index a4517430..4d346bfa 100644 --- a/handlers/swuforward_handler.c +++ b/handlers/swuforward_handler.c @@ -293,6 +293,7 @@ static int install_remote_swu(struct img_type *img, struct dict_list_elem *url; struct dict_list *urls; int index = 0; + const char *fn_parse_answer = NULL; pthread_attr_t attr; int thread_ret = -1; @@ -317,6 +318,17 @@ static int install_remote_swu(struct img_type *img, return -EINVAL; } + /* + * Check if a custom function is set to parse the + * answer form the Webserver + */ + fn_parse_answer = dict_get_value(&img->properties, "parser-function"); + if (fn_parse_answer && !img->L) { + ERROR("Custom parser requires to enable Lua, exiting.."); + ret = FAILURE; + goto handler_exit; + } + /* Reset list of connections */ LIST_INIT(&priv.conns); @@ -344,9 +356,14 @@ static int install_remote_swu(struct img_type *img, goto handler_exit; } + /* + * Set parameters to each connection structure + */ conn->url = url->value; conn->total_bytes = img->size; conn->SWUpdateStatus = IDLE; + conn->L = img->L; + conn->fnparser = fn_parse_answer; LIST_INSERT_HEAD(&priv.conns, conn, next); diff --git a/handlers/swuforward_handler.h b/handlers/swuforward_handler.h index 78d30731..0c32a173 100644 --- a/handlers/swuforward_handler.h +++ b/handlers/swuforward_handler.h @@ -12,6 +12,7 @@ #include "bsdqueue.h" #include "channel_curl.h" #include "channel.h" +#include "lua_util.h" /* * The Webserver in SWUpdate expets a custom header @@ -52,6 +53,8 @@ struct curlconn { size_t total_bytes; /* size of SWU image */ int fifo[2]; /* Pipe for IPC */ char *url; /* URL for forwarding */ + const char *fnparser; /* Parser for the answer via ws */ + lua_State *L; /* Required if fnparser is set */ bool gotMsg; /* set if the remote board has sent a new msg */ RECOVERY_STATUS SWUpdateStatus; /* final status of update */ channel_op_res_t response; From patchwork Sat Mar 9 15:11:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1909978 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=nPWBVyh+; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::33f; helo=mail-wm1-x33f.google.com; envelope-from=swupdate+bncbaabbr7ywgxqmgqesp3tvji@googlegroups.com; receiver=patchwork.ozlabs.org) Received: from mail-wm1-x33f.google.com (mail-wm1-x33f.google.com [IPv6:2a00:1450:4864:20::33f]) (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 4TsRNF2QKpz23qr for ; Sun, 10 Mar 2024 02:12:12 +1100 (AEDT) Received: by mail-wm1-x33f.google.com with SMTP id 5b1f17b1804b1-4131765ac62sf8230185e9.0 for ; Sat, 09 Mar 2024 07:12:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709997129; cv=pass; d=google.com; s=arc-20160816; b=GHH+tH54vxSgw7ehUsSuJ5qv7pf2bYkklHkIa/XmFp2d6zSEQCv6NvccNauQNQKhhd OR2oz6B/bgpioOf3eQYc/2UbR10dRX87eiSoQNYuVED+psHVHhhjfMLHJ8ObWV9ST7TB fyu7ZkY+jscWXQXwJjWXOobOl9tlKxcmaI6qh9k8cskqNMQY5crcjomASd4YkWOpanb5 Ez2+0C4iyj+3JxPl97+PJaHlD4zO2mEEsBVPK7nDdz1MfMTyqD01DZe9NcdEv+rkEoaX /ukjDYkcdXystdbx4cHXzUd2h9327IfZl6Hkn9cRFVV3ByPyF4JncNWqXbgFpHlK8wAO KE6Q== 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=L94ePFCg/YDYf0YjBzfudAQkOPgEvcJAbfFjIy54CHQ=; fh=XmboP/77JO02+pwCe/aeqSEq/uETDGDlnTsdMkz/+tA=; b=mwkYMD+dPeyZacnJdtBjwudx76pkP/3Ex3f1WF+xgikO/KvBQyvesDi4+48My5sRSW KxBfpasZ+3bOVZxeE1U64B4y5zDEKu3bgW52Dw4z+5QxW/q1sPf8e8yFDpYx4MyVyY3j vqrQV8L7NzBt9Y5K7yHInKlip1CH/YEiK0W9DmpcLyZQsh9EDjrxon81uWvy1mkV4tLy IdonIu3WngX73Jesnw94BVCGELFuv5PCFmNSsRkQoGN0r59fY1ywIsTAzA8GSPVHCZ9N 4re2qfd6Fk67K0Y+GLINw8NP1nRKpc2gyz40+MkPMBpiKPyUcU1cqJssTXVsXYoOoxpX zPbg==; 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=bIaB4eRf; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 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=1709997129; x=1710601929; 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=L94ePFCg/YDYf0YjBzfudAQkOPgEvcJAbfFjIy54CHQ=; b=nPWBVyh+JUo31Z4Oe8kel+p1Sv5xz7iGXtd1jcqHk/NRUKhYWS4lR9xJC1T3UEDQfY UU6TTyTONphLEhoi+/r8J9uoixLrLOkZntKgW7qYrxVE5YgQ0IvHaH/XKEw7kvPIl3zB NZ2w6xRNKs7RhJ07AFPrG18DnHfw/nHiAWuebv7NJmnUv9/VCheWIHttUIEgxl5OSAyp PmrfEwhsGZx20WhtIwKW3IWkeeS7V4Y9l+0ZSwS6430/UGEv7fSFr65XVxJZRKbzOejX XJyUkS3mh6k8jdxkur8BU156z8HgiflD7JIk60lcUbWPzXP+JgdloGgeGITYaiDiL4nE 6cTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709997129; x=1710601929; 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=L94ePFCg/YDYf0YjBzfudAQkOPgEvcJAbfFjIy54CHQ=; b=uCHcUXmJnkUtPF3R2kbuzBrHtiRWYSxc1Dg6JHAYyK6eGFdnUmcnkD5hFNhb9nsiN9 0qozaHmtM9Q/Ouq+lc6uY2pVh31w3HWcUua0IT9OlG1FOo/+T6MdN4dg99CPltpMlppU fEosmP3rPpQvMAYV58xFqOClJxUwOFj/8Oopxhsxoy8GMkVjOqO+STYZCq3zksnUWDBf DCdRwLSJZls+q2ZNTVhN+Z8OinNgBOJB+P4kvLUXUYE6RbrmJwLXCJDvYU9kB8vBN6Vr jV0gs+1fQuIz13BA6y3dBNd8SuXlR/PKmvX7k7G096NpNPwNiyNUhFh9TmjKxkj0jmeM 96/Q== Sender: swupdate@googlegroups.com X-Forwarded-Encrypted: i=2; AJvYcCXagBPWLHoblxO+Sm/mbIMNnVqCUsOgc2YJ+iGWFLlRKqL0VccmY+Upb7laA6WlQJvE7on79nLYgXtiiFK6MSijRoSV1g3lF8S0xbJMRA== X-Gm-Message-State: AOJu0YwLjDyw7r4amsbr8Pq0SXw2Nxrz/3shW1MEfIMxKdQSy02XcPH4 bpfZBPhoZjg9AJOsW6VoFtCHWrF6Wsgv7HjjpeyNyQ0H/+v/BCvf X-Google-Smtp-Source: AGHT+IFECc5EA201GpgrmiKai8B6dRiLF9gYO1+hgqMraZynZ62XAX1C0O4FlxS0SDwHQSFODgAlJw== X-Received: by 2002:a05:600c:4ecd:b0:413:1dbd:b4a9 with SMTP id g13-20020a05600c4ecd00b004131dbdb4a9mr1635288wmq.10.1709997127576; Sat, 09 Mar 2024 07:12:07 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a05:600c:1d0b:b0:413:15f2:21ae with SMTP id l11-20020a05600c1d0b00b0041315f221aels907980wms.2.-pod-prod-01-eu; Sat, 09 Mar 2024 07:12:06 -0800 (PST) X-Received: by 2002:a05:600c:1d11:b0:413:21a4:a407 with SMTP id l17-20020a05600c1d1100b0041321a4a407mr997176wms.37.1709997125784; Sat, 09 Mar 2024 07:12:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1709997125; cv=none; d=google.com; s=arc-20160816; b=yWNnDSd00nxTeW2G5bhyOocp99scUQbt6h90gL4w6otq2iXLnXoxhpgAHjZfZFOyqV Tk3fC0C+aj1cqIlYEl6fKPdfbN49jhzHAFmgaFsXQO3YjPCcHOaftQ/OaPO3CybzEYgP 00dR/y1KduV41yCUoQt+Tsa+LoYm32BcoxhGk1NoYaVHIZ1KH3TGYGWBkrkqiKej29BT 5l/79KFagEh637osmGfrEVmAJT/zs99m01HGOcq67h/M3H+kPPb/0NF/Y/+of29Y75OM aJm2vt9ZUqboC/iSZj+X2V4zb2om/w+Ni701XYCJRtu3GCsOZHOEuvc5rlH+68PZf9yY OtVQ== 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=+5O6lt97EwBEtqI1NRFO4o3pbV0Jp4dI981WeOJWHho=; fh=TiEWcqMcKpHk5s7uErzpntoONrNfOXwKpI5P8bIlggk=; b=D4DRdTFQj9DtortKjWCySUy+8nOnpHCO8+CVAFuccR/K+Td8f/M0JxSYDEJN2jKHPv kpKxQCV2jGlOTPz8WvRpHNVcirOJwGCBlvZi/gactozvholJsAHaFU8Vh/yN4THWc486 8pKhNFoMYCKY4seFWKzUDr9zpJZSGTi06kndHaU8Dc49R+I7YDFB0M1+6l459IXPn8n8 yfyLrEoDFUDNcAZv4UiSwORvQYBX0RvPVHtLEURyH2mlQZ80IdDX+OiOfJWc8SIHLuAt wp7PrNSEI0kGY74rvFxCmSkO/3to0xEBgOyKOLcZpBrTQ0JkXluNkLFwBiDcjYuNSMB4 w5lA==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@swupdate.org header.s=s1-ionos header.b=bIaB4eRf; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 as permitted sender) smtp.mailfrom=stefano.babic@swupdate.org Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.17.10]) by gmr-mx.google.com with ESMTPS id o19-20020a05600c4fd300b00412e5895f17si288704wmq.0.2024.03.09.07.12.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 Mar 2024 07:12:05 -0800 (PST) Received-SPF: pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 as permitted sender) client-ip=212.227.17.10; X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from paperino.fritz.box ([88.217.136.221]) by mrelayeu.kundenserver.de (mreue109 [213.165.67.113]) with ESMTPSA (Nemesis) id 1M42fG-1riyMn1Jui-0000bJ; Sat, 09 Mar 2024 16:12:05 +0100 From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic Subject: [swupdate] [PATCH 5/5] doc: extend swuforward documentation Date: Sat, 9 Mar 2024 16:11:59 +0100 Message-Id: <20240309151159.8426-6-stefano.babic@swupdate.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240309151159.8426-1-stefano.babic@swupdate.org> References: <20240309151159.8426-1-stefano.babic@swupdate.org> MIME-Version: 1.0 X-Provags-ID: V03:K1:BlrBb8U0WGiCzc+pr/pWy3zlQPfCO+COtuGxPj5KYJYRtFEc2Hx OnUxbSVzc09Yg01NkXMX4jNihffOYjQN9fv61LfoQrlk0U+xHL5fPSt9eyVza5QoY6cd2AO GCLRc8zbBv2tXoDv0TXwiNouiKtFIwHo+9sFNu3ib8vkCGUmUvIax1Mxof9o8OSLwgsA+KI b8pyi60ZJ73jccINglc9g== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:CAn0zrSWCeg=;vup6q3V7tPBwTyCbKmY1hdPzFaR N2bIRKDJcmRe/p2S2j4yOvSFt+QEfpW51tU3ufKnfD5DifPaDtqVlib8TKvLxX6J3C2yPWJ6E JXmhG5vgwcJBHOvuKfamYW/v3PAFnrJ4hDXRtaLOEHKt9EUchtHb3XFWYScJk/j3SS6Qo9B0Y 0ACWvi9khMrD+/oAP3viS2iGDdgbTFqaDCjVbd+AYlnseRSpjxoEIBBuOlpOgkbwu2zm5CIX4 9f9l52+65OCg9+jsDZAoPGf/f3tWyXGHKXrQAMlfVWGmNe7LV4bMXBXdOG29Yi2Sg+GlBIKWX S2XR3bzglmm6Vp/vNZ++Sc1Lffup1h+VpulPHY1Tx3NXDEt9SEbI/OEZ0BkgY1T1IfLE5mf8x Gr0nRaC37+PKbDqSyOsfx/Wy/7J2D8ATPDu7shAYK+0CJgPgAwn2c8wi5FNjgwXwKR9tsGOKK zXhHEkjElTuEQhLhCOtCEQS/q3lUimHC6L/+fXd8DABZEf9CKkvP5OLtCi+3g5bXbLz8W4uCf fyMCiApSuV/y6WOE2zQSAxNWXp2blMZSqsgB2ERipfn07KzzZ11mCZfew7u2BsP+t5bmOtsy2 KY+zMiQ+IZgGlAudECSdEk4BDafdWDgQ0XQ7RqwMcnxmDsLK85wIhN0Yotn3WnKHoyqIvcaOa sX/a4sRT7Kggmzf4dDqJQwQYSgPteKmjNIyAmi9gP25euPHSd46Efw25sRNFWC0M6o8djsOm8 wp6LTJl0/bJhBv+M58V0aEvMw4raSRoa0z+teOev/mL+5rKkNKH77I= 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=bIaB4eRf; spf=pass (google.com: domain of stefano.babic@swupdate.org designates 212.227.17.10 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: , Describe hot to use the handler as generic uploader. Signed-off-by: Stefano Babic --- doc/source/handlers.rst | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) -- 2.34.1 diff --git a/doc/source/handlers.rst b/doc/source/handlers.rst index da0bbeb8..9e09e420 100644 --- a/doc/source/handlers.rst +++ b/doc/source/handlers.rst @@ -627,6 +627,49 @@ the SWU forwarder: }; }); +The SWU forwarder can be used as generic uploader to an URL. This is requires to enable Lua support. +The back channel should still run via Websocket, if the connected server should communicate a progress status. +The handler allows to link an own Lua code that is able to parse the incoming data, and +report an error. The `properties field` should contain the name of the Lua function that +should be called to parse the answer from the remote system. Note that the data passed to Lua +is converted to a string (and null terminated). + +:: + + images: ( + { + filename = "image.swu"; + type = "swuforward"; + + properties: { + url = ["http://192.168.178.41", "http://192.168.178.42]; + parser-function = "parse_answer"; + }; + }); + +The parser function should be already loaded. The Lua function receives as input a string with the data +received via the Websocket back channel. The function will read the data and return a single scalar value +of swupdate_status, that is one of swupdate.RECOVERY_STATUS.*. +Example: + +:: + + function parse_answer(s) + if string.match (s, 'SUCCESS') then + return swupdate.RECOVERY_STATUS.SUCCESS + end + if string.match (s, 'FAILURE') then + return swupdate.RECOVERY_STATUS.FAILURE + end + + return swupdate.RECOVERY_STATUS.RUN + + end"; + +The handler evaluates the return value, and stops when one of SUCCESS or FAILURE is returned. + +If no parser-function is passed, the handler will run the internal parser used to connect +remote SWUpdate systems, and expects to see a JSON message sent by the Mongoose Webserver. rdiff handler -------------