tech-userlevel archive

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

Re: [PATCH] Fix system() behaviour when parameter is NULL



On Wed, Aug 27, 2008 at 09:42:11PM +0100, David Laight wrote:
> On Fri, Aug 22, 2008 at 12:11:39PM +0300, Andy Shevchenko wrote:
> > On Fri, Aug 22, 2008 at 11:18 AM, Ignatios Souvatzis 
> > <is%netbsd.org@localhost> wrote:
> > >> +      * ISO/IEC 9899:1999 in 7.20.4.6 describes this special case.
> > >> +      * We need to check availability of a command interpreter.
> > >> +      */
> > >> +     if (command == NULL) {
> > >> +             if (access(_PATH_BSHELL, R_OK | X_OK) == 0)
> > > assuming we want to do that: shouldn't checking for X_OK be enough?
> > There is a difference between some readable file and executable one.
> > 
> > Actually glibc makes do_system("exit 0") and checks result for 0. I
> > discussed that with my colleagues and we decide to go by above way.
> 
> Well, the "exit 0" version also checks that the shell can be executed!
> eg required dynamic linker, shared libraries, system call support (etc)
> are also present.
> 
> R_OK might be needed if _PATH_BSHELL_ is actually a shell script :-)

Won't it fail when the interpreter is NOT a shell script and only
installed as --x--x--x?

        -is
-- 
seal your e-mail: http://www.gnupg.org/


Home | Main Index | Thread Index | Old Index