This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/6700] New: utmpname(3) returns interger but man page says void and doesnot returns with failure if file not found.
- From: "halesh dot s at gmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 27 Jun 2008 11:18:28 -0000
- Subject: [Bug libc/6700] New: utmpname(3) returns interger but man page says void and doesnot returns with failure if file not found.
- Reply-to: sourceware-bugzilla at sourceware dot org
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.