WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Busybox strangeness  (Read 3730 times)

Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
Busybox strangeness
« on: September 10, 2017, 12:48:23 PM »
Can someone explain this to me? This is 32-bit busybox on 8.1.

Code: [Select]
tc@box:/mnt/sda1/lamp32/build/vim-master$ tce-status -i | grep unzip
zip-unzip
tc@box:/mnt/sda1/lamp32/build/vim-master$ which unzip
/usr/local/bin/unzip
tc@box:/mnt/sda1/lamp32/build/vim-master$ unzip --help
BusyBox v1.27.1 (2017-08-10 16:51:42 UTC) multi-call binary.

Usage: unzip [-lnopq] FILE[.zip] [FILE]... [-x FILE...] [-d DIR]

Extract FILEs from ZIP archive

        -l      List contents (with -q for short form)
        -n      Never overwrite files (default: ask)
        -o      Overwrite
        -p      Print to stdout
        -q      Quiet
        -x FILE Exclude FILEs
        -d DIR  Extract into DIR
tc@box:/mnt/sda1/lamp32/build/vim-master$ $(which unzip) --help
UnZip 6.00 of 20 April 2009, by Info-ZIP.  Maintained by C. Spieler.  Send
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.

Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]
  Default action is to extract files in list, except those in xlist, to exdir;
  file[.zip] may be a wildcard.  -Z => ZipInfo mode ("unzip -Z" for usage).

  -p  extract files to pipe, no messages     -l  list files (short format)
  -f  freshen existing files, create none    -t  test compressed archive data
  -u  update files, create if necessary      -z  display archive comment only
  -v  list verbosely/show version info       -T  timestamp archive to latest
  -x  exclude files that follow (in xlist)   -d  extract files into exdir
modifiers:
  -n  never overwrite existing files         -q  quiet mode (-qq => quieter)
  -o  overwrite files WITHOUT prompting      -a  auto-convert any text files
  -j  junk paths (do not make directories)   -aa treat ALL files as text
  -C  match filenames case-insensitively     -L  make (some) names lowercase
  -X  restore UID/GID info                   -V  retain VMS version numbers
  -K  keep setuid/setgid/tacky permissions   -M  pipe through "more" pager
See "unzip -hh" or unzip.txt for more help.  Examples:
  unzip data1 -x joe   => extract all files except joe from zipfile data1.zip
  unzip -p foo | more  => send contents of foo.zip via pipe into program more
  unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer

To make matters worse, busybox unzip on 32-bit doesn't preserve the executable bit on ordinary files. I haven't seen this on 64-bit. The zip-unzip does preserve the executable bit. It's hard to compile a package if there aren't any executable scripts.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: Busybox strangeness
« Reply #1 on: September 10, 2017, 02:10:58 PM »
Did you load zip-unzip in that same shell? The path hash table doesn't get updated until you start a new shell or issue the command to do so.

If not, and it only happens in bb ash and not bash, then it could be a bb bug.
The only barriers that can stop you are the ones you create yourself.

Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
Re: Busybox strangeness
« Reply #2 on: September 10, 2017, 05:21:37 PM »
All one shell. I reboot and it still happens. And it happens with every program there's a busybox app for that I've tried so far, like unzip, wget, and tar. I don't see any aliases for any of those. And for some strange reason when I use copy2fs.lst I occaisionally get a "rmdir: '/mnt/test': Permission denied" which apparently comes from tce-load where sudo is used to make that directory but not used to remove it. I don't know if it's related.

Offline polikuo

  • Hero Member
  • *****
  • Posts: 724
Re: Busybox strangeness
« Reply #3 on: September 10, 2017, 10:31:37 PM »
The $PATH looks fine on 64-bit.  :)
Code: [Select]
tc@box:~$ version
8.1
tc@box:~$ uname -r
4.8.17-tinycore64
tc@box:~$ echo $PATH
/home/tc/.local/bin:/usr/local/sbin:/usr/local/bin:/apps/bin:/usr/sbin:/usr/bin:/sbin:/bin:/etc/sysconfig/tcedir/ondemand
tc@box:~$ which unzip
/usr/bin/unzip
tc@box:~$ realpath /usr/bin/unzip
/bin/busybox
tc@box:~$ tce-load -i unzip
unzip.tcz: OK
tc@box:~$ which unzip
/usr/local/bin/unzip
tc@box:~$ unzip --help
UnZip 6.00 of 20 April 2009, by Info-ZIP.  Maintained by C. Spieler.  Send
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.
......

As for the executable bit ...  :P
Code: [Select]
tc@box:/tmp$ mkdir hello
tc@box:/tmp$ cd hello
tc@box:/tmp/hello$ echo 'echo Hello World!' > hello
tc@box:/tmp/hello$ chmod +x hello
tc@box:/tmp/hello$ cd ../
tc@box:/tmp$ zip hello hello/*
  adding: hello/hello (stored 0%)
tc@box:/tmp$ mkdir cache
tc@box:/tmp$ cd cache/
tc@box:/tmp/cache$ /bin/busybox unzip ../hello.zip
Archive:  ../hello.zip
  inflating: hello/hello
tc@box:/tmp/cache$ ./hello/hello
sh: ./hello/hello: Permission denied
tc@box:/tmp/cache$ ls -l hello/hello
-rw-r--r-- 1 tc staff 18  Sep 11 10:22 hello/hello
tc@box:/tmp/cache$ rm -fr *
tc@box:/tmp/cache$ /usr/local/bin/unzip ../hello.zip
Archive:  ../hello.zip
 extracting: hello/hello             
tc@box:/tmp/cache$ ./hello/hello
Hello World!
tc@box:/tmp/cache$ ls -l hello/hello
-rwxr-xr-x 1 tc staff 18 Sep 11 10:18 hello/hello

I haven't checked the copy2fs.lst yet.
« Last Edit: September 10, 2017, 10:33:37 PM by polikuo »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11622
Re: Busybox strangeness
« Reply #4 on: September 10, 2017, 10:43:28 PM »
Hi polikuo
I think andyj is having that problem with the 32 bit version.

Offline polikuo

  • Hero Member
  • *****
  • Posts: 724
Re: Busybox strangeness
« Reply #5 on: September 10, 2017, 11:00:51 PM »
Hi polikuo
I think andyj is having that problem with the 32 bit version.

I know, I'm just saying, on 64-bit, busybox also fails to preserve  the executable bit.  ;)
Not sure why he didn't see that on 32-bit thought.  ???
« Last Edit: September 10, 2017, 11:03:22 PM by polikuo »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14815
Re: Busybox strangeness
« Reply #6 on: September 11, 2017, 06:15:31 AM »
unzip from CorePure64-7.2/busybox-1.24.2 does preserve the executable bit, so it looks like this is a bug in busybox-1.27.1

Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
Re: Busybox strangeness
« Reply #7 on: September 11, 2017, 07:37:29 AM »
I stand corrected. The 64-bit behavior IS the same as 32-bit:

Code: [Select]
tc@box:/mnt/sda1/lamp64/build/temp$ which unzip
/usr/bin/unzip
tc@box:/mnt/sda1/lamp64/build/temp$ unzip --help
BusyBox v1.27.1 (2017-08-10 13:51:41 UTC) multi-call binary.

Usage: unzip [-lnopq] FILE[.zip] [FILE]... [-x FILE...] [-d DIR]

Extract FILEs from ZIP archive

        -l      List contents (with -q for short form)
        -n      Never overwrite files (default: ask)
        -o      Overwrite
        -p      Print to stdout
        -q      Quiet
        -x FILE Exclude FILEs
        -d DIR  Extract into DIR
tc@box:/mnt/sda1/lamp64/build/temp$ unzip ../../../lamp/src/Recode-master.zip
Archive:  ../../../lamp/src/Recode-master.zip
   creating: Recode-master/
...
...
tc@box:/mnt/sda1/lamp64/build/temp$ tce-load -i unzip
unzip.tcz: OK
tc@box:/mnt/sda1/lamp64/build/temp$ which unzip
/usr/local/bin/unzip
tc@box:/mnt/sda1/lamp64/build/temp$ unzip --help
BusyBox v1.27.1 (2017-08-10 13:51:41 UTC) multi-call binary.

Usage: unzip [-lnopq] FILE[.zip] [FILE]... [-x FILE...] [-d DIR]

Extract FILEs from ZIP archive

        -l      List contents (with -q for short form)
        -n      Never overwrite files (default: ask)
        -o      Overwrite
        -p      Print to stdout
        -q      Quiet
        -x FILE Exclude FILEs
        -d DIR  Extract into DIR

tc@box:/mnt/sda1/lamp64/build/temp$ $(which unzip) --help
UnZip 6.00 of 20 April 2009, by Info-ZIP.  Maintained by C. Spieler.  Send
bug reports using http://www.info-zip.org/zip-bug.html; see README for details.

Usage: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir]
  Default action is to extract files in list, except those in xlist, to exdir;
  file[.zip] may be a wildcard.  -Z => ZipInfo mode ("unzip -Z" for usage).

  -p  extract files to pipe, no messages     -l  list files (short format)
  -f  freshen existing files, create none    -t  test compressed archive data
  -u  update files, create if necessary      -z  display archive comment only
  -v  list verbosely/show version info       -T  timestamp archive to latest
  -x  exclude files that follow (in xlist)   -d  extract files into exdir
modifiers:
  -n  never overwrite existing files         -q  quiet mode (-qq => quieter)
  -o  overwrite files WITHOUT prompting      -a  auto-convert any text files
  -j  junk paths (do not make directories)   -aa treat ALL files as text
  -C  match filenames case-insensitively     -L  make (some) names lowercase
  -X  restore UID/GID info                   -V  retain VMS version numbers
  -K  keep setuid/setgid/tacky permissions   -M  pipe through "more" pager
See "unzip -hh" or unzip.txt for more help.  Examples:
  unzip data1 -x joe   => extract all files except joe from zipfile data1.zip
  unzip -p foo | more  => send contents of foo.zip via pipe into program more
  unzip -fo foo ReadMe => quietly replace existing ReadMe if archive file newer


tc@box:/mnt/sda1/lamp64/build/temp$ mv Recode-master/ Recode-master-bb
tc@box:/mnt/sda1/lamp64/build/temp$ $(which unzip) ../../../lamp/src/Recode-master.zip
Archive:  ../../../lamp/src/Recode-master.zip
2d7092a9999194fc0e9449717a8048c8d8e26c18
   creating: Recode-master/
...
...

Comparing the two directories shows that not only is the executable bit not preserved, the file times are not either.
Also, to use GNU diff I had to $(which diff) as busybox prefers it's own here too.

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11622
Re: Busybox strangeness
« Reply #8 on: September 11, 2017, 08:16:52 AM »
Hi andyj
It looks like you are executing this all in the same shell as curaga mentioned. What happens if you add a  hash  command:
Code: [Select]
tc@box:/mnt/sda1/lamp64/build/temp$ tce-load -i unzip
unzip.tcz: OK
tc@box:/mnt/sda1/lamp64/build/temp$ hash -r
tc@box:/mnt/sda1/lamp64/build/temp$ which unzip
/usr/local/bin/unzip
tc@box:/mnt/sda1/lamp64/build/temp$ unzip --help

Your issue looks similar to this:
http://forum.tinycorelinux.net/index.php/topic,13162.msg72644.html#msg72644

Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
Re: Busybox strangeness
« Reply #9 on: September 11, 2017, 09:43:41 AM »
So how would we automagically clear the hash table in the current shell when we load an extension which contains replacements for existing (busybox) executables? Sounds like a manual process unless we source tce-load, and tce-load had a 'hash -r' at the end of it.


Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11622
Re: Busybox strangeness
« Reply #10 on: September 11, 2017, 11:04:55 AM »
Hi andyj
I don't know the answer to that. Did the  hash  command fix the issue?

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14815
Re: Busybox strangeness
« Reply #11 on: September 11, 2017, 12:17:34 PM »
..seems busybox now needs CONFIG_FEATURE_UNZIP_CDF=y (not present in previous versions) for the executable bit to be preserved

Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
Re: Busybox strangeness
« Reply #12 on: September 11, 2017, 12:33:11 PM »

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: Busybox strangeness
« Reply #13 on: September 11, 2017, 03:05:04 PM »
So how would we automagically clear the hash table in the current shell when we load an extension which contains replacements for existing (busybox) executables? Sounds like a manual process unless we source tce-load, and tce-load had a 'hash -r' at the end of it.
We cannot. The issue is the same if you, say, install a program to your home dir on Ubuntu, that also exists via packages. You have to issue the command or start a new shell.
The only barriers that can stop you are the ones you create yourself.