Re: dash test -w oddities

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Today I encountered some oddities using `test -w` as well as `[ -w`.  
> The machine in question is an NFS-root (exported and mounted read-only) 
> server running Ubuntu 8.04 LTS.

important: you *are* root, right?

Some time ago i wanted to rewrite `test`, but due to "`dash` is in
Ubuntu upstream" answer. i've stopped.

So, here it is, naive replacement of access() syscall (with crutches from
GPLed `bash`). I've asked why it's needed and why euidaccess() from glibc
wasn't used, especially in case of selinux stuff. But it seems, like
`dash` fork of `ash` is just in bug-fixing mode.

#/bin/cc
/*
 * Similar to what access(2) does, but uses the effective uid and gid.
 * Doesn't make the mistake of telling root that any file is executable.
 * Returns non-zero if the file is accessible.
 */
static int
test_st_mode(const struct stat64 *st, int mode)
{
        int euid = geteuid();

        if (euid == 0) {
	/* Root can read or write any file. */
                if (mode != X_OK)
                        return 1;
[....]
#cc_end

In case you have no `man` page:
olecom@flower:~$ grep euidaccess </usr/include/unistd.h
extern int euidaccess (__const char *__name, int __type)
olecom@flower:~$

[]
> There are two major products that come out of Berkeley: LSD and UNIX. We 
> don't believe this to be a coincidence.
> Jeremy S. Anderson

LSD && BSD actually :)
____
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux