Hi,
I'm trying to write a function in C that I can load into postgres,
that basically removes a file from the system (quite unsafe thought, but
it'll be suitable for me here):
#include <postgres.h>
#include <stdio.h>
bool file_remove(text *this)
{ if (remove((char *)this) == 0) return (true); else return (false);
}
I compile it and link as instructed for Solaris (where the backend
runs), and load it with:
CREATE FUNCTION file_remove(text) RETURNS bool AS '/path/file_remove.so'
LANGUAGE 'c';
But it always returns false when I try to remove something. I'm sure
that I'm trying to remove files that the the backend's user owns (have
write access). If I try to make any changes on this code (eg.: the
casts...), when I try to use it the backends terminates abnormally. Does someone can give me a clue?
Thanks,
Igor.