public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [kbuild patch] mkcompile_h produces warnings when using domain logins
       [not found] <4D9B63B2.1080701@gmail.com>
@ 2011-04-19  8:28 ` Michal Marek
  2011-04-19 18:23   ` Marcin Nowakowski
  2011-04-25 12:35 ` [PATCH V2] Fix handling of backlash character in LINUX_COMPILE_BY name Marcin Nowakowski
  1 sibling, 1 reply; 4+ messages in thread
From: Michal Marek @ 2011-04-19  8:28 UTC (permalink / raw)
  To: Marcin Nowakowski; +Cc: linux-kbuild

(CC linux-kbuild, please do not send patches to public projects privately)

On 5.4.2011 20:47, Marcin Nowakowski wrote:
> Fix handling of backslash character in LINUX_COMPILE_BY name
> 
> When using a domain login, `whoami` returns the login in
> user\domain format. This leads to either warnings on unrecognised
> escape sequences or escaped characters being generated for the user.
> This patch ensures that any backslash is escaped to a double-backslash
> to make sure the name is preserved correctly
> 
> Signed-off-by: Marcin Nowakowski <marcin.nowakowski.000@gmail.com>
> --- a/scripts/mkcompile_h
> +++ b/scripts/mkcompile_h
> @@ -64,7 +64,7 @@
>     echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\"
> 
>     echo \#define LINUX_COMPILE_TIME \"`date +%T`\"
> -  echo \#define LINUX_COMPILE_BY \"`whoami`\"
> +  echo \#define LINUX_COMPILE_BY \"`whoami | sed 
> "s/\\\\\\\\/\\\\\\\\\\\\\\\\/"`\"
>     echo \#define LINUX_COMPILE_HOST \"`hostname | $UTS_TRUNCATE`\"

Such long sequence of backslashes is rather unreadable. The same command
is equivalent to

  sed 's/\\\\/\\\\\\\\/'

if you use single quotes, but I wonder why you need to match two
backslashes. You say that whoami returns 'user\domain', so the above
regexp wouldn't match it. Also, is it necessary to reproduce the full
user\domain string in the macro? Or could we cut everything after the
backslash, like

  sed  's/\\.*//'

? BTW, I changed the mkcompile_h script recently, see
http://git.kernel.org/?p=linux/kernel/git/mmarek/kbuild-2.6.git;a=blob;f=scripts/mkcompile_h;hb=refs/heads/for-next,
could you base any further version on the for-next branch of
kbuild.2.6.git or on linux-next?

Thanks
Michal

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [kbuild patch] mkcompile_h produces warnings when using domain logins
  2011-04-19  8:28 ` [kbuild patch] mkcompile_h produces warnings when using domain logins Michal Marek
@ 2011-04-19 18:23   ` Marcin Nowakowski
  0 siblings, 0 replies; 4+ messages in thread
From: Marcin Nowakowski @ 2011-04-19 18:23 UTC (permalink / raw)
  To: Michal Marek; +Cc: linux-kbuild

On 19/04/11 09:28, Michal Marek wrote:
> (CC linux-kbuild, please do not send patches to public projects privately)
>
> On 5.4.2011 20:47, Marcin Nowakowski wrote:
>> Fix handling of backslash character in LINUX_COMPILE_BY name
>>
>> When using a domain login, `whoami` returns the login in
>> user\domain format. This leads to either warnings on unrecognised
>> escape sequences or escaped characters being generated for the user.
>> This patch ensures that any backslash is escaped to a double-backslash
>> to make sure the name is preserved correctly
>>
>> Signed-off-by: Marcin Nowakowski<marcin.nowakowski.000@gmail.com>
>> --- a/scripts/mkcompile_h
>> +++ b/scripts/mkcompile_h
>> @@ -64,7 +64,7 @@
>>      echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\"
>>
>>      echo \#define LINUX_COMPILE_TIME \"`date +%T`\"
>> -  echo \#define LINUX_COMPILE_BY \"`whoami`\"
>> +  echo \#define LINUX_COMPILE_BY \"`whoami | sed
>> "s/\\\\\\\\/\\\\\\\\\\\\\\\\/"`\"
>>      echo \#define LINUX_COMPILE_HOST \"`hostname | $UTS_TRUNCATE`\"
>
> Such long sequence of backslashes is rather unreadable. The same command
> is equivalent to
>
>    sed 's/\\\\/\\\\\\\\/'
>
> if you use single quotes, but I wonder why you need to match two
> backslashes. You say that whoami returns 'user\domain', so the above
> regexp wouldn't match it.

The problem in this case is that when using back-quotes for command 
substitution, backslashes are escaped so we need the extra layer of 
escaping. However - having looked again at the bash documentation, I've 
found that if $(...) syntax is used instead of `...` then backslashes 
are treated literally. That, with addition of single quotes as you had 
suggested should allow a simple
echo \#define LINUX_COMPILE_BY \"$(whoami | sed 's/\\/\\\\/g')\"
instead of the rather unreadable solution I initially suggested.

> Also, is it necessary to reproduce the full
> user\domain string in the macro? Or could we cut everything after the
> backslash, like
>
>    sed  's/\\.*//'
>
> ? BTW, I changed the mkcompile_h script recently, see
> http://git.kernel.org/?p=linux/kernel/git/mmarek/kbuild-2.6.git;a=blob;f=scripts/mkcompile_h;hb=refs/heads/for-next,
> could you base any further version on the for-next branch of
> kbuild.2.6.git or on linux-next?

I'll re-send a new patched based on this tree and with the cleanup as 
described above

thanks
Marcin

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH V2] Fix handling of backlash character in LINUX_COMPILE_BY name
       [not found] <4D9B63B2.1080701@gmail.com>
  2011-04-19  8:28 ` [kbuild patch] mkcompile_h produces warnings when using domain logins Michal Marek
