From patchwork Thu Jun 5 08:06:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bytemark X-Patchwork-Id: 4121 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 7EDC13F1DC for ; Thu, 5 Jun 2025 10:06:15 +0200 (CEST) Received: by mail-yb1-f198.google.com with SMTP id 3f1490d57ef6-e8175dad87fsf1327584276.1 for ; Thu, 05 Jun 2025 01:06:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1749110774; cv=pass; d=google.com; s=arc-20240605; b=kCU+jtKf47CoGT+lOj1OgpA/zu/znUO/hi0ekdxdVcg4BUuj1DD4wY12zFrSL2VIfH QEr1j4cAp3LqjJp/T9auFQ+wypDZ6x7Kr8rsOg5MNZ/aUULP86he8x/cZFMyEVnGBfbc qEmGGIQF1bd53rcYpog9ofgxlKDFw+qRXRNion19Mo9Xjb2jkZC7qn11tET3pc2a/ocU FmPeTxZ7aPzN525SvGsrrkL5S+47uelxDZmSKA61cJu8Q/MHxtbdwCO86ZMu7CL59EdC u0vYCzGjCNTwzchKvhfdKdEQ5R/3wpJJKaZixDdr2qKq9Uas8IZY+CPEraxab23UZK+C 0SKQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:date:mime-version:message-id:in-reply-to :references:auto-submitted:subject:cc:from:sender:dkim-signature; bh=G14VlVawr6qdnUJ2o5C8SCQYdfjwNvouueEbnykA3m0=; fh=SyE0VEI6qOkmoO+j0XTMyB+lOJVkfPi0upnNrLnAFNw=; b=kBdf11YEek8KPHRlLlQ4kF14+9NYFgmQzufpGI1sf4tBhRLahW2tBZiniZxMgSKWjd Jf3qFn77eue818fQoL3iWuiWGnLeTy1hZ0QQZE+pJxa8fER+PV05yjAv2LWUcO1/lOWk 2tBzGNaiRvoR9o9daFeyziMJ0QqwX9WNKRfvqPgA6VcxeA4jMBwUTVQ4DFZCc0GNNTZv tmqF5j7VrgtOAXVTn3quhiMGl1hycz1q+O0XOzv3OZOVb4NsJMW7QTCbDU0LdqkOzwHs REei5s/0L+eMLM1ZrevO6urShgqF8MqTJJLZAXFj8mCWa6Q1iF/dBpT//1+qz8npl+x2 wuqA==; darn=patchwork.amarulasolutions.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bytemark.co.uk header.s=bmsupport header.b=k+J4ZVJr; spf=pass (google.com: domain of support@bytemark.co.uk designates 188.227.164.22 as permitted sender) smtp.mailfrom=support@bytemark.co.uk; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bytemark.co.uk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1749110774; x=1749715574; darn=patchwork.amarulasolutions.com; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:date:mime-version:message-id:in-reply-to :references:auto-submitted:subject:cc:from:sender:from:to:cc:subject :date:message-id:reply-to; bh=G14VlVawr6qdnUJ2o5C8SCQYdfjwNvouueEbnykA3m0=; b=ao6vCnqLM4yEFzYthUCvSvDxyjt9B9y+i0lEr6MfWrSqo4+Ge3nOcpOuOmuayyn56K 7uTxCT8ITmItDscOYILneTuobhhMlRWO9kb7v4RJPpTlwbNdtdj8s8FOsciORKdYkBKq 7aHpg68z79C0GpisDgME5al8aPrttNKIz39Mg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749110774; x=1749715574; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:date :mime-version:message-id:in-reply-to:references:auto-submitted :subject:cc:from:x-beenthere:x-gm-message-state:sender:from:to:cc :subject:date:message-id:reply-to; bh=G14VlVawr6qdnUJ2o5C8SCQYdfjwNvouueEbnykA3m0=; b=pfEDG9eINbvU4g4j7lCzX72metolPyFE/jBH/8IWy/T2lhqSw/N1fuIyY4hlUm/O8D 7k4iBxlVN11/vhafhQt4ydzAulPp+tZ8JXisSnIIGtQfhjo6uEHflkvp/ibFavffmMwq 1k3OPviUcKCikhvpClwfrlYxEDgWRzjR8AXVArr1q9Com3OcFmEumXVA1RJ9txcewcXx F7SRen3x7SOZpOwoQ8R1j39V/7AFz5r3/FBlBCmez2omotnPE3Emmr66zaWNqbVE6meD 2bvqaZ+a6oOlBTGgIiA7Y33bMVcFWCbc3sHgGQknISJmR6xoc/QVsm4F0SrjBOdvximG 9mjA== Sender: linux-amarula@amarulasolutions.com X-Forwarded-Encrypted: i=2; AJvYcCUWXlitpp6KDteCcN45Hml8nmqvtkkT6bbOH7ke93Kqjc5BUd6h0sYmYUTOwn7yRzogVKs8WV+2alAWW1G3@patchwork.amarulasolutions.com X-Gm-Message-State: AOJu0Yzo7bLiFXjTSQKeZkXkZpitM8E3y7GBSS2s6y5uKy6aZtuiGCEd vQRMvcn1+qlGzmFM83/ZIKD/AY8DoUcrC2C5l/1Fhe+JskRHXOO3RfY4gjgGSfY+NSloJw== X-Google-Smtp-Source: AGHT+IGy+3cS1NPBT6FBtHp79Fzk1S7oWsPHC+fagaz72U74QUrV548uJvkxo4At8BGLZ06lsmikqA== X-Received: by 2002:a05:6902:1243:b0:e7d:8d0b:1ec9 with SMTP id 3f1490d57ef6-e8179c17886mr7990857276.16.1749110774212; Thu, 05 Jun 2025 01:06:14 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com; h=AZMbMZcFX/0m5iK1s5RHv6Rx/4hX9VO8eaG5a02lG1+FjmJTTA== Received: by 2002:a05:6902:5409:b0:e81:9848:797f with SMTP id 3f1490d57ef6-e819848856fls312596276.1.-pod-prod-03-us; Thu, 05 Jun 2025 01:06:13 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWT7WCVxsq2ONF/rqmVNXY0FOm7qse6DOAVqTglLPp4pb7YhcpRDWy+XUR/xyGwkhIo9Yej2xvnF36aEyzE@amarulasolutions.com X-Received: by 2002:a05:690c:7408:b0:70e:2168:7330 with SMTP id 00721157ae682-710d9f32026mr86161607b3.19.1749110773224; Thu, 05 Jun 2025 01:06:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1749110773; cv=none; d=google.com; s=arc-20240605; b=hS7tsfHdm/47bI6TBukaPt6bD/ulQt9HzorZIP7DokNWrVGitJEI61ioY6smlvczVF EHrAmp2FsXFnmOR0+Gk6e2fLo7xcA93aLLLARpj3RWQMOpbfzx060hJXqRTaZw321ksL zjFRN504mbMVN4woZgx72QINrPjiqR8TWsLJPkxSr5hTJog+MrRLsE0pze5pvBuCCSQY zcm+k/nYpwq3NOXGrT8i5of5CUDy/FI32yEgFW/408B+8XiAuY8vwP61Ae9MvNe0zY1J PpjvFGVV3TQoaChTWBz6mceYEjVzSAXAbZYoe2RQP6Cw7MYyzpmK7UEm5ZirEQZ/wLX+ bnuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=date:mime-version:message-id:in-reply-to:references:auto-submitted :subject:cc:from:dkim-signature; bh=oqiPz+XS5OuA22Uxk+vbCEjRV0YAb3e8fYZu6mDLUzk=; fh=BYGC6VZLiabeMF41p4F/HPRR57fx3qnoaMY/ERgdeoI=; b=BlngvKPS1PU4OOWtNrJcqmWJgrohaVWfnqepsj0AgZczZFeTmMdLo+/6yi56Ge/ODX hYH6x7pAPKw+MygqNb5RtObTbrWMbTI/qCnqcxyRhK/Jj+SzoDLoAA/xnP+C8Yzvn8cS amXsX+CfjbhAhjd8fLVQDNBi20INHrNIj3x8U2RRVke5+RsOCGN7UXS65B4Of8tu3jQj bJwNFThnkOnkOGVkahdU3bgp7wiKxqFG/qAPuCltSd6xk/ChjnkXYKDf8GnzHV30Ar/z mxRYfiMoBDA8JXBlVzry5VGcZ0OUi3ZK9JVvCq483DvFode/K2cZ1lTJe6+EaSC42bQu 61Dg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytemark.co.uk header.s=bmsupport header.b=k+J4ZVJr; spf=pass (google.com: domain of support@bytemark.co.uk designates 188.227.164.22 as permitted sender) smtp.mailfrom=support@bytemark.co.uk; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bytemark.co.uk Received: from 20.smtpout.hostinguk.net (20.smtpout.hostinguk.net. [188.227.164.22]) by mx.google.com with ESMTPS id 00721157ae682-70f96c8c6f8si127725277b3.450.2025.06.05.01.06.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jun 2025 01:06:13 -0700 (PDT) Received-SPF: pass (google.com: domain of support@bytemark.co.uk designates 188.227.164.22 as permitted sender) client-ip=188.227.164.22; Received: from support.hostinguk.net ([217.194.220.78] helo=[127.0.0.1]) by hukstafilt04.hostinguk.net with esmtpsa (TLS1.2) tls TLS_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1uN5c1-0009Ur-QJ; Thu, 05 Jun 2025 09:06:10 +0100 From: Bytemark Cc: connman@lists.linux.dev, denkenz@gmail.com, linux-amarula@amarulasolutions.com, michael@amarulasolutions.com, jussi.laakkonen@jolla.com Subject: (#97600924) [PATCH v4 1/2] Revert "timezone: Fix compare_file comparison in timezone checking" Auto-Submitted: auto-generated X-Auto-Response-Suppress: All References: <20250605080336.21824-2-andrea.ricchi@amarulasolutions.com> <20250605080336.21824-1-andrea.ricchi@amarulasolutions.com> In-Reply-To: Message-ID: <96d30e276a714ca2804c4cd455895e7b@bytemark.co.uk> MIME-Version: 1.0 Date: Thu, 05 Jun 2025 08:06:09 +0000 Content-Type: multipart/alternative; boundary=clRhRe-n X-Originating-IP: 217.194.220.78 X-HostingUK-Domain: bytemark.co.uk X-HostingUK-Username: supportpal X-HostingUK-Outgoing-Class: ham X-HostingUK-Outgoing-Evidence: SB/global_tokens (0.00458648071372) X-Recommended-Action: accept X-Filter-ID: 9kzQTOBWQUFZTohSKvQbgI7ZDo5ubYELi59AwcWUnuXUHcm0nB5eEJt2P1968NM7nhKcciXwYWgC SAEGysTiByu2SmbhJN1U9FKs8X3+Nt1A0oPlBY1VRwEBkZg1k2TTn287AArjgCsRjWBXl1GWedCI EVI9LzXDA1Xh+DPG4pKCbDw4UhnqhjDC22e7OqCkk31k9aIIh+zJRA1xOJoRUKPGxjczx15onleF Kw2XyysZMCi24gMJ/YS0A+uToz+vuDRdbBDXR+4YBxf1TCjRylayMtiLef7u8ZgqIl07RvAYmqxN 2hfHusCh87J0kDcUMWqRJvI8dsIPJIV8gzSa/b0ZFs7AIGlqJcSMQo9hh7ZMxlWmNvECMW5x4ZlZ lIP/Qe+bc+r9MxWEuItVKVsOcgaWZebLForKfrUVUaaaBLpr/xSif3CfLfscPZHu3S83Prrgu04P VFZHtUBmGzDRzNpFcQ+0s2wG4yw/pxUKrJ4kxddwDolVHgblu2Yvbk8Nh4tFH2AdvA6bEdL9gnhi WE/vIqPgMLh1Q0Tb8J1o5qVgIGtB0hR3nZWm4xKKQ46YFVlaUdOQWXBcyzfurp3fFWAga0HSFHed labjEopDjpiomvjaVOFohiDV43gBOgkNZqannj4SbpDQvVh4S0s3vb5BgEUXX+KaJtIgOsmoAYj4 XCfRSPYnbmSJFKjncxIs31/E3ahF5MMcDI7KdpjQKax6VBHifHdnIt47L5jESw9/QxO2BomRjnxv KrWywXsTIK/1NH5THMtlYvyHAYGOGtdwUb9DykyDo4b8MskTdM/jjzP2boSUZJ5dshH4dD5zksOd NQnABGFbB9R+0pDM8j7gqGxHS9sRHm6ktf31kndLSTTmOYvfb0zBNjFJ6RdoLOCQTrSFM7snLE/c SYe0lTg+9o60PRrjgk/nvc6M9SvuMiVYUuUQpiAwBsfYBsUUERWeKKG4PAQYNyavp7c49EO7UICe bhkBuzM7K4dLqPBh8h5xLLTxw8DVSUfsCeqB0ws74BoFGmIy2WRf2/iHt4T8cGeg6MOf2Rl4pIja wzVRXxKF5tPxTxfD0dMN+t5Z/ubbhBP3ZzYIQzEaaw5tOIMzNVdcMoiwkXcv6NgnMi2Oa3mr03Fl +0290v3/Qt9qmAhUiYsvzfiwBpKT5BEY0O6rzOlKk6t+HDmcZTD77+vAuWi2fMJNLA8ETVT8z/gZ 2yAr5ia+Pqhe5gmeLo/qSpIMEwarVeRYydgd6a6lc36x6ZM2c5OI0vxvMyLsFrbq X-Report-Abuse-To: spam@hukstafilt01.hostinguk.net X-Complaints-To: abuse@hukstafilt01.hostinguk.net X-Original-Sender: support@bytemark.co.uk X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@bytemark.co.uk header.s=bmsupport header.b=k+J4ZVJr; spf=pass (google.com: domain of support@bytemark.co.uk designates 188.227.164.22 as permitted sender) smtp.mailfrom=support@bytemark.co.uk; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=bytemark.co.uk Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , -#-#- Please reply above this line -#-#- You are registered as a CC on this ticket #97600924 and the ticket has been updated. You can reply to this email above or review the ticket by going to: https://support.bytemark.co.uk/en/tickets/view/97600924 --------------------------------------------------------------- andrea.ricchi@amarulasolutions.com User - 05/06/2025 09:04 Based on the `man 5 localtime` documentation the `/etc/localtime` file is expected to be a symbolic link, not a standalone regular file. This change replaces `write_file` with `write_symlink`, avoiding unnecessary file I/O and memory mapping. It ensures Localtime accurately reflects the selected timezone without duplicating data. This also fixes `__connman_timezone_lookup()`, which requires Localtime to be a symlink to function correctly. --- src/timezone.c | 50 +++++++++++--------------------------------------- 1 file changed, 11 insertions(+), 39 deletions(-) -- 2.34.1 --------------------------------------------------------------- Ticket Details Ticket #: 97600924 Subject: [PATCH v4 1/2] Revert "timezone: Fix compare_file comparison in timezone checking" Department: Technical Support Status: Open Priority: Standard You can review the ticket by going to: https://support.bytemark.co.uk/en/tickets/view/97600924 Kind Regards, Bytemark To unsubscribe from this group and stop receiving emails from it, send an email to linux-amarula+unsubscribe@amarulasolutions.com. diff --git a/src/timezone.c b/src/timezone.c index 89c44895..f442bc2a 100644 --- a/src/timezone.c +++ b/src/timezone.c @@ -507,28 +507,18 @@ done: return zone; } -static int write_file(void *src_map, struct stat *src_st, const char *pathname) +static int write_symlink(const char *target, const char *link) { struct stat st; - int fd; - ssize_t written; - DBG("pathname %s", pathname); + DBG("pathname %s", link); - if (lstat(pathname, &st) == 0) { - if (S_ISLNK(st.st_mode)) - unlink(pathname); + if (lstat(link, &st) == 0) { + if (S_ISLNK(st.st_mode) || S_ISREG(st.st_mode)) + unlink(link); } - fd = open(pathname, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644); - if (fd < 0) - return -EIO; - - written = write(fd, src_map, src_st->st_size); - - close(fd); - - if (written < 0) + if (symlink(target, link) < 0) return -EIO; return 0; @@ -537,35 +527,17 @@ static int write_file(void *src_map, struct stat *src_st, const char *pathname) int __connman_timezone_change(const char *zone) { struct stat st; - char *map, pathname[PATH_MAX]; - int fd, err; + g_autofree char *pathname = NULL; + int err; DBG("zone %s", zone); - snprintf(pathname, PATH_MAX, "%s/%s", USR_SHARE_ZONEINFO, zone); + pathname = g_strdup_printf("%s/%s", USR_SHARE_ZONEINFO, zone); - fd = open(pathname, O_RDONLY | O_CLOEXEC); - if (fd < 0) + if (stat(pathname, &st) < 0 || !S_ISREG(st.st_mode)) return -EINVAL; - if (fstat(fd, &st) < 0) { - close(fd); - return -EIO; - } - - map = mmap(0, st.st_size, PROT_READ, MAP_SHARED, fd, 0); - if (!map || map == MAP_FAILED) { - close(fd); - return -EIO; - } - - err = write_file(map, &st, connman_setting_get_string("Localtime")); - - munmap(map, st.st_size); - - close(fd); - - return err; + return write_symlink(pathname, connman_setting_get_string("Localtime")); } static guint inotify_watch = 0; -- 2.34.1 --------------------------------------------------------------- andrea.ricchi@amarulasolutions.com User - 05/06/2025 09:04 This reverts commit f20ccd19a62bd01aa117bfc8e7c388d2a16cde05. `compare_file` is intended to work with symlinks, enabling full and accurate matching between the requested timezone and the zoneinfo database. --- src/timezone.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/timezone.c b/src/timezone.c index fba8b925..89c44895 100644 --- a/src/timezone.c +++ b/src/timezone.c @@ -124,8 +124,8 @@ static int compare_file(void *src_map, struct stat *src_st, DBG("real path %s path name %s", real_path, pathname); - if (real_path && !g_strcmp0(real_path, pathname)) - return 0; + if (real_path && g_strcmp0(real_path, pathname)) + return -1; fd = open(pathname, O_RDONLY | O_CLOEXEC); if (fd < 0)