why can lstat fail? (was: Re: 1.5.7: nfs-server 2.2.47-2 troubles on XP)

Baurjan Ismagulov ibr@ata.cs.hun.edu.tr
Wed Feb 11 14:24:00 GMT 2004


Hello,

On Wed, Feb 04, 2004 at 04:41:28PM +0100, Baurjan Ismagulov wrote:
> I've installed cygwin snapshot 20030203 and run nfs-server-config. After
> starting the services, I cannot mount a directory with map_static:
> 
> linuxnfsclient:~# mount -o nolock 192.168.0.10:/etc /mnt
> mount: wrong fs type, bad option, bad superblock on 192.168.0.10:/etc,
>        or too many mounted filesystems

1. I haven't received any answer within a week. I would be very grateful
   if anyone having nfs mounts with proper owners and permissions shared
   his setup. Sam?

2. Ethereal shows that mountd authorizes the MOUNT call. After that the
   client calls GETATTR for /etc, which fails with ENOENT. Running
   rpc.nfsd as SYSTEM with -d all -F options reveals that lstat("/etc",
   ...) fails with ENOENT (line 106 of nfsd-SYSTEM.log; confirmed under
   gdb).

   The question: What makes lstat fail?

   Playing with owners and permissions hasn't given any results
   (perm-original.txt and perm-modified.txt).

   I've also seen that nfsd changes the effective user and group ids.
   Trying to reproduce the problem, I've written a.c, which works
   without problems with both original and modified permissions (2113
   corresponds to root. FWIW, it is disabled, which doesn't seem to
   matter). What else in nfsd could make lstat fail?

   I've also tried to run nfsd as a normal user. If I have "Create a
   token object" privilege (I think this was meant with "impersonate
   logged on user" right, mentioned in nfs-server-2.2.47-2.README), the
   daemon does the same, i.e., fails on lstat. If, however, I don't have
   this privilege, the daemon fails to seteuid and allows the client to
   access the filesystem; naturally, one can't write anything due to
   permissions.

Any help would be greatly appreciated. Thank you in advance.

