[comp.unix.sysv386] root access with NFS on ISC 2.2

rick@gtisqr.uucp (Hendrik Groeneveld) (12/19/90)

Hello all,
I have a small problem with accessing files with NFS and ISC.
When I am logged in as root, I cannot access remote files.
Does anybody out there know how I can get root access to files
that are on remotely mounted directories? It's annoying to have 
to rlogin all the time. Please respond via email.
Thanks in advance.

cpcahil@virtech.uucp (Conor P. Cahill) (12/19/90)

In article <1990Dec18.224004.5668@gtisqr.uucp> gtisqr.uucp writes:
>I have a small problem with accessing files with NFS and ISC.
>When I am logged in as root, I cannot access remote files.
>Does anybody out there know how I can get root access to files
>that are on remotely mounted directories? It's annoying to have 

This is the design of NFS.  The only way around it is to set the "nobody"
variable in the kernel to zero (it defaults to a -2).


Here is a program that will enable you to change the nobody variable to 
zero.  We run this at boot time (Yes one could make the change in the
object file itself, but we don't like to change vendor's software).

To use it:  copy rest of file into kernmod.c, make kernmod, and as root
run: kernmod nobody 0.

#include <sys/types.h>
#include <nlist.h>
#include <fcntl.h>
#include <stdio.h>

main(argc,argv)
	int		  argc;
	char		* argv[];
{
	int		  err;
	char		* kernelfile = "/dev/kmem";
	int		  kfd;
	struct nlist	  nl;
	int		  oflags;
	long		  oldvalue;
	int		  setval;
	char		* unixfileptr = "/unix";
	long		  value;

	if( (argc != 2) && (argc != 3) )
	{
		fprintf(stderr,"Usage: %s symbol [value]\n",argv[0]);
		exit(10);
	}

	nl.n_name = argv[1];
	if( argc == 3 )
	{
		value = atoi(argv[2]);
		setval = 1;
		oflags = O_RDWR;
	}
	else
	{
		setval = 0;
		oflags = O_RDONLY;
	}

	err = nlist(unixfileptr,&nl);

	if( (err == -1) || (nl.n_value == 0) )
	{
		fprintf(stderr,"Unable to find symbol '%s' in '%s'\n",
				nl.n_name, unixfileptr);
		exit(10);
	}

	if( (kfd=open(kernelfile,oflags)) == -1)
	{
		fprintf(stderr,"Unable to open '%s'\n", kernelfile);
		exit(40);
	}

	if( lseek(kfd,nl.n_value,0) != nl.n_value)
	{
		fprintf(stderr,"Unable to seek to %s's location\n",nl.n_name);
		exit(50);
	}

	if( read(kfd,(char *) &oldvalue,sizeof(long)) != sizeof(long))
	{
		fprintf(stderr,"Unable to read %s's data\n",nl.n_name);
		exit(60);
	}

	if( ! setval )
	{
		fprintf(stdout,"value of %s is %ld\n", nl.n_name, oldvalue);
		exit(0);
	}

	/* 
	 * Now go change the value to be what we want it to be...
	 */

	if( lseek(kfd,nl.n_value,0) != nl.n_value)
	{
		fprintf(stderr,"Unable to seek to %s's location\n",nl.n_name);
		exit(70);
	}

	if( write(kfd,(char *) &value,sizeof(long)) != sizeof(long))
	{
		fprintf(stderr,"Unable to change %s's data\n",nl.n_name);
		exit(80);
	}

	fprintf(stdout,"Value of %s changed from %ld to %ld\n",
			nl.n_name, oldvalue, value);
	exit(0);
}
-- 
Conor P. Cahill            (703)430-9247        Virtual Technologies, Inc.,
uunet!virtech!cpcahil                           46030 Manekin Plaza, Suite 160
                                                Sterling, VA 22170 

jmd@gtenmc.UUCP (jmd) (01/05/91)

Please summarize for the net but I think that it is not an ISC problem
but just a general behavior of NFS to prevent root having ``universal''
priviledges - note that the user id of files created while ``root'' have
the value 65734 if memory serves me.  modifying files for which your
user id is the same on the server *and* the client machine behaves as
expected *except* for certain operations which I am still trying to
understand (some programs such as those which include the GNU gdbm
library CANNOT successfully create a file).  Not being an NFS expert, but
rather just getting my feet wet could account for any and all inaccuracies
just cited ;-)

pappy