[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Problem stat-ing nfs directories (atd and nfs mounted var partition, part 2)



Hello.


As some of might have read about a week ago, I thought I had a problem with
atd and it's pid file.

After recompiling at and hacking a little I've discovered that the problem is
in at or perhaps with nfs.

You see, stat-ing a file in a directory that is only readable for root from
a program that is setuid root, that is on a nfs mounted partition fails.

If you didn't follow me in that last sentence, I understand you, so here is
an example:

In the appended program, make sure that FILE_IN_LOCAL_UNREAD_AND_UNEXEC_DIR
points to a LOCAL file that is in a directory which is only readable for root.
Likewise, make sure that FILE_IN_NFS_UNREAD_AND_UNEXEC_DIR points to a file
that is in a partition that is NFS MOUNTED that is in a directory which is
only readable for root (/var/spool/cron/atjobs/.SEQ is perfect if you have
it NFS mounted).

Compile the program ("gcc -o st st.c"), "chown daemon.daemon st" and "chmod
u+s st". Then run it as an ordinaty user.

At me it is like this (/boot is a local directory and /var is nfs mounted):
kant# ls -al /boot/no
total 2
drwx------   2 daemon   daemon       1024 Sep 22 00:54 .
drwxr-xr-x   4 root     root         1024 Sep 22 00:52 ..
-rw-------   1 daemon   daemon          0 Sep 22 00:54 a
kant# ls -la /var/spool/cron/atjobs/
total 6
drwx------   2 daemon   daemon       1024 Sep 22 00:58 .
drwxr-xr-x   5 root     root         1024 Feb 19  1997 ..
-rw-------   1 daemon   daemon          6 Sep 22 00:42 .SEQ
[Some other files (jobs) removed.]

Running this program as an ordinary user (NOT root) I get:
kant:/var/tmp> ./st
stat("/boot/no/a" successful.
stat("/var/spool/cron/.SEQ" unsuccessful.


Now I hope somebody can test this and report if they have the same problem.
Then there's the question: what's wrong? Is it a nfs problem? Can anybody
tell me?


Wrong,

							MartinS

----- Start of st.c -----
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>

#define FILE_IN_LOCAL_UNREAD_AND_UNEXEC_DIR "/boot/no/a"
#define FILE_IN_NFS_UNREAD_AND_UNEXEC_DIR "/var/spool/cron/.SEQ"

main(void)
{
  struct stat statbuf;

  if(stat(FILE_IN_LOCAL_UNREAD_AND_UNEXEC_DIR, &statbuf) == 0
     )
  {
    fprintf(stderr, "stat(\"" FILE_IN_LOCAL_UNREAD_AND_UNEXEC_DIR "\" successfu\
l.\n");
  }
  else
  {
    fprintf(stderr, "stat(\"" FILE_IN_LOCAL_UNREAD_AND_UNEXEC_DIR "\" unsuccess\
ful.\n");
  }

  if(stat(FILE_IN_NFS_UNREAD_AND_UNEXEC_DIR, &statbuf) == 0
     )
  {
    fprintf(stderr, "stat(\"" FILE_IN_NFS_UNREAD_AND_UNEXEC_DIR "\" successful.\
\n");
  }
  else
  {
    fprintf(stderr, "stat(\"" FILE_IN_NFS_UNREAD_AND_UNEXEC_DIR "\" unsuccessfu\
l.\n");
  }

  return(0);

}
----- End of st.c -----


--
TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .


Reply to: