Displaying 2 results from an estimated 2 matches for "wedgelock".
2016 Apr 13
3
[PATCH libguestfs] launch: Implement a safer getumask.
The current implementation of getumask involves writing a file with
mode 0777 and then testing what mode was created by the kernel. This
doesn't work properly if the user set a per-mount umask (or fmask/
dmask).
This alternative method was suggested by Josh Stone. By forking, we
can use the thread-unsafe method (calling umask) and pass the result
back over a pipe.
This change also fixes
2016 Apr 13
0
Re: [PATCH libguestfs] launch: Implement a safer getumask.
...}
> + if (pid == 0) {
> + /* The child process must ONLY call async-safe functions. */
> + close (fd[0]);
> +
> + mask = umask (0);
> + if (mask == -1) {
> + perror ("umask");
perror() is NOT async-safe (it manipulates stdio, and could permanently
wedgelock the child if you happened to fork() while some other thread
was also using stdio). Safe error reporting in a fork()d child is
basically impossible; the best you can do is write() something back to
the parent and let the parent do the error reporting. :(
> + _exit (EXIT_FAILURE);
> +...