search for: oldcwd_fd

Displaying 1 result from an estimated 1 matches for "oldcwd_fd".

2007 Oct 18
0
[PATCH] Use a control socket directory to restrict access
...g to a running tinc daemon. + * Connecting is a bit tricky - we authenticate the server by ensuring + * the socket is in a directory only root can traverse. To do this in + * a race-free manner, we chdir() there temporarily, check permissions, + * and connect with a relative path. + */ + + int oldcwd_fd = -1; + char *controlsocketbasename = controlsocketname; + char *lastslash = strrchr(controlsocketname, '/'); + if(lastslash != NULL) { + /* it's not in our current cwd; need to chdir */ + if((oldcwd_fd = open(".", O_RDONLY)) < 0) { + fprintf(stderr, _("Unable to o...