bug#27640: Bug-report

2018-10-28 Thread Assaf Gordon

tags 27640 fixed
close 27640
stop

(triaging old bugs)

On 2017-07-10 1:08 p.m., Paul Eggert wrote:
Looking at that test's source code, the test was clearly incorrect for 
Unix-like systems, as it incorrectly assumed a 1-1 mapping between user 
names and user IDs. I fixed that in Gnulib by installing the attached 
patch.


Pushed to gnulib here:

https://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=24605b2f03bfa8367a9149835c687c9073aacc2c

So closing as "fixed".

-assaf





bug#27640: Bug-report

2017-07-10 Thread Paul Eggert
Looking at that test's source code, the test was clearly incorrect for 
Unix-like systems, as it incorrectly assumed a 1-1 mapping between user 
names and user IDs. I fixed that in Gnulib by installing the attached 
patch. Wolfgang, could you please try this on your Linux from Scratch 
system? You can do that by downloading these two files:


http://git.savannah.gnu.org/cgit/gnulib.git/plain/tests/test-getlogin.c
http://git.savannah.gnu.org/cgit/gnulib.git/plain/tests/test-getlogin_r.c

Use the first to replace the existing test-getlogin.c in your coreutils 
source directory, and put the second next to the first.


>From 237ea098c82e141713964931f96a37fa6d6cda12 Mon Sep 17 00:00:00 2001
From: Paul Eggert 
Date: Mon, 10 Jul 2017 11:56:48 -0700
Subject: [PATCH] =?UTF-8?q?getlogin:=20don=E2=80=99t=20assume=20one=20name?=
 =?UTF-8?q?=20per=20uid?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Problem reported by Wolfgang F. Muthmann (Bug#27640).
* modules/getlogin-tests (Files): Add tests/test-getlogin_r.c.
(ttyname): Remove test.
* modules/getlogin_r-tests (ttyname): Remove test.
* tests/test-getlogin.c: Replace this near-clone of test-getlogin_r.c
with ‘#define TEST_LOGIN’ followed by ‘#include "test-getlogin_r.c"’.
* tests/test-getlogin_r.c: If TEST_GETLOGIN is defined, test
getlogin rather than getlogin_r.  This avoids code duplication.
(main): Use isatty and fstat rather than ttyname and stat.
Use getpwnam instead of getpwuid, to be portable to test platforms
that have multiple login names for the same uid.
---
 ChangeLog|  15 +++
 modules/getlogin-tests   |   2 +-
 modules/getlogin_r-tests |   1 -
 tests/test-getlogin.c| 112 +--
 tests/test-getlogin_r.c  |  35 +--
 5 files changed, 39 insertions(+), 126 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index af99a9c..e5bfb7e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2017-07-10  Paul Eggert  
+
+	getlogin: don’t assume one name per uid
+	Problem reported by Wolfgang F. Muthmann (Bug#27640).
+	* modules/getlogin-tests (Files): Add tests/test-getlogin_r.c.
+	(ttyname): Remove test.
+	* modules/getlogin_r-tests (ttyname): Remove test.
+	* tests/test-getlogin.c: Replace this near-clone of test-getlogin_r.c
+	with ‘#define TEST_LOGIN’ followed by ‘#include "test-getlogin_r.c"’.
+	* tests/test-getlogin_r.c: If TEST_GETLOGIN is defined, test
+	getlogin rather than getlogin_r.  This avoids code duplication.
+	(main): Use isatty and fstat rather than ttyname and stat.
+	Use getpwnam instead of getpwuid, to be portable to test platforms
+	that have multiple login names for the same uid.
+
 2017-07-10  Tim Rühsen  
 Bruno Haible  
 
diff --git a/modules/getlogin-tests b/modules/getlogin-tests
index c8cdb05..d7d6aea 100644
--- a/modules/getlogin-tests
+++ b/modules/getlogin-tests
@@ -1,12 +1,12 @@
 Files:
 tests/test-getlogin.c
+tests/test-getlogin_r.c
 tests/signature.h
 tests/macros.h
 
 Depends-on:
 
 configure.ac:
-AC_CHECK_FUNCS_ONCE([ttyname])
 
 Makefile.am:
 TESTS += test-getlogin
diff --git a/modules/getlogin_r-tests b/modules/getlogin_r-tests
index 868b1b6..845658f 100644
--- a/modules/getlogin_r-tests
+++ b/modules/getlogin_r-tests
@@ -6,7 +6,6 @@ tests/macros.h
 Depends-on:
 
 configure.ac:
-AC_CHECK_FUNCS_ONCE([ttyname])
 
 Makefile.am:
 TESTS += test-getlogin_r
diff --git a/tests/test-getlogin.c b/tests/test-getlogin.c
index 86b2a9e..6a6d269 100644
--- a/tests/test-getlogin.c
+++ b/tests/test-getlogin.c
@@ -1,110 +1,2 @@
-/* Test of getting user name.
-   Copyright (C) 2010-2017 Free Software Foundation, Inc.
-
-   This program is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 3 of the License, or
-   (at your option) any later version.
-
-   This program is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program.  If not, see .  */
-
-/* Written by Bruno Haible , 2010.  */
-
-#include 
-
-#include 
-
-#include "signature.h"
-SIGNATURE_CHECK (getlogin, char *, (void));
-
-#include 
-#include 
-#include 
-#include 
-#include 
-#if !((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__)
-# include 
-#endif
-
-#include 
-#include 
-
-#include "macros.h"
-
-int
-main (void)
-{
-  char *buf;
-
-  /* Test value.  */
-  buf = getlogin ();
-  if (buf == NULL)
-{
-  if (errno == ENOENT)
-{
-  /* This can happen on GNU/Linux.  */
-  fprintf 

bug#27640: Bug-report

2017-07-10 Thread Bruno Haible
Regarding https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27640 :

Hello Wolfgang,

What type of system is this? You are saying "Linux From Scratch version 8.0".
What type of libc is it using? There are several competing ones [1].

> > FAIL: test-getlogin
> > ===
> > 
> > test-getlogin.c:92: assertion 'strcmp (pwd->pw_name, buf) == 0' failed
> > FAIL test-getlogin (exit status: 134)

Please run the 'test-getlogin' program with ltrace (or, alternatively,
insert printf statements that show what's going on). I get (in a regular
login, or with sudo):

$ ltrace ./test-getlogin
__libc_start_main(0x400b46, 1, 0x7ffef8724a78, 0x403db0 
getlogin()  
 = "bruno"
ttyname(0)  
 = "/dev/pts/13"
__xstat(1, "/dev/pts/13", 0x7ffef87248f0)   
 = 0
getpwuid(1000, 0x7ffef87248f0, 0x7ffef87248f0, 0x7f3d50d1abb5)  
 = 0x7f3d50feadc0
strcmp("bruno", "bruno")
 = 0
+++ exited (status 0) +++

What are the results for you?

What else, that affects the operation of getlogin(), ttyname(), getpwuid(),
could be special in your environment?

Bruno

[1] http://www.etalabs.net/compare_libcs.html






bug#27640: Bug-report

2017-07-10 Thread Pádraig Brady
On 10/07/17 00:46, Wolfgang F. Muthmann wrote:
> FAIL: test-getlogin
> ===
> 
> test-getlogin.c:92: assertion 'strcmp (pwd->pw_name, buf) == 0' failed
> FAIL test-getlogin (exit status: 134)

Forwarding to gnulib

thanks,
Pádraig





bug#27640: Bug-report

2017-07-10 Thread Wolfgang F. Muthmann
Hi, I just encountered the following report during generation of Linux
>From Scratch version 8.0 :
doing: "make RUN_EXPENSIVE_TESTS=yes check"


Testsuite summary for GNU coreutils 8.26

# TOTAL: 311
# PASS:  276
# SKIP:  34
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0

See gnulib-tests/test-suite.log
Please report to bug-coreutils@gnu.org


=
   GNU coreutils 8.26: gnulib-tests/test-suite.log
=

# TOTAL: 311
# PASS:  276
# SKIP:  34
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0

.. contents:: :depth: 2

SKIP: test-set-mode-acl.sh
==

+ test 0 = 0
+ echo 'Skipping test: insufficient ACL support'
Skipping test: insufficient ACL support
+ exit 77
SKIP test-set-mode-acl.sh (exit status: 77)

SKIP: test-set-mode-acl-1.sh


+ test 0 = 0
+ echo 'Skipping test: insufficient ACL support'
Skipping test: insufficient ACL support
+ exit 77
SKIP test-set-mode-acl-1.sh (exit status: 77)

SKIP: test-set-mode-acl-2.sh


+ test 0 = 0
+ echo 'Skipping test: insufficient ACL support'
Skipping test: insufficient ACL support
+ exit 77
SKIP test-set-mode-acl-2.sh (exit status: 77)

SKIP: test-copy-acl.sh
==

+ test 0 = 0
+ echo 'Skipping test: insufficient ACL support'
Skipping test: insufficient ACL support
+ exit 77
SKIP test-copy-acl.sh (exit status: 77)

SKIP: test-copy-acl-1.sh


+ test 0 = 0
+ echo 'Skipping test: insufficient ACL support'
Skipping test: insufficient ACL support
+ exit 77
SKIP test-copy-acl-1.sh (exit status: 77)

SKIP: test-copy-acl-2.sh


+ test 0 = 0
+ echo 'Skipping test: insufficient ACL support'
Skipping test: insufficient ACL support
+ exit 77
SKIP test-copy-acl-2.sh (exit status: 77)

SKIP: test-btowc1.sh


Skipping test: no traditional french locale is installed
SKIP test-btowc1.sh (exit status: 77)

SKIP: test-btowc2.sh


Skipping test: no french Unicode locale is installed
SKIP test-btowc2.sh (exit status: 77)

SKIP: test-file-has-acl.sh
==

+ test 0 = 0
+ echo 'Skipping test: insufficient ACL support'
Skipping test: insufficient ACL support
+ exit 77
SKIP test-file-has-acl.sh (exit status: 77)

SKIP: test-file-has-acl-1.sh


+ test 0 = 0
+ echo 'Skipping test: insufficient ACL support'
Skipping test: insufficient ACL support
+ exit 77
SKIP test-file-has-acl-1.sh (exit status: 77)

SKIP: test-file-has-acl-2.sh


+ test 0 = 0
+ echo 'Skipping test: insufficient ACL support'
Skipping test: insufficient ACL support
+ exit 77
SKIP test-file-has-acl-2.sh (exit status: 77)

FAIL: test-getlogin
===

test-getlogin.c:92: assertion 'strcmp (pwd->pw_name, buf) == 0' failed
FAIL test-getlogin (exit status: 134)

SKIP: test-mbrtowc1.sh
==

Skipping test: no traditional french locale is installed
SKIP test-mbrtowc1.sh (exit status: 77)

SKIP: test-mbrtowc2.sh
==

Skipping test: no french Unicode locale is installed
SKIP test-mbrtowc2.sh (exit status: 77)

SKIP: test-mbrtowc3.sh
==

Skipping test: no traditional japanese locale is installed
SKIP test-mbrtowc3.sh (exit status: 77)

SKIP: test-mbrtowc4.sh
==

Skipping test: no transitional chinese locale is installed
SKIP test-mbrtowc4.sh (exit status: 77)

SKIP: test-mbrtowc-w32-1.sh
===

Skipping test: not a native Windows system
SKIP test-mbrtowc-w32-1.sh (exit status: 77)

SKIP: test-mbrtowc-w32-2.sh
===

Skipping test: not a native Windows system
SKIP test-mbrtowc-w32-2.sh (exit status: 77)

SKIP: test-mbrtowc-w32-3.sh
===

Skipping test: not a native Windows system
SKIP test-mbrtowc-w32-3.sh (exit status: 77)

SKIP: test-mbrtowc-w32-4.sh
===

Skipping test: not a native Windows system
SKIP test-mbrtowc-w32-4.sh (exit status: 77)

SKIP: test-mbrtowc-w32-5.sh
===

Skipping test: not a native Windows system
SKIP test-mbrtowc-w32-5.sh (exit status: 77)

SKIP: test-mbscasecmp.sh


Skipping test: no turkish Unicode locale is installed
SKIP test-mbscasecmp.sh (exit status: 77)

SKIP: test-mbsinit.sh
=

Skipping test: no french Unicode locale is installed
SKIP test-mbsinit.sh (exit status: 77)

SKIP: