root access with NFS on ISC 2.2
Conor P. Cahill
cpcahil at virtech.uucp
Thu Dec 20 00:52:12 AEST 1990
In article <1990Dec18.224004.5668 at 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
More information about the Comp.unix.sysv386
mailing list