<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#ffffff" text="#000000">
Does anyone know if this is going to be fixed in CentOS ?<br>
<br>
// test case code below
<br>
// expected behaviour is "all good" and a return code of zero.
<br>
// this works on 2.6.35-1
<br>
// does not work on 2.6.18-194.17.4.el5 from Centos 5.5
<br>
<br>
// think this bug was fixed in git commit
8948e11f450e6189a79e47d6051c3d5a0b98e3f3
<br>
// around 2.6.22
<br>
// <a class="moz-txt-link-freetext"
href="http://www.mail-archive.com/git-commits-head@vger.kernel.org/msg11654.html">http://www.mail-archive.com/git-commits-head@vger.kernel.org/msg11654.html</a>
<br>
<br>
<br>
#include <fcntl.h>
<br>
#include <stdio.h>
<br>
#include <sys/stat.h>
<br>
#include <sys/types.h>
<br>
#include <unistd.h>
<br>
<br>
int main(int argc, char** argv)
<br>
{
<br>
int fd = open("foo", O_RDONLY);
<br>
if (setuid(1000))
<br>
{
<br>
printf("could not setuid, run as root with correct uid\n");
<br>
return 1;
<br>
}
<br>
<br>
char proc_name[1024];
<br>
<br>
sprintf(proc_name, "<i class="moz-txt-slash"><span
class="moz-txt-tag">/</span>proc/self/fd<span
class="moz-txt-tag">/</span></i>%d", fd);
<br>
struct stat stat_buf;
<br>
<br>
int rc = stat(proc_name, &stat_buf);
<br>
<br>
if (rc == 0)
<br>
{
<br>
printf("all good\n");
<br>
}
<br>
else
<br>
{
<br>
printf("busted, could not access %s\n", proc_name);
<br>
}
<br>
<br>
return rc;
<br>
}
</body>
</html>