@ 2011-04-25 12:35 ` Marcin Nowakowski
  2011-04-29 13:57   ` Michal Marek
  1 sibling, 1 reply; 4+ messages in thread
From: Marcin Nowakowski @ 2011-04-25 12:35 UTC (permalink / raw)
  To: linux-kbuild

When using a domain login, `whoami` returns the login in
user\domain format. This leads to either warnings on unrecognised
escape sequences or escaped characters being generated for the user.
This patch ensures that any backslash is escaped to a double-backslash
to make sure the name is preserved correctly. This patch does not
enforce escaping on the KBUILD_BUILD_USER variable, as this is something
the user has control of and can escape if required.
V2 simplifies a very complex escape pattern introduced initially.

Signed-off-by: Marcin Nowakowski <marcin.nowakowski.000@gmail.com>
diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
index 7ad6bf7..f221ddf 100755
--- a/scripts/mkcompile_h
+++ b/scripts/mkcompile_h
@@ -43,7 +43,7 @@ else
  	TIMESTAMP=$KBUILD_BUILD_TIMESTAMP
  fi
  if test -z "$KBUILD_BUILD_USER"; then
-	LINUX_COMPILE_BY=`whoami`
+	LINUX_COMPILE_BY=$(whoami | sed 's/\\/\\\\/')
  else
  	LINUX_COMPILE_BY=$KBUILD_BUILD_USER
  fi

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH V2] Fix handling of backlash character in LINUX_COMPILE_BY name
  2011-04-25 12:35 ` [PATCH V2] Fix handling of backlash character in LINUX_COMPILE_BY name Marcin Nowakowski
@ 2011-04-29 13:57   ` Michal Marek
  0 siblings, 0 replies; 4+ messages in thread
From: Michal Marek @ 2011-04-29 13:57 UTC (permalink / raw)
  To: Marcin Nowakowski; +Cc: linux-kbuild

On Mon, Apr 25, 2011 at 01:35:21PM +0100, Marcin Nowakowski wrote:
> When using a domain login, `whoami` returns the login in
> user\domain format. This leads to either warnings on unrecognised
> escape sequences or escaped characters being generated for the user.
> This patch ensures that any backslash is escaped to a double-backslash
> to make sure the name is preserved correctly. This patch does not
> enforce escaping on the KBUILD_BUILD_USER variable, as this is something
> the user has control of and can escape if required.
> V2 simplifies a very complex escape pattern introduced initially.

Thanks, this is much more readable :). Applied to kbuild-2.6.git#kbuild.

Michal

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-04-29 13:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <4D9B63B2.1080701@gmail.com>
2011-04-19  8:28 ` [kbuild patch] mkcompile_h produces warnings when using domain logins Michal Marek
2011-04-19 18:23   ` Marcin Nowakowski
2011-04-25 12:35 ` [PATCH V2] Fix handling of backlash character in LINUX_COMPILE_BY name Marcin Nowakowski
2011-04-29 13:57   ` Michal Marek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox