Esempio n. 1
0
int main(char **argv, char **environ)
{
    int uid = sys_getuid();
    struct passwd *pw = getpwuid(uid);
    if(pw) {
        printf("%s\n", pw->pw_name);
    } else {
        printf("whoami: no entry found for uid %d in /etc/passwd!\n", uid);
        sys_exit(-1);
    }
    sys_exit(0);
}
NvError NvRm_Dispatch_Others( void *InBuffer, NvU32 InSize, void *OutBuffer, NvU32 OutSize, NvDispatchCtx* Ctx )
{
    NvU32 packid_;
    NvU32 funcid_;
    NvIdlDispatchTable *table_;

    NV_ASSERT( InBuffer );
    NV_ASSERT( OutBuffer );

    packid_ = ((NvU32 *)InBuffer)[0];
    funcid_ = ((NvU32 *)InBuffer)[1];
    table_ = gs_DispatchTable;

    switch (packid_)
    {
        case NvRm_nvrm_init:
            if ( !(s_FuncAllowedInNvrmInitPackage & (1 << funcid_)) )
                goto fail;
            break;
        case NvRm_nvrm_module:
            if ( !(s_FuncAllowedInNvrmModulePackage & (1 << funcid_)) )
                goto fail;
            break;
        case NvRm_nvrm_power:
            if ( !(s_FuncAllowedInNvrmPowerPackage_1 & (1 << funcid_)) )
                goto fail;
            break;
        default:
            goto fail;
    }

    if ( packid_-1 >= NV_ARRAY_SIZE(gs_DispatchTable) ||
         !table_[packid_ - 1].DispFunc )
        return NvError_IoctlFailed;

    return table_[packid_ - 1].DispFunc( funcid_, InBuffer, InSize,
        OutBuffer, OutSize, Ctx );
fail:
    pr_debug("\n\n\n\n*****nvrm dispatch permission error,"
        "packid_=%d, funcid_=%d,uid=%d,gid=%d****\n\n\n\n",
        packid_, funcid_, (int)sys_getuid(), (int)sys_getgid());
    return NvError_IoctlFailed;
}
Esempio n. 3
0
// Look up and return the inode for a path name.
// If parent != 0, return the inode for the parent and copy the final
// path element into name, which must have room for DIRSIZ bytes.
// Must be called inside a transaction since it calls iput().
int permissionCheck(struct inode *ip){
	int uid = sys_getuid();
	if(ip->ownerId == uid){
		return ip->mode>>8;
	}else{
		return ip->mode;