From 8a02fdc38ef5d02115d152a2d3e79ebd8a462e3e Mon Sep 17 00:00:00 2001 From: Ian-Woo Kim Date: Fri, 14 Feb 2014 14:44:01 -0800 Subject: [PATCH] use USER environmental variable if getting user id by getpwuid is failed in perl scripts: download-from-binary-cache.pl and nix-channel --- scripts/download-from-binary-cache.pl.in | 2 +- scripts/nix-channel.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/download-from-binary-cache.pl.in b/scripts/download-from-binary-cache.pl.in index e6925d731..babf6cd28 100644 --- a/scripts/download-from-binary-cache.pl.in +++ b/scripts/download-from-binary-cache.pl.in @@ -40,7 +40,7 @@ my %requests; my %scheduled; my $caBundle = $ENV{"CURL_CA_BUNDLE"} // $ENV{"OPENSSL_X509_CERT_FILE"}; -my $userName = getpwuid($<) or die "cannot figure out user name"; +my $userName = getpwuid($<) or $ENV{"USER"} or die "cannot figure out user name"; my $requireSignedBinaryCaches = ($Nix::Config::config{"signed-binary-caches"} // "0") ne "0"; diff --git a/scripts/nix-channel.in b/scripts/nix-channel.in index 4a480ae28..db1ca2993 100755 --- a/scripts/nix-channel.in +++ b/scripts/nix-channel.in @@ -22,7 +22,7 @@ my $channelsList = "$home/.nix-channels"; my $nixDefExpr = "$home/.nix-defexpr"; # Figure out the name of the channels profile. -my $userName = getpwuid($<) or die "cannot figure out user name"; +my $userName = getpwuid($<) or $ENV{"USER"} or die "cannot figure out user name"); my $profile = "$Nix::Config::stateDir/profiles/per-user/$userName/channels"; mkpath(dirname $profile, 0, 0755);