Using GPL Code

From SecuriWiki
Revision as of 22:28, 30 March 2015 by matt (Talk | contribs)

Jump to: navigation, search

First you must download the GPL code from the URL found in the forums.

Then, if you're running on an 64bit OS, you may need to patch m4 and bison.

Patching Tools

You will be creating patches directories in tools/m4/ and tools/bison, and adding the following files.

cd $GPL_DIR
mkdir tools/m4/patches tools/bison/patches

tools/m4/patches/010-stdio.in.h.patch

--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -141,7 +141,8 @@ _GL_WARN_ON_USE (fflush, "fflush is not
    so any use of gets warrants an unconditional warning.  Assume it is
    always declared, since it is required by C89.  */
 #undef gets
-_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
+/*_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");*/
+#define gets(a) fgets( a, sizeof(*(a)), stdin)

 #if @GNULIB_FOPEN@
 # if @REPLACE_FOPEN@

tools/bison/patches/010-stdio.in.h.patch

--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -143,7 +143,8 @@ _GL_WARN_ON_USE (fflush, "fflush is not
    so any use of gets warrants an unconditional warning.  Assume it is
    always declared, since it is required by C89.  */
 #undef gets
-_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
+/*_GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");*/
+#define gets(a) fgets( a, sizeof(*(a)), stdin)

 #if @GNULIB_FOPEN@
 # if @REPLACE_FOPEN@
Configuring Build Environment

Assuming you are using the GPL code and SDK toolchain, you need to tell the GPL code where to look (GPL_DIR is where you extracted the GPL code and TOOLCHAIN_DIR is where you have extracted the SDK). You will need to go into the OpenWRT configuration, then set the 3 external toolchain variables to point to the SDK.

cd $GPL_DIR
make menuconfig
Advanced configuration options (for developers)  --->
Use external toolchain  ---> (check this (<space>), then click to enter (<enter>))
(arm-openwrt-linux) Target name
(arm-openwrt-linux-) Toolchain prefix
(TOOLCHAIN_DIR/toolchain-arm_gcc-4.5.1+l_uClibc-0.9.32_eabi) Toolchain root

Escape out of the menus, and save your changes.

Compiling Packages

You can use the instructions at [1]

For example for recompiling udev (a simpler package without dependencies):

make tools/install
make toolchain/install
make package/udev/compile

After the first time, only the last command needs to be run. Then the package can be found in bin/g2/packages. You can also do make menuconfig and choose the packages you want to build, then just run make package/install.