Bug 3259 - Samba didn't notice secrets.tdb was on NFS, and failed
Summary: Samba didn't notice secrets.tdb was on NFS, and failed
Status: RESOLVED WONTFIX
Alias: None
Product: Samba 3.0
Classification: Unclassified
Component: File Services (show other bugs)
Version: 3.0.9
Hardware: All All
: P3 normal
Target Milestone: none
Assignee: Samba Bugzilla Account
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-13 10:03 UTC by David S. Collier-Brown
Modified: 2007-05-19 00:05 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David S. Collier-Brown 2005-11-13 10:03:38 UTC
Wolfgang.Belgardt and Don McCall diagnosed a 
samba problem as secrets.tdb being placed
on an nfs filesystem and rpc.lockd failing.

Andrew Bartlet noted that: "secrets.tdb 
is *not supported* on NFS.  Not only must
locking be coherent, mmap must be as well.  
When I say 'not supported', I mean 'well 
known to break'.  Just don't do it.

Here's a sample program using the open group 
standard statvfs to check for a doubtfull
directory. A return of 0 means "ok",
1- means "we can't do the check" and
any other value indicates a known bad
filesystem.

$ cat mismount.c

/*
 * mismount -- diagnose use of a filesystem type
 *	that will cause Samba to fail
 */
#include <stdio.h>	/* Standard bits. *.
#include <sys/types.h>	/* For statvfs */
#include <sys/statvfs.h>
#include <errno.h>	/* For errno */
#include <string.h>	/* For strerror */

#define GOT_STATVFS 1


int sys_statvfs(const char *path, struct statvfs *buf);
int check_vfstype(char *path, char **prohibited);
void exit(int rc);

 int
main(int argc, char **argv) {
	int	rc;
	char *prohibited[] = {
		"tmpfs",
		"nfs",
		NULL
	};

	if (argc != 2) {
		(void) fprintf(stderr, "Usage: %s directory\n", argv[0]);
		(void) exit(3);
	}
	switch (rc = check_vfstype(argv[1], prohibited)) {
		case 0: 
			(void) fprintf(stderr, "ok\n");
			break;
		case 1: (void) fprintf(stderr, "bad, type=tmpfs\n");
			break;
		case 2: (void) fprintf(stderr, "bad, type=nfs\n");
			break;
		case -1:
		default:  
			(void) fprintf(stderr, "bad, can't tell type, rc=%d\n",rc);
			break;
	}
	(void) exit(rc);
}

/* 
 * check_vfstype -- see if a vfs type is in the prohibited
 *	list. 0 means ok, non-zero means it matched
 *	the N+1th element of the prohibited array, and
 *	-1 means it couldn't tell.
 */
 int
check_vfstype(char *path, char **prohibited) {
	struct statvfs vfsbuf;
	int	rc, i;
	char *p;

	if ((rc = sys_statvfs(path, &vfsbuf)) == 0) {
		(void) fprintf(stderr, "fstype = %s\n",
			vfsbuf.f_basetype);
		for (i=0,p=prohibited[0]; p != NULL; p=prohibited[++i]) {
			if (strcmp(p,vfsbuf.f_basetype) == 0) {
				return i + 1;
			}
		}
		return 0;
	}
	else {
		fprintf(stderr, "Statvfs faied, rc=%d, errno=%d (%s)\n",
			rc, errno, strerror(errno));
		return -1;
	}
}

 int
sys_statvfs(const char *path, struct statvfs *buf) {
#ifdef GOT_STATVFS
	return statvfs(path, buf);
#else
	errno = ENOTSUP;
	return -1;
#endif

$ cat Makefile
all:
	cc -g -o mismount mismount.c
	-mismount .
	-mismount /tmp
Comment 1 James Peach 2007-05-19 00:05:10 UTC
I'm rejecting this on the basic that some NFS implementations do have coherent mmap and locking support (although you can use TDB without mmap support).

There's a lot of filesystems that don't have sufficient locking support for TDB (AFP for example), and I don't think it's practical to enumerate all these. The only thing to do is to suck it and see. If the locking calls fail, then it's not supported :)