unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#17946: Try LOGNAME in addition to USER
@ 2014-07-05 12:36 Taylan Ulrich Bayirli/Kammer
  2014-07-05 13:12 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Taylan Ulrich Bayirli/Kammer @ 2014-07-05 12:36 UTC (permalink / raw)
  To: 17946

Cron jobs may set the LOGNAME environment variable but no USER,
e.g. under Debian 7 (wheezy).  In that case 'guix package' fails to
use $localstatedir/guix/profiles/per-user/$user.  From a quick grep I
couldn't find more places in Guix where USER is used, so here's a
patch that just does it straightforwardly in two places in
scripts/package.scm, but perhaps a more generic solution would be good
for the future.


===File
/home/tub/media/src/guix/0001-Try-LOGNAME-in-addition-to-USER.patch===
From 902267cf99aacaea994cc95b77551f0d2bd35836 Mon Sep 17 00:00:00 2001
From: Taylan Ulrich B <taylanbayirli@gmail.com>
Date: Sat, 5 Jul 2014 15:28:50 +0300
Subject: [PATCH] Try LOGNAME in addition to USER.

Notoriously, cron jobs may set LOGNAME only and not USER.  See
e.g. crontab(5) under Debian 7 (wheezy).

* guix/scripts/package.scm (%profile-directory)
(guix-package): Also try LOGNAME if USER is unset.
---
 guix/scripts/package.scm | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index f930b00..2e626f3 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -59,7 +59,8 @@
 
 (define %profile-directory
   (string-append %state-directory "/profiles/"
-                 (or (and=> (getenv "USER")
+                 (or (and=> (or (getenv "USER")
+                                (getenv "LOGNAME"))
                             (cut string-append "per-user/" <>))
                      "default")))
 
@@ -797,7 +798,9 @@ more information.~%"))
                 %profile-directory)
         (format (current-error-port)
                 (_ "Please change the owner of `~a' to user ~s.~%")
-                %profile-directory (or (getenv "USER") (getuid)))
+                %profile-directory (or (getenv "USER")
+                                       (getenv "LOGNAME")
+                                       (getuid)))
         (rtfm))))
 
   (define (process-actions opts)
-- 
1.8.4

============================================================

Taylan

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#17946: Try LOGNAME in addition to USER
  2014-07-05 12:36 bug#17946: Try LOGNAME in addition to USER Taylan Ulrich Bayirli/Kammer
@ 2014-07-05 13:12 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2014-07-05 13:12 UTC (permalink / raw)
  To: Taylan Ulrich Bayirli/Kammer; +Cc: 17946-done

Taylan Ulrich Bayirli/Kammer <taylanbayirli@gmail.com> skribis:

> Cron jobs may set the LOGNAME environment variable but no USER,
> e.g. under Debian 7 (wheezy).  In that case 'guix package' fails to
> use $localstatedir/guix/profiles/per-user/$user.  From a quick grep I
> couldn't find more places in Guix where USER is used, so here's a
> patch that just does it straightforwardly in two places in
> scripts/package.scm, but perhaps a more generic solution would be good
> for the future.

Good catch.  I agree we’ll need to factorize that eventually.

> From 902267cf99aacaea994cc95b77551f0d2bd35836 Mon Sep 17 00:00:00 2001
> From: Taylan Ulrich B <taylanbayirli@gmail.com>
> Date: Sat, 5 Jul 2014 15:28:50 +0300
> Subject: [PATCH] Try LOGNAME in addition to USER.
>
> Notoriously, cron jobs may set LOGNAME only and not USER.  See
> e.g. crontab(5) under Debian 7 (wheezy).
>
> * guix/scripts/package.scm (%profile-directory)
> (guix-package): Also try LOGNAME if USER is unset.

Pushed after tweaking the commit log.

Thanks!

Ludo’.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-07-05 13:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-05 12:36 bug#17946: Try LOGNAME in addition to USER Taylan Ulrich Bayirli/Kammer
2014-07-05 13:12 ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).