With kind regards,
Baurjan.
-------------- next part --------------
nfsd[1408] 02/12/104 14:35 auth.c 383 : auth_forward_lookup(h1) h1
nfsd[1408] 02/12/104 14:35 auth.c 383 : auth_forward_lookup(h1) h1
nfsd[1408] 02/12/104 14:35 ugid_map.c 328 : h1:/etc map uid rem 0 <-> loc 2113
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044868, 0)
nfsd[1408] 02/12/104 14:35 ugid_map.c 366 : alloc ptr map 0xa045888 @ level 0 (id 0-16777215)
nfsd[1408] 02/12/104 14:35 ugid_map.c 366 : alloc ptr map 0xa045c90 @ level 1 (id 0-65535)
nfsd[1408] 02/12/104 14:35 ugid_map.c 381 : alloc id  map 0xa046098 @ level 2 (id 0-255)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa045c90
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044c70, 2113)
nfsd[1408] 02/12/104 14:35 ugid_map.c 366 : alloc ptr map 0xa0468a0 @ level 0 (id 0-16777215)
nfsd[1408] 02/12/104 14:35 ugid_map.c 366 : alloc ptr map 0xa046ca8 @ level 1 (id 0-65535)
nfsd[1408] 02/12/104 14:35 ugid_map.c 381 : alloc id  map 0xa0470b0 @ level 2 (id 2048-2303)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa046ca8
nfsd[1408] 02/12/104 14:35 ugid_map.c 328 : h1:/etc map uid rem 1 <-> loc 2114
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044868, 1)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa045c90
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044c70, 2114)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa046ca8
nfsd[1408] 02/12/104 14:35 ugid_map.c 328 : h1:/etc map uid rem 2 <-> loc 2115
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044868, 2)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa045c90
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044c70, 2115)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa046ca8
nfsd[1408] 02/12/104 14:35 ugid_map.c 328 : h1:/etc map uid rem 4 <-> loc 2116
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044868, 4)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa045c90
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044c70, 2116)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa046ca8
nfsd[1408] 02/12/104 14:35 ugid_map.c 328 : h1:/etc map uid rem 8 <-> loc 2117
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044868, 8)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa045c90
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044c70, 2117)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa046ca8
nfsd[1408] 02/12/104 14:35 ugid_map.c 328 : h1:/etc map uid rem 12 <-> loc 2118
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044868, 12)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa045c90
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044c70, 2118)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa046ca8
nfsd[1408] 02/12/104 14:35 ugid_map.c 328 : h1:/etc map uid rem 30 <-> loc 2119
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044868, 30)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa045c90
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044c70, 2119)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa046ca8
nfsd[1408] 02/12/104 14:35 ugid_map.c 328 : h1:/etc map uid rem 44 <-> loc 2120
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044868, 44)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa045c90
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044c70, 2120)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa046ca8
nfsd[1408] 02/12/104 14:35 ugid_map.c 328 : h1:/etc map uid rem 65534 <-> loc 2121
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044868, 65534)
nfsd[1408] 02/12/104 14:35 ugid_map.c 381 : alloc id  map 0xa0478b8 @ level 2 (id 65280-65535)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa045c90
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044c70, 2121)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa046ca8
nfsd[1408] 02/12/104 14:35 ugid_map.c 328 : h1:/etc map uid rem 25 <-> loc 2122
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044868, 25)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa045c90
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044c70, 2122)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa046ca8
nfsd[1408] 02/12/104 14:35 ugid_map.c 328 : h1:/etc map uid rem 71 <-> loc 2123
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044868, 71)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa045c90
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044c70, 2123)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa046ca8
nfsd[1408] 02/12/104 14:35 ugid_map.c 328 : h1:/etc map uid rem 51 <-> loc 2124
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044868, 51)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa045c90
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044c70, 2124)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa046ca8
nfsd[1408] 02/12/104 14:35 ugid_map.c 328 : h1:/etc map uid rem 40 <-> loc 2125
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044868, 40)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa045c90
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044c70, 2125)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa046ca8
nfsd[1408] 02/12/104 14:35 ugid_map.c 328 : h1:/etc map uid rem 13 <-> loc 2126
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044868, 13)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa045c90
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044c70, 2126)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa046ca8
nfsd[1408] 02/12/104 14:35 ugid_map.c 328 : h1:/etc map uid rem 9 <-> loc 2127
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044868, 9)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa045c90
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044c70, 2127)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa046ca8
nfsd[1408] 02/12/104 14:35 ugid_map.c 328 : h1:/etc map uid rem 10 <-> loc 2128
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044868, 10)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa045c90
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044c70, 2128)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa046ca8
nfsd[1408] 02/12/104 14:35 auth.c 937 : clnt h1 exports:
nfsd[1408] 02/12/104 14:35 auth.c 939 : 	/etc                
nfsd[1408] 02/12/104 14:35 auth.c 947 : 		options: rw noroot portck
nfsd[1408] 02/12/104 14:35 fh.c 965 : fh_find: psi=205f... not found
nfsd[1408] 02/12/104 14:35 logging.c 202 : getattr [1 70/1/17 08:21:26 saissan 0.0+0]
nfsd[1408] 02/12/104 14:35 logging.c 204 : 	0000205f 900fd
nfsd[1408] 02/12/104 14:35 fh.c 965 : fh_find: psi=205f... not found
nfsd[1408] 02/12/104 14:35 fh.c 1012 : fh_find: created new handle a044038 (path `/etc' psi 0000205f)
nfsd[1408] 02/12/104 14:35 auth_clnt.c 95 : auth_path(/etc): mount point /etc, (root_squash secure rw)
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa044868, 0)
nfsd[1408] 02/12/104 14:35 ugid_map.c 397 : 	result = 0xa045c90
nfsd[1408] 02/12/104 14:35 ugid_map.c 265 : luid(192.168.0.1, 0) = 2113
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa045078, 0)
nfsd[1408] 02/12/104 14:35 ugid_map.c 285 : lgid(192.168.0.1, 0) = 513
nfsd[1408] 02/12/104 14:35 ugid_map.c 356 : ugid_get_entry(0xa045078, 0)
nfsd[1408] 02/12/104 14:35 ugid_map.c 285 : lgid(192.168.0.1, 0) = 513
nfsd[1408] 02/12/104 14:35 getattr.c 74 : getattr(/etc): failed!  errno=2
nfsd[1408] 02/12/104 14:35 nfs_dispatch.c 166 : result: 2
nfsd[1408] 02/12/104 14:35 fh.c 899 : fh_find: psi=205f... found '/etc', fd=-1
nfsd[1408] 02/12/104 14:35 logging.c 202 : getattr [1 70/1/17 08:21:26 saissan 0.0+0]
nfsd[1408] 02/12/104 14:35 logging.c 204 : 	/etc
nfsd[1408] 02/12/104 14:35 fh.c 899 : fh_find: psi=205f... found '/etc', fd=-1
nfsd[1408] 02/12/104 14:35 fh.c 923 : fh_find: stale fh: lstat: m
nfsd[1408] 02/12/104 14:35 fh.c 951 : fh_find: delete cached handle
nfsd[1408] 02/12/104 14:35 fh.c 279 : fh_delete: deleting handle a044038 ('/etc', fd=-1)
nfsd[1408] 02/12/104 14:35 fh.c 965 : fh_find: psi=205f... not found
nfsd[1408] 02/12/104 14:35 nfs_dispatch.c 166 : result: 70
-------------- next part --------------
drwxrwx---+   8 ibr      Users           0 Feb 12 13:55 //
drwxrwx---+   6 ibr      Users           0 Feb 12 14:35 /etc/
# file: /
# owner: ibr
# group: Users
user::rwx
group::rwx
group:root:rwx
group:SYSTEM:rwx
mask:rwx
other:---
default:user::rwx
default:group:root:rwx
default:group:SYSTEM:rwx
default:group:Users:rwx
default:mask:rwx

# file: /etc
# owner: ibr
# group: Users
user::rwx
group::rwx
group:root:rwx
group:SYSTEM:rwx
mask:rwx
other:---
default:user::rwx
default:group:root:rwx
default:group:SYSTEM:rwx
default:group:Users:rwx
default:mask:rwx
-------------- next part --------------
drwxr-xr-x+   8 root     groot           0 Feb 12 13:55 //
drwxr-xr-x+   6 root     groot           0 Feb 12 14:35 /etc/
# file: /
# owner: root
# group: groot
user::rwx
group::r-x
mask:rwx
other:r-x
default:user::rwx
default:group::r-x
default:other:r-x

# file: /etc
# owner: root
# group: groot
user::rwx
group::r-x
mask:rwx
other:r-x
default:user::rwx
default:group::r-x
default:other:r-x
-------------- next part --------------
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

void dump()
{
	struct stat s;

	printf("uid: %d, euid: %d, gid: %d, egid: %d\n"
	       "getting file status...\n",
	       getuid(), geteuid(), getgid(), getegid());
	if (lstat("/etc", &s) == -1) {
		perror("lstat");
		exit(2);
	}
	printf("dev: %x, ino: %lld, mode: %04o\n"
	       "nlink: %d, uid: %d, gid: %d\n"
	       "rdev: %x, size: %ld, blksize: %d, blocks: %d\n"
	       "atime: %ld, mtime: %ld, ctime: %ld\n",
	       s.st_dev, s.st_ino, s.st_mode,
	       s.st_nlink, s.st_uid, s.st_gid,
	       s.st_rdev, s.st_size, s.st_blksize, s.st_blocks,
	       s.st_atime, s.st_mtime, s.st_ctime);
}

int main()
{
	dump();
	printf("changing effective user id...\n");
	if (seteuid(2113) == -1) {
		perror("seteuid");
		exit(2);
	}
	dump();
	return 0;
}

-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list