From patchwork Tue Jan 30 21:21:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13538077 Received: from mail-oa1-f48.google.com (mail-oa1-f48.google.com [209.85.160.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 4D2D871B48 for ; Tue, 30 Jan 2024 21:22:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649747; cv=none; b=jTME+Tw46xmvtb8T/c/dyfVRIFOtw975iyo7PEBCOQDTo/zS8Ze2WNbjhlo//ZKIg9H8SaBOPfceOQXcad7fhE0NxkVYQqxa7jj0Fvm4C3v91dgQ4BiU68dtjbSDYZrooRbchzeDUnKX9xKrKpLUruwbdS/qe2MwwWpnNnT3Ikc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649747; c=relaxed/simple; bh=b2/Q+G77z9qtdxIyClU4hIsTCIq5g9yuq0eg3wyEvrU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=goXzJhllyI8GvJimW1pTeuDHocSiBIIlmAPU1RWbOwntsYkXdfqrUZacevqptkcitBlba8iuYWmDpKuVEZs3obP+TI1hNrdxFwkesXg6CEyeM0xgg6fLdGE92t/iP35lBp/dFW9bOndYELYWXw0r0DJPPBiGMzrBqVLjR7e3ANg= 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=aEexMeQ2; arc=none smtp.client-ip=209.85.160.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="aEexMeQ2" Received: by mail-oa1-f48.google.com with SMTP id 586e51a60fabf-218642337c9so2278439fac.3 for ; Tue, 30 Jan 2024 13:22:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706649745; x=1707254545; 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=aEexMeQ2fVY8zC1xXpYhHfRhQIz9Trgdlti7YNPDKd+DFae80LX09ZZYWVTWYqtlPa ZKKTME3dnp8ls7XCccHendJ2ukBCUB9ZHE+l5dhwi7Wwfa1uL594dlt04WL6phtrfs16 pWUIXjIcDN5HFaMhsx+/Zu4w7VHUz0u0DqnGX8w5TsUxSxBVocjp9zbDovwSw2wjzPiV 50bogzk9slZepvp5GYjL3w4abaHvbdlMsUISccIHIn03Qb1qwOPIMfPv993QNdbCOgtB BNJL606vDHSRaNTvnGpE8+WZROr0LJEoNcEWWY6KcGZlyeqKLuvFE8JsbzEQ8DXtLyhV QYNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706649745; x=1707254545; 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=AS6JLr6qVYFLf+7oOqUswdACzKsnAYqPBkCIG3gtgmJtTuul7I7L2U48Dx37Ok23ro 7l2IhA+Uzq+62wpDGK5UApgJcE2VyCa78y+9hDtPwm5poYVe6oylGPN5IDwsynKsWVMV 38AdIj5NLumxqSOBln7Evi3ceFjasAgZ966aEZqeGxfwzIhVIr6Q1TYnxv1E2j3XwFl1 KqhUbvrlxYsGNd/sr6stkMcJ+PkHHn+fwAEvUsb1ijbvOE18M49kpEzpR4vGwo/t+Loz yda4FCRONlUcLVJHAsKrdFI7uTtrj/ZBA8EvgxA5bE5DF7w8hhG2tEbZ90xoAn2dcdwW 8bmQ== X-Gm-Message-State: AOJu0YyeDXDysqPWhbgn1dyTtLPRqx9BFcozuu8alLfJRwR+NGi9Y/65 wa/XV7zpDRepY1WT7rG3sM0wDJDcUEHy9HHlKvTlJqrqeRiH/n5/cAM5tDP3 X-Google-Smtp-Source: AGHT+IGMQ42y6SXkXomvfxwGKURuN9PrcP2hhbMiGOCXuYR1taTqsrgeWuhP2vt/Qn88B5ZC/uxbIA== X-Received: by 2002:a05:6870:2c8c:b0:206:4d0e:c190 with SMTP id oh12-20020a0568702c8c00b002064d0ec190mr12605552oab.52.1706649745262; Tue, 30 Jan 2024 13:22:25 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id n1-20020a056870a44100b002185412083bsm2105786oal.0.2024.01.30.13.22.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:22:24 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 01/17] umlrunner: Also mount /var/lib as tmpfs Date: Tue, 30 Jan 2024 15:21:06 -0600 Message-ID: <20240130212137.814082-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 Tue Jan 30 21:21:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13538078 Received: from mail-oa1-f54.google.com (mail-oa1-f54.google.com [209.85.160.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 19C58762CE for ; Tue, 30 Jan 2024 21:22:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649748; cv=none; b=Km+cEeKozRKkmflfQR+XWjQTPijwVbE+NOXb4nHsxYzOPryj5Vs1lK+dkb14AUqORkPf7Wrm6KzKndgBKqfGd2Snfb3/rnWEd/CA3SlINSTX2rGyzPbLpnJ3LbdCmyejhn/xzKiZIb1yIX4ORCTJt7qtr8xrm3Kn/MIcdGyPscc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649748; c=relaxed/simple; bh=qNc3Wp33P3lSTcU0kj7FRg41RP3A3W0tLQ/un102U/8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J/eBZWeLwEppr01k7p5SG4pnHuPCAC4cNDmJaCFNUTVV33ghESkGdZAeKHF6ivDrfyjt8cGXr8fQCr3IQBtMvvJlfxtLTVcP8mXLZ4S0V5z91tjBUD60DzE86JBClXe/i8b6qCypkPzyqs4SNujyjSacPHXSXw4YsquaidHkTd8= 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=FdtBdkC6; arc=none smtp.client-ip=209.85.160.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="FdtBdkC6" Received: by mail-oa1-f54.google.com with SMTP id 586e51a60fabf-214ca209184so1995958fac.1 for ; Tue, 30 Jan 2024 13:22:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706649746; x=1707254546; 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=FdtBdkC6++tQcN+PQBf0MzZgGkIMkj4Dv7Oh3bcHChLEwynrWMSDiG4ByxPSa4PCFG XJ82CwCFJs581f+pS94iiqfs1tbk5RDbdISerm3yVK4t/upOUpcxzLHvONamIMa+n0HD 7q9BU7gWgJn2kUT/vCrW1co+4dEaAeJNoWQIvLdK+uRapXeqBT4XMm5F4qRCtHFdeO7X 0TpKFmxHmlAJ0eKUbLX1tlg+8vXufxzxAxLSGjB0xsldurspmXhYd91ecoamGa9YdjG4 8LnqblN8mhH7hj4fnHhqbTQhlaQsbzj7nZQahRXe4GsC+W3ajY8o20k588yEbApb9Smb gsGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706649746; x=1707254546; 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=sFu8JuUEONzpVC2Hunk8ClyerHkzzT12kzv7sOa6wGnHUvir40p63HF5o+s94XdSJT Gj0dLkZ1tqmOrsMqRspMEkWJrQf8gaZ6stVm8h+nii+6TgR4RaUEUis9B3ev3exQqMmp 3rkFZgIpB6y+7PgOnKp4IhLhBVVp+gQLBy8ZE7Vw6aOqve7amwTTHBUCdNrhQC4GCrzm bpwo80rTmIom/MHLRCrVGnkXrMesRHuW/xNIEIydxAFULO+hgtWzfnsY3yT+L5HUFIcN pZDa6bLok0lhV2K6ieBkkOvZTM7FsirbJ6VEpPtYJtutvD+fuD6JUNyLu2TQ+pIMsvvT kPkw== X-Gm-Message-State: AOJu0YxsIL59uqp5tyOR5ZRNrubmBuqK2FOoPUkSez8NMNZAabp+T3Gl oeszFuB84J9lctZ1bAvGFHjre+zn+Kpay1Y8omzWjYzQEzj5HtVezakYdwJb X-Google-Smtp-Source: AGHT+IGyRT46+CNoqtunqNjByujf+tQh4cOcuOh71Au64u10ssmUj3GWFFiQ4WC9lc490OWHRxtybA== X-Received: by 2002:a05:6870:51e:b0:210:9bd3:ad86 with SMTP id j30-20020a056870051e00b002109bd3ad86mr11368941oao.41.1706649745808; Tue, 30 Jan 2024 13:22:25 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id n1-20020a056870a44100b002185412083bsm2105786oal.0.2024.01.30.13.22.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:22:25 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 02/17] build: Only enable backtrace(3) in maintainer mode Date: Tue, 30 Jan 2024 15:21:07 -0600 Message-ID: <20240130212137.814082-2-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130212137.814082-1-denkenz@gmail.com> References: <20240130212137.814082-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 Tue Jan 30 21:21:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13538080 Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (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 D83CE762E1 for ; Tue, 30 Jan 2024 21:22:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649749; cv=none; b=kHnao4Thkw65+QlD5SNHadY1UmDgLyty34otHyPmrUlqCg1t93alCVOmFF4H1P8I9V6Hn/l4DXFvMGxbUw5pJXz7jEgkT4c+rFYydOGxjmHPxYwKXuvEM1zB5Fi8z/nUeHWD8a/1WuL2P9MRR6sqKuLvdz0eKTqGzpy01j9SBZA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649749; c=relaxed/simple; bh=7mCWKmsWvh/ZoiGpWL5uPaBYS2+/oCLqsMZR+ujRYuA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WswYvUqyu17QhsbObbusjUi7YQjw2DaIpv0Isu7l/EMtB6o5XddvxY3QPrn3DdBZT/TvpxvmaGWyPg42WexGZL3AaOAdCbgrnQuQwBbCsqe8Z3bBNuaqQPGe0IjSUMdly287lTIooaGQ/a123CovyfIY2qmc++zhPqVjYUEsv2w= 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=EwD7zTXA; arc=none smtp.client-ip=209.85.167.172 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="EwD7zTXA" Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-3beb504c985so62579b6e.0 for ; Tue, 30 Jan 2024 13:22:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706649746; x=1707254546; 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=B7IP0miPNvtr+ajfcDCLcomjndNqqOknwYRYE7egskI=; b=EwD7zTXAw7/1aOE4o0iQbDvNn8abJrtLm//RxofJCGhvVlfFt16xjSqiH/oAY8bqVp gFuoKO+RqfL/YAawJQ6MEKATv8JCnEeVdhwAwRHelCU0Y95Ey/gQPOjF4xYppC9sRMKJ 1zuHewsEauj7oXlEs6XZNWmwztOPuIXE1nQ7azxWV0V2LYn/fQB7iHUoRAKyOmHMlmA8 i1bjNcuzewzBgIicE7DT5GOqBByhhsQDCk0AmvEhDd598Sn2ko6Mj9yXG9LYEA2uIjrx JOLBSEmKCFRiWeUM1ldEF1S1SR+SKM2Xx8HqIcTU/JEParq8xGFih/AiS0IGzcAdrrYM t9Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706649746; x=1707254546; 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=B7IP0miPNvtr+ajfcDCLcomjndNqqOknwYRYE7egskI=; b=ZmhW5kx20ztrPEVA7ttj4th2+FqyDvZIKk6NWL9UGAFkBxoyizJSfeXfAX/n3ZkBNT 8/ZDHdVpZ7CMktbHysk4fGe9pFAhi/GaqCXdaL4yXJq/GKQ+1oukmDeP4SRkT+XbXmdx 5heCeX8oKhPvj0i6NnAlKTQouoMfcfEGxMp8fHFkMZhAXFn4DAdt5yCOHbrV9IxYkam+ zW+g48Oii/GoOAviN8AAApoBB1M3LM3+oSetLsWgHIdGwqEElqKpjhX0O6tAZgV/ibf2 m3kycr4VjWnCjq4gBgIDKclhZiK2hI8Lsbtf69rnJ8cXBARY+fvVv/OPLhItceGq8hnB ruwg== X-Gm-Message-State: AOJu0YxKJEWmECSWXCeImg7JrRmDHidFEU8+AY1N3htleq003q3jhzg/ lRI9CKTJ8VCEVjOZuh8kbxgTYU/X1hnwb5C7vO/OBwYeCH68GtcEk/OlTGK6 X-Google-Smtp-Source: AGHT+IHcyiSxXlpZ6XBiyLvZtim8sasUUE2O7Cr5IEHkfQZd1yYVlTWUc2Vy5eNVnN7L6OCHtTsE7A== X-Received: by 2002:a05:6871:e78a:b0:218:6f54:966f with SMTP id qb10-20020a056871e78a00b002186f54966fmr581835oac.9.1706649746496; Tue, 30 Jan 2024 13:22:26 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id n1-20020a056870a44100b002185412083bsm2105786oal.0.2024.01.30.13.22.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:22:26 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 03/17] build: Bring in more ell classes Date: Tue, 30 Jan 2024 15:21:08 -0600 Message-ID: <20240130212137.814082-3-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130212137.814082-1-denkenz@gmail.com> References: <20240130212137.814082-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 79645e767b05..5221b1cca138 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 Tue Jan 30 21:21:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13538079 Received: from mail-oa1-f53.google.com (mail-oa1-f53.google.com [209.85.160.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 0B50571B48 for ; Tue, 30 Jan 2024 21:22:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649749; cv=none; b=mjhBLLIPcxrYKwDU23FtZ5wgzILJ2bQlDPstYnlS0NjueXb4+NZ1E03EWKkz3DhrOoxNGfzxtDI8VUGqWProkuogMLTLmg3NIBOZkSAB5JwKW3H25PAKKpdB69tqmwCfkeaTRH/7F6PaP4h8DA1VZSXk3I0gEk4Mv0uz/XMf//g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649749; c=relaxed/simple; bh=hyPteJ2jqQQhUP5+JZGTuesBhi4L5h/BiDZrMdVQw7A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V8z8Ca6iOKRm3I1qTRyCsinL16egojaxe7O+pY3dvHcUF7w0BmFCYJgWABeia8pgg7ZEqAtAXEie0eYOdhmIOIRJxHKUMrKuA7LU0ZgSo6FPB35wIr5yv9P3l3v/vp3BQSHyUwoIyc6aP9Y4aw1IArZi3XGy4LpMqk1gF3+QhJQ= 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=JiWV9q0+; arc=none smtp.client-ip=209.85.160.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="JiWV9q0+" Received: by mail-oa1-f53.google.com with SMTP id 586e51a60fabf-214d1139620so1286044fac.3 for ; Tue, 30 Jan 2024 13:22:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706649747; x=1707254547; 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=JiWV9q0+SBU7sYGlKYo51Uxrc7ugWy9RcJoMtf7WJm94oidfsOJc2hsmcG4rQ1aN2D gjm333+hH8GI95/0Z0OBh1geRnpbEQvClNJmjdkKV0Gv33Y3XMuxoth7SHYlxDXYGRwC nl33J+McoW1KoTjHHJMQPDgFOdAOYLpbDi4UbsN1QLAbq8pn4aLIIzJmKaStcgRtMVUD dORVF2LGOfOJdQ2pwUlAz5bmfBAwhkfP5/zd6hyCwsYZKJU7q5nnTWHyGSvBQ1YQk/dI UEuSIDkG4UYG9CrSLAZOtboqpPVtnKp0E8cP/JmFIEPKkJTi+Wi84eVsJOuUX1YSXOiY 3Ysg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706649747; x=1707254547; 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=PJ2wr86ko4clpbVRa9+LdXgpxVcAVu5LHhKIzGx48pigDK6d6B9INy6WnPZyognZuB LHY+Dc2vEkDTpks/ou65kz5UJ+NF6hEYZbVoRMhfBffTsTt+UiyXdDzTg7SwSVwI6xJm mXD1WrsyoLnejvjTvshOKO/9EVy9I7r3qlAFLgjOSb62ElXmJ+dDte1NfumzLiZxQjc2 4Q+84PezI9A4J5qkzzs0Y88MnSipz+N9uiUawEd6gIykrtJB1wq7KV+2mpYmuHUzxyh4 xZ8+czrXJkrYTCoi8T4+of+lbuDFtd81M7AKpIoNKLQAEWjBBXSiHN6G05qmEexPrITY JJKA== X-Gm-Message-State: AOJu0Yyh0ZZnB+KjRwTnuV+KvX1Wh+eHagTHGmIqPNF2JD4wKBZ9WctL kGh6codoP0NBAx7J12VdPI30+3iM+/Bzg5WvF4Z71K1U+mspGL7xjttcS0tG X-Google-Smtp-Source: AGHT+IFncILvXeARyNTNVEV2ThSUA179G4pEMezH/lMMiKWaMNHLSLt6hLp5ZKd7l1j3TGqvh+JJQg== X-Received: by 2002:a05:6870:65a2:b0:210:ad69:e985 with SMTP id fp34-20020a05687065a200b00210ad69e985mr6735628oab.51.1706649747090; Tue, 30 Jan 2024 13:22:27 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id n1-20020a056870a44100b002185412083bsm2105786oal.0.2024.01.30.13.22.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:22:26 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 04/17] provisiondb: Remove some duplicate MCCMNC entries Date: Tue, 30 Jan 2024 15:21:09 -0600 Message-ID: <20240130212137.814082-4-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130212137.814082-1-denkenz@gmail.com> References: <20240130212137.814082-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 Tue Jan 30 21:21:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13538081 Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) (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 D2D40762CE for ; Tue, 30 Jan 2024 21:22:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649750; cv=none; b=sFgKv1xSsHIEgEomrMXQl38Brnv4U+I56GNUFB/6Hfmo2UXwlc+F6oIvd7LG8JLJXy+JCN3kPNtogFsvJcL7A9G9iQ29fI+nxQ1Aq1inWOINpK+oESh5Xdn1i0nhNDIHF4Yp6GS5dbZk/mGnX0a7JFcrvbTWjAz5q5CQKIOysCg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649750; c=relaxed/simple; bh=ocOP2ENWgfeKcfkofb/GowR+z0pPyYIU9FELfhLwGkg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NRjPI12I1k2OOSkzxxvKhjJNOX49bY36m1Fi/pBJIBH92AIKJYEk0xhRW9voaDrFcyf+9304oy89yhIBSDCpcG4aGBKMoYDMu4f6EEiBxZAlPhJtQU69n1qjyzCK07ICwog3glhUZ7MxuLXpnhD1+uxVFvkDijhmTTZ8OeknU90= 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=YBbRiiK1; arc=none smtp.client-ip=209.85.167.177 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="YBbRiiK1" Received: by mail-oi1-f177.google.com with SMTP id 5614622812f47-3bb9d54575cso3287959b6e.2 for ; Tue, 30 Jan 2024 13:22:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706649747; x=1707254547; 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=YBbRiiK11BTSgh9PGLAkIgaD7a1Yo0b0uIMEnhQ74Q9gpGFFufyYfhpB7vzTvqKMXJ 4EIjtv2Q828hqQTdht9cTbTVib8Tzyg5AUAO54j4vBWAo4X4NMKHb92MeHe3YUOiIeoa uCMxyvhRf8shcu5FEJo5VwVawL9PZ3sM/I98AFTd4v9gzASKUyudGkIPxQQp+pIsjI9Z tC7ROOAWM5GYvNKMS0DeCe7cVVcoxvycGb50IYKm1KF0Ubw2tad7Rqmk3Dptv6rRpx9T uFm9ZkSAQAOeIAFyB467EIyy8drDv22dALChAHFMohYsYM2dX5Uq7biexQBZVoLIsZwv pKzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706649747; x=1707254547; 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=I32vIoZed00ZDDnNMVeubF17Oz63QnDMN21Dm73QBU3xPyMRFAH1FbNix4rRMn3EgD 7WWEDa0BR5CIArcRasUtcD7wCUstqddFkuATNt8lyL297JqgT1K1Fiz9upFBw5eee8xk Gu3bewvIB6ob1UftM+USkwahdK/U6nPOWksQNjfIvZWJAlCqKlYBg0dDd3HDzWYyVl0o F2Uz3B1YgYOTsfXkQ8mGom5OQvbInaonB3Tgk2zX2Ap/TyF+mDl5j181IMfLH20sP02e 1WsnPXEWqRQN700LVVACKD9z9IzN/4OO/5AnQT74McmlnMiA6TEw7Upz7DbJ8bGqocAc dZLA== X-Gm-Message-State: AOJu0Yw0PVQUZDu0Oej4mV2FnTxO2SO1kqKUDrewyF8hpnnx3trqV04K GhakkYfEWPpOWZV3yF2CACLd1HVXpylcM9p//svzgB0s0L6Ho3BjpHGB3xH1 X-Google-Smtp-Source: AGHT+IHF4L6SCzzoU+BldagY80b0562wNKMrEetKveXbpdP/O1cw8ZBeomLxCFcodc50V5QHS3KFoQ== X-Received: by 2002:a05:6871:4e48:b0:214:4761:d39f with SMTP id uj8-20020a0568714e4800b002144761d39fmr9165486oab.34.1706649747793; Tue, 30 Jan 2024 13:22:27 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id n1-20020a056870a44100b002185412083bsm2105786oal.0.2024.01.30.13.22.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:22:27 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 05/17] storage: Introduce storage_get_file_path() Date: Tue, 30 Jan 2024 15:21:10 -0600 Message-ID: <20240130212137.814082-5-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130212137.814082-1-denkenz@gmail.com> References: <20240130212137.814082-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 Tue Jan 30 21:21:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13538082 Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.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 6C6E3762EE for ; Tue, 30 Jan 2024 21:22:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649750; cv=none; b=LFSbUOgUUp/0tOzel2b4bqxK64wamNzOfX08rNi0afkb0uYY1pcO/QglK9c7FaHTIm1HASWh0NionTWoVtzOei2bX2EmAF8rHSZtZEWC/RjFOHWPX8F0L5KVYg1bxfoQQeAaJ09YaxELtaBh/a7DwRjCIE1BOzqGx5+5uqEh1xY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649750; c=relaxed/simple; bh=40HRVDw1RTKi4soStL55YwXnBGZc0jxZnzuvjOlhIUQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GJQD51t0IGejebjn4nKzAJimS7nCjPJPTRYHjDGKCQjy0jPAk35dYQHr/ebUX7CH5qtQD3Mzcm73j7hoi3f5bk7Bju12y6i3euWAccDAtkIGwhDFakkylDtUj1faqJtAwW0z+U5QYhISf8r1o/Tc+MKTeN6Z6pOQeGgonAa9VR4= 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=Cwi14a6A; arc=none smtp.client-ip=209.85.160.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="Cwi14a6A" Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-204f50f305cso3182740fac.3 for ; Tue, 30 Jan 2024 13:22:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706649748; x=1707254548; 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=Cwi14a6AcyjjxOQm9Z8z3bQRlfCE1Db8rRJvAuKwnR7zFjVROi6mzgtsXcB2nDyC5e XxPV4mAOjJDkbqCI1pA207rxNZOWfl/a7Y6mq167IornLen/lC2pweTGn6FM88mbA9// Fajbnyaqa/+r02cM5g4DOFEXqkJtico6n70zLxj27IhmR8C2gnxskpNFcDvipNN822I5 ze0GFeW4ohlpDC3IOopR6kmFR7Lt83SD5YneC1b60mB6roKe+t+RaYesY+8vAEB950xN cCSchGvdiFp8PqaULOD6JAU66U3l2jxtwLRXHRfsGZxm7fstkw08QlPef9Ykm/8f2AK/ Chqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706649748; x=1707254548; 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=o7o6yjv0JqwP2+Rqpi/UhPrCREDwJjuK6zVdHHu8pyoRyrr84BIMSvGla2v10Xa0eX gq8jDvqYsBSQGZ/UnXK12dT/qcl15Hr21GJVKB8oQlfjypVKqnfO8s+3h0g75TyHTAUw PsjvpQCKv3t/iPEoy1yDuVhjY5IsUkpPKLut/ocKmTbbRkwh5QA3hsH7twBYcxdOvlJx bZ0nMTWUf8wzQ40BdAc47LD9/h26fgGhCnMr919vFko0mVeBplkUeTR7elLxsgUvmnUc Dgg36yKW/IMZ0JGWKp4ZUK+uKlbxkILdBRkRAKhzXT+8OtuKBIrBZznNzMyVxzecE+YJ 1FQg== X-Gm-Message-State: AOJu0YyELKRj6gqbCEGxEnhBO2VMki89oiQob0Qu78LCPv/uW4aE4+Fw f5JeF3klqYF98okfOhcVUyWh/v26MdoYyzXYqCZgi9b/rS2NkMdMBdXQ8sWJ X-Google-Smtp-Source: AGHT+IEinxFgZ8ZiLsTcB4sVf0rCVSdALAS1j/zRj8zgsi2gDhmS0PO4flfpKSj7lxpH4d/emMzsPA== X-Received: by 2002:a05:6871:b191:b0:218:55c9:bb20 with SMTP id an17-20020a056871b19100b0021855c9bb20mr438562oac.21.1706649748321; Tue, 30 Jan 2024 13:22:28 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id n1-20020a056870a44100b002185412083bsm2105786oal.0.2024.01.30.13.22.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:22:28 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 06/17] storage: Convert g_strdup_* use to l_strdup_* Date: Tue, 30 Jan 2024 15:21:11 -0600 Message-ID: <20240130212137.814082-6-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130212137.814082-1-denkenz@gmail.com> References: <20240130212137.814082-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 Tue Jan 30 21:21:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13538083 Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) (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 E73F3762E1 for ; Tue, 30 Jan 2024 21:22:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649751; cv=none; b=Q0pTL19NF9qcyo5+GqPorUdycX+3lwPCEUewfIJRrTuFaQySzpc7eAkx6lqtcd0AF5mmXFi8zWVrMAANTEiuwL0e6x8IYttJV/omPtNQd+pwLGfKXA+uwYiDgncoNoWboTj85ix4P6lIFpvH11yzf4IUAWO/pYChqgaZvedP0Qk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649751; c=relaxed/simple; bh=Ngatuek6+l25zNh0xP6q04ZFRNN40k61978NO7LmAp4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DVLgmLpHqc+z5dztxhvtOe5PzYqlO6HzsR1bMWjnDaTR2cm46XrNf0WMY1aSx9+nUXAqAfcW9PdKIWjfNCtz2++cWXWMdBdXGpkpPymcAIBkVfNDKFe+sAf256edg6WwqBXHt84mwVU53KPSdgWRRvjgmjyj+bqgBEfE70nYb6A= 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=mAuYrjdt; arc=none smtp.client-ip=209.85.167.181 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="mAuYrjdt" Received: by mail-oi1-f181.google.com with SMTP id 5614622812f47-3bb9b28acb4so3158054b6e.2 for ; Tue, 30 Jan 2024 13:22:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706649749; x=1707254549; 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=mAuYrjdtbLZ52SFY63GMAmBJHuvx0tdNPYXlEuuN6zq2/MrhmSl4EOf4b1XYLoPmTP qFQI3KSTy4liZdrB15dQYWCT8t5KhIRmvLaKPJ1T1ci8qIgtBPRHRCNm2XrddLLs6jAE qwSNKxdYUwNmIJL+Fegtq3dcq5rVvpvNtjy0RFaV7n8tC6futxYHNCtkX7Zo+o9qUocB ljWEWI6illpCt0K10BaU0LRO2RJ9VKP4Nh5H1EocWsvyxnoGEL1plryTxMzJot/b8YWv 6Gz3tku/Mlr6hWR5lZSPd8tg3n+OJavb9dUMiIQricEILxlWYS5FKfJcTzgc6K+X6HPU Rq0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706649749; x=1707254549; 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=hAVliCF5Z0MQm4InPLTWee0jhXzVNzk5pd00Zt+1NimT5B3VwJ3nAkBpiIuseOVCgY D2B57CAq5FgOtSGHGLIomcA451ovVurDxUF0Pi8r1QxzIzfbGpihP/p+OKqkhsxvCuAb IM0oBKSBObdEadmcEaIN0z2OeG/A/MIZ6MFT4x/+J4CTkvQQss1mq0IgtDU4MCE4DlkU ZvazdbZLiHwK3owJJ9U+kkZE0MTzFhenVNdMtIzk5hg+jTYrJ4qj4f51LOwJQ8INtDqP kN4kZv7Y2978RPaxMH/TpYiI/CCtYMCiV94W0RTqVZcLinqSrYkhhXMFtQ0ojmuIojdC IK8A== X-Gm-Message-State: AOJu0YxI5d/cmER8YCivcRD89t/0Iyn0Xboe3WlREhJJCJ4gUw9z19Yx pajwi9e5w0lrS1VGRTMjnWmILKSof+3Q/kyQZ0mY+t1INiJ0gxG/EADO7vcS X-Google-Smtp-Source: AGHT+IGeTHYb5JcYqTapxfiF6P9fZ9fRVSycqGXxpHpTMK5c2cugywzK65lo6FkUmYkz79Drud2HEg== X-Received: by 2002:a05:6870:610a:b0:214:294d:7835 with SMTP id s10-20020a056870610a00b00214294d7835mr6635367oae.28.1706649748869; Tue, 30 Jan 2024 13:22:28 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id n1-20020a056870a44100b002185412083bsm2105786oal.0.2024.01.30.13.22.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:22:28 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 07/17] common: Drop GLib use from gprs_auth_proto_to_string Date: Tue, 30 Jan 2024 15:21:12 -0600 Message-ID: <20240130212137.814082-7-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130212137.814082-1-denkenz@gmail.com> References: <20240130212137.814082-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 Tue Jan 30 21:21:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13538084 Received: from mail-oa1-f42.google.com (mail-oa1-f42.google.com [209.85.160.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 89DFF762FC for ; Tue, 30 Jan 2024 21:22:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649752; cv=none; b=KgTLSYHtlCxB8sJCnx9KAbcZP0AU+pGaUQODM5KEoxSgHtSEVmL1mBw8OHowwDr0/ycQ7e1A4nC6Uv+R6wWM2XzdPVkG5AFcSkCNLljdGZXAkLiyhdBO1l3ZD9lwq8FBk4jb82TX0W8sc+ZqOEjpEkgdKcsJvJLr97P9VKwQFto= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649752; c=relaxed/simple; bh=ZMMiTVdeQnHJAS/8QiGXwXAUWm/ilJKLjB6UX/sx1cg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GkeM5xiZQXgx6gsX8v2MnNhhPnQUiUf3SViYvWeHzdQSGSGzUpQSxGW8O93qWs/EtYJzrqAC6Rugb5wJgrjkAvLlWXQx+z3whpJ7H8LzT0AVQvZSbOyt/U4qHAmPuX3kxNsdtVZv+1t7KVJKoGABwKeAEDophyl28EpZf4YYXJ8= 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=Gro0NLmZ; arc=none smtp.client-ip=209.85.160.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="Gro0NLmZ" Received: by mail-oa1-f42.google.com with SMTP id 586e51a60fabf-21433afcc53so2446042fac.3 for ; Tue, 30 Jan 2024 13:22:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706649749; x=1707254549; 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=Gro0NLmZFWk2lHtoMC3v1A1VS2OQXPRzjvsYr5V3QiakAe0Dghcv9OSRwgCfkFPvIj Nm4ZNRJRCOvsWER3Egy+KfWTToN939GvH4/nyeddBwBh6GVolGasj/sxgR5qF0OLy8tP p977aw/EV/dCBnidsuXIjCcH5MBgRCANnbDzrEreYGkqEtI7U73Ve1zWdcIxL4/SI1Ix HlfOSuyeAW8kPkqfnyNos/Ye0M75Kt+R0bFDJL3qICI5Yan2qbqwchVV80WTh+9kHpjZ Dsos4K/yybDrhEbLJx7WKjIepEPnJK49ddmoQHDSiy8OB02lvuTIWkofk3kf0I796b1W Ucqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706649749; x=1707254549; 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=mrw1y6EpTRzSNDhYD2etc0+T0CrZJMJIjNRsHSzZ2JgDxmsvyXKRy2y2OK8F62hkWR EQ5LdznvdBYYgzWzZhy62cvZz4bQwCJxAg1RWZcOjKaF+z+gi2WyTj6lCVk9rNhwXF1i K4P1kswg03mF10/cvwIyys5Y/bcPkvfL3Tg1r5nH3Pje9Asx+8BP7SwJDGXwIE1yCLpJ QhCbpqoHPC1E2kdMsCOVt79Yn5Aba1qV/gb+3/deyWEbYB29qYn2ILwXAsDMcuI3T3Zn qmWqv2IsiXIQZ+FxT1nB7UQFv/XbfOgBeSKfhiE8YIR9Q0250RdBnJgQ7PkCAWVAbUcK okCw== X-Gm-Message-State: AOJu0YxlRBdqmvdGxUXNJ12ZtqPT2ht+HwdRAbAUVoUt/SZhO5A/WiMp EgObuGE1VPRiX3dUNVkiCpORWLSRZWITrSnpr/iGWfGWHc9EeCr3XzwoLHvc X-Google-Smtp-Source: AGHT+IF7zngx9hZxXPU1ZtHsbt1iGMA0bHYvW/+zgCvoL0K4PUUGKmY3nSPPMT3OwI7MSMZct2iBqQ== X-Received: by 2002:a05:6870:d693:b0:218:449a:9c6b with SMTP id z19-20020a056870d69300b00218449a9c6bmr7162282oap.15.1706649749476; Tue, 30 Jan 2024 13:22:29 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id n1-20020a056870a44100b002185412083bsm2105786oal.0.2024.01.30.13.22.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:22:29 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 08/17] common: Drop GLib use from gprs_proto_to_string Date: Tue, 30 Jan 2024 15:21:13 -0600 Message-ID: <20240130212137.814082-8-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130212137.814082-1-denkenz@gmail.com> References: <20240130212137.814082-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 Tue Jan 30 21:21:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13538087 Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.182]) (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 23F7278B53 for ; Tue, 30 Jan 2024 21:22:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649754; cv=none; b=ToBrd/3UNAh9SoC3Ny/bFGA1ltCSktsiwu3Q0gafrnLo5h60KMnzWR0DWLSrFMCszW4uTed3ZHsUHq/S4Tfx6x38hu09/RNWif5EMNNmyo+X265UVxS9ktZyGXsbVVmzqXEe6jck24HLfPX8rPBg6hEwbgEqsTb17OGV3EFcx4E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649754; c=relaxed/simple; bh=4dXw3NOJT0RmekpMipDN8TKAXS2MVeQcyWoZJFtLx6k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DdQuW2yylFGdvVNo7tOZNtf5PerRUM3jksyxS8yD7QonGXDxjRxXX8i6475gp1N8ZJjgGLUgwK/6XmYVCp8jXrOll1CvFIOzDa16XzLsOlmn9mMMGNCPUeVTaD/i9LSemQw2XLLdJ5W4kAYqbwO+bwGPsAbHlFcQz1pHQcOyq4I= 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=Ucp3Em61; arc=none smtp.client-ip=209.85.167.182 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="Ucp3Em61" Received: by mail-oi1-f182.google.com with SMTP id 5614622812f47-3be4c0b0e47so1638358b6e.2 for ; Tue, 30 Jan 2024 13:22:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706649750; x=1707254550; 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=oWYM4X5sXvwfqLz2R8FSWT/EI8XJuj1mOlHl5FkpNMI=; b=Ucp3Em61FQsCh7HncCPDL2bX/GdierkkKOEf/BufPT5G7o+jAwOXC8KOsNX3LPd551 QY2ibZQqvkbn7lkaqDZPD471uFFbM7euy6iepNz9pa55jydUng5vSt0HDyjO/bwiaUEB 7e2WCvDm2GB5H9oYFHN+OKwrMGe996LNXCx70QaJDfmxpZRAf+IdeAv24jT5SHp48WiZ LzWxfdQB1Xe2OAAY072YRDTkeTl8Z7InLsTwl4zvqFyXC2kUIX+HgS9zl2HUYYbF+yaB 7yYZ+9X2wqmSN61J2p/vtlggxMozPN0Y/neE50OzczGmeoog7f6o7yn/G5BIK/klhxnZ Co2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706649750; x=1707254550; 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=oWYM4X5sXvwfqLz2R8FSWT/EI8XJuj1mOlHl5FkpNMI=; b=FALEDEly8Xj83i9RsZtBAA67j943wmirBCfya8FNFkFb31KSO//djTMRr1SuZC9a0W 8rV1KLe6sW4NNqvmdzGbUS6YUDTwqQly+/qV7v2V/JF1cjZ0VFz14lK4YHh8kzVv9LiJ dxyrmHd7Np+QYWY8YEAZPPGOvxPFG97CRnWQqIyD5Tyt57VMJhDOMTxasTJurOE+BmYS TM/bkpqPGs0liXflao5IsCxKCS+tJInpRKRbCzkJCQad0QTkaIZHFe3wCgVcwBuBadNg Ao5W522Bn9f/+JAQ4ahtazBiLAkJFI5vBr5L+8HbQ7YL7JAOQrICovNTwqynOsNfJUbE yzog== X-Gm-Message-State: AOJu0YyNXlGASZ3ls5IowhfbkMDofWcoBbTf71rU2iAIiJUgNGF2Ew7P /Xc+VY2wSj5Y1dNHlZARqQi1cdsFtQrukhhbNthW3gIOORD4Gzl1stVZsZVR X-Google-Smtp-Source: AGHT+IEVJQbQ6q5Mm0wzsLT0qJ/yZwDeqnFQnVHWTFpK7+GZLjNJrHK6bsVvNmK8WE66MzTa3V8u/g== X-Received: by 2002:a05:6871:4609:b0:214:dbd9:b8e0 with SMTP id nf9-20020a056871460900b00214dbd9b8e0mr9264090oab.21.1706649750219; Tue, 30 Jan 2024 13:22:30 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id n1-20020a056870a44100b002185412083bsm2105786oal.0.2024.01.30.13.22.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:22:29 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 09/17] storage: Remove mode parameter Date: Tue, 30 Jan 2024 15:21:14 -0600 Message-ID: <20240130212137.814082-9-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130212137.814082-1-denkenz@gmail.com> References: <20240130212137.814082-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..89c11cac4452 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; + mode_t mode = S_IRUSR | S_IWUSR; 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 Tue Jan 30 21:21:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13538085 Received: from mail-oa1-f41.google.com (mail-oa1-f41.google.com [209.85.160.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 2961278B55 for ; Tue, 30 Jan 2024 21:22:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649753; cv=none; b=ig/kUPFBaZjlpAvrA568ogkfnrvfvOZEgr3ALgS9q9i6Grn9MUSu+DPYg4kvxwB1PrgQM3Zj2pgCAHlrk39Y2VlyOJ6n9Y4W4z4GUHYg3S7F8p0RAOIUOIYMnVAeoIMHNHMQYvL0o5xExFVcnNPlzh/3edCv3JoSL+Ng6B7L7PA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649753; c=relaxed/simple; bh=6yxi50K1Wx9rlrL0qY8bOPY+9mfiHds5hJg8RRkZ7LU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I5tH7iUovQ4WYINuLSJmv2SeeSKecUr3jKmbZRGLbWAHHezr9MiiCySkZd1ti+h7YozYvyulzRpjTMP1b3Bl0feAa/zpA62cBXXcPN4619iqsHnENHbSieDeL8076pMag00WVxgadECTikd/6iUWRk/VBcLVtX6dMyPHtNFoaMk= 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=LYw5NyIm; arc=none smtp.client-ip=209.85.160.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="LYw5NyIm" Received: by mail-oa1-f41.google.com with SMTP id 586e51a60fabf-214410e969cso120752fac.0 for ; Tue, 30 Jan 2024 13:22:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706649751; x=1707254551; 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=5MgbNqvldYRKRfhzhD0Oj6pcvP1XJSeq4OjuQVjxM90=; b=LYw5NyImeDnvimmoD6Xf/Y9UEQxJU1a4lq13WyYo8F7lyo6ZGsKAxEaNtql6IVt3eX crW8qCK7f77fmKJCuVuN9RT6zkzRxD4xkIBFsG+npkMTRwO0+QiTUIUN2KXCPsxLNkRT fYpG1tqArKvNC2Pkrwz8rfBqsDCdxDfD4LBmFMde5OT3MAN0GWaIjuw7d4BZmYS1+6Vc Rvv+FEsJg1Su8ogPOQd0QLyXsmOBtH9hUFvAzPfSMgxljhYLecv6bT9OQztwhH7wwd5u tkTJFpU+PpFQpy/SXr5WhpGx7rjnQ2+MO0IXY+xyMipK1jokq1z3VjxnxFbT0QkMt8/d sx/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706649751; x=1707254551; 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=5MgbNqvldYRKRfhzhD0Oj6pcvP1XJSeq4OjuQVjxM90=; b=sLmRi2MN570dNST5Fjvq1D3tMgxHi2yyPHeNWx8lxHbMH65Jdb+w0Ig4DFlC5O8FIS +haVwTAqidL4DWBTzN0fXq8KgLRds9MYpQpJkq3S+nU4006HRsRwTr6sa2Kx9M4zal2T 0eHxsx8tYSgk9gdzWRbXbOuOupYRK9ydsYbd1qs/yEMp9zuHDkv+T90afhQULyeAix+I +CEbZ5mITHCYR3P6PoJMzZuGuoz1Y1DymbjC7tYo5juOLst6FH/N/t/0TvMNnwxzkk3C iF3M5qZVvhKlkgV1gG6VLAu+PRGb4PZ8I7QdoC3ztn5chq3RoPjmfEXTKZ0LnUAN3Jq9 1u7A== X-Gm-Message-State: AOJu0YxBKZ8lykLn60JHkhe7OxzavQsucWYzTPpRLN6Qz+9JVaHxfVii EoaWeZ6gbuQirjTtBKbhM70iPo3WwXWPe4iB/rfg7REWB3uxfQSy06kgwgbp X-Google-Smtp-Source: AGHT+IH+KhA2toHMxZmRDCP52ELi62Dwghed5OQr10bAPDwnGeyL6XSNiabi/AnEK58/Jbl9MZ5NTQ== X-Received: by 2002:a05:6870:8197:b0:210:c514:2303 with SMTP id k23-20020a056870819700b00210c5142303mr871185oae.31.1706649751175; Tue, 30 Jan 2024 13:22:31 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id n1-20020a056870a44100b002185412083bsm2105786oal.0.2024.01.30.13.22.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:22:30 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 10/17] storage: Use l_malloc Date: Tue, 30 Jan 2024 15:21:15 -0600 Message-ID: <20240130212137.814082-10-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130212137.814082-1-denkenz@gmail.com> References: <20240130212137.814082-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 89c11cac4452..1c873474a927 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 Tue Jan 30 21:21:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13538086 Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) (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 EC8CA78B5A for ; Tue, 30 Jan 2024 21:22:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649754; cv=none; b=tgcPUQC97bpGyHXMRyVnkgnw1FJtzQkorPjvwADFL/sg2syM+iHEHoSDSqvWjOmFk7u1E9FSlMzmVidn4ng/ABkzKuXtQBiViuUu3ok19P5Q/sq2EwZ2INeIm55Xuww55KCN1ZsidKnmZ6BPkJXXsCORbhUS+t7Kgz9qCzKG5Ao= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649754; c=relaxed/simple; bh=Ru9cnxY5z7jn1+SaaalHqbxHAuR5Dfg/n3Bmt3Es1pc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pWZrcltACwl2L8vhaeTvTmrT5pbp5qQ8bENxil1mLU4663bYpghRDz1NbUnv0oy03Kc2JsXbsrtB3T8osMOX14lWvBvdmNynSyO3il0U73aUKIQ7EFvJJtwFK/h+AQO2wZOZQEq6wMzMUvqNs7JZ8TqgAYtxqnr8PR2P/a4n12M= 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=Y2I4gmY7; arc=none smtp.client-ip=209.85.160.50 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="Y2I4gmY7" Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-2187ec01d6bso1903839fac.1 for ; Tue, 30 Jan 2024 13:22:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706649752; x=1707254552; 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=3b/xiaWHOZdD9/xLRCljPPRZg717vMewN+EC/KiIntk=; b=Y2I4gmY7sACHBJO9eT1W8BC5gEVcIyRviCWz3AfhS+MzOW2xg746T0BV5ybdmEckFb aIyzFQxj+tUkdO3UZxZ0yxS096MiJKhT/Ajia3m0XIqLl7/VqVauzCZiVCFHHSy9A0KA jjnHvuF4nzn2vZq+iVY/1yW0oqaVNoNxwaoD5oy91mvh25i+17xVUXcM2INHH6giZm0G 2qfxjU5YHzNksgd6GTVUHwSXxglXWedktrZi70WU/TqcaSjKiaYGDn+KSLm8s0Pw1AZe Psg6+LRzpCuVU1iXOku/fByYt5eldPsi+HJjZ/N9wyrPD53SCbR3c4qImWT4vdH+4gRK xx5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706649752; x=1707254552; 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=3b/xiaWHOZdD9/xLRCljPPRZg717vMewN+EC/KiIntk=; b=IccmFJVZPTAkbxbBv/BIBrPH0ZyMOcD7TptmgK0hI57qqfdvHBQPIucw4qf+I1XNIu 3g/Q0ir8oeORnWficVjEpn78o0r4ldV0gJIAnSZe6gj2nuSfWsy1cBnKUGHWkk0vFQeM FcJFEAQJFfJ++xU7amse2I7ydnhVJGTAA2+uVDxRgmfh+Eh0dTLyfu1svlq5UmeJzNZI ekciQelzr+LazQQICyxlXPttneOVEVM4iX0Cd0KjmlQyYhSy2kaSYrkzimDhCB84Sn6f l0sgPd6pGIRnr+ykVzd9L2JaL7HJDkCxzv4yL84319qm+pIMuJ+2RCN8NurZfNa8TquE 5ewQ== X-Gm-Message-State: AOJu0YxwLlQfsltoC4hpHxvPRznYUIzBhEF26XWjvUSrdG9TdbXrZYOT oiasXI4d9YB2tA6oSr8wFo1rptDgwwOZwRvSeYwTmD24x4ctzLZ1opJG6Rfx X-Google-Smtp-Source: AGHT+IFZfWdUvFNzpEi63mZTChQl+kC/up5fNlKtWQRHexvs2prIPBCuvb+mW2EaCQKq35Xtrxuvww== X-Received: by 2002:a05:6871:6ac:b0:210:b5fa:4977 with SMTP id l44-20020a05687106ac00b00210b5fa4977mr9296459oao.52.1706649751792; Tue, 30 Jan 2024 13:22:31 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id n1-20020a056870a44100b002185412083bsm2105786oal.0.2024.01.30.13.22.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:22:31 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 11/17] storage: Remove mode argument Date: Tue, 30 Jan 2024 15:21:16 -0600 Message-ID: <20240130212137.814082-11-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130212137.814082-1-denkenz@gmail.com> References: <20240130212137.814082-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 | 10 ++++++---- src/storage.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/storage.c b/src/storage.c index 1c873474a927..f169195c8df7 100644 --- a/src/storage.c +++ b/src/storage.c @@ -37,6 +37,8 @@ #include "storage.h" +#define STORAGE_DIR_MODE (S_IRUSR | S_IWUSR | S_IXUSR) + const char *ofono_config_dir(void) { return CONFIGDIR; @@ -47,7 +49,7 @@ 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; @@ -71,7 +73,7 @@ int create_dirs(const char *filename, const mode_t mode) strncat(dir, prev + 1, next - prev); - if (mkdir(dir, mode) == -1 && errno != EEXIST) { + if (mkdir(dir, STORAGE_DIR_MODE) == -1 && errno != EEXIST) { l_free(dir); return -1; } @@ -133,7 +135,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 +206,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 Tue Jan 30 21:21:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13538088 Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (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 7CD3B78B67 for ; Tue, 30 Jan 2024 21:22:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649754; cv=none; b=TFxWHNm1AxpIccztLduqzRpWbT1+z6NA27JZWNphYnCAzP+jpukmtQ1CEhE2IYdFaIQYAWluVdkA2K6NcETb/k7bWGBDvBHHSfnlavKh0xO87XOGxDKrl7ECT5lORbmE3eCNWBpGN7V4RXSCtJC2P+sy0ATqxht/NENbSSC0IuM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649754; c=relaxed/simple; bh=/uXtfSHX87EDIJNjKQPz57XQhZZz2/lp7t+34gMs9mM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kBwvaQcDBSffNyNc0VQjIaJAcx8Z+9Tsw63Y9tBI7wnnqKsZs5Fdov1pU3VbcqVXye1sLqxo1TLDGcicxAlJE4nKMlREBe+o5/7IZQ6fe4vZJVWnLlho+SUsMvui+SUzUn9/DTFY7tihlHLvOy/3Mh1OZ9A2yCb2jsnjb9bE5jA= 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=Pezqnu0n; arc=none smtp.client-ip=209.85.210.50 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="Pezqnu0n" Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-6dc8b280155so2624722a34.0 for ; Tue, 30 Jan 2024 13:22:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706649752; x=1707254552; 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=Q1C0XNc0vkyWjPp1kouWBIVc2BKOna9atKyAcwc+BVs=; b=Pezqnu0n++mrs6xE70sXHNVjmJK+UWX4uQtCewWm3d2svdVy08ZkCzc/jOeyrxViae IkahcPOI83rG6ox7U3QAKO4KgkUp7nCfjlm5PLL80CI/DJXsAqBf2qC8da42iJvSoqFA kX8/NKrLZ2yLs7/Ym6L2pbT5AGqbsDszx85h63UbDWhoX6yr/oEzxDWh0E9nYx8u9ClT JJRTYURAZd4R6ZqpvVU7imdfMcNpsHcONAm1pHMKq4J+xvlF5f4/b8lWDjCKKSvWSo7X 2jMcQZfCRyXc1d+g+jQcqhuqmpu9CmXy8hhrQjkVGOgyD1c6BIBgf4cJBPbELh46e82L roWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706649752; x=1707254552; 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=Q1C0XNc0vkyWjPp1kouWBIVc2BKOna9atKyAcwc+BVs=; b=UBolGKLer+yH1my23/peqPHFFex5ozKUrmDb236WsnBkRqnuJRcQ1llAK2jxyxKxJo mmBehlZLaR8lyMW3IErV+7apzgqmx8uMEGQNrLSAi7q6rRugRe0Ftc3G90vcNiY1Yrrp 5ysNCuKWL8uoqWXdMsD+1d4djwRXGwJNnRk1ZQGvd8UXqs32iR7LrmGbro9WCNkUpdu4 KSj+AVHiRskJkAWYLsfsh7NoAfHUgvt2r+36vQhcEhGfFqZuqeHT8UVgOoCAj4RruB2p TFlzVWyDsNoCgMULgjO7DrWcy84vj18GSgxXyNXKB797mYD19opSEh3tUm5A7QVq1wDR vAQQ== X-Gm-Message-State: AOJu0YylaihXtyl16x4neuJnsSGdMIiJN19dXaATq1sJ9R/folq8I+JR k/sQISPbDdnlUFc1FUv9L7WTjIOZ9Z9Boaa+ZmDTiJakKLdPl8M7jkRC0gf9 X-Google-Smtp-Source: AGHT+IF6oUNQqedX8g6mm9pL7sDEXP0bfH9T/Vacpuqi65hXyriwllVd/uAGd3HuaZNhF8+NblQOXQ== X-Received: by 2002:a05:6870:eca2:b0:214:b208:ddd2 with SMTP id eo34-20020a056870eca200b00214b208ddd2mr5413044oab.46.1706649752306; Tue, 30 Jan 2024 13:22:32 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id n1-20020a056870a44100b002185412083bsm2105786oal.0.2024.01.30.13.22.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:22:32 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 12/17] storage: Use void * instead of unsigned char * Date: Tue, 30 Jan 2024 15:21:17 -0600 Message-ID: <20240130212137.814082-12-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130212137.814082-1-denkenz@gmail.com> References: <20240130212137.814082-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 f169195c8df7..30e004e75d91 100644 --- a/src/storage.c +++ b/src/storage.c @@ -83,8 +83,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; @@ -119,8 +118,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 Tue Jan 30 21:21:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13538089 Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) (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 1DBAD76C87 for ; Tue, 30 Jan 2024 21:22:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649755; cv=none; b=TitjPvYC2A1YPSIa1hnQ3bpQw2U+D4b24abUJkib9sATy3X3ebqEZrQKSku8XDkyrbUh7XhdFN02w/dPLaKLvXF44QZdMewRrFVLIt+IpNAc7YfAL/NonCDrLKdW+0XkI5YRBnxGZnvZ+jYwSVX4lHZLq8K1m9A3UJLGsotUlk4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649755; c=relaxed/simple; bh=mYxwPgYSG4byzJilt5DBxW9ht5h0BDDnE1RQtYELBqY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oHwx9/KShKPtvTTUOrJxEOkWcHILgQIY66oorVYs98TxinBCXCGjeZlayrkr4jtSGHQe9PICIwNm7DBxGTmf6WYG0ma9f9PutwDVeGeokD/FpFkRdmg1FULx4Euvlg3ILHZ1zl2JTXyGvYhi5mQfSkockXwOdxxVnskvUeSIpxI= 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=PRBG/Z51; arc=none smtp.client-ip=209.85.160.50 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="PRBG/Z51" Received: by mail-oa1-f50.google.com with SMTP id 586e51a60fabf-214ca209184so1996019fac.1 for ; Tue, 30 Jan 2024 13:22:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706649753; x=1707254553; 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=w9W7uBfXrrWqqZB7aYpdTIdvqR93StqblSi5KfQSWLo=; b=PRBG/Z51cpB/JJbe5d885izKf9ogVWrgJV1dix8pdQRRjWr99Wmx99azySB/AmN2rL 5PYRpGGYLzizynLr9ydy3dRM3RO64uIeZZFRDmvUBXyZ1lCxkwtpFy9fltT54T0IoH/S GukNGJn8Ys6CMNin/RJBscQ2V7DwcjVSibl0/QfUOPNOL+dZGhOtQxL3XS+9GO+3WR6d dt6pQc235aPfdVBPyLC/DoRHz9Q5U2HxGrubA2UpEafEI2YsxAIlNh53QvqnQjvanQS0 LK6Pom7GPBVd1nKe6mWZVEvYHIqEWW4AK/AmqyI7LElCstg28eTu1Hv5g8PozLmrwdR2 9oXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706649753; x=1707254553; 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=w9W7uBfXrrWqqZB7aYpdTIdvqR93StqblSi5KfQSWLo=; b=X2eFuxH143iGVQCilLQmbzXYIz0wOu+rtWWrjQrRXxiD2NvjglwrrHfIn1YEmWw3w3 EQD0EQMo3SI1K+Pw8GW+bxiIoboCSgAEGLuwOhWihhBt/e1arxF20kxdTBy0iOp+lw7N uNlGlZVbjvaxBDW0lEp/7FC6oIi18/dfKS8jD9I1mRl0rRa+RkSin5cuQ6idGpLE5LMV AZlnSf72kZRlhQ13RkMqH7OsA0RJcZX7DQXy7bqoxNrQX0MLignJTRtTH1h/Or/OyqmJ gaxTZnBH1vkBjo/MHDo61aihGJHtQgsFNvFYZdDd5dMa7vMUjKnHtIG1Ydp3zrlm+1mX lkBw== X-Gm-Message-State: AOJu0YyMhWbf+ocDuaBdg1Z1h6heuXTO71Mc9Xa359r7c1NsN0CGY0I3 QlaM3T+HuP44UmlPD092f1sqxP4Cf5PNQOdoOPjZuKUlV+8VNvjDCbZwZ9EF X-Google-Smtp-Source: AGHT+IG9MFYeRky1APfrx5CKoVGCvkA3dNNp8t0Qmqj634JcPnCTppNWrYEAG9lixghuK3J6yNGbtQ== X-Received: by 2002:a05:6870:3287:b0:203:ef0f:7042 with SMTP id q7-20020a056870328700b00203ef0f7042mr11423944oac.21.1706649753016; Tue, 30 Jan 2024 13:22:33 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id n1-20020a056870a44100b002185412083bsm2105786oal.0.2024.01.30.13.22.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:22:32 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 13/17] storage: use l_file_set_contents Date: Tue, 30 Jan 2024 15:21:18 -0600 Message-ID: <20240130212137.814082-13-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130212137.814082-1-denkenz@gmail.com> References: <20240130212137.814082-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 30e004e75d91..130fcc9ce4a7 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 @@ -121,50 +122,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; - mode_t mode = S_IRUSR | S_IWUSR; + 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 Tue Jan 30 21:21:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13538091 Received: from mail-oi1-f182.google.com (mail-oi1-f182.google.com [209.85.167.182]) (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 CC6DC76C87 for ; Tue, 30 Jan 2024 21:22:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649757; cv=none; b=YERuR2AuIKtQxs+4yegzo0UOcOtkb1T5/dmxz8ml8yqVMA8tl9cNcxgswPUqJUrFbNEjL7PZj02j4i3K7L62TDak+JU2laj9PVscq3IpBSs6VQOhPG5Os19YkJIE7adJ1prPiOBxCebCkNk7EX0dXWK16L2jcmum/If3pTO0oWk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649757; c=relaxed/simple; bh=W7qdf5MvGmr4jAxM51WnyMfVC+Xkts0o9ZVQfb3NIOU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GvFfkTLw0WThL4Gv2h1di4vKfwdWrBjgVsrNjrQDaFPJpUBAWVbz7uGs6ABAGvl/mAfO8FHAfnjov9nOiHqjIVurU4ZOFyMeRY0uMKLI8u1Ly5ybdbnu17Q0Ys/ALfcLpEMhRfnwlT1B87uy3qCFHEqaS5AEUWswnebuAHzKYFE= 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=SDlbo3g7; arc=none smtp.client-ip=209.85.167.182 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="SDlbo3g7" Received: by mail-oi1-f182.google.com with SMTP id 5614622812f47-3bbbc6bcc78so3514750b6e.1 for ; Tue, 30 Jan 2024 13:22:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706649754; x=1707254554; 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=/asj+PQDU2JvGzvRCInLFoPH7wGSo3ElHlbin6l4ShY=; b=SDlbo3g7eQuZxRLEWRSW3rD6I9AWTFFyh2AcaVthb43LWHe03lPpYWLh6foocMaVbO 5iaYULNIBYuDrm8tb8oDpvcYmmLIqIdNo9pOPK3eKHPTg0Q985fkkG+W+3CzIhjjNtuu hKHNecThjFiCf6Js+qcy3+yaKolQ5ZEViOCvHMTyrjPhvrLYZ5YEyU6yRnMdU7Q3tU0P 29qlBCe2zseAYf6ASEuEAAWNUbkC0L0swa/WuCvjEjEUy3h2mxNvAbFS0l6GLDxWa+VP +0UWKGH3adyA2JAmNuQr1Vc8kxgP95KciQkV3aJyj8PuYBxuvQ5A15LSgKWqijmw9wyb 8KoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706649754; x=1707254554; 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=/asj+PQDU2JvGzvRCInLFoPH7wGSo3ElHlbin6l4ShY=; b=T2l37qwJvFMkDxw/ktFcCEnR802VrP+sZVu1zGK406rNsiNiNBGp8oeN0Xqx2wabu+ Gu1oN4BK2p+pZcNs6c8F//7ajfKTRKcA9AxSUuQGfsco/HjVEYm5lwswEyd7k8WZdoCi eFNwvA+Weh9uSMS7o5EYiNNVmNQQrHM3//5/ITC622j1lwpYRaUDQAkuFu60LaVbCXNv yDyTT0/xi7LDcGJmrNoXIsz29NAEDjqTBYCZAGQHMNmAc9cKvDytQtgab8gVvRqTo8zn hn2RB+3yaCG7oZn+K8ImRrfhRDnMgzrA95r/Jg6ybMwy9DRtuqk/T8SLn82eTn+yz5s2 f6mA== X-Gm-Message-State: AOJu0Yy3pr5+lxBqqDDDKwv9mGk195eXXVXhZyGf1hjBEan4bml/E1Cq LaguA1XWtZEYVykMjh6UgfwpHiYa0yJcuZO46kdFAT/nDSXZU7zXkSxoy2jP X-Google-Smtp-Source: AGHT+IE7EpExYg5cgcp36PzgIt7Qi85NiiNCtfho3ZUes0XTQWxAdwRqW1fJMM8396XefJSZdqtHwQ== X-Received: by 2002:a05:6870:4992:b0:214:b399:4d2c with SMTP id ho18-20020a056870499200b00214b3994d2cmr539418oab.20.1706649753652; Tue, 30 Jan 2024 13:22:33 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id n1-20020a056870a44100b002185412083bsm2105786oal.0.2024.01.30.13.22.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:22:33 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 14/17] lte: Refactor lte settings management Date: Tue, 30 Jan 2024 15:21:19 -0600 Message-ID: <20240130212137.814082-14-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130212137.814082-1-denkenz@gmail.com> References: <20240130212137.814082-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 | 169 +++++++++++++++++++++++++++--------------------------- 1 file changed, 85 insertions(+), 84 deletions(-) diff --git a/src/lte.c b/src/lte.c index 7280b2913a8d..d412e15d90f9 100644 --- a/src/lte.c +++ b/src/lte.c @@ -32,6 +32,8 @@ #include #include +#include +#include #include "ofono.h" @@ -50,59 +52,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 +103,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 +190,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 +210,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 +224,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 +267,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 +296,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 +342,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 +396,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 Tue Jan 30 21:21:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13538090 Received: from mail-oa1-f52.google.com (mail-oa1-f52.google.com [209.85.160.52]) (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 39D1E78B6B for ; Tue, 30 Jan 2024 21:22:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649756; cv=none; b=otUo9g6zyxHidFV822+n2vCuuqoDxRC4GdIW8QRG/jW+DeswtShAAatR8CdFyWanR8K0ir7QfrpuEWAszFHWehtUFX1i7lR6ImFCenVwQoZxcTz6modPIPHY5BrbPaFIJ5XLLEZzPcvnCiSCnWr+pBHZHJbBJuhiQABmrlX2U1w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649756; c=relaxed/simple; bh=3QV3ma7/uzwM4oylamqffSp6Qw81djNiReXkbSzAgoo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hoV+ZfdJm73h5Jk6kEFpI7T+BpT0NM0+AYiz+/vllwuxnA5M5nibOx+bPtgFo6YkCW+cBK9SipMS3nPW0H1dWOAKahnKARWx+Nr7DqYlMBaMTnwGyLEIYSXuYhkcGruYM3sY4BaeS/eIkhRLuImI1jVfdBf91dn6KotPCszevH4= 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=CiGrltLv; arc=none smtp.client-ip=209.85.160.52 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="CiGrltLv" Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-2185d5f4366so1587069fac.2 for ; Tue, 30 Jan 2024 13:22:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706649754; x=1707254554; 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=Yhlyj12NGSzJjxgnXEsxEUSdEARBAKn0LKDhQKEgKGA=; b=CiGrltLvFX/mJx4dwuzopX0PXa7ajViQLyCee8/nnvbyaXE57oM1EaGHBkqVg48eL4 GdojKgo1ThfN9aXbJLcYCYg87Gmy89AVw9QNjrdZ1rQciDhaB6BZZAzm4OtLdiHFZomn bhtYuYwCsVrH7B+IBGZqQajwV94ec7rE8cDkFIo8zP08M+juSChWeJCurZ3Ngrp0X1Q6 ffKtmgZfwvDoYT6HbMQUN1nqcsFjKaBqzDukB5EtQZd0VBKciU/UBChA0loq5LPd8Sbt Qn3J/xHuD6RAXA1O+N4vtgZSDorlidHzr40xypohf0lYgx2IJ2kJHJUrlqP3fFDn7snY ovEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706649754; x=1707254554; 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=Yhlyj12NGSzJjxgnXEsxEUSdEARBAKn0LKDhQKEgKGA=; b=hiEDaQKhy3MJrdqhN8kiY2ct1eduKxArYjl06oISie2FRCUvo/eb6kO6oWHFVrl274 mc9N4607rVm5bRurr5BpXFghX6sNE3XXqbxMOR8C40OGxm/Q5PlqRKJUg2ZTr5ebUZv8 SZglgfaTG/2gssERiDsSUnb+iG2H4gXsUERzVw00Sd16P334Z8I13xus5xl3q71+XN4p 9HWjbFW1HpXsOBHdyZ1oWPX+B+xCk/jcCpCo/ARfiaMwpDWVo3bfoTJmRYGtqzjBTFsX RX2ANHgJGjWtQj9AiFt8V3Juw7WSBrWiP+V61ZjKrxp1cb5xdCp1IwFMMdDLkT2dB82d Rh/Q== X-Gm-Message-State: AOJu0YyDeqgmJbke1Lm/Qoe2OZy51diHvjr9nlY6Vq/Yb4ZSWM468K3e h6lS52g6OzDujF/FU/z2QkonBZZb5ygLYS+8LsnY+evmkHatGas/F5OyQynD X-Google-Smtp-Source: AGHT+IFKWAgcABMRh7293Sum85IiPt6KU1pco1qDz56PcW3tL/3GzAO4hYEtIXmt5boW9CwhFX+Xww== X-Received: by 2002:a05:6870:c08a:b0:218:515f:a81c with SMTP id c10-20020a056870c08a00b00218515fa81cmr6376732oad.6.1706649754184; Tue, 30 Jan 2024 13:22:34 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id n1-20020a056870a44100b002185412083bsm2105786oal.0.2024.01.30.13.22.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:22:33 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 15/17] lte: Add provisioning support Date: Tue, 30 Jan 2024 15:21:20 -0600 Message-ID: <20240130212137.814082-15-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130212137.814082-1-denkenz@gmail.com> References: <20240130212137.814082-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 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 d412e15d90f9..433b18956468 100644 --- a/src/lte.c +++ b/src/lte.c @@ -37,6 +37,7 @@ #include "ofono.h" +#include "provisiondb.h" #include "common.h" #include "storage.h" @@ -56,8 +57,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); @@ -361,6 +408,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); @@ -394,11 +446,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, @@ -406,7 +485,6 @@ void ofono_lte_register(struct ofono_lte *lte) return; } -finish_register: ofono_lte_finish_register(lte); } From patchwork Tue Jan 30 21:21:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13538092 Received: from mail-oi1-f177.google.com (mail-oi1-f177.google.com [209.85.167.177]) (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 A13F778B53 for ; Tue, 30 Jan 2024 21:22:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649759; cv=none; b=HngycLcSo7erTHwFxf5plF77Y2uIArHqoRQKtWcGxAamswDUOlPurYg+M5g6XDxyVz/IaSDEApL3OT32Q8sHeI70RdHeLcjzpKYp1uT70Ulm8BtKTmPbOtvfab5PE4BNK8owe1QA6EVX9UsonCXXS14x1MfDrNQOH+JPqB6NRz8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649759; c=relaxed/simple; bh=aFANccxePynoAJB7yKTQzGpbqxQl0W1cspHAtif3CN4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kr3nWptzmz4v6E0mxDIEqHIyNDQdcfoSrVUswLQPczOVTvJDis07vuJkeh0ANYDdBSe5AqhXCgZuJZgJn/1eYaJC+j8rhF7j8mzxR5r7/JakJZ0gDOr+Cp2epDND7AuUUZQlV2nkyOya9p+z5arJ4T9/NnYtYJ5cl4/XcC5EGRw= 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=Q7yQxETE; arc=none smtp.client-ip=209.85.167.177 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="Q7yQxETE" Received: by mail-oi1-f177.google.com with SMTP id 5614622812f47-3be61123c8fso1375221b6e.0 for ; Tue, 30 Jan 2024 13:22:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706649756; x=1707254556; 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=Q7yQxETErBZmN3c1V/rrTMPLLYV0b4FyIU/Cf3PSrqbJY3ECvUwj4AtCslxm0T7M9U OuBWK/586JIosjjgxl/sRIyPt0qJkNQ81KUIg9yl4erRKLb+Na4OBYL0fpU+lhhZ43Vf RqkyiPP3uywDMui0JLq4RtELgNjljyh38mTt/G4vadanwxFSaezB3MgIpINemT4Jfms2 ipPZ79eVurpzLXIY8bkoEfOEcQ/v6CK1DqvUHO1jYvV7dByyyPib30ukPnGpT4x2bnat +VQwtOoFuB1+8HsGm1NY1YGpwMMXwrUPIe3/lrLwdt9X8wI8N30uf0VLT6+zQLZM8KLn TvAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706649756; x=1707254556; 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=QnA+blTzivL/k8nvq1Ta56+VBdZX+XoDzMvgZjS7OJlGmJVTgnsbPGbdHspJjD8rS3 2EkCbsJqClAM5hCCU7tNnZ8wKt2JdzN/z6t4Blmim1vOEOzabkoDbMDy0aFUg+ytJYuw yOgnEASiaO/bVUYzFqS1LS4agRVrLsG/XoTg7vjbz03xwhgpCnlUi4891mhfQT1AfjFO dHOTxgTknTx3PiqlOoxFkl9pthFfzZjkIHhhwU8EMsIdlydVL9h3x2LsdLzNOf0wSB9j 7xTeW+nkxArgyf+zykY2dF+6DSyplQmtKMNxL0E13Rk6EqL2TPZP/Tf+KCVpYgpbWxIQ 9Hkg== X-Gm-Message-State: AOJu0YyitTGRXVxT53+0wCFYXRrT88/mNOk8HyHYwTl3zOgB/itObUx8 dl6fkigFvxDoIuPuhkw4dNJ8NX2HjDl07Wpln24IAc9JVd1WvfBEiHtFJSrf X-Google-Smtp-Source: AGHT+IExfTKYhSVMUMTgQyok83n43bSIJMprXnWqvUVcjPCA6VUjU5/UqpWftE2stR/rjznz2OpRGw== X-Received: by 2002:a05:6870:230c:b0:218:b0f4:6c72 with SMTP id w12-20020a056870230c00b00218b0f46c72mr2194356oao.14.1706649754715; Tue, 30 Jan 2024 13:22:34 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id n1-20020a056870a44100b002185412083bsm2105786oal.0.2024.01.30.13.22.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:22:34 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 16/17] phonesim: Add lte atom Date: Tue, 30 Jan 2024 15:21:21 -0600 Message-ID: <20240130212137.814082-16-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130212137.814082-1-denkenz@gmail.com> References: <20240130212137.814082-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 Tue Jan 30 21:21:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Kenzior X-Patchwork-Id: 13538093 Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) (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 646A3762F5 for ; Tue, 30 Jan 2024 21:22:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649759; cv=none; b=H7Rez5DKkqqUTlYvzThk+5IbiDJzfdR/j+D5cqyue6mqSR7n+Gye0H4DlLQR002X3h9sO9+CjjL3hFpzZXlYBsLkDy2VLUjahhxRTTXm1gHG3kthuCoeqqD6gQCpBUL5c6lXn4vRCyGiD+j0btOwYxxHfhlxPc6+B+SB1C8qfKs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706649759; c=relaxed/simple; bh=X0vrAGIBKKFDTAps+KOrfmw2qO86PQaIDc0Ihh/rDvI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LtzbW4pLaHeJQg1lVxppRjgHVjFCQi6OuAzJbJxmioO3w8jqSlPYsQ/GR53kMbhpoTjvPPLozqsMG354U1e5NmQ3HvULzuPiL7VXbPczrDL2UQotdQXA2ZB09i192tNCfWjc1alXzY6ugGbZR01hAC1re2w3ZBB8LZtolr/WaMQ= 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=dsOUcyNR; arc=none smtp.client-ip=209.85.160.43 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="dsOUcyNR" Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-2185a9966bcso123813fac.0 for ; Tue, 30 Jan 2024 13:22:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706649757; x=1707254557; 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=0eKAng6k2Govtm1grkqVM5DJwcbaIUMW2LdH0r3DYNg=; b=dsOUcyNR1lUf1iMoz6kBwY9nR9DcDqOT7V0xccQxqEY0oogsc/o0dYBCcaOeV3EUGG 4QtedFL/rcS6IkMKBwVZNJwqVphNCqTcg84pQRcgVKMPfPdOaQVm2auTMGAmTiNsDDIk wuBiRk4CzCLW8tUtFVkt7ztx1K2SuY4ADdSKjOfXhvYxXnQDyzGs/q8JXmz5F3aK+XBO enIxoxUBrytgptQqXOzIS6nTgoh6dDZL1s8Uy+PkbHtv2HFAETncUrHhzqvGWgOXodhI N24WQ5WZCP4lrj5Z23zMeHiCNgkFsYkxcTHaTfvpQBWZoSvAkT8jF8qIdw2Fg2CzekRQ dFjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706649757; x=1707254557; 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=0eKAng6k2Govtm1grkqVM5DJwcbaIUMW2LdH0r3DYNg=; b=seUsgTLfhrCdw3LhXiw0OfBcIXbfj9/vpUprV57yTUPTvyhx/96oouW2F9LVA9+a3j AmO+0vGhtu2Hj0OY9q+2xEF3IFZtCssFaqib6IqK5Dp89+HCs4ZqOczttq+E90vqh7Po UXZuOxhwDbeU315e/8l75Dmrm7rHKaaMsDOXJAE96wlVFUeycuZNqzW6Y5i3nGnoGbwq 8N+YPzZKUU48WcINysiOl05CobwGmnsAkOc5gKnlGs+HAQVuRJGw6poNNLgj7eVmbZ31 POqXp3JOhRnzaY7jdkygUMrDanv2mbyp6g7Gp5a9LbUD8xWhXDp+uEn5IjjNAQ7F4cgl kflA== X-Gm-Message-State: AOJu0Yw5N3TiMuRQZurCqob77EBurVz1x/C2fQudIbIsQGGBXqRFvQL5 m/cKr5WRC8e/a7Kb7dAgWK7J7JKWJQ0sGn0vmP6vPH/7yjr+mFpBEoB+9rXx X-Google-Smtp-Source: AGHT+IHHU/BpxkO8qY3jCQ3fWJDVJt5kr8HXiYDqOlfbQm8Hmo0d31n2xit2U7i5rUzzARn0IHIMIA== X-Received: by 2002:a05:6870:b253:b0:218:54f8:b9aa with SMTP id b19-20020a056870b25300b0021854f8b9aamr885914oam.15.1706649757212; Tue, 30 Jan 2024 13:22:37 -0800 (PST) Received: from localhost.localdomain (070-114-247-242.res.spectrum.com. [70.114.247.242]) by smtp.gmail.com with ESMTPSA id n1-20020a056870a44100b002185412083bsm2105786oal.0.2024.01.30.13.22.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:22:36 -0800 (PST) From: Denis Kenzior To: ofono@lists.linux.dev Cc: Denis Kenzior Subject: [PATCH 17/17] lte: Write provisioned info to disk Date: Tue, 30 Jan 2024 15:21:22 -0600 Message-ID: <20240130212137.814082-17-denkenz@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130212137.814082-1-denkenz@gmail.com> References: <20240130212137.814082-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 433b18956468..c3decc5c891c 100644 --- a/src/lte.c +++ b/src/lte.c @@ -451,11 +451,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,