From: Laurent Desnogues <laurent.desnogues@gmail.com>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [6485] linux-user: identify running binary in /proc/self/exe
Date: Mon, 2 Feb 2009 08:59:14 +0100 [thread overview]
Message-ID: <761ea48b0902012359u2f73e99ajb6a1a4ea56fc0e6b@mail.gmail.com> (raw)
In-Reply-To: <E1LSzfi-0004P0-60@cvs.savannah.gnu.org>
On Fri, Jan 30, 2009 at 9:09 PM, Aurelien Jarno <aurelien@aurel32.net> wrote:
> Revision: 6485
> http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6485
> Author: aurel32
> Date: 2009-01-30 20:09:01 +0000 (Fri, 30 Jan 2009)
>
> Log Message:
> -----------
> linux-user: identify running binary in /proc/self/exe
>
> Some applications like to test /proc/self/exe to find
> out who they are. Fake the result of readlink() for
> them. Use realpath() to return full path to binary
> (which the links /proc/self/exe are)
>
> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
>
> Modified Paths:
> --------------
> trunk/linux-user/main.c
> trunk/linux-user/qemu.h
> trunk/linux-user/syscall.c
>
[...]
> Modified: trunk/linux-user/syscall.c
> ===================================================================
> --- trunk/linux-user/syscall.c 2009-01-30 19:59:17 UTC (rev 6484)
> +++ trunk/linux-user/syscall.c 2009-01-30 20:09:01 UTC (rev 6485)
> @@ -4410,13 +4410,22 @@
> #endif
> case TARGET_NR_readlink:
> {
> - void *p2;
> + void *p2, *temp;
> p = lock_user_string(arg1);
> p2 = lock_user(VERIFY_WRITE, arg2, arg3, 0);
> if (!p || !p2)
> ret = -TARGET_EFAULT;
> - else
> - ret = get_errno(readlink(path(p), p2, arg3));
> + else {
> + if (strncmp((const char *)p, "/proc/self/exe", 14) == 0) {
> + char real[PATH_MAX];
> + temp = realpath(exec_path,real);
> + ret = (temp==NULL) ? get_errno(-1) : strlen(real) ;
> + snprintf((char *)p2, arg3, "%s", real);
> + }
> + else
> + ret = get_errno(readlink(path(p), p2, arg3));
> + break;
Do we really want to skip unlock_user?
> + }
> unlock_user(p2, arg2, ret);
> unlock_user(p, arg1, 0);
> }
Laurent
next prev parent reply other threads:[~2009-02-02 7:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-30 20:09 [Qemu-devel] [6485] linux-user: identify running binary in /proc/self/exe Aurelien Jarno
2009-02-02 7:59 ` Laurent Desnogues [this message]
2009-02-02 9:15 ` Riku Voipio
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=761ea48b0902012359u2f73e99ajb6a1a4ea56fc0e6b@mail.gmail.com \
--to=laurent.desnogues@gmail.com \
--cc=qemu-devel@nongnu.org \
/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;
as well as URLs for NNTP newsgroup(s).