Subject: Re: sunos emulation...
To: Theo Deraadt <deraadt@fsa.ca>
From: None <lm@CS.Stanford.EDU>
List: port-sparc
Date: 11/27/1993 10:59:20
A good place to check out low level details is in strace(1),
a reimplementation of Sun's trace program.  I dunno how the
auther got his information but Sun has never challenged it.

This is what it does for exportfs (more info past this):

int
sys_exportfs(tcp)
struct tcb *tcp;
{
        struct export e;
        int i;

        if (entering(tcp)) {
                (void)printstr(tcp->pid, tcp->u_args[0], -1);
                if (umove(tcp->pid, tcp->u_args[1], sizeof e, (char *)&e) < 0) {
                        tprintf("%#x", tcp->u_args[1]);
                        return 0;
                }
                tprintf("{fl:%u, anon:%u, ", e.ex_flags, e.ex_anon);
                printxval(ex_auth_flags, e.ex_auth, "AUTH_???");
                tprintf(", roots:[");
                if (e.ex_auth == AUTH_UNIX) {
                        for (i=0; i<e.ex_u.exunix.rootaddrs.naddrs; i++) {
                                printsock(tcp->pid,
					(int)&e.ex_u.exunix.rootaddrs.addrvec[i]);
                        }
                        tprintf("], writers:[");
                        for (i=0; i<e.ex_writeaddrs.naddrs; i++) {
                                printsock(tcp->pid,
                                        (int)&e.ex_writeaddrs.addrvec[i]);
                        }
                        tprintf("]");
                } else {
                        for (i=0; i<e.ex_u.exdes.nnames; i++) {
                                printsock(tcp->pid,
                                        (int)&e.ex_u.exdes.rootnames[i]);
                                tprintf(", ");
                        }
                        tprintf("], window:%u", e.ex_u.exdes.window);
                }
                tprintf("}");
        }
        return 0;
}


OK, and the struct export (nfs/export.h):
/*
 * The export information passed to exportfs()
 */
struct export {
        int ex_flags;           /* flags */
        unsigned  ex_anon;      /* uid for unauthenticated requests */
        int ex_auth;    /* switch */
        union {
                struct unixexport exunix;       /* case AUTH_UNIX */
                struct desexport exdes;         /* case AUTH_DES */
        } ex_u;
        struct exaddrlist ex_writeaddrs;
};
#define ex_des ex_u.exdes
#define ex_unix ex_u.exunix

And the output from strace on my machine:

....
exportfs("/home"{fl:0, anon:65534, AUTH_UNIX, roots:[], writers:[]}) = 0

So, exportfs(2), is setting up the permissions for the exported file
systems.  It looks like it is passing a bunch of gunk down to the
kernel, gunk that is parsed from the /etc/exports file, and then used
for permission checking.

I would not bother with AUTH_DES, it is not known to work well.
I'm not sure you need to bother with this at all, my 4.4 BSD system
is sucessfully exportign file systems, can you rip off that code
or is that a no-no?

------------------------------------------------------------------------------