From: fred@cv.ruu.nl (Fred Appelman)
Subject: Re: backup of NFS partitions: acces denied
Date: Mon, 17 Aug 1992 07:05:44 GMT
Organization: University of Utrecht, 3D Computer Vision Research Group

In <kirchhof.3.713982347@ph1.physik.uni-konstanz.de> kirchhof@ph1.physik.uni-konstanz.de (Thomas Kirchhoff) writes:

>I want to do backups using GNU-tar on a Hp720/HPUX8.05 of NFS 
>mounted partitions. This doesn't work. GNU-tar is saying 'bad filenumber' 
>whenit is told to read read-protected files. I created on both HP's a userid
>'backup' with uid=0 and primary groupid=3. So this should mean that i can 
>read any file on the NFS-mounted partition, shouldn't it ?
>The rest of the user and group id's are not the same on both machines.
>So how am I supposed to do backups via NFS ?
>
>thomas.

The userid '0' is automatically mapped to userID NOBODY which has standard
the value of -2. There are two methods to fix this. You should first ask 
yourselve if you really want to backup over NFS. If you care about 
performance you shouldn't. 

Solution 1 (using NFS):
	You have to change the userid of the user 'nobody'  from -2 to 0.
	The script below will do this for you. There are some security
	riscs (so I have been told) when you map the user nobody 
	from -2 to 0, but I don't know which.
#! /bin/sh
#---------------------------------------------------------------------------
#	PATCHKERNEL	??-???-??	Fred Appelman	<fred@cv.ruu.nl>
#	rootnfs-1.0	18-Jan-90	Edwin Kremer	<edwin@cs.ruu.nl>
#
#	rootnfs		- enable/disable root permission over NFS by
#			  setting the kernel variable "_nobody" to
#			  0 or -2 respectively.
#
#---------------------------------------------------------------------------
PATH='/bin:/usr/bin:/etc:/usr/etc'			; export PATH
PROG=`basename $0`
#---------------------------------------------------------------------------
UNIX='/hp-ux'				# specify where your UNIX kernel is
ADB_OPT='-w'				# open kernel for writing
ADB_CMD='W'				# write a four-byte value in decimal
#---------------------------------------------------------------------------

DoMemory()
{
	echo "nobody/${ADB_CMD}${NOBODY}" |
	adb ${ADB_OPT} ${UNIX} /dev/kmem |
	Display 'MEMORY'
}

DoDisk()
{
	echo "nobody?${ADB_CMD}${NOBODY}" |
	adb ${ADB_OPT} ${UNIX} - |
	Display 'DISK'
}

Display()
{
	while read line
	do
		echo "$1-> $line"
	done
}
Usage()
{
	echo "Usage: ${PROG}  deny|allow|inspect  memory|disk|both"
	exit 1
}

if [ $# -ne 2 ]
then
	Usage
fi

case $1 in
	deny)
		NOBODY='-2'
		;;
	allow)
		NOBODY='0'
		;;
	inspect)
		NOBODY=''		# no need to assign a value
		ADB_OPT=''		# no need to open kernel for writing
		ADB_CMD='D'		# print a four-byte value in decimal
		;;
	*)
		Usage
		;;
esac

case $2 in
	memory)
		DoMemory
		;;
	disk)
		DoDisk
		;;
	both)
		DoMemory
		DoDisk
		;;
	*)
		Usage
		;;
esac

exit 0

Solution 2 (not using NFS):
	Run a remote backup on the NFS exporting host. Start this from
	the host that has the tapeunit. The following script is what
	I use myself. It runs on a host called 'odin', and backups
	disks from three other hosts. You have to setup .rhosts file
	to use this. This script is ofcourse just an example and
	needs editing.

#!/bin/sh
#
#	datbackup - start backup on prisma, triton and wodan from 
#                   odin.

HOST=`hostname`
if [ $HOST != odin ]
then
	echo Must be run on odin
	exit 1;
fi

echo `date` Start triton
remsh triton gnutar cblfz 100 odin:/dev/rmt/0mn /Userspace1
echo `date` Start wodan
remsh wodan gnutar cblfz 100 odin:/dev/rmt/0mn /Userspace1
echo `date` Start prisma
remsh prisma gnutar cblfz 100 odin:/dev/rmt/0m /Userspace1
echo `date` Done



-- 
Fred J.R. Appelman, 3D Computer Vision, Utrecht University
AZU, Heidelberglaan 100, 3584 CX Utrecht, The Netherlands.
Telephone: +31-30-506710 Fax: +31-30-513399
e-mail: fred@cv.ruu.nl or appelman@cs.unc.edu

Newsgroups: comp.sys.hp,comp.windows.x.motif