On Fri, Mar 13, 2009 at 9:30 AM, Greg Wooledge <wool...@eeg.ccf.org> wrote:
> This still doesn't address the original poster's concerns if, for
> example, a web browser creates a new ~/.browserconf directory the first
> time it's invoked.  But nothing bash can do will solve that.

True, but what about a wrapper?

--- sticky.c
#include <dlfcn.h>
#include <sys/stat.h>
#include <sys/types.h>

int mkdir (const char *path, mode_t mode)
{
    typedef int (*FP_mkdir)(const char *, mode_t);
    FP_mkdir org_mkdir = dlsym(((void *) -1l), "mkdir");
    return org_mkdir(path, mode | S_ISVTX);
}
--- building
$ gcc -fPIC -c -Wall sticky.c -o sticky.o
$ gcc -shared sticky.o -ldl -lstdc++ -o sticky.so
--- running
$ export LD_PRELOAD=$PWD/sticky.so:$LD_PRELOAD
--- for long-term use, add to bash startup files

How portable this is I don't know, but I tested it briefly and it
seems okay; YMMV.

Dave


Reply via email to