[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Creating directories with sticky bit set
From: |
Dave Rutherford |
Subject: |
Re: Creating directories with sticky bit set |
Date: |
Fri, 13 Mar 2009 11:40:58 -0400 |
On Fri, Mar 13, 2009 at 9:30 AM, Greg Wooledge <wooledg@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