vnfs: add -i flag to allow remote root

This commit is contained in:
Brian L. Stuart 2008-07-20 04:50:09 -04:00
parent 94e1f2a438
commit d63790eec8
4 changed files with 21 additions and 6 deletions

View file

@ -52,7 +52,7 @@ back up Unix file systems to Venti
.PP .PP
.B vnfs .B vnfs
[ [
.B -ELLRVr .B -ELLRVir
] ]
[ [
.B -a .B -a
@ -277,6 +277,12 @@ file system mentioned in the configuration.
.BI -c " cachesize .BI -c " cachesize
Set the number of blocks stored by the in-memory venti cache. Set the number of blocks stored by the in-memory venti cache.
.TP .TP
.B -i
Run in ``insecure'' mode, allowing remote root users to
use uid and gid 0 and read any file.
(Normally, remote root is mapped to uid and gid \-1
and has no special permissions.)
.TP
.B -r .B -r
Respond to all requests with a Sun RPC rejection. Respond to all requests with a Sun RPC rejection.
This is useful during debugging. This is useful during debugging.

View file

@ -10,6 +10,8 @@
#include <nfs3.h> #include <nfs3.h>
#include "nfs3srv.h" #include "nfs3srv.h"
int insecure = 0;
static SunStatus static SunStatus
authunixunpack(SunRpc *rpc, SunAuthUnix *au) authunixunpack(SunRpc *rpc, SunAuthUnix *au)
{ {
@ -23,10 +25,12 @@ authunixunpack(SunRpc *rpc, SunAuthUnix *au)
ep = p+ai->ndata; ep = p+ai->ndata;
if(sunauthunixunpack(p, ep, &p, au) < 0) if(sunauthunixunpack(p, ep, &p, au) < 0)
return SunGarbageArgs; return SunGarbageArgs;
if(au->uid == 0) if(!insecure){
au->uid = -1; if(au->uid == 0)
if(au->gid == 0) au->uid = -1;
au->gid = -1; if(au->gid == 0)
au->gid = -1;
}
return SunSuccess; return SunSuccess;
} }

View file

@ -9,6 +9,8 @@ Nfs3Status fsreaddir(SunAuthUnix*, Nfs3Handle*, u32int, u64int, uchar**, u32int*
extern void nfs3proc(void*); extern void nfs3proc(void*);
extern void mount3proc(void*); extern void mount3proc(void*);
extern int insecure;
enum enum
{ {
MaxDataSize = 8192 MaxDataSize = 8192

View file

@ -74,7 +74,7 @@ u64int unittoull(char*);
void void
usage(void) usage(void)
{ {
fprint(2, "usage: vnfs [-LLRVr] [-a addr] [-b blocksize] [-c cachesize] configfile\n"); fprint(2, "usage: vnfs [-LLRVir] [-a addr] [-b blocksize] [-c cachesize] configfile\n");
threadexitsall("usage"); threadexitsall("usage");
} }
@ -128,6 +128,9 @@ threadmain(int argc, char **argv)
case 'c': case 'c':
cachesize = unittoull(EARGF(usage())); cachesize = unittoull(EARGF(usage()));
break; break;
case 'i':
insecure = 1;
break;
case 'r': case 'r':
srv->alwaysreject++; srv->alwaysreject++;
break; break;