public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/6700] New: utmpname(3) returns interger but man page says void and doesnot returns with failure if file not found.
@ 2008-06-27 11:19 halesh dot s at gmail dot com
2008-06-27 12:37 ` [Bug libc/6700] " halesh dot s at gmail dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: halesh dot s at gmail dot com @ 2008-06-27 11:19 UTC (permalink / raw)
To: glibc-bugs
Hi,
In glibc 2.7 I found, Man page of utmpname(3) says its prototype as...
void utmpname(const char *file);
But if we check the source in login/utmpname.c
int
__utmpname (const char *file)
{
....
....
}
This is conflicting one, so man page needs to be fixed.
And utmpname(3) does not reports failure if the file that we pass and
it does not exists.
The testcase is...
$ ls -l utmp1
ls: utmp1: No such file or directory
$ cat test.c
#include <stdio.h>
#include <utmp.h>
int main()
{
printf("%d\n", utmpname("./utmp1"));
}
$ gcc test.c -o test
$ ./test
0
This intern affecting the other commands like who (1).
$ who ./utmp1
$ echo $?
0
**Even utmp1 file not exists, its exit status is zero.
Fixing the issue in utmp will fix the other dependencies.
Patch to fix the issue
=======================
--- utmpname.c.old 2008-06-24 16:36:27.000000000 +0530
+++ utmpname.c 2008-06-24 16:37:12.000000000 +0530
@@ -21,6 +21,7 @@
#include <stdlib.h>
#include <string.h>
#include <utmp.h>
+#include <sys/stat.h>
#include "utmp-private.h"
@@ -39,6 +40,12 @@
__utmpname (const char *file)
{
int result = -1;
+ struct stat buf;
+
+ if (stat(file, &buf) != 0)
+ {
+ return result;
+ }
__libc_lock_lock (__libc_utmp_lock);
Thanks,
Halesh
--
Summary: utmpname(3) returns interger but man page says void and
doesnot returns with failure if file not found.
Product: glibc
Version: unspecified
Status: NEW
Severity: minor
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: halesh dot s at gmail dot com
CC: glibc-bugs at sources dot redhat dot com
http://sourceware.org/bugzilla/show_bug.cgi?id=6700
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libc/6700] utmpname(3) returns interger but man page says void and doesnot returns with failure if file not found.
2008-06-27 11:19 [Bug libc/6700] New: utmpname(3) returns interger but man page says void and doesnot returns with failure if file not found halesh dot s at gmail dot com
@ 2008-06-27 12:37 ` halesh dot s at gmail dot com
2008-06-28 23:20 ` pasky at suse dot cz
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: halesh dot s at gmail dot com @ 2008-06-27 12:37 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From halesh dot s at gmail dot com 2008-06-27 12:37 -------
Hi Ulrich,
In the link
http://www.gnu.org/software/libtool/manual/libc/Manipulating-the-Database.html
It has mentioned that
"The utmpname function returns a value of 0 if the new name was successfully
stored, and a value of -1 to indicate an error. Note that utmpname does not try
to open the database, and that therefore the return value does not say anything
about whether the database can be successfully opened."
This means utmpname(3) never reports faiure if database doesnot exists.
In readutmp.c of coreutils it has mentioned
"Solaris' utmpname returns 1 upon success -- which is contrary to what the GNU
libc version does. In addition, older GNU libc versions are actually void."
But GNU libc utmpname returns -1 on failure, May it returns differen values on
success I think it does not causes any contrary with Solaris utmpname failure.
Even we did not open database can we include the database existance checking,
Will it causes any effects.
As mentioned above this may resolve who(1) problem, and which helps in
processing other commands based on who(1) o/p.
Thanks,
Halesh
--
http://sourceware.org/bugzilla/show_bug.cgi?id=6700
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libc/6700] utmpname(3) returns interger but man page says void and doesnot returns with failure if file not found.
2008-06-27 11:19 [Bug libc/6700] New: utmpname(3) returns interger but man page says void and doesnot returns with failure if file not found halesh dot s at gmail dot com
2008-06-27 12:37 ` [Bug libc/6700] " halesh dot s at gmail dot com
@ 2008-06-28 23:20 ` pasky at suse dot cz
2008-06-30 7:10 ` halesh dot s at gmail dot com
2008-08-13 4:33 ` drepper at redhat dot com
3 siblings, 0 replies; 5+ messages in thread
From: pasky at suse dot cz @ 2008-06-28 23:20 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From pasky at suse dot cz 2008-06-28 23:19 -------
Note that the manpage does not come from libc but linux-manpages:
http://www.kernel.org/doc/man-pages/
--
http://sourceware.org/bugzilla/show_bug.cgi?id=6700
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libc/6700] utmpname(3) returns interger but man page says void and doesnot returns with failure if file not found.
2008-06-27 11:19 [Bug libc/6700] New: utmpname(3) returns interger but man page says void and doesnot returns with failure if file not found halesh dot s at gmail dot com
2008-06-27 12:37 ` [Bug libc/6700] " halesh dot s at gmail dot com
2008-06-28 23:20 ` pasky at suse dot cz
@ 2008-06-30 7:10 ` halesh dot s at gmail dot com
2008-08-13 4:33 ` drepper at redhat dot com
3 siblings, 0 replies; 5+ messages in thread
From: halesh dot s at gmail dot com @ 2008-06-30 7:10 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From halesh dot s at gmail dot com 2008-06-30 07:10 -------
Thanks Petr Baudis.
I have raised a bug for the manpage after refering your mentione link.
http://bugzilla.kernel.org/show_bug.cgi?id=11011
Can you please verfiy the second part of this defect, about the return value
when file not found?
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |pasky at suse dot cz
http://sourceware.org/bugzilla/show_bug.cgi?id=6700
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug libc/6700] utmpname(3) returns interger but man page says void and doesnot returns with failure if file not found.
2008-06-27 11:19 [Bug libc/6700] New: utmpname(3) returns interger but man page says void and doesnot returns with failure if file not found halesh dot s at gmail dot com
` (2 preceding siblings ...)
2008-06-30 7:10 ` halesh dot s at gmail dot com
@ 2008-08-13 4:33 ` drepper at redhat dot com
3 siblings, 0 replies; 5+ messages in thread
From: drepper at redhat dot com @ 2008-08-13 4:33 UTC (permalink / raw)
To: glibc-bugs
------- Additional Comments From drepper at redhat dot com 2008-08-13 04:31 -------
It makes no sense for utmpname to check whether the file exists. It does not
open the file so the file might not yet exist at the time of the call or it
might disappear before it is actually used. The code is fine.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
http://sourceware.org/bugzilla/show_bug.cgi?id=6700
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-08-13 4:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-27 11:19 [Bug libc/6700] New: utmpname(3) returns interger but man page says void and doesnot returns with failure if file not found halesh dot s at gmail dot com
2008-06-27 12:37 ` [Bug libc/6700] " halesh dot s at gmail dot com
2008-06-28 23:20 ` pasky at suse dot cz
2008-06-30 7:10 ` halesh dot s at gmail dot com
2008-08-13 4:33 ` drepper at redhat dot com
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).