You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Simone Piunno (JIRA)" <ji...@apache.org> on 2007/01/20 13:40:30 UTC
[jira] Created: (DAEMON-92) jsvc fails to execve() self on Linux
jsvc fails to execve() self on Linux
------------------------------------
Key: DAEMON-92
URL: https://issues.apache.org/jira/browse/DAEMON-92
Project: Commons Daemon
Issue Type: Bug
Affects Versions: 1.0.1 Final
Reporter: Simone Piunno
Fix For: 1.0.1 Final
On Linux jsvc execve() itself.
execve() requires an absolute path as the first argument therefore use of argv[0] only works when jsvc was invoked with a full path.
Executing jsvc as relative path fails with "jsvc error: Cannot execute JSVC executor process".
On Linux the full path to self is very easy to find: "/proc/self/exe"
I'm attaching a patch fixing this problem and falling back to argv[0] in case /proc is not mounted.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (DAEMON-92) jsvc fails to execve() self on Linux
Posted by "Petteri Räty (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DAEMON-92?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12472114 ]
Petteri Räty commented on DAEMON-92:
------------------------------------
trunk already seems to be using /proc/self/exe so this can be closed or wait until the fix is in a release version
/* execve needs a full path */
ret = readlink("/proc/self/exe",buf,sizeof(buf)-1);
betelgeuse@pena /mnt/checkouts/commons-daemon-trunk $ grep /proc/self/ -r .
./src/native/unix/.svn/text-base/CHANGES.txt.svn-base: * fix 36030. (using /proc/self/exe and readlink).
./src/native/unix/native/.svn/text-base/jsvc-unix.c.svn-base: ret = readlink("/proc/self/exe",buf,sizeof(buf)-1);
./src/native/unix/native/jsvc-unix.c: ret = readlink("/proc/self/exe",buf,sizeof(buf)-1);
./src/native/unix/CHANGES.txt: * fix 36030. (using /proc/self/exe and readlink).
> jsvc fails to execve() self on Linux
> ------------------------------------
>
> Key: DAEMON-92
> URL: https://issues.apache.org/jira/browse/DAEMON-92
> Project: Commons Daemon
> Issue Type: Bug
> Affects Versions: 1.0.1
> Reporter: Simone Piunno
> Attachments: 1.0.1-execve-self.patch
>
>
> On Linux jsvc execve() itself.
> execve() requires an absolute path as the first argument therefore use of argv[0] only works when jsvc was invoked with a full path.
> Executing jsvc as relative path fails with "jsvc error: Cannot execute JSVC executor process".
> On Linux the full path to self is very easy to find: "/proc/self/exe"
> I'm attaching a patch fixing this problem and falling back to argv[0] in case /proc is not mounted.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (DAEMON-92) jsvc fails to execve() self on Linux
Posted by "Simone Piunno (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DAEMON-92?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12467335 ]
Simone Piunno commented on DAEMON-92:
-------------------------------------
I'm sorry you are right.
The problem is not for relative vs absolute paths, but execve(2) not searching throught the $PATH.
roentgen ~ # cat execve.c
#include <unistd.h>
#include <stdio.h>
int main(int myargc, char **myargv)
{
char * const argv[] = { NULL };
char * const envp[] = { NULL };
if (myargc > 1) {
printf("One round more\n");
execve(myargv[0], argv, envp);
return 1;
}
printf("Hello, world\n");
}
roentgen ~ # make execve
cc execve.c -o execve
roentgen ~ # ./execve 1
One round more
Hello, world
roentgen ~ # mv execve /usr/bin
roentgen ~ # which execve
/usr/bin/execve
roentgen ~ # execve
Hello, world
roentgen ~ # execve 1
One round more
roentgen ~ # /usr/bin/execve 1
One round more
Hello, world
roentgen ~ # strace execve 1
execve("/usr/bin/execve", ["execve", "1"], [/* 53 vars */]) = 0
brk(0) = 0x501000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b73728cf000
uname({sys="Linux", node="roentgen", ...}) = 0
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=182778, ...}) = 0
mmap(NULL, 182778, PROT_READ, MAP_PRIVATE, 3, 0) = 0x2b73728d0000
close(3) = 0
open("/lib/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220\324"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1314256, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b73728fd000
mmap(NULL, 2330760, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x2b73729d0000
mprotect(0x2b7372b00000, 1048576, PROT_NONE) = 0
mmap(0x2b7372c00000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x130000) = 0x2b7372c00000
mmap(0x2b7372c05000, 16520, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x2b7372c05000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b7372c0a000
arch_prctl(ARCH_SET_FS, 0x2b7372c0a6f0) = 0
mprotect(0x2b7372c00000, 12288, PROT_READ) = 0
mprotect(0x2b73729ce000, 4096, PROT_READ) = 0
munmap(0x2b73728d0000, 182778) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 1), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x2b73728d0000
write(1, "One round more\n", 15One round more
) = 15
execve("execve", [], [/* 0 vars */]) = -1 ENOENT (No such file or directory)
exit_group(1) = ?
Process 29655 detached
> jsvc fails to execve() self on Linux
> ------------------------------------
>
> Key: DAEMON-92
> URL: https://issues.apache.org/jira/browse/DAEMON-92
> Project: Commons Daemon
> Issue Type: Bug
> Affects Versions: 1.0.1 Final
> Reporter: Simone Piunno
> Fix For: 1.0.1 Final
>
> Attachments: 1.0.1-execve-self.patch
>
>
> On Linux jsvc execve() itself.
> execve() requires an absolute path as the first argument therefore use of argv[0] only works when jsvc was invoked with a full path.
> Executing jsvc as relative path fails with "jsvc error: Cannot execute JSVC executor process".
> On Linux the full path to self is very easy to find: "/proc/self/exe"
> I'm attaching a patch fixing this problem and falling back to argv[0] in case /proc is not mounted.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (DAEMON-92) jsvc fails to execve() self on Linux
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DAEMON-92?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Henri Yandell updated DAEMON-92:
--------------------------------
Fix Version/s: (was: 1.0.1 Final)
> jsvc fails to execve() self on Linux
> ------------------------------------
>
> Key: DAEMON-92
> URL: https://issues.apache.org/jira/browse/DAEMON-92
> Project: Commons Daemon
> Issue Type: Bug
> Affects Versions: 1.0.1
> Reporter: Simone Piunno
> Attachments: 1.0.1-execve-self.patch
>
>
> On Linux jsvc execve() itself.
> execve() requires an absolute path as the first argument therefore use of argv[0] only works when jsvc was invoked with a full path.
> Executing jsvc as relative path fails with "jsvc error: Cannot execute JSVC executor process".
> On Linux the full path to self is very easy to find: "/proc/self/exe"
> I'm attaching a patch fixing this problem and falling back to argv[0] in case /proc is not mounted.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Updated: (DAEMON-92) jsvc fails to execve() self on Linux
Posted by "Simone Piunno (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DAEMON-92?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Simone Piunno updated DAEMON-92:
--------------------------------
Attachment: 1.0.1-execve-self.patch
> jsvc fails to execve() self on Linux
> ------------------------------------
>
> Key: DAEMON-92
> URL: https://issues.apache.org/jira/browse/DAEMON-92
> Project: Commons Daemon
> Issue Type: Bug
> Affects Versions: 1.0.1 Final
> Reporter: Simone Piunno
> Fix For: 1.0.1 Final
>
> Attachments: 1.0.1-execve-self.patch
>
>
> On Linux jsvc execve() itself.
> execve() requires an absolute path as the first argument therefore use of argv[0] only works when jsvc was invoked with a full path.
> Executing jsvc as relative path fails with "jsvc error: Cannot execute JSVC executor process".
> On Linux the full path to self is very easy to find: "/proc/self/exe"
> I'm attaching a patch fixing this problem and falling back to argv[0] in case /proc is not mounted.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org
[jira] Commented: (DAEMON-92) jsvc fails to execve() self on Linux
Posted by "Petteri Räty (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/DAEMON-92?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12467164 ]
Petteri Räty commented on DAEMON-92:
------------------------------------
execve works just fine with relative paths here:
betelgeuse@pena ~/c-koodaus $ ./exec
Hello World!
betelgeuse@pena ~/c-koodaus $ cat exec.c
#include <unistd.h>
int main(int nArgs, char **ppArgs)
{
char *const argv[] = {NULL};
char *const envp[] = {NULL};
execve("./hello", argv, envp);
}
> jsvc fails to execve() self on Linux
> ------------------------------------
>
> Key: DAEMON-92
> URL: https://issues.apache.org/jira/browse/DAEMON-92
> Project: Commons Daemon
> Issue Type: Bug
> Affects Versions: 1.0.1 Final
> Reporter: Simone Piunno
> Fix For: 1.0.1 Final
>
> Attachments: 1.0.1-execve-self.patch
>
>
> On Linux jsvc execve() itself.
> execve() requires an absolute path as the first argument therefore use of argv[0] only works when jsvc was invoked with a full path.
> Executing jsvc as relative path fails with "jsvc error: Cannot execute JSVC executor process".
> On Linux the full path to self is very easy to find: "/proc/self/exe"
> I'm attaching a patch fixing this problem and falling back to argv[0] in case /proc is not mounted.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org