commit: 273767168b5c82472e534c5d7ca2f37da3906d0a
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sun Aug 10 01:18:07 2025 +0000
Commit: Kerin Millar <kfm <AT> plushkava <DOT> net>
CommitDate: Sun Aug 10 01:20:20 2025 +0000
URL: https://gitweb.gentoo.org/proj/locale-gen.git/commit/?id=27376716
Report the username if $locale_dir cannot be modified
Presently, if the user is unable to modify the directory that is
supposed to contain the locale archive, an exception shall be thrown
that mentions the effective UID.
Aborting because UID 1234 can't modify '/usr/lib/locale': Permission denied
Instead, mention the username.
Aborting because 'kerin' can't modify '/usr/lib/locale': Permission denied
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
locale-gen | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/locale-gen b/locale-gen
index fb1a9bf..998df2c 100755
--- a/locale-gen
+++ b/locale-gen
@@ -370,7 +370,8 @@ sub check_archive_dir ($prefix, $locale_dir) {
# Check whether the directory exists and can be modified by the EUID.
if (! utime undef, undef, $archive_dir) {
- die "$PROGRAM: Aborting because UID $> can't modify
'$archive_dir': $!\n";
+ my $username = get_username();
+ die "$PROGRAM: Aborting because '$username' can't modify
'$archive_dir': $!\n";
}
}
@@ -588,6 +589,11 @@ sub trim_line ($line) {
return $line;
}
+sub get_username () {
+ local $!;
+ return getpwuid($>) // $ENV{'LOGNAME'};
+}
+
END {
if ($$ == $PID) {
if (length $TEMPDIR) {