{"thread":{"id":"37754","subject":"[PATCH] t1304: Set LOGNAME even if USER is unset or null","startedAt":"2014-10-17T21:39:00Z","lastAt":"2014-10-20T18:34:23Z","messageCount":4,"participants":["W. Trevor King","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"250802","messageId":"12975d1f2b5b1cd4cc6052b829bf4814300a7ffd.1413581788.git.wking@tremily.us","threadId":"37754","inReplyTo":null,"subject":"[PATCH] t1304: Set LOGNAME even if USER is unset or null","fromName":"W. Trevor King","fromEmail":"wking@tremily.us","sentAt":"2014-10-17T21:39:00Z","receivedAt":"2014-10-17T21:39:00Z","isPatch":true,"sender":{"key":"wking@tremily.us","avatar":"https://avatars.githubusercontent.com/u/209920?v=4"},"body":"Avoid:\n\n  # ./t1304-default-acl.sh\n  ok 1 - checking for a working acl setup\n  ok 2 - Setup test repo\n  not ok 3 - Objects creation does not break ACLs with restrictive umask\n  #\n  #               # SHA1 for empty blob\n  #               check_perms_and_acl .git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391\n  #\n  not ok 4 - git gc does not break ACLs with restrictive umask\n  #\n  #               git gc &&\n  #               check_perms_and_acl .git/objects/pack/*.pack\n  #\n  # failed 2 among 4 test(s)\n  1..4\n\non systems where USER isn't set.  It's usually set by the login\nprocess, but it isn't set when launching some Docker images.  For\nexample:\n\n  $ docker run --rm debian env\n  HOME=/\n  PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin\n  HOSTNAME=b2dfdfe797ed\n\n'id -u -n' has been in POSIX from Issue 2 through 2013 [1], so I don't\nexpect compatibility issues.\n\n[1]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/id.html\n\nSigned-off-by: W. Trevor King <wking@tremily.us>\n---\nThe patch is based on the current maint branch.\n\nPrevious LOGNAME discussion:\n\n* Michael Gruber on 2011-05-06 suggesting a discussing a whoami\n  fallback [1] (but whoami isn't POSIX).\n* René Scharfe on 2011-10-14 suggesting USER as a fallback for\n  LOGNAME [2].\n* Matthieu Moy on 2012-09-17 suggesting dropping $LOGNAME in\n  favor of numerical user IDs 'id -u' for a system with multiple\n  usernames sharing the same user ID [3].\n\nObviously, you can work around the problem with:\n\n  # USER=$(id -u -n) ./t1304-default-acl.sh\n\nso the question is really \"Are empty-USER systems worth supporting out\nof the box?\".\n\nCheers,\nTrevor\n\n[1]: http://thread.gmane.org/gmane.comp.version-control.git/172883/focus=172961\n[2]: http://thread.gmane.org/gmane.comp.version-control.git/183586\n[3]: http://thread.gmane.org/gmane.comp.version-control.git/205690/focus=205703\n\n t/t1304-default-acl.sh | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/t/t1304-default-acl.sh b/t/t1304-default-acl.sh\nindex 79045ab..f5422f1 100755\n--- a/t/t1304-default-acl.sh\n+++ b/t/t1304-default-acl.sh\n@@ -26,7 +26,7 @@ test_expect_success 'checking for a working acl setup' '\n \n if test -z \"$LOGNAME\"\n then\n-\tLOGNAME=$USER\n+\tLOGNAME=\"${USER:-$(id -u -n)}\"\n fi\n \n check_perms_and_acl () {\n-- \n2.1.0.60.g85f0837\n"},{"id":"250837","messageId":"xmqqegu3r7y7.fsf@gitster.dls.corp.google.com","threadId":"37754","inReplyTo":"12975d1f2b5b1cd4cc6052b829bf4814300a7ffd.1413581788.git.wking@tremily.us","subject":"Re: [PATCH] t1304: Set LOGNAME even if USER is unset or null","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-10-19T22:49:36Z","receivedAt":"2014-10-19T22:49:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"W. Trevor King\" <wking@tremily.us> writes:\n\n> Previous LOGNAME discussion:\n>\n> * Michael Gruber on 2011-05-06 suggesting a discussing a whoami\n>   fallback [1] (but whoami isn't POSIX).\n> * René Scharfe on 2011-10-14 suggesting USER as a fallback for\n>   LOGNAME [2].\n> * Matthieu Moy on 2012-09-17 suggesting dropping $LOGNAME in\n>   favor of numerical user IDs 'id -u' for a system with multiple\n>   usernames sharing the same user ID [3].\n>\n> Obviously, you can work around the problem with:\n>\n>   # USER=$(id -u -n) ./t1304-default-acl.sh\n>\n> so the question is really \"Are empty-USER systems worth supporting out\n> of the box?\".\n>\n> Cheers,\n> Trevor\n>\n> [1]: http://thread.gmane.org/gmane.comp.version-control.git/172883/focus=172961\n> [2]: http://thread.gmane.org/gmane.comp.version-control.git/183586\n> [3]: http://thread.gmane.org/gmane.comp.version-control.git/205690/focus=205703\n>\n>  t/t1304-default-acl.sh | 2 +-\n>  1 file changed, 1 insertion(+), 1 deletion(-)\n>\n> diff --git a/t/t1304-default-acl.sh b/t/t1304-default-acl.sh\n> index 79045ab..f5422f1 100755\n> --- a/t/t1304-default-acl.sh\n> +++ b/t/t1304-default-acl.sh\n> @@ -26,7 +26,7 @@ test_expect_success 'checking for a working acl setup' '\n>  \n>  if test -z \"$LOGNAME\"\n>  then\n> -\tLOGNAME=$USER\n> +\tLOGNAME=\"${USER:-$(id -u -n)}\"\n\nI'll queue this as-is, but it makes me wonder if we want to do this\nwithout if/then/fi, e.g.\n\n\t: ${LOGNAME:=${USER:-$(id -u -n)}\n\nSpelling everything out with if/then/fi is obviously at the other\nextreme, i.e.\n\n\tif test -z \"$LOGNAME\"\n\tthen\n\t\tif test -n \"$USER\"\n                then\n\t\t\tLOGNAME=$USER\n\t\telse\n\t\t\tLOGNAME=$(id -u -n)\n\t\tfi\n\tfi\n\nbut it probably is a very bad idea.\n\n\nMore importantly, what if none of the alternatives work?  I\npersonally feel it is OK to punt and declare test_done early,\ninstead of giving false positive breakages like you saw without this\npatch.\n"},{"id":"250857","messageId":"20141020152809.GR17200@odin.tremily.us","threadId":"37754","inReplyTo":"xmqqegu3r7y7.fsf@gitster.dls.corp.google.com","subject":"Re: [PATCH] t1304: Set LOGNAME even if USER is unset or null","fromName":"W. Trevor King","fromEmail":"wking@tremily.us","sentAt":"2014-10-20T15:28:09Z","receivedAt":"2014-10-20T15:28:09Z","isPatch":true,"sender":{"key":"wking@tremily.us","avatar":"https://avatars.githubusercontent.com/u/209920?v=4"},"body":"On Sun, Oct 19, 2014 at 03:49:36PM -0700, Junio C Hamano wrote:\n> I'll queue this as-is, but it makes me wonder if we want to do this\n> without if/then/fi, e.g.\n> \n> \t: ${LOGNAME:=${USER:-$(id -u -n)}\n\nI'm fine with that too.\n\n> Spelling everything out with if/then/fi is obviously at the other\n> extreme, i.e.\n\nAnd I'm fine with this ;).\n\n> More importantly, what if none of the alternatives work?  I\n> personally feel it is OK to punt and declare test_done early,\n> instead of giving false positive breakages like you saw without this\n> patch.\n\nI can put this into a v2 if you like.  Which conditional syntax do you\nprefer?\n\nCheers,\nTrevor\n\n-- \nThis email may be signed or encrypted with GnuPG (http://www.gnupg.org).\nFor more information, see http://en.wikipedia.org/wiki/Pretty_Good_Privacy\n"},{"id":"250866","messageId":"xmqqk33u380g.fsf@gitster.dls.corp.google.com","threadId":"37754","inReplyTo":"20141020152809.GR17200@odin.tremily.us","subject":"Re: [PATCH] t1304: Set LOGNAME even if USER is unset or null","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-10-20T18:34:23Z","receivedAt":"2014-10-20T18:34:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"W. Trevor King\" <wking@tremily.us> writes:\n\n> On Sun, Oct 19, 2014 at 03:49:36PM -0700, Junio C Hamano wrote:\n>> I'll queue this as-is, but it makes me wonder if we want to do this\n>> without if/then/fi, e.g.\n>> \n>> \t: ${LOGNAME:=${USER:-$(id -u -n)}\n>\n> I'm fine with that too.\n>\n>> Spelling everything out with if/then/fi is obviously at the other\n>> extreme, i.e.\n>\n> And I'm fine with this ;).\n>\n>> More importantly, what if none of the alternatives work?  I\n>> personally feel it is OK to punt and declare test_done early,\n>> instead of giving false positive breakages like you saw without this\n>> patch.\n>\n> I can put this into a v2 if you like.  Which conditional syntax do you\n> prefer?\n\nProbably\n\n    if test -z \"$LOGNAME\"\n    then\n            LOGNAME=\"${USER:-$(id -u -n)}\"\n    else\n            : cannot test acl operations without a usable user name\n            test_punt!\n    fi\n"}]}