Re: [PATCH] Use full path to dnsdomainname and domainname in scripts/mkcompile_h

From: Glenn Sommer
Date: Wed Jan 20 2010 - 10:07:03 EST


2010/1/20 AmÃrico Wang <xiyou.wangcong@xxxxxxxxx>:
> On Wed, Jan 20, 2010 at 2:29 AM, Glenn Sommer <glemsom@xxxxxxxxx> wrote:
>> With reference to: http://bugzilla.kernel.org/show_bug.cgi?id=14920
>> I'll post my suggestion here.
>>
>> Currently scripts/mkcompile_h checks for "/bin/dnsdomainname" and
>> "/bin/domainname" when trying to find the DNS name.
>> Though, when running the executable - the full path isn't used!
>>
>> IMO if we check for "/bin/dnsdomainname", we should also use
>> "/bin/dnsdomainname" - and not blindly trust /bin is the first directory in
>> $PATH Âwhich contains a executable named "dnsdomainname"
>>
>>
>> I propose to use the full path, that we know is valid. Here's my proposed patch:
>>
>>
>> --- scripts/mkcompile_h.orig  Â2009-12-28 23:02:34.000000000 +0100
>> +++ scripts/mkcompile_h 2009-12-28 23:03:12.000000000 +0100
>> @@ -66,9 +66,9 @@
>> Â echo \#define LINUX_COMPILE_HOST \"`hostname | $UTS_TRUNCATE`\"
>>
>> Â if [ -x /bin/dnsdomainname ]; then
>> - Â Âecho \#define LINUX_COMPILE_DOMAIN \"`dnsdomainname | $UTS_TRUNCATE`\"
>> + Â Âecho \#define LINUX_COMPILE_DOMAIN \"`/bin/dnsdomainname | $UTS_TRUNCATE`\"
>> Â elif [ -x /bin/domainname ]; then
>> - Â Âecho \#define LINUX_COMPILE_DOMAIN \"`domainname | $UTS_TRUNCATE`\"
>> + Â Âecho \#define LINUX_COMPILE_DOMAIN \"`/bin/domainname | $UTS_TRUNCATE`\"
>> Â else
>> Â Â echo \#define LINUX_COMPILE_DOMAIN
>> Â fi
>>
>>
>> Signed-off-by: Glenn Sommer <glemsom@xxxxxxxxx>
>
> Makes sense, but is that possible we have 'domainname' installed in two
> different directories?
>

Usually "domainname" should be installed in /bin.
I'm just thinking if one does something like this:

* Place shellscript named "domainname" in /home/stupiduser/scripts
(This shellscript should output some text... Let's say
"my-stupid-shell-script")
* Set PATH=/home/stupiduser/scripts:$PATH
* Compile Linux kernel

Doing the above will result in scripts/mkcompile_h testing for
/bin/domainname, but actually using
/home/stupiduser/scripts/domainname - which is this case will output
something wrong.
One could argue it's your own fault then - and I agree! Doing the
above is stupid!

Anyway, if we test for the executable using a complete path - we
should also use that complete path when running the executable!


Alternatively, if we want it to be more flexible(and allow the above)
- we should do something like:

domainname_executable=`which domainname`
if [ ! -z "$domainname_executable" ] && [ -x "$domainname_executable" ]; then
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/