I got a couple of requests for a function which isn't support on Linux so far. Also not supportable, i.e., cannot be emulated at userlevel. It has some history in other systems (QNX I think), though, and helps with some security issues. It really not adding much new functionality and I hope I got it right with my "monkey see, monkey do" technique of looking up other places doing similar things. The syscall I mean is int flink (int fd, const char *newname) Similar to link(), but the first parameter is a file decsriptor. Using the file descriptor helps to avoid races in some situation. Look at this code bit (this is constructed and just a little test case): #include #define EE(a,x) {int e = a;if (e!=x)printf("%s = %d (%m)\n", #a, errno);} #define E(a) EE(a,0) int main() { printf("uid = %d, euid = %d, gid = %d, egid = %d\n", getuid(), geteuid(), getgid(), getegid()); E(setfsuid(getuid())); E(setfsgid(getgid())); char buf[] = "aaXXXXXX"; int fd = mkstemp (buf); EE(setfsuid(0),getuid()); EE(setfsgid(0),getgid()); E(fchown(fd,48,48)); E(setfsuid(getuid())); E(setfsgid(getgid())); E(syscall(268,fd,"aa")); E(unlink(buf)); return 0; } This is for a SUID/SGID root application. A temporary file is created carefully using the permissions of the user running the program. If the syscall 268 (flink) line would be link(buf,"aa) instead, somebody with limited priviledges could in theory have unlinked the temporary file and created a new one. With flink() this isn't possible. And the best is: the unlink() line can be moved right below the mkstemp() call. This means no temporary files are around if something goes wrong before the unlink(). (For me this is at least as important as the security issue, it simplifies temp file handling and reduces the number of bugs == leftover fiels). The patch itself is very minimal. The impact on the link() syscall is not measurable and the extra code for sys_flink is only a few bytes. Is this acceptable? Shall I add more syscall definitions for platforms != x86 (I'd think the port maintainers want to do this themselves)? -- --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `---------------------------