a bit more careful, even if probably unnecessary

This commit is contained in:
tg 2015-10-09 15:28:20 +00:00
parent eb9050b8f8
commit 59e7366036

12
exec.c
View File

@ -3,7 +3,7 @@
/*- /*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, * Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
* 2011, 2012, 2013, 2014, 2015 * 2011, 2012, 2013, 2014, 2015
* mirabilos <tg@mirbsd.org> * mirabilos <m@mirbsd.org>
* *
* Provided that these terms and disclaimer and all copyright notices * Provided that these terms and disclaimer and all copyright notices
* are retained or reproduced in an accompanying document, permission * are retained or reproduced in an accompanying document, permission
@ -23,7 +23,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.163 2015/09/06 19:46:59 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/exec.c,v 1.164 2015/10/09 15:28:20 tg Exp $");
#ifndef MKSH_DEFAULT_EXECSHELL #ifndef MKSH_DEFAULT_EXECSHELL
#define MKSH_DEFAULT_EXECSHELL MKSH_UNIXROOT "/bin/sh" #define MKSH_DEFAULT_EXECSHELL MKSH_UNIXROOT "/bin/sh"
@ -1266,9 +1266,13 @@ search_access(const char *fn, int mode)
/* file does not exist */ /* file does not exist */
return (ENOENT); return (ENOENT);
/* LINTED use of access */ /* LINTED use of access */
if (access(fn, mode) < 0) if (access(fn, mode) < 0) {
/* file exists, but we can't access it */ /* file exists, but we can't access it */
return (errno); int eno;
eno = errno;
return (eno ? eno : EACCES);
}
if (mode == X_OK && (!S_ISREG(sb.st_mode) || if (mode == X_OK && (!S_ISREG(sb.st_mode) ||
!(sb.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH)))) !(sb.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH))))
/* access(2) may say root can execute everything */ /* access(2) may say root can execute everything */