From: edwin@cs.ruu.nl (Edwin Kremer)
Newsgroups: comp.sys.hp
Subject: Re: NFS and root
Keywords: NFS root access
Date: 11 Apr 92 22:32:53 GMT
Organization: Utrecht University, Dept. of Computer Science

In <1992Apr10.203600.4759@ux1.cso.uiuc.edu> chlg1043@uxa.cso.uiuc.edu
(Christopher H Lee) writes:

   | I heard that one can patch up the kernel to allow root to 
   | access mounted file systems as 'root' and not 'nobody'.
   | 
   | Has anyone tried doing this, and if so, what is the
   | procedure?

I've written a shell script (or actually Fred Appelman started it and I made
a couple of changes) -- here is it in a SHAR-archive.
______________________________________________________________________________
# This is a shell archive.  Remove anything before this line,
# then unpack it by saving it in a file and typing "sh file".
#
# Wrapped by Edwin Kremer <edwin@cs.ruu.nl> on Sun Apr 12 00:30:07 1992
#
# This archive contains:
#	rootnfs	
#
# Existing files will not be overwritten.
# Error checking via wc(1) will be performed.

LANG=""; export LANG
PATH=/bin:/usr/bin:$PATH; export PATH

if test -f rootnfs
then
	echo Ok to overwrite existing file rootnfs\?
	read answer
	case "$answer" in
	[yY]*)	echo Proceeding;;
	*)	echo Aborting; exit 1;;
	esac
	rm -f rootnfs
	if test -f rootnfs
	then
		echo Error: could not remove rootnfs, aborting
		exit 1
	fi
fi
echo x - rootnfs
cat >rootnfs <<'@EOF'
#! /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
@EOF
set `wc -lwc <rootnfs`
if test $1$2$3 != 841841523
then
	echo ERROR: wc results of rootnfs are $* should be 84 184 1523
fi

chmod 700 rootnfs

exit 0



-- 
Edwin Kremer, systems and network administrator.  [NIC-Whois handle: EHK3]
     Department of Computer Science,  Utrecht University,  The Netherlands
     Email: edwin@cs.ruu.nl                NeXT-mail: edwin@edge.cs.ruu.nl
Newsgroups: comp.sys.hp