From: Sven Eckelmann <sven.eckelmann@gmx.de>
To: b.a.t.m.a.n@open-mesh.net
Cc: Marek Lindner <lindner_marek@yahoo.de>
Subject: Re: [B.A.T.M.A.N.] [PATCH] Don't detach batmand to background by default
Date: Wed, 1 Apr 2009 12:28:56 +0200 [thread overview]
Message-ID: <200904011229.01236.sven.eckelmann@gmx.de> (raw)
In-Reply-To: <200904010226.08922.lindner_marek@yahoo.de>
[-- Attachment #1: Type: text/plain, Size: 2068 bytes --]
On Tuesday 31 March 2009 20:26:08 Marek Lindner wrote:
> thanks a lot for addressing this issue by sending your patch. Although I'm
> not too happy about the chosen approach. Changing the default behaviour and
> adding a new command line option seems not to be the best solution. Do you
> think we can put this exec call into batman itself and thus hiding this
> ulibc thread disaster ?
First thing is that you have to add a option to disable the fork to the
background. Otherwise all batmand execs will again fork to the background and
exec again a batmand. Then there is the issue of finding the right executable
to execute. The argv[0] approach isn't ideal since there must not be any
connections to the real executable. Take for example this small snipped:
#include <unistd.h>
int main()
{
char* const argv[] = {"/fake", NULL};
execv("/bin/sh", argv);
return 0;
}
Make a `echo $0` in a normal shell and one in the shell started by this
program. An approach to start a program again is to use start the program
again over /proc/self/exe. This can fail due to different reasons. First one
is that there is no proc filesystem mounted. Second one is that there is that
the file which was used to start the program was moved to another location (or
deleted). Maybe there are other ways I don't know, but please don't suggest
fexecve since this is even less POSIX and takes a similar approach, but
involves more 'guessing' since you first have to open a file to get the
correct fd.
Under (Free)BSD you will have to find a similar approach since it doesn't have
/proc/self/exe unless you mounted linprocfs.
As you can see the real problem is the association between the process and
it's executable you need to execute batmand again. I will post a proof-of-
concept patch to show this approach. Be prepared that it eats your pets and
converts wine into water. I cannot test the patches again the current openwrt
trunk since https://svn.openwrt.org/openwrt/trunk is broken at the moment.
Regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
next prev parent reply other threads:[~2009-04-01 10:28 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-18 14:43 [B.A.T.M.A.N.] Problem with B.A.T.M.A.N. 0.3.1 rv1206 (compatibility version 5) Max
2009-03-19 2:55 ` Marek Lindner
2009-03-19 13:38 ` Max
2009-03-20 12:47 ` Marek Lindner
2009-03-20 13:03 ` Max
2009-03-21 1:13 ` Marek Lindner
2009-03-21 13:07 ` Max
2009-03-23 17:13 ` Marek Lindner
2009-03-23 22:05 ` Sven Eckelmann
2009-03-24 19:17 ` Sven Eckelmann
2009-03-25 2:44 ` Marek Lindner
2009-03-26 12:59 ` [B.A.T.M.A.N.] [PATCH] Don't detach batmand to background by default Sven Eckelmann
2009-03-31 18:26 ` Marek Lindner
2009-04-01 10:28 ` Sven Eckelmann [this message]
2009-04-01 10:31 ` [B.A.T.M.A.N.] [PATCH 1/2] Add parameter to disable fork to background Sven Eckelmann
2009-04-01 10:31 ` [B.A.T.M.A.N.] [PATCH 2/2] Sanitise batmand process by reexecuting it Sven Eckelmann
2009-04-01 22:20 ` [B.A.T.M.A.N.] [PATCHv2 " Sven Eckelmann
2009-03-24 12:45 ` [B.A.T.M.A.N.] Problem with B.A.T.M.A.N. 0.3.1 rv1206 (compatibility version 5) P. Mazart
2009-04-11 0:54 ` Marek Lindner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200904011229.01236.sven.eckelmann@gmx.de \
--to=sven.eckelmann@gmx.de \
--cc=b.a.t.m.a.n@open-mesh.net \
--cc=lindner_marek@yahoo.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox