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 599753 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.
reproducer
reproducer.c (text/plain), 2.53 KB, created by
Michal Hlavinka
on 2012-07-23 10:51:40 UTC
(
hide
)
Description:
reproducer
Filename:
MIME Type:
Creator:
Michal Hlavinka
Created:
2012-07-23 10:51:40 UTC
Size:
2.53 KB
patch
obsolete
>#include <stdio.h> >#include <unistd.h> >#include <sys/types.h> >#include <sys/stat.h> >#include <sys/wait.h> >#include <spawn.h> >#include <signal.h> >#include <fcntl.h> >#include <string.h> >/* if it uses fork() why bother? */ >#undef fork >#define NOTE(a) fprintf(stderr,"%s\n",a) >pid_t fork (void) { NOTE("uses fork()"); return -1; } >pid_t _fork (void) { NOTE("uses _fork()"); return -1; } >pid_t __fork (void) { NOTE("uses __fork()"); return -1; } >int >main(argc, argv) >int argc; >char** argv; >{ > char* s; > pid_t pid; > posix_spawnattr_t attr; > int n; > int status; > char* cmd[3]; > char tmp[1024]; > if (argv[1]) > _exit(signal(SIGHUP, SIG_DFL) != SIG_IGN); > signal(SIGHUP, SIG_IGN); > if (posix_spawnattr_init(&attr)) > { > NOTE("posix_spawnattr_init() FAILED"); > _exit(0); > } > if (posix_spawnattr_setpgroup(&attr, 0)) > { > NOTE("posix_spawnattr_setpgroup() FAILED"); > _exit(0); > } > if (posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETPGROUP)) > { > NOTE("posix_spawnattr_setflags() FAILED"); > _exit(0); > } > /* first try an a.out and verify that SIGHUP is ignored */ > cmd[0] = argv[0]; > cmd[1] = "test"; > cmd[2] = 0; > if (posix_spawn(&pid, cmd[0], 0, &attr, cmd, 0)) > { > NOTE("posix_spawn() FAILED"); > _exit(0); > } > status = 1; > if (wait(&status) < 0) > { > NOTE("wait() FAILED"); > _exit(0); > } > if (status != 0) > { > NOTE("SIGHUP ignored in parent not ignored in child"); > _exit(0); > } > /* must return exec-type errors or its useless to us *unless* there is no [v]fork() */ > n = strlen(cmd[0]); > if (n >= (sizeof(tmp) - 3)) > { > NOTE("test executable path too long"); > _exit(0); > } > strcpy(tmp, cmd[0]); > tmp[n] = '.'; > tmp[n+1] = 's'; > tmp[n+2] = 'h'; > tmp[n+3] = 0; > if ((n = open(tmp, O_CREAT|O_WRONLY, S_IRWXU|S_IRWXG|S_IRWXO)) < 0 || > chmod(tmp, S_IRWXU|S_IRWXG|S_IRWXO) < 0 || > write(n, "exit 99\n", 8) != 8 || > close(n) < 0) > { > NOTE("test script create FAILED"); > _exit(0); > } > cmd[0] = tmp; > n = 0; /* 0 means reject */ > pid = -1; > if (posix_spawn(&pid, cmd[0], 0, &attr, cmd, 0)) > n = 2; /* ENOEXEC produces posix_spawn() error => BEST */ > else if (pid == -1) > NOTE("ENOEXEC returns pid == -1"); > else if (wait(&status) != pid) > NOTE("ENOEXEC produces no child process"); > else if (!WIFEXITED(status)) > NOTE("ENOEXEC produces signal exit"); > else > { > status = WEXITSTATUS(status); > if (status == 127) > { > NOTE("ENOEXEC produces exist status 127 => GOOD"); > n = 1; /* ENOEXEC produces exit status 127 => GOOD */ > } > else if (status == 99) > NOTE("ENOEXEC invokes sh"); > else if (status == 0) > NOTE("ENOEXEC reports no error"); > } > _exit(n); >} >
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 Raw
Actions:
View
Attachments on
bug 842280
: 599753 |
602562