Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
git-mirror
/
glibc
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
0
Security
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security
Insights
Files
e49b221
argp
assert
benchtests
bits
catgets
conf
conform
crypt
csu
ctype
debug
dirent
dlfcn
elf
gmon
gnulib
grp
gshadow
hesiod
hurd
iconv
iconvdata
include
inet
intl
io
libidn
libio
locale
localedata
login
mach
malloc
manual
math
mathvec
misc
nis
nptl
nptl_db
nscd
nss
po
posix
bits
rxspencer
sys
BOOST.tests
Depend
Makefile
PCRE.tests
PTESTS
PTESTS2C.sed
TESTS
TESTS2C.sed
Versions
_exit.c
alarm.c
annexc.c
bsd-getpgrp.c
bug-ga1.c
bug-ga2.c
bug-getopt1.c
bug-getopt2.c
bug-getopt3.c
bug-getopt4.c
bug-getopt5.c
bug-glob1.c
bug-glob2.c
bug-glob3.c
bug-regex1.c
bug-regex10.c
bug-regex11.c
bug-regex12.c
bug-regex13.c
bug-regex14.c
bug-regex15.c
bug-regex16.c
bug-regex17.c
bug-regex18.c
bug-regex19.c
bug-regex2.c
bug-regex20.c
bug-regex21.c
bug-regex22.c
bug-regex23.c
bug-regex24.c
bug-regex25.c
bug-regex26.c
bug-regex27.c
bug-regex28.c
bug-regex29.c
bug-regex3.c
bug-regex30.c
bug-regex31.c
bug-regex31.input
bug-regex32.c
bug-regex33.c
bug-regex34.c
bug-regex35.c
bug-regex36.c
bug-regex4.c
bug-regex5.c
bug-regex6.c
bug-regex7.c
bug-regex8.c
bug-regex9.c
confstr.c
cpio.h
environ.c
execl.c
execle.c
execlp.c
execv.c
execve.c
execvp.c
execvpe.c
fexecve.c
fnmatch.c
fnmatch.h
fnmatch_loop.c
fork.c
fpathconf.c
gai.conf
gai_strerror.c
get_child_max.c
getaddrinfo.c
getconf-speclist.c
getconf.c
getegid.c
geteuid.c
getgid.c
getgroups.c
getopt.c
getopt.h
getopt1.c
getopt_init.c
getopt_int.h
getpgid.c
getpgrp.c
getpid.c
getppid.c
getresgid.c
getresuid.c
getsid.c
getuid.c
glob.c
glob.h
glob64.c
globtest.c
globtest.sh
group_member.c
init-posix.c
nanosleep.c
pathconf.c
pause.c
posix-conf-vars.h
posix-conf-vars.list
posix-envs.def
posix_madvise.c
pread.c
pread64.c
ptestcases.h
pwrite.c
pwrite64.c
re_comp.h
regcomp.c
regex.c
regex.h
regex_internal.c
regex_internal.h
regexbug1.c
regexec.c
runptests.c
runtests.c
sched.h
sched_cpualloc.c
sched_cpucount.c
sched_cpufree.c
sched_getaffinity.c
sched_getp.c
sched_gets.c
sched_primax.c
sched_primin.c
sched_rr_gi.c
sched_setaffinity.c
sched_setp.c
sched_sets.c
sched_yield.c
setgid.c
setpgid.c
setpgrp.c
setresgid.c
setresuid.c
setsid.c
setuid.c
sleep.c
spawn.c
spawn.h
spawn_faction_addclose.c
spawn_faction_adddup2.c
spawn_faction_addopen.c
spawn_faction_destroy.c
spawn_faction_init.c
spawn_int.h
spawn_valid_fd.c
spawnattr_destroy.c
spawnattr_getdefault.c
spawnattr_getflags.c
spawnattr_getpgroup.c
spawnattr_getschedparam.c
spawnattr_getschedpolicy.c
spawnattr_getsigmask.c
spawnattr_init.c
spawnattr_setdefault.c
spawnattr_setflags.c
spawnattr_setpgroup.c
spawnattr_setschedparam.c
spawnattr_setschedpolicy.c
spawnattr_setsigmask.c
spawni.c
spawnp.c
sysconf.c
tar.h
test-vfork.c
testcases.h
testfnm.c
times.c
transbug.c
tst-boost.c
tst-chmod.c
tst-cpucount.c
tst-cpuset.c
tst-dir.c
tst-exec-static.c
tst-exec.c
tst-execl1.c
tst-execl2.c
tst-execle1.c
tst-execle2.c
tst-execlp1.c
tst-execlp2.c
tst-execv1.c
tst-execv2.c
tst-execve1.c
tst-execve2.c
tst-execvp1.c
tst-execvp2.c
tst-execvp3.c
tst-execvp4.c
tst-execvpe1.c
tst-execvpe2.c
tst-execvpe3.c
tst-execvpe4.c
tst-execvpe5.c
tst-execvpe6.c
tst-fnmatch.c
tst-fnmatch.input
tst-fnmatch2.c
tst-fnmatch3.c
tst-fork.c
tst-getaddrinfo.c
tst-getaddrinfo2.c
tst-getaddrinfo3.c
tst-getaddrinfo4.c
tst-getaddrinfo5.c
tst-getconf.sh
tst-getopt_long1.c
tst-gnuglob.c
tst-mmap-offset.c
tst-mmap.c
tst-nanosleep.c
tst-nice.c
tst-pathconf.c
tst-pcre.c
tst-posix_spawn-fd.c
tst-preadwrite.c
tst-preadwrite64.c
tst-regex.c
tst-regex2.c
tst-regexloc.c
tst-rfc3484-2.c
tst-rfc3484-3.c
tst-rfc3484.c
tst-rxspencer-no-utf8.c
tst-rxspencer.c
tst-spawn-static.c
tst-spawn.c
tst-spawn2.c
tst-sysconf.c
tst-truncate.c
tst-truncate64.c
tst-vfork1.c
tst-vfork2.c
tst-vfork3.c
tst-waitid.c
tstgetopt.c
uname-values.h
uname.c
unistd.h
vfork.c
wait.c
wait.h
wait3.c
wait4.c
waitid.c
waitpid.c
wordexp-test.c
wordexp-tst.sh
wordexp.c
wordexp.h
pwd
resolv
resource
rt
scripts
setjmp
shadow
signal
socket
soft-fp
stdio-common
stdlib
streams
string
sunrpc
sysdeps
sysvipc
termios
time
timezone
wcsmbs
wctype
.gitattributes
.gitignore
BUGS
CONFORMANCE
COPYING
COPYING.LIB
ChangeLog
ChangeLog.1
ChangeLog.10
ChangeLog.11
ChangeLog.12
ChangeLog.13
ChangeLog.14
ChangeLog.15
ChangeLog.16
ChangeLog.17
ChangeLog.2
ChangeLog.3
ChangeLog.4
ChangeLog.5
ChangeLog.6
ChangeLog.7
ChangeLog.8
ChangeLog.9
ChangeLog.old-ports
ChangeLog.old-ports-aarch64
ChangeLog.old-ports-aix
ChangeLog.old-ports-alpha
ChangeLog.old-ports-am33
ChangeLog.old-ports-arm
ChangeLog.old-ports-cris
ChangeLog.old-ports-hppa
ChangeLog.old-ports-ia64
ChangeLog.old-ports-linux-generic
ChangeLog.old-ports-m68k
ChangeLog.old-ports-microblaze
ChangeLog.old-ports-mips
ChangeLog.old-ports-powerpc
ChangeLog.old-ports-tile
INSTALL
LICENSES
Makeconfig
Makefile
Makefile.in
Makerules
NAMESPACE
NEWS
PROJECTS
README
Rules
WUR-REPORT
abi-tags
aclocal.m4
config.h.in
config.make.in
configure
configure.ac
cppflags-iterator.mk
extra-lib.mk
extra-modules.mk
gen-locales.mk
libc-abis
o-iterator.mk
shlib-versions
test-skeleton.c
version.h
Breadcrumbs
glibc
/
posix
/
tst-execvpe5.c
Blame
Blame
Latest commit
History
History
160 lines (131 loc) · 3.85 KB
Breadcrumbs
glibc
/
posix
/
tst-execvpe5.c
Top
File metadata and controls
Code
Blame
160 lines (131 loc) · 3.85 KB
Raw
/* General tests for execpve. Copyright (C) 2016 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 modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ #include <errno.h> #include <fcntl.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <wait.h> /* Nonzero if the program gets called via `exec'. */ static int restart; #define CMDLINE_OPTIONS \ { "restart", no_argument, &restart, 1 }, /* Prototype for our test function. */ extern void do_prepare (int argc, char *argv[]); extern int do_test (int argc, char *argv[]); #include "../test-skeleton.c" #define EXECVPE_KEY "EXECVPE_ENV" #define EXECVPE_VALUE "execvpe_test" static int handle_restart (void) { /* First check if only one variable is passed on execvpe. */ int env_count = 0; for (char **e = environ; *e != NULL; ++e) if (++env_count == INT_MAX) { printf ("Environment variable number overflow"); exit (EXIT_FAILURE); } if (env_count != 1) { printf ("Wrong number of environment variables"); exit (EXIT_FAILURE); } /* Check if the combinarion os "EXECVPE_ENV=execvpe_test" */ const char *env = getenv (EXECVPE_KEY); if (env == NULL) { printf ("Test environment variable not found"); exit (EXIT_FAILURE); } if (strncmp (env, EXECVPE_VALUE, sizeof (EXECVPE_VALUE))) { printf ("Test environment variable with wrong value"); exit (EXIT_FAILURE); } return 0; } int do_test (int argc, char *argv[]) { pid_t pid; int status; /* We must have - one or four parameters left if called initially + path for ld.so optional + "--library-path" optional + the library path optional + the application name if --enable-hardcoded-path-in-tests is used, just + the application name */ if (restart) { if (argc != 1) { printf ("Wrong number of arguments (%d) in restart\n", argc); exit (EXIT_FAILURE); } return handle_restart (); } if (argc != 2 && argc != 5) { printf ("Wrong number of arguments (%d)\n", argc); exit (EXIT_FAILURE); } /* We want to test the `execvpe' function. To do this we restart the program with an additional parameter. */ pid = fork (); if (pid == 0) { /* This is the child. Construct the command line. */ /* We cast here to char* because the test itself does not modify neither the argument nor the environment list. */ char *envs[] = { (char*)(EXECVPE_KEY "=" EXECVPE_VALUE), NULL }; if (argc == 5) { char *args[] = { argv[1], argv[2], argv[3], argv[4], (char *) "--direct", (char *) "--restart", NULL }; execvpe (args[0], args, envs); } else { char *args[] = { argv[0], (char *) "--direct", (char *) "--restart", NULL }; execvpe (args[0], args, envs); } puts ("Cannot exec"); exit (EXIT_FAILURE); } else if (pid == (pid_t) -1) { puts ("Cannot fork"); return 1; } /* Wait for the child. */ if (waitpid (pid, &status, 0) != pid) { puts ("Wrong child"); return 1; } if (WTERMSIG (status) != 0) { puts ("Child terminated incorrectly"); return 1; } status = WEXITSTATUS (status); return status; }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
You can’t perform that action at this time.