From d1dece447309b8e720f48664543b49b9f5008d13 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 22 Oct 2024 15:06:29 +0200 Subject: [PATCH] [libcalamares] Expand file-permissions to allow leading 'o' --- src/libcalamares/utils/Permissions.cpp | 14 ++++++++++++-- src/libcalamares/utils/Permissions.h | 5 ++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/libcalamares/utils/Permissions.cpp b/src/libcalamares/utils/Permissions.cpp index c028cff6f..a67932fdc 100644 --- a/src/libcalamares/utils/Permissions.cpp +++ b/src/libcalamares/utils/Permissions.cpp @@ -119,8 +119,8 @@ Permissions::apply( const QString& path, const Calamares::Permissions& p ) return r; } -int -parseFileMode( const QString& mode ) +static int +parseOctalFileMode( const QString& mode ) { bool ok; int octal = mode.toInt( &ok, 8 ); @@ -139,4 +139,14 @@ parseFileMode( const QString& mode ) return octal; } +int +parseFileMode( const QString& mode ) +{ + if ( mode.startsWith( 'o' ) ) + { + return parseOctalFileMode( mode.mid( 1 ) ); + } + return parseOctalFileMode( mode ); +} + } // namespace Calamares diff --git a/src/libcalamares/utils/Permissions.h b/src/libcalamares/utils/Permissions.h index 128ec8375..1062dbd98 100644 --- a/src/libcalamares/utils/Permissions.h +++ b/src/libcalamares/utils/Permissions.h @@ -100,7 +100,10 @@ private: * * Valid forms of @p mode are: * - octal representation, with an optional leading 0 and at most three - * octal digits (e.g. 0755 or 644) + * octal digits (e.g. 0755 or 644). + * - octal representation with a leading 'o' (letter) and at most three + * octal digits (e.g. o755 or o644). Use this in YAML where a string + * of digits would otherwise be interpreted as a (base-10) integer. */ DLLEXPORT int parseFileMode( const QString& mode );