Login
Log in using an SSO provider:
Fedora Account System
Red Hat Associate
Red Hat Customer
Login using a Red Hat Bugzilla account
Forgot Password
Create an Account
Red Hat Bugzilla – Attachment 602562 Details for
Bug 842280
posix_spawn() invokes sh when it should not
Home
New
Search
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh92 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
[?]
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Potential fix
glibc-rh842280.patch (text/plain), 8.50 KB, created by
Jeff Law
on 2012-08-06 19:06:42 UTC
(
hide
)
Description:
Potential fix
Filename:
MIME Type:
Creator:
Jeff Law
Created:
2012-08-06 19:06:42 UTC
Size:
8.50 KB
patch
obsolete
>commit d96de9634a334af16c0ac711074c15ac1762b23c >Author: Ulrich Drepper <drepper@gmail.com> >Date: Mon Sep 5 20:24:50 2011 -0400 > > Try shell in posix_spawn* only in compat mode > >diff --git a/posix/spawn.c b/posix/spawn.c >index b93b320..dd68fbd 100644 >--- a/posix/spawn.c >+++ b/posix/spawn.c >@@ -1,4 +1,4 @@ >-/* Copyright (C) 2000 Free Software Foundation, Inc. >+/* Copyright (C) 2000, 2011 Free Software Foundation, Inc. > This file is part of the GNU C Library. > > The GNU C Library is free software; you can redistribute it and/or >@@ -18,14 +18,31 @@ > > #include <spawn.h> > #include "spawn_int.h" >+#include <shlib-compat.h> > > /* Spawn a new process executing PATH with the attributes describes in *ATTRP. > Before running the process perform the actions described in FILE-ACTIONS. */ > int >-posix_spawn (pid_t *pid, const char *path, >- const posix_spawn_file_actions_t *file_actions, >- const posix_spawnattr_t *attrp, char *const argv[], >- char *const envp[]) >+__posix_spawn (pid_t *pid, const char *path, >+ const posix_spawn_file_actions_t *file_actions, >+ const posix_spawnattr_t *attrp, char *const argv[], >+ char *const envp[]) > { > return __spawni (pid, path, file_actions, attrp, argv, envp, 0); > } >+versioned_symbol (libc, __posix_spawn, posix_spawn, GLIBC_2_15); >+ >+ >+#if SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_15) >+int >+attribute_compat_text_section >+__posix_spawn_compat (pid_t *pid, const char *file, >+ const posix_spawn_file_actions_t *file_actions, >+ const posix_spawnattr_t *attrp, char *const argv[], >+ char *const envp[]) >+{ >+ return __spawni (pid, file, file_actions, attrp, argv, envp, >+ SPAWN_XFLAGS_TRY_SHELL); >+} >+compat_symbol (libc, __posix_spawn_compat, posix_spawn, GLIBC_2_2); >+#endif >diff --git a/posix/spawn_int.h b/posix/spawn_int.h >index a3e9347..5609e58 100644 >--- a/posix/spawn_int.h >+++ b/posix/spawn_int.h >@@ -29,10 +29,13 @@ struct __spawn_action > } action; > }; > >+#define SPAWN_XFLAGS_USE_PATH 0x1 >+#define SPAWN_XFLAGS_TRY_SHELL 0x2 >+ > extern int __posix_spawn_file_actions_realloc (posix_spawn_file_actions_t * > file_actions); > > extern int __spawni (pid_t *pid, const char *path, > const posix_spawn_file_actions_t *file_actions, > const posix_spawnattr_t *attrp, char *const argv[], >- char *const envp[], int use_path); >+ char *const envp[], int xflags); >diff --git a/posix/spawni.c b/posix/spawni.c >index c7d5f59..4e5f77f 100644 >--- a/posix/spawni.c >+++ b/posix/spawni.c >@@ -1,5 +1,5 @@ > /* Guts of POSIX spawn interface. Stub version. >- Copyright (C) 2001 Free Software Foundation, Inc. >+ Copyright (C) 2001, 2011 Free Software Foundation, Inc. > This file is part of the GNU C Library. > > The GNU C Library is free software; you can redistribute it and/or >@@ -36,7 +36,7 @@ int > __spawni (pid_t *pid, const char *file, > const posix_spawn_file_actions_t *file_actions, > const posix_spawnattr_t *attrp, char *const argv[], >- char *const envp[], int use_path) >+ char *const envp[], int xflags) > { > __set_errno (ENOSYS); > return -1; >diff --git a/posix/spawnp.c b/posix/spawnp.c >index 2b15391..79886fb 100644 >--- a/posix/spawnp.c >+++ b/posix/spawnp.c >@@ -1,4 +1,4 @@ >-/* Copyright (C) 2000 Free Software Foundation, Inc. >+/* Copyright (C) 2000, 2011 Free Software Foundation, Inc. > This file is part of the GNU C Library. > > The GNU C Library is free software; you can redistribute it and/or >@@ -18,14 +18,32 @@ > > #include <spawn.h> > #include "spawn_int.h" >+#include <shlib-compat.h> > > /* Spawn a new process executing FILE with the attributes describes in *ATTRP. > Before running the process perform the actions described in FILE-ACTIONS. */ > int >-posix_spawnp (pid_t *pid, const char *file, >- const posix_spawn_file_actions_t *file_actions, >- const posix_spawnattr_t *attrp, char *const argv[], >- char *const envp[]) >+__posix_spawnp (pid_t *pid, const char *file, >+ const posix_spawn_file_actions_t *file_actions, >+ const posix_spawnattr_t *attrp, char *const argv[], >+ char *const envp[]) > { >- return __spawni (pid, file, file_actions, attrp, argv, envp, 1); >+ return __spawni (pid, file, file_actions, attrp, argv, envp, >+ SPAWN_XFLAGS_USE_PATH); > } >+versioned_symbol (libc, __posix_spawnp, posix_spawnp, GLIBC_2_15); >+ >+ >+#if SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_15) >+int >+attribute_compat_text_section >+__posix_spawnp_compat (pid_t *pid, const char *file, >+ const posix_spawn_file_actions_t *file_actions, >+ const posix_spawnattr_t *attrp, char *const argv[], >+ char *const envp[]) >+{ >+ return __spawni (pid, file, file_actions, attrp, argv, envp, >+ SPAWN_XFLAGS_USE_PATH | SPAWN_XFLAGS_TRY_SHELL); >+} >+compat_symbol (libc, __posix_spawnp_compat, posix_spawnp, GLIBC_2_2); >+#endif >diff --git a/sysdeps/mach/hurd/spawni.c b/sysdeps/mach/hurd/spawni.c >index 244ca2d..3d2b591 100644 >--- a/sysdeps/mach/hurd/spawni.c >+++ b/sysdeps/mach/hurd/spawni.c >@@ -1,5 +1,5 @@ > /* spawn a new process running an executable. Hurd version. >- Copyright (C) 2001,02,04 Free Software Foundation, Inc. >+ Copyright (C) 2001,02,04,11 Free Software Foundation, Inc. > This file is part of the GNU C Library. > > The GNU C Library is free software; you can redistribute it and/or >@@ -41,7 +41,7 @@ __spawni (pid_t *pid, const char *file, > const posix_spawn_file_actions_t *file_actions, > const posix_spawnattr_t *attrp, > char *const argv[], char *const envp[], >- int use_path) >+ int xflags) > { > pid_t new_pid; > char *path, *p, *name; >@@ -391,7 +391,7 @@ __spawni (pid_t *pid, const char *file, > > /* Make sure the dtable can hold NEWFD. */ > #define EXPAND_DTABLE(newfd) \ >- ({ \ >+ ({ \ > if ((unsigned int)newfd >= dtablesize \ > && newfd < _hurd_rlimits[RLIMIT_OFILE].rlim_cur) \ > { \ >@@ -399,7 +399,7 @@ __spawni (pid_t *pid, const char *file, > NEW_TABLE (dtable, newfd); \ > NEW_TABLE (ulink_dtable, newfd); \ > NEW_TABLE (dtable_cells, newfd); \ >- dtablesize = newfd + 1; \ >+ dtablesize = newfd + 1; \ > } \ > ((unsigned int)newfd < dtablesize ? 0 : EMFILE); \ > }) >@@ -543,7 +543,7 @@ __spawni (pid_t *pid, const char *file, > conditions are diagnosed first and what side effects (file creation, > etc) can be observed before what errors. */ > >- if (! use_path || strchr (file, '/') != NULL) >+ if ((xflags & SPAWN_XFLAGS_USE_PATH) == 0 || strchr (file, '/') != NULL) > /* The FILE parameter is actually a path. */ > err = child_lookup (file, O_EXEC, 0, &execfile); > else >diff --git a/sysdeps/posix/spawni.c b/sysdeps/posix/spawni.c >index f19862f..129edcd 100644 >--- a/sysdeps/posix/spawni.c >+++ b/sysdeps/posix/spawni.c >@@ -28,6 +28,7 @@ > #include "spawn_int.h" > #include <not-cancel.h> > #include <local-setxid.h> >+#include <shlib-compat.h> > > > /* The Unix standard contains a long explanation of the way to signal >@@ -38,6 +39,7 @@ > #define SPAWN_ERROR 127 > > >+#if SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_15) > /* The file is accessible but it is not an executable file. Invoke > the shell to interpret it as a script. */ > static void >@@ -64,6 +66,10 @@ script_execute (const char *file, char *const argv[], char *const envp[]) > __execve (new_argv[0], new_argv, envp); > } > } >+# define tryshell (xflags & SPAWN_XFLAGS_TRY_SHELL) >+#else >+# define tryshell 0 >+#endif > > > /* Spawn a new process executing PATH with the attributes describes in *ATTRP. >@@ -72,7 +78,7 @@ int > __spawni (pid_t *pid, const char *file, > const posix_spawn_file_actions_t *file_actions, > const posix_spawnattr_t *attrp, char *const argv[], >- char *const envp[], int use_path) >+ char *const envp[], int xflags) > { > pid_t new_pid; > char *path, *p, *name; >@@ -226,12 +232,12 @@ __spawni (pid_t *pid, const char *file, > } > } > >- if (! use_path || strchr (file, '/') != NULL) >+ if ((xflags & SPAWN_XFLAGS_USE_PATH) == 0 || strchr (file, '/') != NULL) > { > /* The FILE parameter is actually a path. */ > __execve (file, argv, envp); > >- if (errno == ENOEXEC) >+ if (tryshell && errno == ENOEXEC) > script_execute (file, argv, envp); > > /* Oh, oh. `execve' returns. This is bad. */ >@@ -277,7 +283,7 @@ __spawni (pid_t *pid, const char *file, > /* Try to execute this name. If it works, execv will not return. */ > __execve (startp, argv, envp); > >- if (errno == ENOEXEC) >+ if (tryshell && errno == ENOEXEC) > script_execute (startp, argv, envp); > > switch (errno)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 842280
:
599753
| 602562