Re: [PATCH 2/5] daemon: if one of the standard fds is missing open it to /dev/null

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Morten Welinder <mwelinder@xxxxxxxxx> wrote:
> >+               if (devnull == -1 &&
> >+                       (devnull = open("/dev/null", O_RDWR, 0)) == -1)
> >+                       die("open /dev/null failed: %s", strerror(errno));
> >+               if (dup2(devnull, i) != i)
> >+                       die("dup2 failed: %s", strerror(errno));
> 
> "die" probably won't work well at this point.
At least with --syslog there will be an error message in the logs.
If the user does not use --syslog and closes fd 2 it is just his own
fault imho.

> Should git (and most other programs) do something like this in general?
> fprintf will happily write to fd=2 regardless of whether that is some critical
> file you opened.
I thought of that too.  It might be not that important because I
cannot think of anyway that this could happen accidentally or could be
exploited.
-
: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]