On 1/4/2019 9:15 AM, Salz, Rich via openssl-users wrote:
>     Jakob - you’re a star! Thanks so much, your suggestion works. So I added
>     </dev/null to now give:
> ...
>     I’m wondering if this would be something worthy of attention in openssl?
>    
> Maybe open an issue to catch this.  Seems like the apps could check and 
> redirect to /dev/null if the FD isn't valid.


All kinds of Bad Stuff will happen if file descriptors {0,1,2} aren't
set up right.  Start with, say, an application opening a database,
getting fd  2 because that happens to be the first available, and then
for some reason writing an error message to stderr.

I'd be shocked if cron starts an application without *something*
reasonable on {0,1,2}.  I'd consider it to be a very serious bug in
cron.  (I can't speak to anything else, but Solaris cron has 0 on
/dev/null and 1 and 2 leading to a temporary file that gets mailed to
the user if non-empty.)

Whether an application should try to cope with such a broken
environment... shrug.  Few if any do.

If you want to, what you want is something like:

        int fd;
        do {
                fd = open("/dev/null", O_RDWR);
        } while (fd < 3);
        close(fd);

(That's strictly not quite right, since it leaves 0 open writable and 1
and 2 open readable, but that's pretty harmless.)

-- 
Jordan Brown, Oracle Solaris

-- 
openssl-users mailing list
To unsubscribe: https://mta.openssl.org/mailman/listinfo/openssl-users

Reply via email to