martijnvanbrummelen / nwipe

nwipe secure disk eraser
GNU General Public License v2.0
789 stars 86 forks source link

nwipe 0.18 fails to build on 64bit systems #19

Closed xambroz closed 8 years ago

xambroz commented 8 years ago

Hello, nwipe pre-release fails to build on 64bit architecture because the off64_t macro is defined only on the 32bit architecture. On 64bit architecture the native size of off_t is already 64bit.

This is the transcript of the build errors:

$ rpmbuild -ba nwipe.spec 
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.3pYaFm
+ umask 022
+ cd /home/mambroz/rpmbuild/BUILD
+ cd /home/mambroz/rpmbuild/BUILD
+ rm -rf nwipe-d01b00b4f82ea1899eee1f0ffb47ebc6ac7e5dc2
+ /usr/bin/gzip -dc /home/mambroz/rpmbuild/SOURCES/nwipe-0.18-d01b00b.tar.gz
+ /usr/bin/tar -xof -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd nwipe-d01b00b4f82ea1899eee1f0ffb47ebc6ac7e5dc2
+ /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ echo 'Patch #0 (nwipe-twister_64bit.patch):'
Patch #0 (nwipe-twister_64bit.patch):
+ /usr/bin/patch -p1 -b --suffix .64bit --fuzz=0
patching file src/prng.c
patching file src/prng.h
+ echo 'Patch #1 (nwipe-epel6.patch):'
Patch #1 (nwipe-epel6.patch):
+ /usr/bin/patch -p1 -b --suffix .epel6 --fuzz=0
patching file configure.ac
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.zHaxVx
+ umask 022
+ cd /home/mambroz/rpmbuild/BUILD
+ cd nwipe-d01b00b4f82ea1899eee1f0ffb47ebc6ac7e5dc2
+ autoreconf -vif
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force 
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool
autoreconf: running: /usr/bin/autoconf --force
autoreconf: running: /usr/bin/autoheader --force
autoreconf: running: automake --add-missing --copy --force-missing
configure.ac:6: warning: AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated.  For more info, see:
configure.ac:6: http://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_005fINIT_005fAUTOMAKE-invocation
configure.ac:12: installing './compile'
configure.ac:6: installing './install-sh'
configure.ac:6: installing './missing'
src/Makefile.am: installing './depcomp'
autoreconf: Leaving directory `.'
+ CFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic'
+ export CFLAGS
+ CXXFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic'
+ export CXXFLAGS
+ FFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -I/usr/lib64/gfortran/modules'
+ export FFLAGS
+ FCFLAGS='-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -I/usr/lib64/gfortran/modules'
+ export FCFLAGS
+ LDFLAGS='-Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld'
+ export LDFLAGS
+ '[' 1 = 1 ']'
+++ dirname ./configure
++ find . -name config.guess -o -name config.sub
+ '[' 1 = 1 ']'
+ '[' x '!=' x-specs=/usr/lib/rpm/redhat/redhat-hardened-ld ']'
++ find . -name ltmain.sh
+ ./configure --build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --program-prefix= --disable-dependency-tracking --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating man/Makefile
checking for x86_64-redhat-linux-gnu-gcc... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking for style of include used by make... GNU
checking dependency style of gcc... none
checking for x86_64-redhat-linux-gnu-pkg-config... /usr/bin/x86_64-redhat-linux-gnu-pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for PANEL... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for NCURSES... yes
checking for libintl_dgettext in -lintl... no
checking for uuid_generate in -luuid... yes
checking for PARTED... yes
checking for main in -lpthread... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking for inttypes.h... (cached) yes
checking netinet/in.h usability... yes
checking netinet/in.h presence... yes
checking for netinet/in.h... yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking for stdint.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking sys/file.h usability... yes
checking sys/file.h presence... yes
checking for sys/file.h... yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking for unistd.h... (cached) yes
checking for size_t... yes
checking for struct stat.st_blksize... yes
checking for stdlib.h... (cached) yes
checking for GNU libc compatible malloc... yes
checking for fdatasync... yes
checking for memset... yes
checking for regcomp... yes
checking for strdup... yes
checking for strerror... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating man/Makefile
config.status: creating config.h
config.status: executing depfiles commands
+ make -j4
make  all-recursive
make[1]: Entering directory '/home/mambroz/rpmbuild/BUILD/nwipe-d01b00b4f82ea1899eee1f0ffb47ebc6ac7e5dc2'
Making all in src
make[2]: Entering directory '/home/mambroz/rpmbuild/BUILD/nwipe-d01b00b4f82ea1899eee1f0ffb47ebc6ac7e5dc2/src'
gcc -DHAVE_CONFIG_H -I. -I..     -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic   -c -o nwipe-isaac_rand.o `test -f 'isaac_rand.c' || echo './'`isaac_rand.c
gcc -DHAVE_CONFIG_H -I. -I..     -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic   -c -o nwipe-nwipe.o `test -f 'nwipe.c' || echo './'`nwipe.c
gcc -DHAVE_CONFIG_H -I. -I..     -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic   -c -o nwipe-gui.o `test -f 'gui.c' || echo './'`gui.c
gcc -DHAVE_CONFIG_H -I. -I..     -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic   -c -o nwipe-pass.o `test -f 'pass.c' || echo './'`pass.c
gcc -DHAVE_CONFIG_H -I. -I..     -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic   -c -o nwipe-device.o `test -f 'device.c' || echo './'`device.c
In file included from gui.c:37:0:
context.h:85:2: error: unknown type name 'off64_t'
  off64_t           device_size;   /* The device size in bytes.                                      */
  ^
gui.c: In function 'nwipe_gui_title':
gui.c:140:6: warning: variable 'wy' set but not used [-Wunused-but-set-variable]
  int wy;
      ^
gui.c: In function 'nwipe_gui_status':
gui.c:1814:17: warning: pointer targets in passing argument 1 of 'strlen' differ in signedness [-Wpointer-sign]
     if ( strlen(c[i]->identity.serial_no) )
                 ^
In file included from nwipe.h:49:0,
                 from gui.c:36:
/usr/include/string.h:394:15: note: expected 'const char *' but argument is of type 'unsigned char *'
 extern size_t strlen (const char *__s)
               ^
Makefile:422: recipe for target 'nwipe-gui.o' failed
make[2]: *** [nwipe-gui.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from pass.c:27:0:
context.h:85:2: error: unknown type name 'off64_t'
  off64_t           device_size;   /* The device size in bytes.                                      */
  ^
pass.c: In function 'nwipe_random_verify':
pass.c:49:2: error: unknown type name 'off64_t'
  off64_t offset;
  ^
pass.c:101:17: error: 'off64_t' undeclared (first use in this function)
  if( offset == (off64_t)-1 )
                 ^
pass.c:101:17: note: each undeclared identifier is reported only once for each function it appears in
pass.c: In function 'nwipe_random_pass':
pass.c:228:2: error: unknown type name 'off64_t'
  off64_t offset;
  ^
pass.c:270:17: error: 'off64_t' undeclared (first use in this function)
  if( offset == (off64_t)-1 )
                 ^
pass.c: In function 'nwipe_static_verify':
pass.c:391:2: error: unknown type name 'off64_t'
  off64_t offset;
  ^
pass.c:473:17: error: 'off64_t' undeclared (first use in this function)
  if( offset == (off64_t)-1 )
                 ^
pass.c: In function 'nwipe_static_pass':
pass.c:590:2: error: unknown type name 'off64_t'
  off64_t offset;
  ^
pass.c:641:17: error: 'off64_t' undeclared (first use in this function)
  if( offset == (off64_t)-1 )
                 ^
Makefile:436: recipe for target 'nwipe-pass.o' failed
make[2]: *** [nwipe-pass.o] Error 1
In file included from nwipe.c:29:0:
context.h:85:2: error: unknown type name 'off64_t'
  off64_t           device_size;   /* The device size in bytes.                                      */
  ^
nwipe.c: In function 'main':
nwipe.c:290:29: warning: pointer targets in passing argument 1 of 'strlen' differ in signedness [-Wpointer-sign]
                 if ( strlen(c2[i]->identity.serial_no) ) {
                             ^
In file included from nwipe.h:49:0,
                 from nwipe.c:28:
/usr/include/string.h:394:15: note: expected 'const char *' but argument is of type 'unsigned char *'
 extern size_t strlen (const char *__s)
               ^
nwipe.c:359:44: error: 'off64_t' undeclared (first use in this function)
                 if( c2[i]->device_size == (off64_t)-1 )
                                            ^
nwipe.c:359:44: note: each undeclared identifier is reported only once for each function it appears in
Makefile:408: recipe for target 'nwipe-nwipe.o' failed
make[2]: *** [nwipe-nwipe.o] Error 1
In file included from device.c:27:0:
context.h:85:2: error: unknown type name 'off64_t'
  off64_t           device_size;   /* The device size in bytes.                                      */
  ^
Makefile:450: recipe for target 'nwipe-device.o' failed
make[2]: *** [nwipe-device.o] Error 1
make[2]: Leaving directory '/home/mambroz/rpmbuild/BUILD/nwipe-d01b00b4f82ea1899eee1f0ffb47ebc6ac7e5dc2/src'
Makefile:360: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/mambroz/rpmbuild/BUILD/nwipe-d01b00b4f82ea1899eee1f0ffb47ebc6ac7e5dc2'
Makefile:301: recipe for target 'all' failed
make: *** [all] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.zHaxVx (%build)

RPM build errors:
    Bad exit status from /var/tmp/rpm-tmp.zHaxVx (%build)

Best regards Michal Ambroz

martijnvanbrummelen commented 8 years ago

Hi Michal, Which distro are trying to build it on? It build fine on Debian Unstable 32/64 bit.

Kind regards, Martijn

xambroz commented 8 years ago

Hello, I did some tests and it seems that the build actually fails o x86 as well. The key is probably version of gcc or something like that. Build fails on everything prior to Fedora24.

https://copr.fedorainfracloud.org/coprs/rebus/infosec-rebus/build/437644/

Best regards Michal Ambroz

martijnvanbrummelen commented 8 years ago

Hi Michal,

Please check if this patch will fix your problem.

--- nwipe-0.18.orig/src/nwipe.h +++ nwipe-0.18/src/nwipe.h @@ -27,6 +27,11 @@

define _LARGEFILE64_SOURCE

endif

+/* workaround for Fedora */ +#ifndef off64_t +# define off64_t off_t +#endif +

ifndef _FILE_OFFSET_BITS

define _FILE_OFFSET_BITS 64

endif

xambroz commented 8 years ago

Patch works for Fedora <= 23

xambroz commented 8 years ago

It would be nice if it can get to the head of upstream nwipe. Thank you

martijnvanbrummelen commented 8 years ago

Fixed

xambroz commented 8 years ago

Thank you