add O_MAYEXEC support for CLIP OS, zero cost otherwise
cf. https://lwn.net/Articles/768819/
This commit is contained in:
		
							
								
								
									
										4
									
								
								exec.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								exec.c
									
									
									
									
									
								
							| @@ -23,7 +23,7 @@ | |||||||
|  |  | ||||||
| #include "sh.h" | #include "sh.h" | ||||||
|  |  | ||||||
| __RCSID("$MirOS: src/bin/mksh/exec.c,v 1.202 2018/10/07 01:10:11 tg Exp $"); | __RCSID("$MirOS: src/bin/mksh/exec.c,v 1.203 2018/10/30 17:10:14 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" | ||||||
| @@ -886,7 +886,7 @@ scriptexec(struct op *tp, const char **ap) | |||||||
| 	*tp->args-- = tp->str; | 	*tp->args-- = tp->str; | ||||||
|  |  | ||||||
| #ifndef MKSH_SMALL | #ifndef MKSH_SMALL | ||||||
| 	if ((fd = binopen2(tp->str, O_RDONLY)) >= 0) { | 	if ((fd = binopen2(tp->str, O_RDONLY | O_MAYEXEC)) >= 0) { | ||||||
| 		unsigned char *cp; | 		unsigned char *cp; | ||||||
| #ifndef MKSH_EBCDIC | #ifndef MKSH_EBCDIC | ||||||
| 		unsigned short m; | 		unsigned short m; | ||||||
|   | |||||||
							
								
								
									
										6
									
								
								main.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								main.c
									
									
									
									
									
								
							| @@ -34,7 +34,7 @@ | |||||||
| #include <locale.h> | #include <locale.h> | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| __RCSID("$MirOS: src/bin/mksh/main.c,v 1.349 2018/05/08 17:37:36 tg Exp $"); | __RCSID("$MirOS: src/bin/mksh/main.c,v 1.350 2018/10/30 17:10:15 tg Exp $"); | ||||||
|  |  | ||||||
| #ifndef MKSHRC_PATH | #ifndef MKSHRC_PATH | ||||||
| #define MKSHRC_PATH	"~/.mkshrc" | #define MKSHRC_PATH	"~/.mkshrc" | ||||||
| @@ -513,7 +513,7 @@ main_init(int argc, const char *argv[], Source **sp, struct block **lp) | |||||||
| #else | #else | ||||||
| 		s->file = argv[argi++]; | 		s->file = argv[argi++]; | ||||||
| #endif | #endif | ||||||
| 		s->u.shf = shf_open(s->file, O_RDONLY, 0, | 		s->u.shf = shf_open(s->file, O_RDONLY | O_MAYEXEC, 0, | ||||||
| 		    SHF_MAPHI | SHF_CLEXEC); | 		    SHF_MAPHI | SHF_CLEXEC); | ||||||
| 		if (s->u.shf == NULL) { | 		if (s->u.shf == NULL) { | ||||||
| 			shl_stdout_ok = false; | 			shl_stdout_ok = false; | ||||||
| @@ -713,7 +713,7 @@ include(const char *name, int argc, const char **argv, bool intr_ok) | |||||||
| 	volatile int old_argc; | 	volatile int old_argc; | ||||||
| 	int i; | 	int i; | ||||||
|  |  | ||||||
| 	shf = shf_open(name, O_RDONLY, 0, SHF_MAPHI | SHF_CLEXEC); | 	shf = shf_open(name, O_RDONLY | O_MAYEXEC, 0, SHF_MAPHI | SHF_CLEXEC); | ||||||
| 	if (shf == NULL) | 	if (shf == NULL) | ||||||
| 		return (-1); | 		return (-1); | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										6
									
								
								sh.h
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								sh.h
									
									
									
									
									
								
							| @@ -182,7 +182,7 @@ | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifdef EXTERN | #ifdef EXTERN | ||||||
| __RCSID("$MirOS: src/bin/mksh/sh.h,v 1.866 2018/10/20 18:45:58 tg Exp $"); | __RCSID("$MirOS: src/bin/mksh/sh.h,v 1.867 2018/10/30 17:10:16 tg Exp $"); | ||||||
| #endif | #endif | ||||||
| #define MKSH_VERSION "R56 2018/10/20" | #define MKSH_VERSION "R56 2018/10/20" | ||||||
|  |  | ||||||
| @@ -491,6 +491,10 @@ extern int __cdecl setegid(gid_t); | |||||||
| #define O_BINARY	0 | #define O_BINARY	0 | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | #ifndef O_MAYEXEC | ||||||
|  | #define O_MAYEXEC	0 | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #ifdef MKSH__NO_SYMLINK | #ifdef MKSH__NO_SYMLINK | ||||||
| #undef S_ISLNK | #undef S_ISLNK | ||||||
| #define S_ISLNK(m)	(/* CONSTCOND */ 0) | #define S_ISLNK(m)	(/* CONSTCOND */ 0) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user