From patchwork Fri Feb 2 22:53:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13543539 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B1545B697 for ; Fri, 2 Feb 2024 22:54:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914496; cv=none; b=lxIB52CuRPD0bj22X+ml8Ogl15/hGnpw22w5ya59DA6+zIlwQJqDhpz3yi4/ATrfZ61ypunl8YPm6e3wADaJ4NlJMDnaF8RmlJG3/Y3M+Up8jUZYqebg879LBfyplfRZhZhW1XZzWUF8xSazhbcu+15OdCt5UGS6jg0uUwrH4GQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914496; c=relaxed/simple; bh=b2/Q+G77z9qtdxIyClU4hIsTCIq5g9yuq0eg3wyEvrU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=RScqMJCB327eIdiuAnHX4wKYqSsFFjorEWNKn2iGrPrnSKKg472meGAyO5YXcG9FZuGf9ANsN0zVnu2WZZbRcWbFlij8KgV8b/elsMefbdr7W6EFeQNl/q1lwfG9LXVEcmd+6Vcd7/2IrYslMMNXkTY4roUNQICZNRDeQznm8zY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mM75nZ+A; arc=none smtp.client-ip=209.85.210.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mM75nZ+A" Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-6e11faeb125so1252110a34.2 for ; Fri, 02 Feb 2024 14:54:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706914493; x=1707519293; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=QL2/69l/hPQNUE7M6NPnzmVVlli3t5FRfvoixHWe4mY=; b=mM75nZ+AyrRyutjetWrGKQmK0pxNMAUDFYvvgQ1Ac4cCu6J25OOUk/ZCYsqJVH1hNZ 0FLD2J/kyM0mmbYHz/a5JF0oZVx0D9iDUoC/WG3MClKngAJXQ8Q/IiLyDqYmWDnpvCWn CZZrv0xym/0ezXfKqspq6MaELz6OmfFOrmiKi/cMZDNlcSFRl407fz6gBF/Mqje/RhMs TsKjMkdpiRtPgEcdR3ypbL7NJn2XD/82iIRXBuh1peqwbK/jnVpCrhrGc9oVTnIheI4D lVBzMIg6Waa96UqJNVv8SifvEYPIcY1Ulemn0mix8EuyFp8fQGJTJMo1rPtQb8mRkZJa 6hnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706914493; x=1707519293; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QL2/69l/hPQNUE7M6NPnzmVVlli3t5FRfvoixHWe4mY=; b=ERJuYuLLFyaSvYuE3Iko2cySqjELRFLfcfhj/lUQV55XYcmJ2c9Ltvgi36GnO39lR2 eru4pB84mFXIHZLtzoqGsRms5MVh64JvAYoqkg9yf7QdjRTILBI7OpV/yVSRZOqVeyRM VID6+DbZ21A5O5VzXpXaqAk9KJOqu70VrJ9rgktRVWTAxeogKoTKCTKopjPm3N5Gx3u9 GR65KkFEVCtsUlPz+nHtPF3Ki5n1F5UmoaamOV07XGrLRzYiBRN/u4wwhI0hrcO/Bzxz V/9F7RpWYoA2V99tEMqHHThgN6y7Z13w06IiUz/BsaBobbknzRvndTy9u77nz9pX257/ 9GAw== X-Gm-Message-State: AOJu0YxIIIMrhV8vs+ATsxzmxKRgBNHNCqJ7wVMuuYlFWm4SaGoNZmQ1 IQ8zWgf5IE1/Tb/qIjlC7wSIpdknSGF83w7frXzpDZhbVVzOGj0PpYBEMDMk X-Google-Smtp-Source: AGHT+IEc8w0qVCSJlARml9W/GPGUZzb/KGHc0zm9ti2cBumvmnUYgNZ+ktPYg0Dp1/dymxfBkwFX7A== X-Received: by 2002:a9d:750f:0:b0:6e1:37b:5678 with SMTP id r15-20020a9d750f000000b006e1037b5678mr6712147otk.34.1706914493450; Fri, 02 Feb 2024 14:54:53 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j20-20020a9d7d94000000b006e1424847d2sm563485otn.12.2024.02.02.14.54.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 14:54:52 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 01/18] umlrunner: Also mount /var/lib as tmpfs Date: Fri, 2 Feb 2024 16:53:33 -0600 Message-ID: <20240202225405.993792-1-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 /var/lib is used by oFono to store various long term settings. Make sure the settings from the system are not used by mistake. Also, since the host filesystem is mounted read-only, updating of /var/lib locations by oFono wouldn't work anyway, which might be confusing. --- tools/umlrunner | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/umlrunner b/tools/umlrunner index c1d4c9864487..bb2f24a6dbb9 100755 --- a/tools/umlrunner +++ b/tools/umlrunner @@ -45,6 +45,8 @@ mounts_common = [ MountInfo('tmpfs', 'tmpfs', '/etc', '', 0), MountInfo('tmpfs', 'tmpfs', '/usr/share/dbus-1', 'mode=0755', MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME), + MountInfo('tmpfs', 'tmpfs', '/var/lib', 'mode=0755', + MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME), ] dev_table = [ From patchwork Fri Feb 2 22:53:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13543540 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5462385958 for ; Fri, 2 Feb 2024 22:54:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914496; cv=none; b=bdzLJHouwDMTqPVraedFF82Gdkfje6oN38w/xbBcpGREFY0fs6s2nHG1f5VdnK8YYLcCIN3tlnFSAS+A0yziqs5wGGoCKFZiyb78JZVZJNqwI4R6DLWHwYMfcoC3lDI/7V6wod+igAQNfT9lubefrpJ0I+O8h8NpIJIoOAo5Hrs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914496; c=relaxed/simple; bh=qNc3Wp33P3lSTcU0kj7FRg41RP3A3W0tLQ/un102U/8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=soBOaZVpj1Xhici5y9O8ETzr9gRezAcNVklnroYv7IAcUAeAheY1am5nL/Yy7reJD70zGiJnvQHCH9NngmdbCTbyFnRMpyxzgxlna79q7RNn2WWXfBX0VCwDdp6FLl8AU1XspyePdCjgWPLlOPUXb6Der1uN0/PT0icPfLQuUlk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dnE7MhUM; arc=none smtp.client-ip=209.85.210.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dnE7MhUM" Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-6ddf26eba3cso1951978a34.0 for ; Fri, 02 Feb 2024 14:54:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706914494; x=1707519294; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XcCKwqfJOURxSpC+fkwQR4gkkhDdnHZ6bLx/qbhv6Ek=; b=dnE7MhUM0Z7aYIy2g1L7hmIDyM9UWgi+qPTdIx4cp8pn+rPTaokVKze4xQakJuN0Q2 a9SsatVN2wxjlOf4dMRWLw+XeAVSv+l7G2b/3fC4TOs4s4igE8RSNZjNbcwM0/gC0Acy u+aRQwrnxB6Yjr66FvqpmPLLwBQF/gEodk8fBjO2UO5qcj9zWy660GL/jvIOSirTJFyM cB8HORGrryO1Kbo+pnG/Ix/M3Q7+la5fywBf8gkA+nsajTS/S9TDxaG8XNCEmdv1o64w JCxxWxhtrd5t2hgkz9aakWqZmrp08vZcf+pTG/5erSOXKaWWJo/hG0x3LzLhmvS1782f EHDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706914494; x=1707519294; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XcCKwqfJOURxSpC+fkwQR4gkkhDdnHZ6bLx/qbhv6Ek=; b=RoebdPAv7hFMsDW4/ZE9EEZ7mLydSDz3iC1n5o8aL3frTaIc/y2TKrpSQwTW78HDTB lNTpCI1RlFggmDWSLohagVYmabKbXW329n3l1+ZEpmj7A1+0uBoh04stBDl9eJ2taxqv rP9EW2mzsu9KwusvDAqCz3xS/H1ziYkrx6pPfI6Zav1A4iAEJt4LQh2+cjAGnv0VYTMC HvNKzzBmkVaZast5GxoeXNtM00SqKziQQoWta40k78tBAh1U7b9FOv2J+TDrQJmENwiB CBVtNI3TiLEZnfTPkDTbKAAHApJkyeuiw37nup+Tlk68/1N03S8zbZ6R4MxX1Gwxu0PS HnyA== X-Gm-Message-State: AOJu0Yx6NgRwDLa32BZX9kUr2M9RpE+Wb/kf2ZT6MX5Y9aJWJKJsbP4L IotD4tc83lXVLgwuGFyPbDwGxt0Vi7Yh+MGcuUriXuDS5mhcY26fAEJiTdta X-Google-Smtp-Source: AGHT+IE9oCfk0hzAljJYcPnNN+rFigp3lt+Ju549H2XrswWuJAqJyS1wnPOa9yCE8OmV6YUgB0yYCw== X-Received: by 2002:a9d:7c88:0:b0:6dd:e9e2:de67 with SMTP id q8-20020a9d7c88000000b006dde9e2de67mr7676960otn.20.1706914494096; Fri, 02 Feb 2024 14:54:54 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j20-20020a9d7d94000000b006e1424847d2sm563485otn.12.2024.02.02.14.54.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 14:54:53 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 02/18] build: Only enable backtrace(3) in maintainer mode Date: Fri, 2 Feb 2024 16:53:34 -0600 Message-ID: <20240202225405.993792-2-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202225405.993792-1-denkenz@gmail.com> References: <20240202225405.993792-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Using backtrace() is of no use when building with PIE (which most distro compilers do by default) and prevents catching the coredump for later retracing, which is needed since distros usually don't install debug symbols by default either. This patch thus only enables backtrace() when --enable-maintainer-mode is passed and also tries to explicitly disable PIE. This commit is based on the following commit from 'iwd': b6910e121082 ("build: only enable backtrace(3) in maintainer mode") --- configure.ac | 11 +++++++++++ src/log.c | 8 ++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index c18cfa3a696f..551f863538ed 100644 --- a/configure.ac +++ b/configure.ac @@ -110,6 +110,17 @@ AC_ARG_ENABLE(ubsan, AS_HELP_STRING([--enable-ubsan], AC_CHECK_FUNCS(explicit_bzero) AC_CHECK_FUNCS(rawmemchr) +# In maintainer mode: try to build with application backtrace and disable PIE. +if (test "${USE_MAINTAINER_MODE}" = yes); then + AC_SEARCH_LIBS([backtrace], [execinfo], + [ + AC_DEFINE([HAVE_BACKTRACE], [1], + [Define to 1 if you have backtrace(3).]) + CFLAGS="$CFLAGS -fno-PIE" + LDFLAGS="$LDFLAGS -no-pie" + ]) +fi + AC_CHECK_FUNC(signalfd, dummy=yes, AC_MSG_ERROR(signalfd support is required)) diff --git a/src/log.c b/src/log.c index b33a7d262474..a8b4ef10eaae 100644 --- a/src/log.c +++ b/src/log.c @@ -30,7 +30,7 @@ #include #include #include -#ifdef __GLIBC__ +#ifdef HAVE_BACKTRACE #include #endif #include @@ -115,7 +115,7 @@ void ofono_debug(const char *format, ...) va_end(ap); } -#ifdef __GLIBC__ +#ifdef HAVE_BACKTRACE static void print_backtrace(unsigned int offset) { void *frames[99]; @@ -303,7 +303,7 @@ int __ofono_log_init(const char *program, const char *debug, if (detach == FALSE) option |= LOG_PERROR; -#ifdef __GLIBC__ +#ifdef HAVE_BACKTRACE signal_setup(signal_handler); #endif @@ -320,7 +320,7 @@ void __ofono_log_cleanup(void) closelog(); -#ifdef __GLIBC__ +#ifdef HAVE_BACKTRACE signal_setup(SIG_DFL); #endif From patchwork Fri Feb 2 22:53:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13543541 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E364985934 for ; Fri, 2 Feb 2024 22:54:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914497; cv=none; b=CNjE7/6v121uF0t9Pca/NBHEHAIJhu/2YYpqUGzXiezNlk4Ewytn81CJqIOE+C9SmGCQ/TREv4rc/sNluPu7jAzwij2iqK5DtGVOC7RiEoGVut58DSGwmII5p4zswc6M88mMIgdZSrs9p7+htT3wL6ayT2VJUYgaHWv3zp39rdQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914497; c=relaxed/simple; bh=SVq3h8lFWDedz+JfWGYEjrib5K0S3qC4CbGyaa7Vu8M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Iaen6vo56opMx77xM1HoAKQWbbeLYlSvFaLnJN6QwH18ZZyw5U0KBHdFgzEghcGBuY3v897f7dh99wRzkipjQY/UOZto8PM9eUpYznQm0h9sRrRzyGYH9U7muhfT+DK/+QINjfdKYjBNCLPTs4bEfyZX4tpjhIx0bxG/Iky7FiA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=VhrfgQCg; arc=none smtp.client-ip=209.85.210.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VhrfgQCg" Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-6e27401a244so1230484a34.0 for ; Fri, 02 Feb 2024 14:54:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706914495; x=1707519295; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2WweB9jMXpj+jfBpvMM2LyldcXE3A5CZcgD4gDZEx9Q=; b=VhrfgQCg/9U61noB4mLEvFzz8fvsyiwaYgKxeLGUdX6fNx04IxSqwXQHgWoiiMXK0C q/YQMZJw6p/+hUFNfFCE5esihVkVEHI7rEdMOhUcuKfaXAurQEVEXh86m5GH9NeZ4bOt belwZR7ymIs/eYvt+AnfWXq6chniwBKv36YQ5WmRrd2bfTMUSxvMwORVSIrW39re64j4 y+r46gqacR/fqQgX71S6BYFz9AyAbq2mwRDSguz5iW0fSJ09koO0AeUVVSZ1Mu3zjNbZ tL+0lsKItCEkeJHIKLhYB9sMWw75wZAT0BcTxrKniQOUdsCV+yVGs58p0OG7SHN+AxJE gaaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706914495; x=1707519295; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2WweB9jMXpj+jfBpvMM2LyldcXE3A5CZcgD4gDZEx9Q=; b=uyZxgU5SYSknLACKZJtAyOlt38Xc8z/4sNTKCeXweJowvtew0s7WWnvp7+cgYCBAp/ 2vKMhLUFoeRu0m+dqavDejkR+XaTTskatqfcaGRznuBjpNM0IOgqUuBmsWqWYica7LJQ JvB1oHhu3K8v+jCKKrrwvo6fUXvgYkGmQKZtqupPxY08BJAYwl3pZIUKKVvkOn2pjLRp pkTancQyPJgbdAIxiBD1/ZD51RHiM2DINBxxMCdcYdhMP71jLbGDd6uzLZbIp6nZ8hR9 0saARiZK4krGWfNO1VLf9y4RjO86P2cudrdFj7HxWI1+4NOKCZ+fOQG7A7TviNxpu85i +oCA== X-Gm-Message-State: AOJu0Yy09lpociUJK0eFYUl5SJGMunfV1x23gEThILJBvQe9DLxp7Zlo eyOLmSJbpTDWOzU+o39do7NLZHWQP+FwEZm34Cv1UnwR8k+iF3L2f+EBmzbF X-Google-Smtp-Source: AGHT+IFGgvHR4gLIle5VOn8l8YgHmenxtRjxzp0UwI/6zuv2ylN+OTfDSkzT+91Q+FgAeXSOknYvqA== X-Received: by 2002:a05:6830:1bc8:b0:6e1:79a:fc8f with SMTP id v8-20020a0568301bc800b006e1079afc8fmr3051153ota.35.1706914494860; Fri, 02 Feb 2024 14:54:54 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j20-20020a9d7d94000000b006e1424847d2sm563485otn.12.2024.02.02.14.54.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 14:54:54 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 03/18] build: Bring in more ell classes Date: Fri, 2 Feb 2024 16:53:35 -0600 Message-ID: <20240202225405.993792-3-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202225405.993792-1-denkenz@gmail.com> References: <20240202225405.993792-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Some ell classes are still not used by oFono. Bring them all into the build for future use. --- Makefile.am | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/Makefile.am b/Makefile.am index 60ea9d193eac..8517bc0309d1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -36,8 +36,8 @@ ell_headers = ell/util.h \ ell/checksum.h \ ell/netlink.h \ ell/genl.h \ - ell/dbus.h \ ell/rtnl.h \ + ell/dbus.h \ ell/dbus-service.h \ ell/dbus-client.h \ ell/hwdb.h \ @@ -52,14 +52,20 @@ ell_headers = ell/util.h \ ell/file.h \ ell/dir.h \ ell/net.h \ + ell/dhcp.h \ + ell/dhcp6.h \ ell/cert.h \ ell/ecc.h \ ell/ecdh.h \ ell/time.h \ + ell/gpio.h \ ell/path.h \ + ell/icmp6.h \ + ell/acd.h \ ell/cleanup.h \ + ell/netconfig.h \ ell/sysctl.h \ - ell/gpio.h + ell/minheap.h ell_sources = ell/private.h \ ell/missing.h \ @@ -103,30 +109,46 @@ ell_sources = ell/private.h \ ell/uintset.c \ ell/base64.c \ ell/asn1-private.h \ - ell/pem.c \ ell/pem-private.h \ + ell/pem.c \ ell/tls-private.h \ ell/tls.c \ ell/tls-record.c \ - ell/tls-suites.c \ ell/tls-extensions.c \ + ell/tls-suites.c \ ell/uuid.c \ ell/key.c \ ell/file.c \ ell/dir.c \ ell/net-private.h \ ell/net.c \ + ell/dhcp-private.h \ + ell/dhcp.c \ + ell/dhcp-transport.c \ + ell/dhcp-lease.c \ + ell/dhcp6-private.h \ + ell/dhcp6.c \ + ell/dhcp6-transport.c \ + ell/dhcp6-lease.c \ + ell/dhcp-util.c \ + ell/dhcp-server.c \ ell/cert-private.h \ ell/cert.c \ - ell/ecc-external.c \ + ell/cert-crypto.c \ ell/ecc-private.h \ + ell/ecc-external.c \ ell/ecc.c \ ell/ecdh.c \ ell/time.c \ ell/time-private.h \ + ell/gpio.c \ ell/path.c \ + ell/icmp6.c \ + ell/icmp6-private.h \ + ell/acd.c \ + ell/netconfig.c \ ell/sysctl.c \ - ell/gpio.c + ell/minheap.c ell_shared = ell/useful.h ell/asn1-private.h From patchwork Fri Feb 2 22:53:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13543542 Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D5DB25B697 for ; Fri, 2 Feb 2024 22:54:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914498; cv=none; b=W+mo+D4uhDHea971+mpSibGNs1h6R5zTcsQ55hAsL9N1hwqFRv6ha8TZ3exWTaBX6BV4YMuBVvAuzif6MZGRJa1xERMp3Lls0b5Q1P4naOWAxTg/7xDnQvLcvNpYlwNo58VwuWaUF6035x4olstCraYKMeeRtOAjEMypeW503dg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914498; c=relaxed/simple; bh=zYukKacgjBk5sjwZjSTp+TgvRl7rXLTUNOPT8nLntg8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QG//j9JgwfrmMEI4sNnoU6E3nPe03Hjhwgh4nC6Ab55GDd3osZyKOtvluICpHPdlRGKOjTc2tb1gLrxl889iSeP/PPkyRW0Yqb9bWcNCzs20EThMR242uHNtV9UiPo/O/7yoKDeaDjYXqeS417hBDMr/oSbbDkJLCAcFTX8EJy8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NxbBQxi6; arc=none smtp.client-ip=209.85.210.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NxbBQxi6" Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-6ddf26eba3cso1951993a34.0 for ; Fri, 02 Feb 2024 14:54:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706914495; x=1707519295; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hqSTsP42ny05nEPplpfoYzMkecwWrPoMKfxMzWZWMw8=; b=NxbBQxi6xbxy4yUsgkjXLaMdLIir8TbulJM4rxO28HJJbNIxswEvbMjn7PMwGsm+Lo uM+kSZUFHTqbLXirBjszu7psTr/UCyIHKtFZhKdAoBL2pM4mFkbdJWNh/mK8XoBsjAIY y1u0uPS7WY7ta9gacMOVucXzjhQvOXJpbUVgfbH1QYfvTqayUPh8NlCX3oawIkaoq+Jz UHJmG1z0pACd3N7jmVyTcrblAc1Kojdd/KsotjersSGCaWPMgZApr0ZFoTggbqeOXB15 3Z9dcZV3wDn0BlPthmfGl6G7Cx3l0svhTfUkAR0nTQ/0BJiI4AKS9iTCNZnb8t6LFcHK fZqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706914495; x=1707519295; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hqSTsP42ny05nEPplpfoYzMkecwWrPoMKfxMzWZWMw8=; b=sbVeqRYWGKz7mgTA+MLcSZSYrVnVV9bxaTnVyb2a2Mkx1mpOUUObclVMaUMcDjXvq1 sVlh1ty114xhGngbKMIhcQ7h/kDpW2GcWXsShtxZYjabqeHOQWJlSZMQKriVxy8U+CUe /DqEh7fcfYPDsBdXbuZEGAC5GHnLRaEbkoFuwkG+SphVwHG7Ra19m8WvEoGC9Aotcdi/ XSlNGJMeoUkGD2muKw7h3ayZo/FbPg2+qMqtw+rS0cSViWmpHSWZohAgtC8phap8JPN5 92s0JjwVtUl1Eao0TyuoH+rbayKZZLNmn0T2cjypCCEkKzDjrRovwDpcrnw8PfGRmv73 +F9w== X-Gm-Message-State: AOJu0YyyWLSvoLm21Bj2ygxDYJ3vjfqdyoUIbope5Tz0RCUUrE3MpFz7 9tZkMhwzgeuvRxb4XFVhIXA+1MdABpkZPVTduWik6NwRAQK8F5j6ZYTz00y5 X-Google-Smtp-Source: AGHT+IGZpFu5Vm3VoOs/REof/QYMI8Q5JPjTrnhF2HpJLB0SLezgU0EANtOHGeuPqn7CVpKxEDlrBw== X-Received: by 2002:a9d:7dd0:0:b0:6dd:e530:8c12 with SMTP id k16-20020a9d7dd0000000b006dde5308c12mr7227827otn.4.1706914495638; Fri, 02 Feb 2024 14:54:55 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j20-20020a9d7d94000000b006e1424847d2sm563485otn.12.2024.02.02.14.54.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 14:54:55 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 04/18] build: Enable _auto_ syntax Date: Fri, 2 Feb 2024 16:53:36 -0600 Message-ID: <20240202225405.993792-4-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202225405.993792-1-denkenz@gmail.com> References: <20240202225405.993792-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index 551f863538ed..b866e5487443 100644 --- a/configure.ac +++ b/configure.ac @@ -299,4 +299,5 @@ AC_DEFINE_UNQUOTED(CONFIGDIR, "${configdir}", AC_CONFIG_FILES(Makefile include/version.h src/ofono.service ofono.pc \ dundee/dundee.service) +AC_DEFINE([_auto_], [__L_AUTODESTRUCT], [autodestruct syntax]) AC_OUTPUT From patchwork Fri Feb 2 22:53:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13543543 Received: from mail-ot1-f49.google.com (mail-ot1-f49.google.com [209.85.210.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62FC385958 for ; Fri, 2 Feb 2024 22:54:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914498; cv=none; b=bScDWhajarWVYcrwXHeVJahbcUAvS1WExoRx/y1Xu6FV2+AFre/m46inq7Gze50rOzcg4AjybgexwB9toLEvzmMQB7nfpOiBDs/0CbAfG+x8wWKeosP7NQfj5cvJEGjBwqY+ImkcHQFVmSLUi0kDn3zYrlScqMGg1FHlkbUc3Mo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914498; c=relaxed/simple; bh=hyPteJ2jqQQhUP5+JZGTuesBhi4L5h/BiDZrMdVQw7A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dIqducHZPz6PxOsdJYJKdKlzhagV8biAQxeHN6lJa7nni1MTNnWPD0/zcD4D7kl2vZy7t9d5fWDyLSkKPjIxw+xvSuYdgmsKRZ4PV0K2owYzxszRWc1Qt+B+uwPbBvPzmZyYSosmYjbgSXHouvGhAeFUL+0Pjvp7dXKNN+oOMTg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=h0LWn0SH; arc=none smtp.client-ip=209.85.210.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="h0LWn0SH" Received: by mail-ot1-f49.google.com with SMTP id 46e09a7af769-6dbcebaf9a9so1535737a34.3 for ; Fri, 02 Feb 2024 14:54:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706914496; x=1707519296; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=td95VSf+KXU7eik86JTqU2W3lIsWJfE2VRdq1kJg8nc=; b=h0LWn0SHUcJjn6EkPCsY5zr6uMP3Rw9ro4FsgPoahQSymMkNmNkDhAYt904E1eXj/Q iiyQEdgVIS2rxLh9kt+SDg++mX8PMXLcpzk4nTMt7qPAcj0Zix9fttaPTd4xDdua/RVh 3/ty1lLyva7pCz14CrESqwAKTcJghg7wfaLJLfahoNxAduqqW8Ly2dBe9nAMvdYKj4Am cHgHi0/pTTGNnrCOdEv5PvvJl5GtK7PaxYMlg3zzjdbUkDgmkF/ZylZR/WZfWTs+ly2U 6ADYB+UtsAi2pKgk6k/B13+pbszzal9eAeJ7y8112ilLeVytQyxvJT5yTQyCmXvlj01W HxjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706914496; x=1707519296; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=td95VSf+KXU7eik86JTqU2W3lIsWJfE2VRdq1kJg8nc=; b=A6V04KRwADgFRpcvrbkcM0sTinUZAMW1KMfC9uZcxCt2bB343sFuyPo8rXOo2qHs4Z fYqazCtnwHBW8mKBWKiiEATyzv+aIU9pC4U+4hrd8X1rfhN4mcNeVpNimr1eirX/C4eD YOvGFRm/T2oXXU5r6xIk+/6eNWUqZy0Svd3hDvVghsbzL8g00V+qLpN+uKSCin0izSuB 6FdlQ3iavBosX3ETVCfAtoaF+PjZtCNYQW4JYkdd1WXyu+Z5Z3rRjqHvnQAFrLxBli2r oKvuLJYHv/IxmN5xBCu0hTk3wPFv+ppvdpRhH7ieQcjf+Gw41+5vPBUtkZSReK2ai9u1 /BuQ== X-Gm-Message-State: AOJu0YzXO9OG4vCqfUENqrsbdJtb/QunyskDS3+t7x5ZfQXPFWvqp+QQ eYEfWZklFV2qGFZxAbCilY+VBuVhxY939VG5+b9dxIV3ktvQ4G6zPE3v24qd X-Google-Smtp-Source: AGHT+IFnN9ET7Hpl5NV6zlw950uXARm9DzOsltUggkML3N1bgNugIfjNf3GTSSofNA9BfwB5cb8I3Q== X-Received: by 2002:a05:6830:196:b0:6dd:cd73:3b0e with SMTP id q22-20020a056830019600b006ddcd733b0emr10125661ota.23.1706914496289; Fri, 02 Feb 2024 14:54:56 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j20-20020a9d7d94000000b006e1424847d2sm563485otn.12.2024.02.02.14.54.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 14:54:55 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 05/18] provisiondb: Remove some duplicate MCCMNC entries Date: Fri, 2 Feb 2024 16:53:37 -0600 Message-ID: <20240202225405.993792-5-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202225405.993792-1-denkenz@gmail.com> References: <20240202225405.993792-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- provision.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/provision.json b/provision.json index ae9a08482254..77d5bb977254 100644 --- a/provision.json +++ b/provision.json @@ -14145,7 +14145,6 @@ "310070", "310080", "310090", - "310090", "310150", "310170", "310280", @@ -14153,8 +14152,6 @@ "310410", "310560", "310670", - "310670", - "310680", "310680", "310950", "311070", @@ -14309,7 +14306,6 @@ "310011", "310012", "311480", - "311480", "311481", "311482", "311483", @@ -15038,4 +15034,4 @@ } ] } -] \ No newline at end of file +] From patchwork Fri Feb 2 22:53:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13543544 Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F18B126F2C for ; Fri, 2 Feb 2024 22:54:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914499; cv=none; b=a+V85LI5O74QUK7UFCbgHTGkvF+tUKyOvrEQXkL3RI9P1fkm5l4191A0Gv+UKjwzRB0kWUHjQ5LGaHRegJE0og4txxYy3RDUAMqEiRZCx+uYCJFWnJS5IEBygQxpjtgVLS71R5o5HLjAdTvtRE/mnO11bEzJQfyWhX/Wpa0Sk50= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914499; c=relaxed/simple; bh=ocOP2ENWgfeKcfkofb/GowR+z0pPyYIU9FELfhLwGkg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bse52WduMI0kNkSJJJW8IYn5Oq/BoBkLlqLV53WqFiqK0qVFe29kGjY5ASEMtEXsKiB0/q14zJjQWrycZboACPOXn+YAvsnyr757Z6CFheuB/UZVp7Z7cC41s1Bxmh9o11SbVJs5MPUPYBRH5zB4YwfX9rg12yM3u9g3ZqWzT1M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nF+4G6ll; arc=none smtp.client-ip=209.85.210.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nF+4G6ll" Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-6e114e247a2so1319080a34.0 for ; Fri, 02 Feb 2024 14:54:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706914497; x=1707519297; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xJ/Hif7k39MhIpB+VGwN9tPfBsV5uUV3MaA8EewrxfE=; b=nF+4G6lliKOy/VFT4YYGjTKGLQhSejEXJBdPGn6CCHdDX/EbIQ1ttyUeSX/APVh9e2 FcHxpHOz1CDHhPDFyOnfQzOmIMwC/z/R/PUZbE1fDmjUKOeDvh38nstcxkj8OGRGY4zl X7iL9Olvq+1TJlPDKf6638g/E3GFnE7ad9TZyk5gJpLRjcPlOD73Y67wkLKKHBoXy3Dc 9Y5ogLDZnZ/Y85ph0trDR4KICo1oplQLKYqifKeNCAu2jzIG1k+1YZFmOn13pVtB5OKz DNkB3I8r52peZleLjhdpLh5H5pjrBHZDdqIjKvfuCBDlII0vPy7i0TfPRyJqV1NR3SUJ yH/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706914497; x=1707519297; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xJ/Hif7k39MhIpB+VGwN9tPfBsV5uUV3MaA8EewrxfE=; b=b3u8Q3OtPPyHwgE+HZEl2ydDu43QjQQwmvSqKaU4xVZ+AHuTaBVBVXePAoCBpZi31S Y1gddLlIVs8hlAz9G+ny8QTifApCYcvjlR3uO6qa5UtFiJddfVf0znegwsxhnz1BENsC g+TS9HFOoXezST0VkHlTGRBGR0HMV5iu4AUDggQkbBvRxQmqgXwIRyTgZXXAP9LZryrB gtncvahb87/wEmkAx8ghSOy+D0LK+9w7SVMe40Fg/hXZ0uOqJ9dAWheh8LR/tDqCZD7Z AQEBS35rvBbzBPJnrCvTF4b+qJwnxcbK1hEc9Ewaoc1dAeI+7smY+FfXKe0Vwdd58doG kVDQ== X-Gm-Message-State: AOJu0YwCZtnRma2kZbfmTXSe/kQHUHE1EoN8pWkq9SHbkrD8PNNchpqa e+wQvfQTK93yox3StFHKGKvxM0UutWnS9KVXRIr0Df9yokhroDRNzFy6US8w X-Google-Smtp-Source: AGHT+IHvLf+D0lKe/Kb7eT9/rS3Yj45W4xJGlPDzWHDJo8hccsZVpQ7a+ieM4Pv8l1WVhVqu4iiqTA== X-Received: by 2002:a05:6830:1d92:b0:6e1:4dc4:cda3 with SMTP id y18-20020a0568301d9200b006e14dc4cda3mr8984069oti.29.1706914497387; Fri, 02 Feb 2024 14:54:57 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j20-20020a9d7d94000000b006e1424847d2sm563485otn.12.2024.02.02.14.54.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 14:54:56 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 06/18] storage: Introduce storage_get_file_path() Date: Fri, 2 Feb 2024 16:53:38 -0600 Message-ID: <20240202225405.993792-6-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202225405.993792-1-denkenz@gmail.com> References: <20240202225405.993792-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There are multiple locations where the same steps are followed to produce a file path for a given storage location. Pull this logic into a single function and expose it for potential use by other modules. While here, convert use of GLib functions to ell. --- src/storage.c | 36 +++++++++++++++++------------------- src/storage.h | 1 + 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/storage.c b/src/storage.c index 05d9b88a0237..c7bbb1c6142a 100644 --- a/src/storage.c +++ b/src/storage.c @@ -171,45 +171,43 @@ error_create_dirs: return r; } -GKeyFile *storage_open(const char *imsi, const char *store) +char *storage_get_file_path(const char *imsi, const char *store) { - GKeyFile *keyfile; - char *path; - if (store == NULL) return NULL; if (imsi) - path = g_strdup_printf(STORAGEDIR "/%s/%s", imsi, store); + return l_strdup_printf(STORAGEDIR "/%s/%s", imsi, store); else - path = g_strdup_printf(STORAGEDIR "/%s", store); + return l_strdup_printf(STORAGEDIR "/%s", store); +} - keyfile = g_key_file_new(); +GKeyFile *storage_open(const char *imsi, const char *store) +{ + GKeyFile *keyfile; + char *path = storage_get_file_path(imsi, store); - if (path) { - g_key_file_load_from_file(keyfile, path, 0, NULL); - g_free(path); - } + if (!path) + return NULL; + + keyfile = g_key_file_new(); + g_key_file_load_from_file(keyfile, path, 0, NULL); + l_free(path); return keyfile; } void storage_sync(const char *imsi, const char *store, GKeyFile *keyfile) { - char *path; + char *path = storage_get_file_path(imsi, store); char *data; gsize length = 0; - if (imsi) - path = g_strdup_printf(STORAGEDIR "/%s/%s", imsi, store); - else - path = g_strdup_printf(STORAGEDIR "/%s", store); - if (path == NULL) return; if (create_dirs(path, S_IRUSR | S_IWUSR | S_IXUSR) != 0) { - g_free(path); + l_free(path); return; } @@ -218,7 +216,7 @@ void storage_sync(const char *imsi, const char *store, GKeyFile *keyfile) g_file_set_contents(path, data, length, NULL); g_free(data); - g_free(path); + l_free(path); } void storage_close(const char *imsi, const char *store, GKeyFile *keyfile, diff --git a/src/storage.h b/src/storage.h index 4dc792ccf7f9..3a1e64493546 100644 --- a/src/storage.h +++ b/src/storage.h @@ -32,6 +32,7 @@ ssize_t write_file(const unsigned char *buffer, size_t len, mode_t mode, const char *path_fmt, ...) __attribute__((format(printf, 4, 5))); +char *storage_get_file_path(const char *imsi, const char *store); GKeyFile *storage_open(const char *imsi, const char *store); void storage_sync(const char *imsi, const char *store, GKeyFile *keyfile); void storage_close(const char *imsi, const char *store, GKeyFile *keyfile, From patchwork Fri Feb 2 22:53:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13543545 Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D85488592F for ; Fri, 2 Feb 2024 22:54:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914501; cv=none; b=Jcjk7n2rslav8CYqkEqkc9RJqbHeFbN8V2BOqzigzKuTETd596bVjW3Ih7w0H1vkR3p9yjtQENhELYgxeqpROJKs5EfTiJPfQhpNJeAN0C+N2g6gYamrT7NH9ZXtvTq47D25ZB5GnEgoapB4zWD7mQXAWSxcHC33B7V3UIhFV7g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914501; c=relaxed/simple; bh=40HRVDw1RTKi4soStL55YwXnBGZc0jxZnzuvjOlhIUQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ixjdb9YkWVSC7dJ68MLpvh3IPPE/Qsi340aYA0h1n9mCZ3OC7SZCWOFx+12Hd+tZH2Z396/QPeHrcB8tmJlZaCHN9T/O5EhXDmJ5qlE2Z01mknN6yfNQOlBXaU/QPZ9z3HcYSWK5E46+63yGO3niPSNnA0vo4n+PlwQo6sXn4+g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LgOafrvn; arc=none smtp.client-ip=209.85.210.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LgOafrvn" Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-6e118da997cso1354034a34.3 for ; Fri, 02 Feb 2024 14:54:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706914499; x=1707519299; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+WEpQGXsL5Z7LPeMPtMuaTVdpXfGJCDv4AbBy0SUiyY=; b=LgOafrvneOmHEKygiH6bqSa4Pj1I0680mpNrOMkCqHRKyxSiEn6uGARXrXe1V82f00 a3WfWBtztMTE6wy8fXi09133DljhNiHed8o76XkvAQwu7ZWDHp7RgpGnlW0Bwp3KCUPc OoOOgUfac191Qf9v1lqWQUDqF4T4iRUYU0eciLfgeWdymqFEUultuo50ys/5rE2mwc3G 6r/CUlsmBfMUefWl9EbCsqH9ayip372vWKKwgdtg7IfML2kgxZhAjfxuurd90yh5p2Uo oCN6jHTUiC2oEWzExKqMf1gfYHk3B9GQG4O5fQeOKvrZlPbTq1O7a25wXHHrTmaGa9EV CzVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706914499; x=1707519299; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+WEpQGXsL5Z7LPeMPtMuaTVdpXfGJCDv4AbBy0SUiyY=; b=LoVIPqW1aWDwm0GECKfNYtsLd79zDur5MAoI9PcLEEWe1tiU3WHVitlSH40TZ4zYFE EYTaArLACzW/pbOIHX09+o9+ct/la6I9AE1WYZzXKjj2nA2WJ9HtSA6ZKt/7t9SxkEaQ kpTqiiOUHcKx+Lk9YlVldUCKGPRXpJhrSPV1KkPnGRlHpjyPeRyDFqrh07cy/viJNxQg q1pT6mrv7CiXaaJiEekgc6D8o2vBHY5UET+jXfdEVs7l3zGWV43OA/W/CVuZ+/S2bUVt MxTIhAGVJ1viA+4kYkM1zsXrVVZScZefur5tE4LRm/WHfBo6+UzT+mMlMab1LYsHKlyq PBlA== X-Gm-Message-State: AOJu0YyophuH6na6Le/B8aBVebV+E/nhs0OuUdeRMyw7cPZdnzEEIcBq n9aKaDpuRytJxdxN3fSglNnreg3ITsF/HvGQGOF9SNKTGFEohWuaCtj5C+SM X-Google-Smtp-Source: AGHT+IGeJVlZy7/WZqglBg3N2yE6CNg9TkoxV/eOo5lkgiYTxHG6R5NUmMwjG3Ww9oqhmox9Pi9ciA== X-Received: by 2002:a9d:4f0b:0:b0:6dd:eebc:da3f with SMTP id d11-20020a9d4f0b000000b006ddeebcda3fmr3426588otl.23.1706914498871; Fri, 02 Feb 2024 14:54:58 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j20-20020a9d7d94000000b006e1424847d2sm563485otn.12.2024.02.02.14.54.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 14:54:58 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 07/18] storage: Convert g_strdup_* use to l_strdup_* Date: Fri, 2 Feb 2024 16:53:39 -0600 Message-ID: <20240202225405.993792-7-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202225405.993792-1-denkenz@gmail.com> References: <20240202225405.993792-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- src/storage.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/storage.c b/src/storage.c index c7bbb1c6142a..2313835a49ce 100644 --- a/src/storage.c +++ b/src/storage.c @@ -93,12 +93,12 @@ ssize_t read_file(unsigned char *buffer, size_t len, int fd; va_start(ap, path_fmt); - path = g_strdup_vprintf(path_fmt, ap); + path = l_strdup_vprintf(path_fmt, ap); va_end(ap); fd = L_TFR(open(path, O_RDONLY)); - g_free(path); + l_free(path); if (fd == -1) return -1; @@ -129,10 +129,10 @@ ssize_t write_file(const unsigned char *buffer, size_t len, mode_t mode, int fd; va_start(ap, path_fmt); - path = g_strdup_vprintf(path_fmt, ap); + path = l_strdup_vprintf(path_fmt, ap); va_end(ap); - tmp_path = g_strdup_printf("%s.XXXXXX.tmp", path); + tmp_path = l_strdup_printf("%s.XXXXXX.tmp", path); r = -1; if (create_dirs(path, mode | S_IXUSR) != 0) @@ -166,8 +166,8 @@ error_write: unlink(tmp_path); error_mkstemp_full: error_create_dirs: - g_free(tmp_path); - g_free(path); + l_free(tmp_path); + l_free(path); return r; } From patchwork Fri Feb 2 22:53:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13543546 Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC13F126F22 for ; Fri, 2 Feb 2024 22:55:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914502; cv=none; b=DmbRNulli93bAlO6VhzB+eogPjovn8qGirY/+ymMDQbKnic2MGC2zetNQkT+VETiSUqm3mCC/etlcmK2AVedOMkzMq5V+1UL32kBXgq/EJjapoOd7JOEUyODH0rRNr5sqEWlIcMvpNxRx1zCgak8Hka7pBW1XKlEac9mwjxtoAc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914502; c=relaxed/simple; bh=Ngatuek6+l25zNh0xP6q04ZFRNN40k61978NO7LmAp4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O1bYjFrCsHQ1EmLCqskLpbLDn81asK1MJB6JRdQmN6DKqHRceZVks9z+1BOdQ85iCIGb4dlwTK4pgirMZpYgdj8bWPbuTUgrvcBpdf+Vr6vfOBZ3eux6vfr6sWAcP9NByGx6F85rEKUo+CdrwQPBblB05xv9Awkzle51gddq190= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=mjy3Rqro; arc=none smtp.client-ip=209.85.210.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mjy3Rqro" Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-6ddf26eba3cso1952033a34.0 for ; Fri, 02 Feb 2024 14:55:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706914499; x=1707519299; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6IAtEmaXu1T49urJjbCViXJjnctMYSLnV5sU6xtoewQ=; b=mjy3Rqrow2wnOUxJTR6N2NYEA+ouXHsE+FIdW+jesiYkAs7kmYgxj3psW7LNp3XZdD OweAzPKMQG1EJXMzSRCtlVbH4H05BL0VvT+S6ENVlxfRoO15D04iNf7nk9vouSJ1oqX6 qRSh9bzPnx9yOQwQYivRG8eZNlZEgI4qahWWrfGX4AEy33Hoh195ZW+DZ9ANnifFW4DL I5ooXi+91ctpprK5rqTcg8qqq59c7UqYL5vblc3GIWX+z7JEu+rV84vljGiLZoRoFJIA XY2SrG7FkpvSVfRv+Olo9zgfHAxwLTEXYcGYMTa8E/beFV33IjwOh8M/AtW8vhSMgNH5 sgCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706914499; x=1707519299; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6IAtEmaXu1T49urJjbCViXJjnctMYSLnV5sU6xtoewQ=; b=o05geIGOUhriHS3Vgthk2MnlHglsnm0qdMb+zr28Tz1waxtEI0qneB9I4BFxEJlJb4 s7MvNKjK4gHrhwW8/FHqkwmPeD/EwjrhST1ClF/mHxQ2yzYbH8sfxrtNgSj2rs5T6BKa LR0wcIlcPMqMotDEuVnl3cw+9t1gYB44LiAD4rcq9WaZGju32c+pHD+3LJkYtMGookGk B5Iz3ILqfk2KdqCP9nDNN7zMd2px4LMziHIafraETE3TutoCoZ7AeYPBTC8J8dUrWqQv fnJMrqt0yeLz9rgTKulMsdk+GUJbLxQbETNmmGHQiajdPKvIRdJ05AGVVV5yEKYhjy2H s4NQ== X-Gm-Message-State: AOJu0YySFC3o+m5LQc0F47cQOOgbb/HLw06a9KcX8P36GymCJVuPGY1y 6Yq8KH1b199T5OFOG55CgPTT1/EjLuYH381VRF34KIWsPZYSETkWv36KwWB1 X-Google-Smtp-Source: AGHT+IHlWoZ0g/Q2Nb+9t5i20tWp75nsjeKHUMQ4yBE6SNgYLfpT/YQD7Uoyy1oi7nuzXRRIgiCzEw== X-Received: by 2002:a05:6830:44c:b0:6dd:e0fc:258f with SMTP id d12-20020a056830044c00b006dde0fc258fmr7887113otc.5.1706914499612; Fri, 02 Feb 2024 14:54:59 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j20-20020a9d7d94000000b006e1424847d2sm563485otn.12.2024.02.02.14.54.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 14:54:59 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 08/18] common: Drop GLib use from gprs_auth_proto_to_string Date: Fri, 2 Feb 2024 16:53:40 -0600 Message-ID: <20240202225405.993792-8-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202225405.993792-1-denkenz@gmail.com> References: <20240202225405.993792-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Refactor this function to use bool from stdbool.h as well as drop usage of GLib in favor of ell. --- src/common.c | 15 ++++++++------- src/common.h | 3 ++- src/gprs.c | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/common.c b/src/common.c index 9a55990b6435..79094ee4906c 100644 --- a/src/common.c +++ b/src/common.c @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -747,20 +748,20 @@ const char *gprs_proto_to_string(enum ofono_gprs_proto proto) return NULL; } -gboolean gprs_proto_from_string(const char *str, enum ofono_gprs_proto *proto) +bool gprs_proto_from_string(const char *str, enum ofono_gprs_proto *proto) { - if (g_str_equal(str, "ip")) { + if (l_streq0(str, "ip")) { *proto = OFONO_GPRS_PROTO_IP; - return TRUE; - } else if (g_str_equal(str, "ipv6")) { + return true; + } else if (l_streq0(str, "ipv6")) { *proto = OFONO_GPRS_PROTO_IPV6; - return TRUE; + return true; } else if (g_str_equal(str, "dual")) { *proto = OFONO_GPRS_PROTO_IPV4V6; - return TRUE; + return true; } - return FALSE; + return false; } const char *gprs_auth_method_to_string(enum ofono_gprs_auth_method auth) diff --git a/src/common.h b/src/common.h index 3d30e2497ebb..779de7278446 100644 --- a/src/common.h +++ b/src/common.h @@ -19,6 +19,7 @@ * */ +#include #include #include @@ -185,7 +186,7 @@ gboolean is_valid_apn(const char *apn); const char *call_status_to_string(enum call_status status); const char *gprs_proto_to_string(enum ofono_gprs_proto proto); -gboolean gprs_proto_from_string(const char *str, enum ofono_gprs_proto *proto); +bool gprs_proto_from_string(const char *str, enum ofono_gprs_proto *proto); const char *gprs_auth_method_to_string(enum ofono_gprs_auth_method auth); gboolean gprs_auth_method_from_string(const char *str, diff --git a/src/gprs.c b/src/gprs.c index 7b681d850c21..3eb7df83ac54 100644 --- a/src/gprs.c +++ b/src/gprs.c @@ -1087,7 +1087,7 @@ static DBusMessage *pri_set_proto(struct pri_context *ctx, GKeyFile *settings = ctx->gprs->settings; enum ofono_gprs_proto proto; - if (gprs_proto_from_string(str, &proto) == FALSE) + if (!gprs_proto_from_string(str, &proto)) return __ofono_error_invalid_format(msg); if (ctx->context.proto == proto) @@ -3162,7 +3162,7 @@ static gboolean load_context(struct ofono_gprs *gprs, const char *group) if (protostr == NULL) protostr = g_strdup("ip"); - if (gprs_proto_from_string(protostr, &proto) == FALSE) + if (!gprs_proto_from_string(protostr, &proto)) goto error; username = g_key_file_get_string(gprs->settings, group, From patchwork Fri Feb 2 22:53:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13543547 Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AADB512C7F6 for ; Fri, 2 Feb 2024 22:55:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914503; cv=none; b=ObTrkFYM5PXXU85nQa5iP2shBT+Bj/rlDFc/RAn9aRxxclcjaLaJU5bFLiIWVlwbhqu9w+Rfy7tRT1vUPtNhcJxJBbAvi1xz5agIsVETxVc0nyb3iPNqBHhAU8GDjmIVeUkMncIl0teKpXEi6DtEFSNwScaKptkYUSMoqmtazoI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914503; c=relaxed/simple; bh=ZMMiTVdeQnHJAS/8QiGXwXAUWm/ilJKLjB6UX/sx1cg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qApLbTQAobjxT567jq3WVgWuzh5xZ4+LhJ/CRwP0yQsBbis44AvF+x8BtV+DmfK9iMGX1jGWlALVScrYq8tKjvc5vZnGRWoyCo19rHt/YKf4XNKvdXTiRwFlj+YXnlW77iRs/EO0iFuLxaPiwNDE8x8esI46qeuvIANYiq4SG9g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=CY37KFBL; arc=none smtp.client-ip=209.85.210.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CY37KFBL" Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-6e12db57fedso519942a34.1 for ; Fri, 02 Feb 2024 14:55:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706914500; x=1707519300; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zKMDcWb7/Hz1o/SS9+fE6kkkILRaJrotU8QEBL553Vg=; b=CY37KFBLwHE8ux6RRPPmjHTwZUeP0M6BdqfREB7TCIXGVzNpy/r29sCoNhFz+6WiGQ nu/Hxcb2BL5OXkI4MfFs6Zgg4qJVdLLK+2IbGhiC3E4LEEzwJEO9kRbh6ZHI0oItJhOa XmJZK96876ns5jN4UaxAx/9LWVLgLBQwVGJYBNTsePh59XAEDY0gsrx20GhUCQddylqx thYeVnHX5l1wK2g5hwkM+txsgVlTZvlaONxmpd8BNYrTmE1lQt1RFvpFQkDsDW0Td7qN qmqL77sRYeRxnt62s+CwnxtY5DgSFRi4ez9nH2VUsNVSwhP6SKEpbAYroFvPuPMoxjuM Z8Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706914500; x=1707519300; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zKMDcWb7/Hz1o/SS9+fE6kkkILRaJrotU8QEBL553Vg=; b=D+61NZGWgp5GkN8YVGmFbVb3RPHn2RTKVBy3YsO3VRF+scy8D826nzD0hxTWuTd5HB Yzdx7zevAwjiffKAfmitE4viobUAACYzHZ/5hgYlqvk1OyqIZpWjDeAXxYA9rmJ6t3Pk hH5TsksRLdU2HzyVbmujD3ApxsElgtTzMzU4215hrJJh69LytvzOFtowJiqwODniX/G2 WBfCvYAUjkonlTcGJ32cCGFdjy9BY8vXUpUDoizO7mH/BftSYMBwXl65UKxn5UwTWfn5 v/84UGDWr8vj/zkITfnF3N5+zLLc8ZUUWxbk/3VqO/D7lMf4F1lqB4SVv3KTDnCcDD5v 8+ZQ== X-Gm-Message-State: AOJu0YwrB4EjGE6KzXCYpMZVAacaUZaDglA0SRCw4I2AD6CHfzsmtiRA CYOxRp33bHcWnjUfxXByeF5F9+KgFyXh+uTc17Ef/3uT8Yfb3Qmtjwelft7+ X-Google-Smtp-Source: AGHT+IFYc5xeb/xW8I+2p4VbImf+4SsWkcA4tzj9XNxkJy+rJ8Yp/unKZiyzQBK29raxSukY+ZFvVQ== X-Received: by 2002:a9d:6e85:0:b0:6e1:3531:549b with SMTP id a5-20020a9d6e85000000b006e13531549bmr31525otr.0.1706914500402; Fri, 02 Feb 2024 14:55:00 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j20-20020a9d7d94000000b006e1424847d2sm563485otn.12.2024.02.02.14.54.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 14:55:00 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 09/18] common: Drop GLib use from gprs_proto_to_string Date: Fri, 2 Feb 2024 16:53:41 -0600 Message-ID: <20240202225405.993792-9-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202225405.993792-1-denkenz@gmail.com> References: <20240202225405.993792-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Refactor this function to use bool from stdbool.h as well as drop usage of GLib in favor of ell. --- src/common.c | 16 ++++++++-------- src/common.h | 2 +- src/gprs.c | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/common.c b/src/common.c index 79094ee4906c..abb151b6e8a1 100644 --- a/src/common.c +++ b/src/common.c @@ -778,19 +778,19 @@ const char *gprs_auth_method_to_string(enum ofono_gprs_auth_method auth) return NULL; } -gboolean gprs_auth_method_from_string(const char *str, +bool gprs_auth_method_from_string(const char *str, enum ofono_gprs_auth_method *auth) { - if (g_str_equal(str, "chap")) { + if (l_streq0(str, "chap")) { *auth = OFONO_GPRS_AUTH_METHOD_CHAP; - return TRUE; - } else if (g_str_equal(str, "pap")) { + return true; + } else if (l_streq0(str, "pap")) { *auth = OFONO_GPRS_AUTH_METHOD_PAP; - return TRUE; - } else if (g_str_equal(str, "none")) { + return true; + } else if (l_streq0(str, "none")) { *auth = OFONO_GPRS_AUTH_METHOD_NONE; - return TRUE; + return true; } - return FALSE; + return false; } diff --git a/src/common.h b/src/common.h index 779de7278446..bfbf2cff0437 100644 --- a/src/common.h +++ b/src/common.h @@ -189,5 +189,5 @@ const char *gprs_proto_to_string(enum ofono_gprs_proto proto); bool gprs_proto_from_string(const char *str, enum ofono_gprs_proto *proto); const char *gprs_auth_method_to_string(enum ofono_gprs_auth_method auth); -gboolean gprs_auth_method_from_string(const char *str, +bool gprs_auth_method_from_string(const char *str, enum ofono_gprs_auth_method *auth); diff --git a/src/gprs.c b/src/gprs.c index 3eb7df83ac54..dbf9b0605b7c 100644 --- a/src/gprs.c +++ b/src/gprs.c @@ -1201,7 +1201,7 @@ static DBusMessage *pri_set_auth_method(struct pri_context *ctx, GKeyFile *settings = ctx->gprs->settings; enum ofono_gprs_auth_method auth; - if (gprs_auth_method_from_string(str, &auth) == FALSE) + if (!gprs_auth_method_from_string(str, &auth)) return __ofono_error_invalid_format(msg); if (ctx->context.auth_method == auth) @@ -3183,7 +3183,7 @@ static gboolean load_context(struct ofono_gprs *gprs, const char *group) if (authstr == NULL) authstr = g_strdup("chap"); - if (gprs_auth_method_from_string(authstr, &auth) == FALSE) + if (!gprs_auth_method_from_string(authstr, &auth)) goto error; if (strlen(password) > OFONO_GPRS_MAX_PASSWORD_LENGTH) From patchwork Fri Feb 2 22:53:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13543548 Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 62875126F22 for ; Fri, 2 Feb 2024 22:55:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914503; cv=none; b=mp/oMQkUW1vDBeozb0ZGTWuIQMSwc4Z26z+wQHwdPFQLvTYfViRQmajvFje3NlwyZ5PORj0LziYYKLWWNmQZ+mhcp24xW1ljZRxI/JV7FS6883GL1yHc52qx88+klFNVrTJKU2+t5mvoLK3546u60QPrf3rB4QNvLZz4+gKrJiw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914503; c=relaxed/simple; bh=61fyQzNnKHj5QARlfxXcK5nSKB1DrWReECiyghMxOMc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=grM5FUk+K/5neUhOtHXQQZxfrl7NAuyTu1lea4aX7oqkU/QZwHGgvbH+B/wtKPvjt/UPyCX3S5GmjdMrL8cOTZ7C4gNVef3CJ7xU0T1UqBhzLJSLind89GF17hftK8ANO2AW4n4zxm9FiLr76r0vOeZvxJKUA91ZbimV9cO6srQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TtcFAeJl; arc=none smtp.client-ip=209.85.210.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TtcFAeJl" Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-6dc36e501e1so1685578a34.1 for ; Fri, 02 Feb 2024 14:55:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706914501; x=1707519301; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6hYJchzeiiEi5NAPlegGc7r3+ynvJ4n/A3YMHO2SCrI=; b=TtcFAeJl5VfnDy3z69oEVUUimefcejBwvvSd7cdQ1ACZ0sRAcXXXYd9vKCgh9swUWM 44Q4CgafdjJB6uu2+bJVvSeEDJpkU70h3A0zdT+ArDihvKh9jMNZP4fizN7GRDtQDtum 6i6YQ4DE52ixMcW2TiRn9Xf7TXFq+7tvnMQBfB9NaHyFywNJ8qge3Mw6sdZAEPL/yGIY 51Ce4NXvaDlFiUrgNeLOaM4rbDKzzqxUX1yhyhqkOudPqSo4SCEo3+dZj1SfQBxfWEjx iXaB2Zlt4IGxeuJ80Kvit6LOTpsHOugXsVyKmZca2wIcWCmEn9OVj0ClpQ6+pNGzlDlN /3AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706914501; x=1707519301; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6hYJchzeiiEi5NAPlegGc7r3+ynvJ4n/A3YMHO2SCrI=; b=a2e3yp3VwDxZupi2bHim/rfUOHQHyKd+p7s8euaYfTW7PM+BDXrpQesqMtguNxbYLD GTY5vn1f2Ebe2FDT/bzIOJXc8X44MvGyezoDAk5NxJ0DRdMQdzl9A32oOgYHGuDHUClC 2qLZESTjiiy1Ij4awL9RyIzifXmgjUPnTmI+r8CujGR1ye9PCRS09Gy/9H04W5i37DUe Nu6dWP3lpj6PEdb2onwIgy4oefYbLsfpxvtiN71oPsvdWVBdP4H/gERbcayMqHMU8i5z +wDjIXDU106WLmX22+zCHaq7qjA0DA7r55P2S5q4vv+Ued4CjBUOv4MSYc+pP6wn/lwu A2QA== X-Gm-Message-State: AOJu0Yxkw421JmcIUn0dwFSH9bdDogZeHtePs2+haAMlTRcN9Q0M6LGK XbrvuFJEN3lDG8XsPRyarhmPc3F4dYidj60GYDLt12SERZYhGyF6wEvnmUzA X-Google-Smtp-Source: AGHT+IFfIGuB/bOHeKVPc8u9repHB+t7FjduDJffEjTIwH7fqnTb0aOdCQFUqHlmMCKGpRK8uY+iNQ== X-Received: by 2002:a9d:7d97:0:b0:6dd:ec7f:f46d with SMTP id j23-20020a9d7d97000000b006ddec7ff46dmr10025905otn.11.1706914501327; Fri, 02 Feb 2024 14:55:01 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j20-20020a9d7d94000000b006e1424847d2sm563485otn.12.2024.02.02.14.55.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 14:55:00 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 10/18] storage: Remove mode parameter Date: Fri, 2 Feb 2024 16:53:42 -0600 Message-ID: <20240202225405.993792-10-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202225405.993792-1-denkenz@gmail.com> References: <20240202225405.993792-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Files are always written with owner read and write permissions. No other permissions make sense, so remove the mode parameter to simplify calling code. --- src/simfs.c | 5 ++--- src/smsutil.c | 8 +++----- src/storage.c | 3 ++- src/storage.h | 4 ++-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/simfs.c b/src/simfs.c index 515f5c97f7a7..38d4852b1886 100644 --- a/src/simfs.c +++ b/src/simfs.c @@ -1158,8 +1158,7 @@ void sim_fs_cache_image(struct sim_fs *fs, const char *image, int id) return; write_file((const unsigned char *) image, strlen(image), - SIM_CACHE_MODE, SIM_IMAGE_CACHE_PATH, imsi, - phase, id); + SIM_IMAGE_CACHE_PATH, imsi, phase, id); } char *sim_fs_get_cached_image(struct sim_fs *fs, int id) @@ -1262,7 +1261,7 @@ void sim_fs_check_version(struct sim_fs *fs) sim_fs_cache_flush(fs); version = SIM_FS_VERSION; - write_file(&version, 1, SIM_CACHE_MODE, SIM_CACHE_VERSION, imsi, phase); + write_file(&version, 1, SIM_CACHE_VERSION, imsi, phase); } void sim_fs_cache_flush(struct sim_fs *fs) diff --git a/src/smsutil.c b/src/smsutil.c index f2b6f44c2aa9..d07960190103 100644 --- a/src/smsutil.c +++ b/src/smsutil.c @@ -42,7 +42,6 @@ #define uninitialized_var(x) x = x -#define SMS_BACKUP_MODE 0600 #define SMS_BACKUP_PATH STORAGEDIR "/%s/sms_assembly" #define SMS_BACKUP_PATH_DIR SMS_BACKUP_PATH "/%s-%i-%i" #define SMS_BACKUP_PATH_FILE SMS_BACKUP_PATH_DIR "/%03i" @@ -2505,8 +2504,7 @@ static gboolean sms_assembly_store(struct sms_assembly *assembly, len = sms_serialize(buf, sms); - if (write_file(buf, len, SMS_BACKUP_MODE, - SMS_BACKUP_PATH_FILE, assembly->imsi, straddr, + if (write_file(buf, len, SMS_BACKUP_PATH_FILE, assembly->imsi, straddr, node->ref, node->max_fragments, seq) != len) return FALSE; @@ -2889,7 +2887,7 @@ static gboolean sr_assembly_add_fragment_backup(const char *imsi, return FALSE; /* storagedir/%s/sms_sr/%s-%s */ - if (write_file((unsigned char *) node, len, SMS_BACKUP_MODE, + if (write_file((unsigned char *) node, len, SMS_SR_BACKUP_PATH_FILE, imsi, straddr, msgid_str) != len) return FALSE; @@ -3370,7 +3368,7 @@ gboolean sms_tx_backup_store(const char *imsi, unsigned long id, /* * file name is: imsi/tx_queue/order-flags-uuid/pdu */ - if (write_file(buf, len, SMS_BACKUP_MODE, SMS_TX_BACKUP_PATH_FILE, + if (write_file(buf, len, SMS_TX_BACKUP_PATH_FILE, imsi, id, flags, uuid, seq) != len) return FALSE; diff --git a/src/storage.c b/src/storage.c index 2313835a49ce..eddb98c79598 100644 --- a/src/storage.c +++ b/src/storage.c @@ -120,13 +120,14 @@ ssize_t read_file(unsigned char *buffer, size_t len, * file with a temporary name and when closed, it is renamed to the * specified name (@path_fmt+args). */ -ssize_t write_file(const unsigned char *buffer, size_t len, mode_t mode, +ssize_t write_file(const unsigned char *buffer, size_t len, const char *path_fmt, ...) { va_list ap; char *tmp_path, *path; ssize_t r; int fd; + static const mode_t mode = 0600; va_start(ap, path_fmt); path = l_strdup_vprintf(path_fmt, ap); diff --git a/src/storage.h b/src/storage.h index 3a1e64493546..76069949e747 100644 --- a/src/storage.h +++ b/src/storage.h @@ -28,9 +28,9 @@ ssize_t read_file(unsigned char *buffer, size_t len, const char *path_fmt, ...) __attribute__((format(printf, 3, 4))); -ssize_t write_file(const unsigned char *buffer, size_t len, mode_t mode, +ssize_t write_file(const unsigned char *buffer, size_t len, const char *path_fmt, ...) - __attribute__((format(printf, 4, 5))); + __attribute__((format(printf, 3, 4))); char *storage_get_file_path(const char *imsi, const char *store); GKeyFile *storage_open(const char *imsi, const char *store); From patchwork Fri Feb 2 22:53:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13543549 Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F70512C7ED for ; Fri, 2 Feb 2024 22:55:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914504; cv=none; b=W2TWujn0M1RYGc1I4+jwTz6Sr7xklCt+94V03ny8uKGFLSrG/ywuTJn7w+bChj/cqg1dG3QcSE0SyUZ8iJdLHHHJlT+TDrHu19ZrzesxF7T/HXOYluajiDJmVztFVoWzOVvCrow4hxqn4UjNlpc0eCE4xzPOqH/euRWZ5zyTDas= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914504; c=relaxed/simple; bh=Z7ctEh4XA2yzXnArktl4KmH0EMMv+ya97IuMrm0sCsk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A5xmdgb6UNLKli1PVmpTvzWzqEcUPjm+aevUrJZp36wmaTbifet86/0LmGj0FXHWGTXs8hS3TB2M3gcMY/d5vNTo0Syp4efSz8baagWcVySvP/ecq6QJB5CTe/74kDjqjPPXu6eVg4TlPD6EeSxDzqYenPpnzB015T77v82+HoI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XDg1Nox3; arc=none smtp.client-ip=209.85.167.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XDg1Nox3" Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-3bfc3c3d5cfso223345b6e.1 for ; Fri, 02 Feb 2024 14:55:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706914502; x=1707519302; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uE87/0wYKXIeyz1wrfXQzQmSBH/HtUrL/kMalNyUS5A=; b=XDg1Nox3VIisvj2LeQSEjoPtfPIqQjL/haRc9gi/p9abPx6zBPC/SXodQSDFa0tLCi KPf2jhKP9sfOugYsAfqaQqDVCAbO/x/wQJPDPpt5aGEMi5JbuudmXWT5a29T51eiUAqM cyoJHnWESfY1+yKksygFJ6yQWvNeVqCFeDM1oi+koJDTJrk9WBi9ugo+C1+jSXqR6BOJ 4jfjmPkQvnCIdaGqVl8JSaVaMltEgTw1XqGF4xvKNkoeO1G8MiG+Ze8XFJrZZifipQDS NxA0PIAOpXWjzIlfcVnOVMPBmv3pb/OA4+e8cNxAxvMyjHclCnHLExhhSZs4RpSlIrER VrHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706914502; x=1707519302; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uE87/0wYKXIeyz1wrfXQzQmSBH/HtUrL/kMalNyUS5A=; b=p5HDa/gWzbQmgKLo0/liwqs4NcYShlGqig5eUHyMybX0mOrg4B990Op0nusmWRaBeX xORNEqh1W/yLP/XDY2G6DunBlkQ8KKvno7bXdHAkGtGy0oCBh5X77legnEopP2sNvcd/ ROyOccHAwpEigWW33xAKbSjslE94mCTmmf4BbvWgKY8qMORRew6Wp5YzayA9v+aMnR/w 7FjsRM4JQIGlMJWzgqhu2eNODSV4T4J492cAiGyrFGJ2U3AWAEHJ0Fi0hKzbUVPIt6hB 6zQyategMWJaTcRD0sL+6Ak/M9gY28vM92wKG84MpwwZMWaztZhH0iPpb1QohDm9Ka+Y 9iFA== X-Gm-Message-State: AOJu0YwVEMIC+9G906zFlBbSs67bYg9zJPaZ7bgl2tJEeBkMoXqFGaru rdZGmw4/lyXuF6W/DTFVmnpRpfBRkq+QymeIEkuDmUKUWI8ac3oxlCMlmAmQ X-Google-Smtp-Source: AGHT+IHkMJMJobqf4fUbul+V9S+2iC9dVIvhDBehZdT7MsSnjZBuAFZkIgS6Ly5yqKXA2K/nuA+n6Q== X-Received: by 2002:a05:6808:2a44:b0:3bf:c555:edcd with SMTP id fa4-20020a0568082a4400b003bfc555edcdmr24883oib.9.1706914502121; Fri, 02 Feb 2024 14:55:02 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j20-20020a9d7d94000000b006e1424847d2sm563485otn.12.2024.02.02.14.55.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 14:55:01 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 11/18] storage: Use l_malloc Date: Fri, 2 Feb 2024 16:53:43 -0600 Message-ID: <20240202225405.993792-11-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202225405.993792-1-denkenz@gmail.com> References: <20240202225405.993792-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Instead of g_try_malloc --- src/storage.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/storage.c b/src/storage.c index eddb98c79598..47429c22d1bc 100644 --- a/src/storage.c +++ b/src/storage.c @@ -61,10 +61,7 @@ int create_dirs(const char *filename, const mode_t mode) if (!err && S_ISREG(st.st_mode)) return 0; - dir = g_try_malloc(strlen(filename) + 1); - if (dir == NULL) - return -1; - + dir = l_malloc(strlen(filename) + 1); strcpy(dir, "/"); for (prev = filename; (next = strchr(prev + 1, '/')); prev = next) { @@ -75,12 +72,12 @@ int create_dirs(const char *filename, const mode_t mode) strncat(dir, prev + 1, next - prev); if (mkdir(dir, mode) == -1 && errno != EEXIST) { - g_free(dir); + l_free(dir); return -1; } } - g_free(dir); + l_free(dir); return 0; } From patchwork Fri Feb 2 22:53:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13543550 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C16912C80B for ; Fri, 2 Feb 2024 22:55:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914505; cv=none; b=MMNa6amXThk/sDnTiNibKt9bsC4Aw8WaTtMpfUsJcAGOWN5BxcZVNV7kJeQ2+7wXDrLdHn45uMgwdBfe5bC2b2VjHxl1n91Ev4EK1/46lRSPheUeKMjqRonYHEjppUupRoXUiwqm0vlJCG0F21Hoqwfd8YPoZHf+iDAvy1jLc9s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914505; c=relaxed/simple; bh=gMqc4dy0hjylmgsbxIg2lYpH5Re5rsD2z2eWAoVbBTY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Eyh1raIwLhdnAS1SOC5L7TmhcCu3tfHmj1LrcxeD3tZdec99xfR7nKiPU7U5h3pa0DJqzgD7jINefAIn6ctS1mpOPbmjiqnnlAl3r1Jwb9Wa85BRTEBjZagFxluCbdxEhotkL4DOUUOhBBlL5EDKaLPohFd0Ui1+ztAscjMFdzI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TJ/FVqeW; arc=none smtp.client-ip=209.85.210.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TJ/FVqeW" Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-6e117e0fee8so1373189a34.2 for ; Fri, 02 Feb 2024 14:55:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706914503; x=1707519303; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4YEJXClJXndANP0ft48gNZnomKIqyKfHWvhmCOVS8MM=; b=TJ/FVqeWKO3ckzezBY/VXQTsYxJxTNyQizIzYpK1Gl814zk8M1Wi4EMuWPcRjwWnPh coSkED7JWtSTvGeReb9mx6U5pTYP96mkVaXBQoI7S4w+QqPGDuhP5pWZjXclbNkBj993 dMycsFjoE/dMGIntYfPMPxd6OnhpPlXP2s7GdSWUt1juDdY+PvsuLPGlot/dv8r3n9Wn 5/h/1/d6c+HJaqgcZb+7YeUaAgn9wkllVXm+cZq5z3zYbHroE6R53lvlT6mSxD6Hd+HN 2zHz50u6EXKEMIyYHvD9EW6UggEBWIWXlPHden7sRWPBGGN/beWFp/EQb3JPo6KZoEKA NVYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706914503; x=1707519303; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4YEJXClJXndANP0ft48gNZnomKIqyKfHWvhmCOVS8MM=; b=KFpo5VabTurCqNOzPHAiTn8i2RkBO0lfwVAJxg7/X2sPJv1vSYvEiKJgN6peRk0jp1 NwWqPjjB8WC1H5LCMM4SsLHSRCY6Th0muK/YRsnvS3fJUsNPlis1sb20UhgZsrqQk5FZ Zp4XsSTtoTCIudzAf2YgH/xuOrvbJrjrGbwfEKh8aWmm3nFJnblX8VaEDSk0LsQlEEEW VDfBnbN54nbuXswET8Im0sgE52yDeqYHlWfq1fvJtDZALZUNzCJ938j/C+JZAc+SEOlG pGqmbIU+jCb924oZx+DMBbvE+EmH9pdqOiAPaz5dcRMOZtfOBoZZoXFTHX30DbnxwmLH Vktg== X-Gm-Message-State: AOJu0YzWzAgJFehw9dKiu641ID9FvmGjZC0dR/EDx9AsYgbYJGmOqubQ ZjIK7JuezcVu5C1OuqytZmGLugmKK0ZbhYD+/7L5rfbD9bj1gmk3dSQs6/hG X-Google-Smtp-Source: AGHT+IELINjMmbEYr8O1rfYHCnb6VaID9JqnFOIBO3qP72pneXjbBAFb3yqNNqZTlbPa3gHoRK8/Qg== X-Received: by 2002:a9d:7302:0:b0:6dd:ecaa:3aea with SMTP id e2-20020a9d7302000000b006ddecaa3aeamr10773211otk.1.1706914502941; Fri, 02 Feb 2024 14:55:02 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j20-20020a9d7d94000000b006e1424847d2sm563485otn.12.2024.02.02.14.55.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 14:55:02 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 12/18] storage: Remove mode argument Date: Fri, 2 Feb 2024 16:53:44 -0600 Message-ID: <20240202225405.993792-12-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202225405.993792-1-denkenz@gmail.com> References: <20240202225405.993792-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 oFono should be making all sub-directories in STORAGEDIR (typically /var/lib/ofono) as owner readable/writable. No other permissions make sense. Remove the mode argument from the function signature to make this explicit. --- src/storage.c | 7 ++++--- src/storage.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/storage.c b/src/storage.c index 47429c22d1bc..1b761c4ce57a 100644 --- a/src/storage.c +++ b/src/storage.c @@ -47,12 +47,13 @@ const char *ofono_storage_dir(void) return STORAGEDIR; } -int create_dirs(const char *filename, const mode_t mode) +int create_dirs(const char *filename) { struct stat st; char *dir; const char *prev, *next; int err; + static const mode_t mode = 0700; if (filename[0] != '/') return -1; @@ -133,7 +134,7 @@ ssize_t write_file(const unsigned char *buffer, size_t len, tmp_path = l_strdup_printf("%s.XXXXXX.tmp", path); r = -1; - if (create_dirs(path, mode | S_IXUSR) != 0) + if (create_dirs(path) != 0) goto error_create_dirs; fd = L_TFR(g_mkstemp_full(tmp_path, O_WRONLY | O_CREAT | O_TRUNC, mode)); @@ -204,7 +205,7 @@ void storage_sync(const char *imsi, const char *store, GKeyFile *keyfile) if (path == NULL) return; - if (create_dirs(path, S_IRUSR | S_IWUSR | S_IXUSR) != 0) { + if (create_dirs(path) != 0) { l_free(path); return; } diff --git a/src/storage.h b/src/storage.h index 76069949e747..46efd2d1a208 100644 --- a/src/storage.h +++ b/src/storage.h @@ -22,7 +22,7 @@ #include #include -int create_dirs(const char *filename, const mode_t mode); +int create_dirs(const char *filename); ssize_t read_file(unsigned char *buffer, size_t len, const char *path_fmt, ...) From patchwork Fri Feb 2 22:53:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13543551 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D4E512C80C for ; Fri, 2 Feb 2024 22:55:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914506; cv=none; b=GNOOz+UQTgYe5nVxljOsBumizXFvjhZy93qSEkj7WZeeY3/h05eykGNBbnx5O+vnie3jCCi7yZqxIHOxIX7p5dbt5Y1jeRxkExZhrr3holJvXk+JeJ07S9P8ksfaJSQ1JoIPC3nJKxfMta9DbTAuytwuHEPsU+M4RKgMkkRYkiA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914506; c=relaxed/simple; bh=a+jxi9QixNGyk3ipZTueAhPHBscTTc0vwO0eOodccOE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oLqZOojo1GHywb5ntlAsrPndX+ESOKyE3CZZ/rN3/ZdekNhvLluR7idDgs32ZV0Fhov+s/MVIDUoEa3NJ/+rmRzw+LV/wUS/2BdnE+cPLJWXeBJgnkmtT8AIPzfsTEdvyfdNtyXVA+rmb2DIdj/NtFVTpr3A66pp72GFxtAvLAQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=C6hS6Gn6; arc=none smtp.client-ip=209.85.210.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C6hS6Gn6" Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-6e117e0fee8so1373195a34.2 for ; Fri, 02 Feb 2024 14:55:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706914503; x=1707519303; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/275mKN5hiZ2GPBZ62+urJQue5a7aTrxJsi5NaMDxAA=; b=C6hS6Gn6lXedRkfYWvJeRO/YnboJTQfgPQsyVG/0xIvNzusrlSVI4iVKy9y/FUN9EO lZEQG7b1DomPIx5/prC7Vxztco8Z8horUdAlhJ+Mv4dTPGhHRA7+Jucp881sM8DB/3hn d2QHW39YzMSX6gKEoCavyolI8MmZHTa3tuxsOojd7xsncM8xM0DDMv8QBE5wVtDog+V1 38bYbFDF9PLMjtuFT8nTSNbjUauYZsXZ3ljmstJp/v4SzHqpys81eat/9WBQ8otYTQGM 9qlC2/kaGLGYpHCj8Xh2EzSGjeV9nVYhFcpV5YUr3M187AaK5bpbzCkn/k8etM5DLqvs RIaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706914503; x=1707519303; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/275mKN5hiZ2GPBZ62+urJQue5a7aTrxJsi5NaMDxAA=; b=uzioSVqJEcDxdyaNnfo5Kz/2g1t4ujLYU+P1YYqkxoarY0GREiYacpXLYxqD7yrd07 FoNepIUKX3W99Iseu9U/fpB5Kn02GvLCkbYHadmYXGzeq8gTY4kRD7CtcT6ttYGh68Gc szPTPrPp/Ddf8HqHT+BRIWN8LKD4pt7GHc7qMNoP41lEsczjPE+jJ0JCNi0EE3zTFSve t1b9iku9DXxm2oHjwwLwK5IV56v2mIsINUojoS9XNbOittD49Nvwi1OCrFH3n8YEZHXD yo9IFCcVxX43LpqLRAd1eyEVbQeyDukrzEYr/HK0oJhKVXk4pkwUGrsRUGlrCvslj5hB M2+A== X-Gm-Message-State: AOJu0YyMWfXXzG8ZNILahRwj4cOBdEr7rJmlGSuN9viZxavP78yQs0va 3VyX36rGC0FTcPwVI7dGSXvjPVmZ4Kid0AKYsYjfgxp+Rmosuejk9KnrYf0/ X-Google-Smtp-Source: AGHT+IHrhTaabzl0G1r451oVo4ocPP21IyQjq39ijJyQSU6pDFD07/pFqzh41f5ZU/iCIEyOEmA83g== X-Received: by 2002:a9d:6411:0:b0:6e1:1570:d4a2 with SMTP id h17-20020a9d6411000000b006e11570d4a2mr8798075otl.33.1706914503629; Fri, 02 Feb 2024 14:55:03 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j20-20020a9d7d94000000b006e1424847d2sm563485otn.12.2024.02.02.14.55.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 14:55:03 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 13/18] storage: Use void * instead of unsigned char * Date: Fri, 2 Feb 2024 16:53:45 -0600 Message-ID: <20240202225405.993792-13-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202225405.993792-1-denkenz@gmail.com> References: <20240202225405.993792-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This allows passing both binary and string data to write_file() and read_file() --- src/storage.c | 6 ++---- src/storage.h | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/storage.c b/src/storage.c index 1b761c4ce57a..5b12c69ba6dd 100644 --- a/src/storage.c +++ b/src/storage.c @@ -82,8 +82,7 @@ int create_dirs(const char *filename) return 0; } -ssize_t read_file(unsigned char *buffer, size_t len, - const char *path_fmt, ...) +ssize_t read_file(void *buffer, size_t len, const char *path_fmt, ...) { va_list ap; char *path; @@ -118,8 +117,7 @@ ssize_t read_file(unsigned char *buffer, size_t len, * file with a temporary name and when closed, it is renamed to the * specified name (@path_fmt+args). */ -ssize_t write_file(const unsigned char *buffer, size_t len, - const char *path_fmt, ...) +ssize_t write_file(const void *buffer, size_t len, const char *path_fmt, ...) { va_list ap; char *tmp_path, *path; diff --git a/src/storage.h b/src/storage.h index 46efd2d1a208..135674c6f517 100644 --- a/src/storage.h +++ b/src/storage.h @@ -24,12 +24,10 @@ int create_dirs(const char *filename); -ssize_t read_file(unsigned char *buffer, size_t len, - const char *path_fmt, ...) +ssize_t read_file(void *buffer, size_t len, const char *path_fmt, ...) __attribute__((format(printf, 3, 4))); -ssize_t write_file(const unsigned char *buffer, size_t len, - const char *path_fmt, ...) +ssize_t write_file(const void *buffer, size_t len, const char *path_fmt, ...) __attribute__((format(printf, 3, 4))); char *storage_get_file_path(const char *imsi, const char *store); From patchwork Fri Feb 2 22:53:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13543552 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 452C712C812 for ; Fri, 2 Feb 2024 22:55:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914506; cv=none; b=tNXTsaSWvSpcacNUnDgAfQuNg2v6kwv91mbqGMvD53gWgWjQbN1y+H13HrnJMqvmnzclYdaZ83+oIXfDvkbhn3go29ipPMnumiov/2XMFexTdX1JnEx9Q6TeSth3xwhFpjeh2btSKH/9LLptmpnitfAzfVCc8IvWm93umLV6ats= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914506; c=relaxed/simple; bh=+IAj5/cYSSgOLSMK7pV3pIOZ6oTbviP6AB9sjLMys4M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FvA5ZZccppbJlSBHWyWK51HwQ183raP+yVxdm9vmuHOaBR/PL3IyxT5/xCMj3REdz85eHVkRE830MZ2kI54Yh0YxRrI0OYFb9up9dq7c1zWDhcV59WeCQAoF+VjvlMS8QMeZA17rZNHIyu3nnir2a9UrhCWgng8txvhFehwfL3k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HDW261qn; arc=none smtp.client-ip=209.85.210.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HDW261qn" Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-6e11faeb125so1252177a34.2 for ; Fri, 02 Feb 2024 14:55:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706914504; x=1707519304; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cVRCuVGPEoLGVvSyzuBR5NWdqYsZ6rUc159zqiqyK28=; b=HDW261qnpE3bdYofQsYUxuAEHn9jqDO83NjHLFS59O2IVOUYoCV93ya60uYaWhiP6+ Q1Rlxy9XWHAISpAElNtzGuyLGTbNJ8+WCOnsKyo6/zn0JTuVUTwBggO62MQ9Ka34adfC RG16+Rfg5SWXoHhVaUqSoRFSfVwFO3lBB13XEpNPfG0HmC9YbsbQsIWeEjAabPNbHhIw XsHJscvu5Lkeb6lQ88UMB5zu9T0Ln7jSwj0y6rd/YI84qYVlj8O+c4gE1VsZiySDFl7B op5uQoK38/dECUSJEZsB/pKLGM33vQeRNS2JFogavmu3RYyUEJ6kUnM1e9nExxyTi516 aoYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706914504; x=1707519304; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cVRCuVGPEoLGVvSyzuBR5NWdqYsZ6rUc159zqiqyK28=; b=tTwkJZ0aQkq31ClKNB6IDN7phFo2AWsKQqMl9fsy1bt5FNEuxliU28+tDt28wgOW8e MUFunwNj+hoQYvFQlhYj4hpwz/MPif2yfaOatVdbTh76PWJcfBk0bno1rXgR8SAxTKYQ 0bqDnhOwd0WvmqC13EhmwwBrmCcenHQ09dqWimcj4R9AwZgYqwlHf8LTccFe7aZ40ugj PEJiSw876kT9lDTBZB0kjnCWXMnc+DxMeftp+0z0WawrdjWOFE4lPspBJ65m6ZvwpuPv 3jA0iCDRfg7D9ldziiupnOoMN8M22M3yaf2Xb5a+xX6EmkIYN4Q+UhJFffYoKk3SNAnw rMkg== X-Gm-Message-State: AOJu0Ywvgm/Hi4UAOD7E9ajYqdeNqya1Se9DaFEMf/9IA1pgfYVvRgzc 5DufcJezjIbVJJsDHQCZc7u1YviEqDgUjWgOOsQLcTwOMnAYIgAnCpcJU3j2 X-Google-Smtp-Source: AGHT+IHoMUl9KlNBGs/oKkz+jUkVgNTurgeSKGLzaifAJg60c07lI3AfBH9Qqro2kQsfEijxvPAnpQ== X-Received: by 2002:a9d:66d6:0:b0:6dd:636b:c95c with SMTP id t22-20020a9d66d6000000b006dd636bc95cmr7224237otm.25.1706914504388; Fri, 02 Feb 2024 14:55:04 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j20-20020a9d7d94000000b006e1424847d2sm563485otn.12.2024.02.02.14.55.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 14:55:04 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 14/18] storage: use l_file_set_contents Date: Fri, 2 Feb 2024 16:53:46 -0600 Message-ID: <20240202225405.993792-14-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202225405.993792-1-denkenz@gmail.com> References: <20240202225405.993792-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use ell convenience function to set the file contents. --- src/storage.c | 41 ++++++----------------------------------- 1 file changed, 6 insertions(+), 35 deletions(-) diff --git a/src/storage.c b/src/storage.c index 5b12c69ba6dd..00469f48510c 100644 --- a/src/storage.c +++ b/src/storage.c @@ -3,6 +3,7 @@ * oFono - Open Source Telephony * * Copyright (C) 2008-2011 Intel Corporation. All rights reserved. + * Copyright (C) 2024 Cruise, LLC * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -120,50 +121,20 @@ ssize_t read_file(void *buffer, size_t len, const char *path_fmt, ...) ssize_t write_file(const void *buffer, size_t len, const char *path_fmt, ...) { va_list ap; - char *tmp_path, *path; - ssize_t r; - int fd; - static const mode_t mode = 0600; + char *path; + int r; va_start(ap, path_fmt); path = l_strdup_vprintf(path_fmt, ap); va_end(ap); - tmp_path = l_strdup_printf("%s.XXXXXX.tmp", path); - - r = -1; - if (create_dirs(path) != 0) + r = create_dirs(path); + if (r < 0) goto error_create_dirs; - fd = L_TFR(g_mkstemp_full(tmp_path, O_WRONLY | O_CREAT | O_TRUNC, mode)); - if (fd == -1) - goto error_mkstemp_full; - - r = L_TFR(write(fd, buffer, len)); - - L_TFR(close(fd)); - - if (r != (ssize_t) len) { - r = -1; - goto error_write; - } - - /* - * Now that the file contents are written, rename to the real - * file name; this way we are uniquely sure that the whole - * thing is there. - */ - unlink(path); - - /* conserve @r's value from 'write' */ - if (link(tmp_path, path) == -1) - r = -1; + r = l_file_set_contents(path, buffer, len); -error_write: - unlink(tmp_path); -error_mkstemp_full: error_create_dirs: - l_free(tmp_path); l_free(path); return r; } From patchwork Fri Feb 2 22:53:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13543553 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B44112C80C for ; Fri, 2 Feb 2024 22:55:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914508; cv=none; b=UWkFPy+dzYct2FWfqzj46jE+c5rl48vZaOaSRo/friGhrjpq+uFhgYzsV6NtzfFEN/b5dIIiIntRNYSaYmLpHuTdzwvWWDK2Qdfps7xwXjSDnn8B8zhREIiW6ANaLFn6Pb0mBdW5ZESjx57ZPsHvEv6Bj/Vm9uUOk7UDtch5ViU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914508; c=relaxed/simple; bh=UxrmgW9reG25GHRAwrrWHbD2mXVxWbkskvWdg/K+RmQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oCXV1jYVmhhrdc4i9DPTU9GdpYZz29TitrULH+Gpuw17waV1J1eSU86/4/rrn+XjSqFkwFkFq++aBhmAvGviKOlYbMZaqwXqILyY4IJJJaTEOug7xDbAJC5wl18G7ZabRU9vRcWSf9YxWOkBsTBWj59vhrHHlxwsvSO5+MFiF/o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PB7GUX+/; arc=none smtp.client-ip=209.85.210.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PB7GUX+/" Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-6e1214ae9d4so1373978a34.3 for ; Fri, 02 Feb 2024 14:55:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706914505; x=1707519305; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jWm384YdiQF1W0XYQWFOO4Irk31kuG+rGnT/0PYc8a4=; b=PB7GUX+/psGR8HJyR9Iqy5S7y3dl6IQa+WTXwmMPiog/hhfmpEfH12aSNr1ZvJaiF3 GewZtk9yETjQ42WZFuzQBvhbRzIFEnP7B+pnUwrDlkaE2VDiUEPcYh/9VynNyKMu7ccu 7nxdtoOgTFWsxFViK/fhsiLGd9SbWeCkItE6rpNxZyivE9+hxL1I0DdwxBF5Byy7RAO7 SFgqHs0qIWF0DgWEm42ZK4ayAIavi0NJW8YptK/tTyBLQiIrl3lS8AldhrP8erl7yBkc cUWFYx3R128vfEEQjMcmv4BaGYgC3WEqpImCcBWCgTKcQtzZAIUwjN1k9eGrCSlnXs4V Izog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706914505; x=1707519305; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jWm384YdiQF1W0XYQWFOO4Irk31kuG+rGnT/0PYc8a4=; b=ghh3+1ABmp6W37HHHUTXzcn3WIC9xtsg8zXLzev+a1/4POPc6q72UQxvt/WJ1p8ecc V/h+4pnLx0DV13qXxT8O+qIKDytH9yZKiVE3y/v0kKfhXAK08VQWc10G7geZPKSTfiG9 tKz3EPqS6CXyIeT1peRgwSpDbceF/F6BQbJueHzX9wjeMcRXQxBDfXEvxEtgyd1QnEoW UXObRRpRHzZdTNZYNcfrcmQ6B81F2ZUZwxdmkq3QNNd7IwASEMgHu0ZN/TvoY0ADu+r6 USw5MxYR55pYrX+Yg4RgEtUWqRduMALJ0Wxn69dBoYu5Wm+pufbJvS3YARrsp08lxVsr 5z6Q== X-Gm-Message-State: AOJu0YxJG4zkCFcwCfl7H6egDzWAzo+pNne5iV24e0L70wMsw5qvjTjn gZn2cmh8wT349kBuawfOU5sn8ldspayjD2NBTYCkKw9zg+wXyJMSekr4iYKw X-Google-Smtp-Source: AGHT+IGYUsqm0CuZayESh3mDJsYzxQkaedJUAxK1Wl9002QjGnLjFa2YdhUJ/qddL51pSQcyvFAn/Q== X-Received: by 2002:a9d:5c06:0:b0:6e1:11b7:9a39 with SMTP id o6-20020a9d5c06000000b006e111b79a39mr9494409otk.23.1706914505254; Fri, 02 Feb 2024 14:55:05 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j20-20020a9d7d94000000b006e1424847d2sm563485otn.12.2024.02.02.14.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 14:55:05 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 15/18] lte: Refactor lte settings management Date: Fri, 2 Feb 2024 16:53:47 -0600 Message-ID: <20240202225405.993792-15-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202225405.993792-1-denkenz@gmail.com> References: <20240202225405.993792-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In preparation for support LTE Default bearer provisioning, refactor how the settings are loaded and saved from disk: 1. Instead of storing the imsi in a malloced variable, obtain it directly from the sim atom. 2. Do not try to save the settings when the lte atom is removed. If the settings have not been provisioned or modified by the user, writing the settings file will have no effect, and makes it harder to detect whether provisioning should be attempted in the future. 3. Use ell for the nicer to use _auto_ variables, access to the L_WARN macro. 4. Use l_settings instead of g_key_file. The underlying file format is identical. 5. Convert g_strlcpy to l_strlcpy 6. Convert g_str_equal to l_streq0 7. Convert strdup/g_free to l_strdup and l_free --- src/lte.c | 168 +++++++++++++++++++++++++++--------------------------- 1 file changed, 84 insertions(+), 84 deletions(-) diff --git a/src/lte.c b/src/lte.c index 7280b2913a8d..158c8e9c2b17 100644 --- a/src/lte.c +++ b/src/lte.c @@ -32,6 +32,7 @@ #include #include +#include #include "ofono.h" @@ -50,59 +51,50 @@ struct ofono_lte { const struct ofono_lte_driver *driver; void *driver_data; struct ofono_atom *atom; - char *imsi; - GKeyFile *settings; + struct l_settings *settings; DBusMessage *pending; struct ofono_lte_default_attach_info pending_info; struct ofono_lte_default_attach_info info; }; -static void lte_load_settings(struct ofono_lte *lte) +static int lte_load_settings(struct ofono_lte *lte) { - char *apn; - char *proto_str; - char *auth_method_str; - char *username; - char *password; - - if (lte->imsi == NULL) - return; - - lte->settings = storage_open(lte->imsi, SETTINGS_STORE); - - if (lte->settings == NULL) { - ofono_error("LTE: Can't open settings file, " - "changes won't be persistent"); - return; - } - - apn = g_key_file_get_string(lte->settings, SETTINGS_GROUP, - LTE_APN, NULL); - proto_str = g_key_file_get_string(lte->settings, SETTINGS_GROUP, - LTE_PROTO, NULL); - auth_method_str = g_key_file_get_string(lte->settings, SETTINGS_GROUP, - LTE_AUTH_METHOD, NULL); - username = g_key_file_get_string(lte->settings, SETTINGS_GROUP, - LTE_USERNAME, NULL); - password = g_key_file_get_string(lte->settings, SETTINGS_GROUP, - LTE_PASSWORD, NULL); - if (apn && is_valid_apn(apn)) - strcpy(lte->info.apn, apn); + struct ofono_modem *modem = __ofono_atom_get_modem(lte->atom); + struct ofono_sim *sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem); + const char *imsi = ofono_sim_get_imsi(sim); + _auto_(l_free) char *path = NULL; + _auto_(l_free) char *apn = NULL; + const char *proto_str; + const char *auth_method_str; + _auto_(l_free) char *username = NULL; + _auto_(l_free) char *password = NULL; + + if (L_WARN_ON(!sim || !imsi)) + return -ENOKEY; + + path = storage_get_file_path(imsi, SETTINGS_STORE); + if (!l_settings_load_from_file(lte->settings, path)) + return -ENOENT; + + apn = l_settings_get_string(lte->settings, SETTINGS_GROUP, LTE_APN); + proto_str = l_settings_get_value(lte->settings, SETTINGS_GROUP, + LTE_PROTO); + auth_method_str = l_settings_get_value(lte->settings, SETTINGS_GROUP, + LTE_AUTH_METHOD); + username = l_settings_get_string(lte->settings, SETTINGS_GROUP, + LTE_USERNAME); + password = l_settings_get_string(lte->settings, SETTINGS_GROUP, + LTE_PASSWORD); - if (proto_str == NULL) - proto_str = g_strdup("ip"); + if (!gprs_auth_method_from_string(auth_method_str, + <e->info.auth_method)) + lte->info.auth_method = OFONO_GPRS_AUTH_METHOD_NONE; - /* this must have a valid default */ if (!gprs_proto_from_string(proto_str, <e->info.proto)) lte->info.proto = OFONO_GPRS_PROTO_IP; - if (auth_method_str == NULL) - auth_method_str = g_strdup("none"); - - /* this must have a valid default */ - if (!gprs_auth_method_from_string(auth_method_str, - <e->info.auth_method)) - lte->info.auth_method = OFONO_GPRS_AUTH_METHOD_NONE; + if (apn && is_valid_apn(apn)) + strcpy(lte->info.apn, apn); if (username && strlen(username) <= OFONO_GPRS_MAX_USERNAME_LENGTH) strcpy(lte->info.username, username); @@ -110,11 +102,28 @@ static void lte_load_settings(struct ofono_lte *lte) if (password && strlen(password) <= OFONO_GPRS_MAX_PASSWORD_LENGTH) strcpy(lte->info.password, password); - g_free(apn); - g_free(proto_str); - g_free(auth_method_str); - g_free(username); - g_free(password); + return 0; +} + +static void lte_save_settings(struct ofono_lte *lte) +{ + struct ofono_modem *modem = __ofono_atom_get_modem(lte->atom); + struct ofono_sim *sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem); + const char *imsi = ofono_sim_get_imsi(sim); + _auto_(l_free) char *path = NULL; + _auto_(l_free) char *data = NULL; + size_t len; + + if (!imsi) + return; + + data = l_settings_to_data(lte->settings, &len); + if (!data) + return; + + path = storage_get_file_path(imsi, SETTINGS_STORE); + + L_WARN_ON(write_file(data, len, "%s", path) < 0); } static DBusMessage *lte_get_properties(DBusConnection *conn, @@ -180,12 +189,12 @@ static void lte_set_default_attach_info_cb(const struct ofono_error *error, */ dbus_message_iter_init(lte->pending, &iter); dbus_message_iter_get_basic(&iter, &str); - key = strdup(str); + key = l_strdup(str); dbus_message_iter_next(&iter); dbus_message_iter_recurse(&iter, &var); dbus_message_iter_get_basic(&var, &str); - value = strdup(str); + value = l_strdup(str); memcpy(<e->info, <e->pending_info, sizeof(lte->info)); @@ -200,13 +209,13 @@ static void lte_set_default_attach_info_cb(const struct ofono_error *error, */ if (!*value) /* Clear entry on empty string. */ - g_key_file_remove_key(lte->settings, - SETTINGS_GROUP, key, NULL); + l_settings_remove_key(lte->settings, + SETTINGS_GROUP, key); else - g_key_file_set_string(lte->settings, - SETTINGS_GROUP, key, value); + l_settings_set_string(lte->settings, + SETTINGS_GROUP, key, value); - storage_sync(lte->imsi, SETTINGS_STORE, lte->settings); + lte_save_settings(lte); } ofono_dbus_signal_property_changed(conn, path, @@ -214,8 +223,8 @@ static void lte_set_default_attach_info_cb(const struct ofono_error *error, key, DBUS_TYPE_STRING, &value); - g_free(value); - g_free(key); + l_free(value); + l_free(key); } static DBusMessage *lte_set_property(DBusConnection *conn, @@ -257,14 +266,14 @@ static DBusMessage *lte_set_property(DBusConnection *conn, memcpy(<e->pending_info, <e->info, sizeof(lte->info)); if ((strcmp(property, LTE_APN) == 0)) { - if (g_str_equal(str, lte->info.apn)) + if (l_streq0(str, lte->info.apn)) return dbus_message_new_method_return(msg); /* We do care about empty value: it can be used for reset. */ if (is_valid_apn(str) == FALSE && str[0] != '\0') return __ofono_error_invalid_format(msg); - g_strlcpy(lte->pending_info.apn, str, + l_strlcpy(lte->pending_info.apn, str, OFONO_GPRS_MAX_APN_LENGTH + 1); } else if ((strcmp(property, LTE_PROTO) == 0)) { if (!gprs_proto_from_string(str, &proto)) @@ -286,19 +295,19 @@ static DBusMessage *lte_set_property(DBusConnection *conn, if (strlen(str) > OFONO_GPRS_MAX_USERNAME_LENGTH) return __ofono_error_invalid_format(msg); - if (g_str_equal(str, lte->info.username)) + if (l_streq0(str, lte->info.username)) return dbus_message_new_method_return(msg); - g_strlcpy(lte->pending_info.username, str, + l_strlcpy(lte->pending_info.username, str, OFONO_GPRS_MAX_USERNAME_LENGTH + 1); } else if (strcmp(property, LTE_PASSWORD) == 0) { if (strlen(str) > OFONO_GPRS_MAX_PASSWORD_LENGTH) return __ofono_error_invalid_format(msg); - if (g_str_equal(str, lte->info.password)) + if (l_streq0(str, lte->info.password)) return dbus_message_new_method_return(msg); - g_strlcpy(lte->pending_info.password, str, + l_strlcpy(lte->pending_info.password, str, OFONO_GPRS_MAX_PASSWORD_LENGTH + 1); } else return __ofono_error_invalid_args(msg); @@ -332,24 +341,19 @@ static void lte_remove(struct ofono_atom *atom) DBG("atom: %p", atom); - if (lte == NULL) - return; - - if (lte->settings) { - storage_close(lte->imsi, SETTINGS_STORE, lte->settings, TRUE); - lte->settings = NULL; - } + l_settings_free(lte->settings); if (lte->driver && lte->driver->remove) lte->driver->remove(lte); - g_free(lte->imsi); - lte->imsi = NULL; - g_free(lte); } -OFONO_DEFINE_ATOM_CREATE(lte, OFONO_ATOM_TYPE_LTE) +OFONO_DEFINE_ATOM_CREATE(lte, OFONO_ATOM_TYPE_LTE, { + atom->settings = l_settings_new(); + atom->info.proto = OFONO_GPRS_PROTO_IP; + atom->info.auth_method = OFONO_GPRS_AUTH_METHOD_NONE; +}) static void lte_atom_unregister(struct ofono_atom *atom) { @@ -391,29 +395,25 @@ static void lte_init_default_attach_info_cb(const struct ofono_error *error, void ofono_lte_register(struct ofono_lte *lte) { - struct ofono_modem *modem = __ofono_atom_get_modem(lte->atom); - struct ofono_sim *sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem); - const char *imsi = ofono_sim_get_imsi(sim); + /* No settings, go straight to registering the interface on D-Bus */ + if (lte_load_settings(lte) < 0) + goto finish_register; - if (imsi == NULL) { - ofono_error("No sim atom found. It is required for registering LTE atom."); - return; - } - - lte->imsi = g_strdup(imsi); - - lte_load_settings(lte); if (lte->driver->set_default_attach_info) { lte->driver->set_default_attach_info(lte, <e->info, lte_init_default_attach_info_cb, lte); return; } +finish_register: ofono_lte_finish_register(lte); } void ofono_lte_remove(struct ofono_lte *lte) { + if (!lte) + return; + __ofono_atom_free(lte->atom); } From patchwork Fri Feb 2 22:53:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13543555 Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A01B12C810 for ; Fri, 2 Feb 2024 22:55:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914509; cv=none; b=Iv9AzSUZArhU59YEc9Jz8b0037AsU6QpymxbABSAbKxo5rKmOvCIklsq2KulggzjpkNRherI/SvHSKiOzJjMRerWTGRLoEVcnRzbezweJ7BhIe9i55rIzEbWoOkMcmVF0tdqBY21KQV7fN6ukYitfnF4EbUXoqkvslCIasiOVmA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914509; c=relaxed/simple; bh=Rvf1wt3DL1gF68gWo0UPhRqEBRVsnomfRS7T6APvh24=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gXeDTIocvW3LfUU/RjXJT8Zh26BY8u3ttM/RgRRRaWZzLYNyhDL3YhpJFOm5sUxa0NUTh2TBpxu8f1rode9yciWeMCkWGTH6IsesTio7t94cq9ayayQD+xu62F+rRb5oK0+ANDUo0KZ8fNAGc1GzUVq3ZRJCEYZq6JfYnEz9fjc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KJq7N4Vt; arc=none smtp.client-ip=209.85.210.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KJq7N4Vt" Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-6e118b528aeso1310390a34.1 for ; Fri, 02 Feb 2024 14:55:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706914506; x=1707519306; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1KYQimDqzavqIfuniZATZ7O2xCetUFdJmq2iH0KiZLg=; b=KJq7N4Vt9DmA76dXer9yei8ceY7Ze1kvhHym82pYE9NRSinY+EEWi8B2aTd8YqNd3N IUEfbgPjjb2RC3e3MqA5tlPpCOdcHhKKQAxBPUPah2LZoqlYBRIPGKSlz/x/yiMvZLXe S+VnGWPLruqds5CCWRo9A6ViY2Q5WloslSPPuIuzn6+qGV0J/v0ypKvBtGC8+sVOCDg2 K1w1KK0vdwXcDezpPZHWRdrdulh3Yl6+NkArfuvowymFvBp13dfD3knEn61H93owNwM7 EHBwsh4zHZ7/7cwjUNKtdHixN+cbj/KCU4lxS9+3xEgKZXEOda/7vMM/H6s7/FpaBHtc hAfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706914506; x=1707519306; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1KYQimDqzavqIfuniZATZ7O2xCetUFdJmq2iH0KiZLg=; b=ibl4PLVZZfIS/1ZAnpNZW+hA7Trbw9XfX166D/y4R1fNiM9yQMwHnB7/tPwl0v2feC atlE8agYs33zaxZM2g2HKFi1j8gBUxg/Tg9wuWfk10+HykOIDR0bxCRNIZOIpV8m88fI KOaTCrWDzfWM04MzIjAhXujDbEJwFz2NFTlDJwig7AG7GwlN+6ISGR1ileYifrKiXa60 GaSgfxhpPCeYilmGAoa3o27WeswWmbgD44PTtKYzPv5u2oTGPvLBfu+sCI2DdDhVCgN0 bZSmpFUlN7cEcAYQKqks7AVK/XEbV5YnOh2kbJ5JXPt2z15s5nQ1DYL2kveVvaSKiJnr 54/A== X-Gm-Message-State: AOJu0YzxE5gYR3QB22/PZk3cIqTMbJu6+DJnBb/kjsfSskIZTq5/7Y0i zVjS5r1ITq8ssl4dc9EkvKLgXVapZvBDYGFbChCh5LbECVq3FI1MIf7tBLRX X-Google-Smtp-Source: AGHT+IFaHa7FMbc4h+KluSkxLV6S5PRR4+mSL9xk56ei3uTpDLPaVZg+tdkNvUpLc7qr737/8L9Ctw== X-Received: by 2002:a05:6830:157:b0:6e1:7b4:833c with SMTP id j23-20020a056830015700b006e107b4833cmr7995738otp.15.1706914506064; Fri, 02 Feb 2024 14:55:06 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j20-20020a9d7d94000000b006e1424847d2sm563485otn.12.2024.02.02.14.55.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 14:55:05 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 16/18] lte: Add provisioning support Date: Fri, 2 Feb 2024 16:53:48 -0600 Message-ID: <20240202225405.993792-16-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202225405.993792-1-denkenz@gmail.com> References: <20240202225405.993792-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If settings do not exist on disk, try to obtain them from the provisioning database. This requires for lte atom to wait until the EFspn has been read from the SIM. This is accomplished by creating a sim spn watch and providing a callback. When the callback is invoked, try to provision settings with the MCC/MNC/SPN. If provisioning succeeds, set the settings into the currently active default_attach_info. In all cases, forward the settings to the driver and register the interface with D-Bus. --- src/lte.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 82 insertions(+), 4 deletions(-) diff --git a/src/lte.c b/src/lte.c index 158c8e9c2b17..706d596b59b2 100644 --- a/src/lte.c +++ b/src/lte.c @@ -36,6 +36,7 @@ #include "ofono.h" +#include "provisiondb.h" #include "common.h" #include "storage.h" @@ -55,8 +56,54 @@ struct ofono_lte { DBusMessage *pending; struct ofono_lte_default_attach_info pending_info; struct ofono_lte_default_attach_info info; + unsigned int spn_watch; }; +static bool provision_default_attach_info(struct ofono_lte *lte, + const char *mcc, const char *mnc, + const char *spn) +{ + struct provision_db_entry *settings; + _auto_(l_free) const struct provision_db_entry *ap = NULL; + size_t count; + size_t i; + + DBG("Provisioning default bearer info with mcc:'%s', mnc:'%s', spn:'%s'", + mcc, mnc, spn); + + if (!__ofono_provision_get_settings(mcc, mnc, spn, &settings, &count)) + return false; + + DBG("Obtained %zu candidates", count); + + for (i = 0; i < count; i++) { + if (settings[i].type & OFONO_GPRS_CONTEXT_TYPE_IA) { + ap = &settings[i]; + break; + } + } + + if (!is_valid_apn(ap->apn)) + return false; + + if (ap->username && strlen(ap->username) > + OFONO_GPRS_MAX_USERNAME_LENGTH) + return false; + + if (ap->password && strlen(ap->password) > + OFONO_GPRS_MAX_PASSWORD_LENGTH) + return false; + + l_strlcpy(lte->info.apn, ap->apn, sizeof(lte->info.apn)); + l_strlcpy(lte->info.username, ap->username, sizeof(lte->info.username)); + l_strlcpy(lte->info.password, ap->password, sizeof(lte->info.password)); + lte->info.proto = ap->proto; + lte->info.auth_method = ap->auth_method; + + DBG("Provisioned successfully"); + return true; +} + static int lte_load_settings(struct ofono_lte *lte) { struct ofono_modem *modem = __ofono_atom_get_modem(lte->atom); @@ -360,6 +407,11 @@ static void lte_atom_unregister(struct ofono_atom *atom) DBusConnection *conn = ofono_dbus_get_connection(); struct ofono_modem *modem = __ofono_atom_get_modem(atom); const char *path = __ofono_atom_get_path(atom); + struct ofono_lte *lte = __ofono_atom_get_data(atom); + struct ofono_sim *sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem); + + if (lte->spn_watch) + ofono_sim_remove_spn_watch(sim, <e->spn_watch); ofono_modem_remove_interface(modem, OFONO_LTE_INTERFACE); g_dbus_unregister_interface(conn, path, OFONO_LTE_INTERFACE); @@ -393,11 +445,38 @@ static void lte_init_default_attach_info_cb(const struct ofono_error *error, ofono_lte_finish_register(lte); } +static void spn_read_cb(const char *spn, const char *dc, void *data) +{ + struct ofono_lte *lte = data; + struct ofono_modem *modem = __ofono_atom_get_modem(lte->atom); + struct ofono_sim *sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem); + + ofono_sim_remove_spn_watch(sim, <e->spn_watch); + + provision_default_attach_info(lte, ofono_sim_get_mcc(sim), + ofono_sim_get_mnc(sim), spn); + + if (lte->driver->set_default_attach_info) { + lte->driver->set_default_attach_info(lte, <e->info, + lte_init_default_attach_info_cb, lte); + return; + } + + ofono_lte_finish_register(lte); +} + void ofono_lte_register(struct ofono_lte *lte) { - /* No settings, go straight to registering the interface on D-Bus */ - if (lte_load_settings(lte) < 0) - goto finish_register; + /* Wait for SPN to be read in order to try provisioning */ + if (lte_load_settings(lte) < 0) { + struct ofono_modem *modem = __ofono_atom_get_modem(lte->atom); + struct ofono_sim *sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, + modem); + + ofono_sim_add_spn_watch(sim, <e->spn_watch, + spn_read_cb, lte, NULL); + return; + } if (lte->driver->set_default_attach_info) { lte->driver->set_default_attach_info(lte, <e->info, @@ -405,7 +484,6 @@ void ofono_lte_register(struct ofono_lte *lte) return; } -finish_register: ofono_lte_finish_register(lte); } From patchwork Fri Feb 2 22:53:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13543554 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F0FB4126F2E for ; Fri, 2 Feb 2024 22:55:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914509; cv=none; b=gw4FCmokPmAgvw/gKI5bGDEE7QwXV0mLc7OeznyAR4M17N9JNwt6cEh1AHDWxip4CUbdNleEYTF8awho402lghGi1Gjv1MLUdrBPU+1/AhG8PJCoxRAZq6Y7ji1mEZYx8vKg750/5gM6OGycoWGURaZp0kBWY6EmtK3RzkH+RNU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914509; c=relaxed/simple; bh=aFANccxePynoAJB7yKTQzGpbqxQl0W1cspHAtif3CN4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pwkngUx7IOClen/ZGuHRJMbqeo7JgqbHTghFuJKWuoJ6hoPfuOcvojx8QUHG/R3ewhC1BhHhe8DnKQgfMGU0MvtHLxNdba0sQ5SPsi/3X9csas+QJzGfqSCJt1bBzczEOUPdN2xc0gcQfpqVKaPo1Dxsi1ODED7D84OWCuTJiHU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SdXugbu+; arc=none smtp.client-ip=209.85.210.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SdXugbu+" Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-6e125818649so1426202a34.1 for ; Fri, 02 Feb 2024 14:55:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706914507; x=1707519307; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=leoBmhEqct4rNkQA+tsmAqJiN6/EiQ2Jc++bg5qXugk=; b=SdXugbu+FWvToTD9xMCZy9LJ9Ho68PxAK5g6qKhAevpL9rVbjKm+1zSh2nwVxpXlNo Qi4R8CKvs3Hc+5Oz3ob84bgKGm0EOPF/zbKnv7+mg3yVo2WGJuKAmb3TkC23tWhkm/7z +h8hIctqN0lfNgzJjJnhq/nzJq1wLxugUoOihSCsY7FBWk0663IuYzgN1whHzlipAhqO LEAiYECYcbjfglIPhDJYqPWCthtvq2VSDGI3FD2penxL7PeC9rYf3FXB4R1aytn0NyFM LXQ7GlboYrw5HOC8fRt52x77XjB35u5T91lI0Nxe8k7k6cP7A7QXXTdHFfseUxK8C3p+ MrKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706914507; x=1707519307; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=leoBmhEqct4rNkQA+tsmAqJiN6/EiQ2Jc++bg5qXugk=; b=icx3uA2sQND14wS19lNV8HWvZHFCNST5rYcG/9tkQwkUdwDQA5y0JEj83i5/hx8m7v oXXyw7PvyOaOoOIbFTNImeJ8TSfGFbL2D4GoJ4leKTZMVvMUCsIumRSY7gd91LbcL0WJ h0mvy6Cn047w5HCEhGY8mT03tCmJA6E2LOQfbuek3L6J+ZR3K8Zzrk9a8eZ+gobOfYqA Zjq/edNNIADpQPxsGiQN0y5ueD8J1sELI2+xEkzg99VzUJJObhPbH2n04susHHeiwi0f 5PVzSbO2xl9H9tUdnW7t68Mdqcb6x6IuiVFuHU2I921+iLGuAZ8xjRWVcQ4laYEZt2w0 psGw== X-Gm-Message-State: AOJu0YyBd1/KGGySyGxapI5/xHAAD/wyYVdvaPmMNyD5xCrsFnxRb6uD +QR7xcK1EPE0jhrahYiVGU49tsQOuZd7NBZhsVSCC0mkSS7HPP6dMbjbeC5t X-Google-Smtp-Source: AGHT+IG92Q/3GzzOfsXiAyltyFYVUYZA2cz9+AEbPBCN2lvTnzXDzEEW1xb8b+EtF0amcPQYUnjkRg== X-Received: by 2002:a05:6830:1410:b0:6e0:fd9d:69e9 with SMTP id v16-20020a056830141000b006e0fd9d69e9mr3733707otp.1.1706914506803; Fri, 02 Feb 2024 14:55:06 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j20-20020a9d7d94000000b006e1424847d2sm563485otn.12.2024.02.02.14.55.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 14:55:06 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 17/18] phonesim: Add lte atom Date: Fri, 2 Feb 2024 16:53:49 -0600 Message-ID: <20240202225405.993792-17-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202225405.993792-1-denkenz@gmail.com> References: <20240202225405.993792-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- plugins/phonesim.c | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/phonesim.c b/plugins/phonesim.c index 67cdc605189b..a4fdddc68489 100644 --- a/plugins/phonesim.c +++ b/plugins/phonesim.c @@ -864,6 +864,7 @@ static void phonesim_post_sim(struct ofono_modem *modem) ofono_radio_settings_create(modem, 0, "phonesim", data->chat); ofono_sim_auth_create(modem); + ofono_lte_create(modem, 0, "atmodem", data->chat); } static void phonesim_post_online(struct ofono_modem *modem) From patchwork Fri Feb 2 22:53:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13543556 Received: from mail-ot1-f46.google.com (mail-ot1-f46.google.com [209.85.210.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7118612C7E0 for ; Fri, 2 Feb 2024 22:55:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914509; cv=none; b=IpUsCl0mfmB/p1scC3Rife/YHs5WJYNZod4CAlIKHYi77wOg4ULDCB/tYIYebOoWoe3FGPhAr9mUWw6101vnfSUx3ym7Qa5rTA902qyPe0HAvD27Dwn6GVKQTYRwjosGdX2mc8O6JNrYbjVUIgsrlv/1jpZuM4IbqvPNcPQDeWQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706914509; c=relaxed/simple; bh=IzXzFFgS3b8+0T+p2h8GAZfKn95E9budQkbShILeJmU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A/90AOWvoS1WmZyuSh9wpQCIow61FGUVjEx0gykfKzDwYq7pexa8Nd0N77dDfdJnlbhvOjWXd9/lUailup7KDjaYWAQ7yGBNm3lVZiNK+oSnM3bYjI+1gqkXV+uCSfjeefUzswQ7D5ALYtv2gFfwZjaoHDSn/X4LAWo+ajmLcR4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UDCtY5If; arc=none smtp.client-ip=209.85.210.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UDCtY5If" Received: by mail-ot1-f46.google.com with SMTP id 46e09a7af769-6e11cda9f6fso1469204a34.2 for ; Fri, 02 Feb 2024 14:55:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706914507; x=1707519307; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=tZBBICPga2eVDUp3Vr4DNhiKRGhVCNAias4ZQWusImY=; b=UDCtY5IfWe4pfXQE1eJfqTL/NuPspxPy/wbOhyIAbQlAM8w6nUthGS2NHVhoYkYcxT pGuNa4VJb7xgrKRiuYLr22w7jb7TU5TaSZ14AtPPgAstheoAu1VbjDpPpgvRwQFf5n9H UNbd88b4hJkPa5q7mCtOWLWTSZxlA9PDx/++3xyb43xiTYO8KI42NUz7poOzC67CP7gd 1YPDiRuOiWoaiZjEh5/+M4KxGWMtP5MftkepQJZdZ0FID+b6GRvEUoHtipV6nVvRrP5v QqC3W5hDaJdgfe/OOAZ0B7zVUS12RKN3+l/jlpeeP0hASbLLJ6zOQn/EA8HKh8IEcqia elSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706914507; x=1707519307; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tZBBICPga2eVDUp3Vr4DNhiKRGhVCNAias4ZQWusImY=; b=Ya4/wk7JQE60LywJQ6+fW+1OZ9x5pFoVr21IHjvp9v1rS6RAMjY8QJL99m6povUHhG Hk8+b8HP97XvrgmrZ+ipVJn10a89IH2rXSQwyBcu3y9cTXL+yKMVe1+SLt6TQAVE0wRQ Ckk3i9cnF4wLcJ6g1zYSbG6CLsCmrHRG7QRuGjbqBtiCPGw7YSe74xIH+vpa2yT6eVfl Gj+wyoa0U2yiIruBFTHNJhwdzfCUOxAuzgppLWZnU9BSRNRwnGGGeFO3Emf4LlPC4Pv4 P4Gg7GG3FTYPnfbr6cPy9Q1GDl2LYlHAqT/oXbzO7YfEuqwJvPE0zQvD1DNIgx48jSQ0 KK5Q== X-Gm-Message-State: AOJu0YyGejqKZMTEKzxBSUfZbtmstrEsHMHJ6vouvWIoqMP1fz4eRWFQ RXSN4g0lycahjD5k6/Cqml5PFKIDjS5TJYWObCkrbtOCguREQ2tbTq9Qf2kJ X-Google-Smtp-Source: AGHT+IEL34JL8MaGPZz5ruWV4MOPLfuLbrWCuDt7E0OBhJTRMbBfWb+mhWYJ+mgnDyjRpy25i4UO8Q== X-Received: by 2002:a05:6830:11c9:b0:6e1:eb2:af15 with SMTP id v9-20020a05683011c900b006e10eb2af15mr3628910otq.4.1706914507502; Fri, 02 Feb 2024 14:55:07 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id j20-20020a9d7d94000000b006e1424847d2sm563485otn.12.2024.02.02.14.55.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 14:55:07 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH v2 18/18] lte: Write provisioned info to disk Date: Fri, 2 Feb 2024 16:53:50 -0600 Message-ID: <20240202225405.993792-18-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202225405.993792-1-denkenz@gmail.com> References: <20240202225405.993792-1-denkenz@gmail.com> Precedence: bulk X-Mailing-List: ofono@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If provisioning succeeded, then save the information to disk. Next time the modem is powered, the saved information will be used instead of being obtained via provisioning. --- src/lte.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/lte.c b/src/lte.c index 706d596b59b2..05491c3a1391 100644 --- a/src/lte.c +++ b/src/lte.c @@ -450,11 +450,37 @@ static void spn_read_cb(const char *spn, const char *dc, void *data) struct ofono_lte *lte = data; struct ofono_modem *modem = __ofono_atom_get_modem(lte->atom); struct ofono_sim *sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem); + bool r; ofono_sim_remove_spn_watch(sim, <e->spn_watch); - provision_default_attach_info(lte, ofono_sim_get_mcc(sim), - ofono_sim_get_mnc(sim), spn); + r = provision_default_attach_info(lte, ofono_sim_get_mcc(sim), + ofono_sim_get_mnc(sim), spn); + if (r) { + const char *str; + + if (lte->info.apn[0]) + l_settings_set_string(lte->settings, SETTINGS_GROUP, + LTE_APN, lte->info.apn); + + if (lte->info.username[0]) + l_settings_set_string(lte->settings, SETTINGS_GROUP, + LTE_USERNAME, lte->info.username); + + if (lte->info.password[0]) + l_settings_set_string(lte->settings, SETTINGS_GROUP, + LTE_PASSWORD, lte->info.password); + + str = gprs_proto_to_string(lte->info.proto); + l_settings_set_string(lte->settings, SETTINGS_GROUP, + LTE_PROTO, str); + + str = gprs_auth_method_to_string(lte->info.auth_method); + l_settings_set_string(lte->settings, SETTINGS_GROUP, + LTE_AUTH_METHOD, str); + + lte_save_settings(lte); + } if (lte->driver->set_default_attach_info) { lte->driver->set_default_attach_info(lte, <e->info,