]> git.neil.brown.name Git - history.git/commitdiff
kbuild: Enforce UTS limit, use LANG=C for date/time
authorKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
Thu, 6 Jun 2002 05:09:52 +0000 (00:09 -0500)
committerKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
Thu, 6 Jun 2002 05:09:52 +0000 (00:09 -0500)
Patch by Keith Owens, ported to 2.5.

If the length of $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
exceeds 64 characters it silently corrupts the utsname data, resulting
in garbage for uname -r and problems running the kernel and modules.
Abort if KERNELRELEASE is too long.  Truncation is not good enough, it
results in ambiguous /lib/modules/`uname -r` contents.

Ensure that the date/time in uname are always in LANG=C.  Users with
other languages report that 8 bit values cause the boot messages to go
haywire.

Makefile
init/Makefile
scripts/mkcompile_h

index ba741667ec40e355cfe58925df0e52ff7b7d6825..2c2a223cd185e944ae05ea9a64287019d99598ad 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -298,7 +298,13 @@ include/linux/autoconf.h: .config
 #      version.h changes when $(KERNELRELEASE) etc change, as defined in
 #      this Makefile
 
+uts_len := 64
+
 include/linux/version.h: Makefile
+       @if expr length "$(KERNELRELEASE)" \> $(uts_len) >/dev/null ; then \
+         echo '"$(KERNELRELEASE)" exceeds $(uts_len) characters' >&2; \
+         exit 1; \
+       fi;
        @echo -n 'Generating $@'
        @(echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"; \
          echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)`; \
index 455416572bac8ec2a1c0332946aea41b28855416..c68a879dde8fc612b5cbfb9461dd9b045c782b37 100644 (file)
@@ -22,4 +22,5 @@ $(TOPDIR)/include/linux/compile.h: ../include/linux/compile.h ;
 # actual file if its content has changed.
 
 ../include/linux/compile.h: FORCE
+       @echo -n 'Generating $@'
        @../scripts/mkcompile_h $@ "$(ARCH)" "$(CONFIG_SMP)" "$(CC) $(CFLAGS)"
index e18fc4f263e350363e08578eafc336a43189b100..6313db961724ee0775e2c580a59f0734cf1401e2 100755 (executable)
@@ -10,24 +10,32 @@ else
   echo 0 > ../.version
 fi
 
+
+UTS_VERSION="#$VERSION"
+if [ -n "$SMP" ] ; then UTS_VERSION="$UTS_VERSION SMP"; fi
+UTS_VERSION="$UTS_VERSION `LANG=C date`"
+
+# Truncate to maximum length
+
+UTS_LEN=64
+UTS_TRUNCATE="sed -e s/\(.\{1,$UTS_LEN\}\).*/\1/"
+
 # Generate a temporary compile.h
 
 ( echo /\* This file is auto generated, version $VERSION \*/
 
   echo \#define UTS_MACHINE \"$ARCH\"
 
-  echo -n \#define UTS_VERSION \"\#$VERSION
-  if [ -n "$SMP" ] ; then echo -n " SMP"; fi
-  echo ' '`date`'"'
+  echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\"
 
-  echo \#define LINUX_COMPILE_TIME \"`date +%T`\"
+  echo \#define LINUX_COMPILE_TIME \"`LANG=C date +%T`\"
   echo \#define LINUX_COMPILE_BY \"`whoami`\"
-  echo \#define LINUX_COMPILE_HOST \"`hostname`\"
+  echo \#define LINUX_COMPILE_HOST \"`hostname | $UTS_TRUNCATE`\"
 
   if [ -x /bin/dnsdomainname ]; then
-    echo \#define LINUX_COMPILE_DOMAIN \"`dnsdomainname`\"
+    echo \#define LINUX_COMPILE_DOMAIN \"`dnsdomainname | $UTS_TRUNCATE`\"
   elif [ -x /bin/domainname ]; then
-    echo \#define LINUX_COMPILE_DOMAIN \"`domainname`\"
+    echo \#define LINUX_COMPILE_DOMAIN \"`domainname | $UTS_TRUNCATE`\"
   else
     echo \#define LINUX_COMPILE_DOMAIN
   fi
@@ -48,10 +56,10 @@ if [ -r $TARGET ] && \
       grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' $TARGET > .tmpver.1 && \
       grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' .tmpcompile > .tmpver.2 && \
       cmp -s .tmpver.1 .tmpver.2; then
-   echo $TARGET was not updated;
+   echo ' (unchanged)'
    rm -f .tmpcompile
 else
-   echo $TARGET was updated
+   echo ' (updated)'
    mv -f .tmpcompile $TARGET
 fi
 rm -f .tmpver.1 .tmpver.2