Andrej Filipcic
2011-Aug-09 13:16 UTC
[Lustre-discuss] inconsistent client behavior when creating an empty directory
Hi, the following code does not work as expected: --------- #include <sys/stat.h> #include <errno.h> #include <stdio.h> int main(int argc, char** argv) { int rc; rc=mkdir(argv[1],S_IRWXU); if(rc) perror("failed create dir"); chown(argv[1],4103,4100); struct stat buf; /* stat(argv[1],&buf); */ setresuid(0,4103,4100); rc=mkdir(argv[1],S_IRWXU); if(rc) perror("failed create dir as user"); } --------- initial status: # ls -ld /lustre/test drwxr-xr-x 2 root root 4096 Aug 9 14:59 /lustre/test # ls -l /lustre/test total 0 1) running the test program: # /tmp/test /lustre/test/testdir failed create dir as user: Permission denied # ls -l /lustre/test total 4 drwx------ 2 griduser03 grid 4096 Aug 9 15:02 testdir griduser03, grid correspond to uid=4103,gid=4100 2) running the test program, but with uncommented stat call: # /tmp/test /lustre/test/testdir failed create dir as user: File exists # ls -l /lustre/test total 4 drwx------ 2 griduser03 grid 4096 Aug 9 15:04 testdir The code first makes the testdir as root and changes the ownership to uid 4103. Then it tries to (re)create the same dir with the user privileges. If "stat" is called, the code behaves as expected (case 2), but if not (case 1), the second mkdir should return EEXIST and not EACCES. Is this behavior expected or is it a client bug? The client runs lustre 1.8.6. The code just illustrates, what is actually used in a complex software. Andrej -- _____________________________________________________________ prof. dr. Andrej Filipcic, E-mail: Andrej.Filipcic at ijs.si Department of Experimental High Energy Physics - F9 Jozef Stefan Institute, Jamova 39, P.o.Box 3000 SI-1001 Ljubljana, Slovenia Tel.: +386-1-477-3674 Fax: +386-1-477-3166 -------------------------------------------------------------
Kevin Van Maren
2011-Aug-09 16:14 UTC
[Lustre-discuss] inconsistent client behavior when creating an empty directory
This appears to be the same issue as https://bugzilla.lustre.org/show_bug.cgi?id=23459 Kevin Andrej Filipcic wrote:> Hi, > > the following code does not work as expected: > --------- > #include <sys/stat.h> > #include <errno.h> > #include <stdio.h> > > int main(int argc, char** argv) { > > int rc; > rc=mkdir(argv[1],S_IRWXU); > if(rc) perror("failed create dir"); > chown(argv[1],4103,4100); > > struct stat buf; > /* stat(argv[1],&buf); */ > > setresuid(0,4103,4100); > rc=mkdir(argv[1],S_IRWXU); > if(rc) perror("failed create dir as user"); > } > --------- > > initial status: > > # ls -ld /lustre/test > drwxr-xr-x 2 root root 4096 Aug 9 14:59 /lustre/test > # ls -l /lustre/test > total 0 > > 1) running the test program: > > # /tmp/test /lustre/test/testdir > failed create dir as user: Permission denied > # ls -l /lustre/test > total 4 > drwx------ 2 griduser03 grid 4096 Aug 9 15:02 testdir > > griduser03, grid correspond to uid=4103,gid=4100 > > > 2) running the test program, but with uncommented stat call: > # /tmp/test /lustre/test/testdir > failed create dir as user: File exists > # ls -l /lustre/test > total 4 > drwx------ 2 griduser03 grid 4096 Aug 9 15:04 testdir > > > The code first makes the testdir as root and changes the ownership to uid 4103. > Then it tries to (re)create the same dir with the user privileges. > > If "stat" is called, the code behaves as expected (case 2), but if not (case > 1), the second mkdir should return EEXIST and not EACCES. Is this behavior > expected or is it a client bug? The client runs lustre 1.8.6. > > The code just illustrates, what is actually used in a complex software. > > Andrej > >