NodeJS ZIP symlink and can't read them on Windows 10 - windows-10

I'm using Archiver in a NodeJS environment (running on linux) to create a ZIP with a structure like this:
/root
/documents
/doc1.pdf
/doc2.pdf
/doc3.pdf
/clientA
/doc1.pdf < symlink to ../documents/doc1.pdf
/clientB
/doc3.pdf < symlink to ../documents/doc3.pdf
Using these functions of ArchiverJS:
archiverInstance.append(filestream, {name: '/root/documents/doc1.pdf'})
archiverInstance.symlink('/root/clientA/doc1.pdf', '../documents/doc1.pdf')
When I download this ZIP on linux, I can open the symlinks.
# linux ubuntu 19.04
ls -l ~/root/clientA
lrwxrwxrwx 1 usr usr 28 oct 11 11:51 doc1.pdf -> ../documents/doc1.pdf`
But when I download this ZIP on Windows 10, symlinks are broken, using the standard "Extract" button from the windows explorer.
# windows 10
cd root/clientA
dir
10/11/2019 02:49 AM <DIR> .
10/11/2019 02:49 AM <DIR> ..
10/11/2019 02:49 28 doc1.pdf < click on it = PDF corrupted
1 File(s) 28 bytes
2 Dir(s)
Why this does not work on Windows 10? And is there an alternative to make it work?
Thanks

Related

tar command with -zxvf not extracting contents as expected

(ubuntu 18.04)
I'm attempting to extract an odbc driver from a tarball and following these instructions with command:
tar --directory=/opt -zxvf /SimbaODBCDriverforGoogleBigQuery_2.4.6.1015-Linux.tar.gz
This results in the following output:
root#08ba33ec2cfb:/# tar --directory=/opt -zxvf SimbaODBCDriverforGoogleBigQuery_2.4.6.1015-Linux.tar.gzSimbaODBCDriverforGoogleBigQuery_2.4.6.1015-Linux/
SimbaODBCDriverforGoogleBigQuery_2.4.6.1015-Linux/GoogleBigQueryODBC.did
SimbaODBCDriverforGoogleBigQuery_2.4.6.1015-Linux/docs/
SimbaODBCDriverforGoogleBigQuery_2.4.6.1015-Linux/docs/release-notes.txt
SimbaODBCDriverforGoogleBigQuery_2.4.6.1015-Linux/docs/Simba Google BigQuery ODBC Connector Install and Configuration Guide.pdf
SimbaODBCDriverforGoogleBigQuery_2.4.6.1015-Linux/docs/OEM ODBC Driver Installation Instructions.pdf
SimbaODBCDriverforGoogleBigQuery_2.4.6.1015-Linux/setup/
SimbaODBCDriverforGoogleBigQuery_2.4.6.1015-Linux/setup/simba.googlebigqueryodbc.ini
SimbaODBCDriverforGoogleBigQuery_2.4.6.1015-Linux/setup/odbc.ini
SimbaODBCDriverforGoogleBigQuery_2.4.6.1015-Linux/setup/odbcinst.ini
SimbaODBCDriverforGoogleBigQuery_2.4.6.1015-Linux/SimbaODBCDriverforGoogleBigQuery32_2.4.6.1015.tar.gz
SimbaODBCDriverforGoogleBigQuery_2.4.6.1015-Linux/SimbaODBCDriverforGoogleBigQuery64_2.4.6.1015.tar.gz
The guide linked to above says:
The Simba Google BigQuery ODBC Connector files are installed in the
/opt/simba/googlebigqueryodbc directory
Not for me, but I do see:
ls -l /opt/
total 8
drwxr-xr-x 1 1000 1001 4096 Apr 26 00:39 SimbaODBCDriverforGoogleBigQuery_2.4.6.1015-Linux
And:
ls -l /opt/SimbaODBCDriverforGoogleBigQuery_2.4.6.1015-Linux/
total 52324
-rwxr-xr-x 1 1000 1001 400 Apr 26 00:39 GoogleBigQueryODBC.did
-rw-rw-rw- 1 1000 1001 26688770 Apr 26 00:39 SimbaODBCDriverforGoogleBigQuery32_2.4.6.1015.tar.gz
-rw-rw-rw- 1 1000 1001 26876705 Apr 26 00:39 SimbaODBCDriverforGoogleBigQuery64_2.4.6.1015.tar.gz
drwxr-xr-x 1 1000 1001 4096 Apr 26 00:39 docs
drwxr-xr-x 1 1000 1001 4096 Apr 26 00:39 setup
I was specifically looking for the .so driver file. All the above is on a docker container. I tried extracting the tarball locally on Ubuntu 18.04 (Same as my Docker container) and when I use Ubuntu desktop gui to extract by double clicking the tar.gz file and then clicking 'extract', I do indeed see the expected files.
It seems my tar command (tar --directory=/opt -zxvf /SimbaODBCDriverforGoogleBigQuery_2.4.6.1015-Linux.tar.gz) is not extracting the tarball as expected.
How can I extract the contents of the tarball properly? The tarball in question is the linux one on this link.
[edit]
Adding screens of contents of the tarball per comments. I had to click down two levels of nesting to arrive at 'stuff':
The instructions you linked to do not match the contents of the file I found from here. The first .tar.gz contains two other .tar.gz files. I looked into the 64 bit one and it has:
SimbaODBCDriverforGoogleBigQuery64_2.4.6.1015/
SimbaODBCDriverforGoogleBigQuery64_2.4.6.1015/ErrorMessages/
SimbaODBCDriverforGoogleBigQuery64_2.4.6.1015/ErrorMessages/en-US/
SimbaODBCDriverforGoogleBigQuery64_2.4.6.1015/ErrorMessages/en-US/SimbaBigQueryODBCMessages.xml
SimbaODBCDriverforGoogleBigQuery64_2.4.6.1015/ErrorMessages/en-US/ODBCMessages.xml
SimbaODBCDriverforGoogleBigQuery64_2.4.6.1015/ErrorMessages/en-US/SQLEngineMessages.xml
SimbaODBCDriverforGoogleBigQuery64_2.4.6.1015/ErrorMessages/en-US/DSMessages.xml
SimbaODBCDriverforGoogleBigQuery64_2.4.6.1015/ErrorMessages/en-US/DSCURLHTTPClientMessages.xml
SimbaODBCDriverforGoogleBigQuery64_2.4.6.1015/third-party-licenses.txt
SimbaODBCDriverforGoogleBigQuery64_2.4.6.1015/lib/
SimbaODBCDriverforGoogleBigQuery64_2.4.6.1015/lib/libgooglebigqueryodbc_sb64.so
SimbaODBCDriverforGoogleBigQuery64_2.4.6.1015/lib/cacerts.pem
SimbaODBCDriverforGoogleBigQuery64_2.4.6.1015/lib/EULA.txt
SimbaODBCDriverforGoogleBigQuery64_2.4.6.1015/Tools/
SimbaODBCDriverforGoogleBigQuery64_2.4.6.1015/Tools/get_refresh_token.sh
Your .so is in the lib directory. Based on the instructions it looks like you need to extract this file (or the 32 bit if appropriate) and rename, in this case SimbaODBCDriverforGoogleBigQuery64_2.4.6.1015 to simba/googlebigqueryodbc. The tar command is doing what it is told but the instructions are way off.

file zip/tar in linux at specific location

I want to zip a set of directories and files on my centos 8 VM.
There are 3 directories and 1 file which I want to zip in such a way that only env.conf file will move to /etc/env.txt after unzipping it and remaining directories will be unzipped at current location.
Is there any way to achieve this.
drwxr-xr-x. 9 root root 114 Feb 25 12:40 config
-rw-r--r--. 1 root root 340 Feb 25 09:01 env.conf
drwxr-xr-x. 9 root root 4096 Feb 28 05:11 platform
drwxr-xr-x. 2 root root 135 Feb 28 07:49 install
I don't think this is possible. in fact this is considered a vulnerability if you could do that.
Imagine you download a zip file from some website. and after you unzip it in a temp folder. It registers itself as a service by writing a file in /etc somewhere, and gets control over your pc.
Example: zip-slip
You could however create a one-liner that extracts and moves the file wherever you want like this:
unzip <filename> && mv env.conf /etc/env.txt

WSL: Unable to view the folders (appear as file) in Windows explorer if using symlink, but works if symlink on the same directory

No idea why but it seems that Windows explorer unable to view symlinked directories that the target is not on the same directory as the source target.
Is there a way to fix it? As it also make win32 applications unable to read the files under the symlinked directory. (I understand Windows equivalent mklink exist, but I need to do it in WSL's ln.)
Thanks a lot.
Sysinfo:
Windows 10 Pro 2004 Build 19041.264
(No idea how to check WSL build number)
WSL2
Subsystem uname: Linux PC 4.19.104-microsoft-standard #1 SMP Wed Feb 19 06:37:35 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Ubuntu:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
Example:
$ pwd
/mnt/d/symlink_test/innerFolder
$ mkdir source
$ touch source/testfile
$ ls source
testfile
$ ln -s source target
$ ls -l
total 0
drwxrwxrwx 1 user user 4096 Jun 6 10:55 source
lrwxrwxrwx 1 user user 6 Jun 6 10:55 target -> source
Now view the output in Windows explorer:
As you can tell, the target folder is recognizable by Windows Explorer
As well as the file testfile is accessable in Windows Explorer
Counter Example:
$ rm -rf target #Just clean things up
$ ls
source
$ ln -s /mnt/d/symlink_test/innerFolder/source ../upper_target #make a symlink to upper dir, or any directory that is not in the same dir, with the source dir being absolute path
$ ls -l .. #List files on the upper dir
total 0
drwxrwxrwx 1 user user 4096 Jun 6 11:03 innerFolder
lrwxrwxrwx 1 user user 6 Jun 6 11:04 upper_target -> /mnt/d/symlink_test/innerFolder/source
$ ls ../upper_target
testfile
However, but now, if you view it in Windows Explorer, the upper_target will become a single file instead of a folder, like above:

How to access the desktop with cygwin

I want access to my windows 10 desktop with Cygwin. I tried this
$cd cygdrive/c/
$ls -al
But I can't see no one folder named "Desktop".
As you discovered the Desktop for any user is located in the disk at
C:\Users\[username]\Desktop
and its equivalent for Cygwin is
$ cygpath -u 'C:\Users\[username]\Desktop'
/cygdrive/c/Users/[username]/Desktop
It is NOT a Cygwin specific issue. Also with Windows Commond Prompt there is no
Desktop folder at the root of the C: disk structure
Microsoft Windows [Version 10.0.17134.472]
(c) 2018 Microsoft Corporation. Alle Rechte vorbehalten.
C:\Users\Marco>cd \
C:\>dir
Datenträger in Laufwerk C: ist Windows
Volumeseriennummer: 98EE-C713
Verzeichnis von C:\
15.07.2018 12:13 <DIR> inetpub
19.06.2018 16:34 <DIR> Intel
12.04.2018 00:38 <DIR> PerfLogs
05.10.2018 12:15 <DIR> Program Files
30.12.2018 04:27 <DIR> Program Files (x86)
18.07.2018 16:39 <DIR> SWSetup
18.07.2018 16:51 <DIR> temp
19.09.2018 10:44 <DIR> Users
03.01.2019 23:07 <DIR> Windows
0 Datei(en), 0 Bytes
9 Verzeichnis(se), 174.164.725.760 Bytes frei
C:\>
Explorer is showing a Virtual structure putting together the User data folders and the Disks at the same level.
I think that OneDrive is automatically "eating" the Desktop folder. Look here:
/cygdrive/c/users/[user-name]/OneDrive/Desktop.
For me it worked.....

Ftp backup folder download as files,, i cant find .tar.gz files

i create backup folder in ftp server , and send all my .tar.gz file into /backup folder
using (put file.tar.gz backup)
while i retrieve backup,, i get backup folder as backup files. ,, how to convert the file to folder ..
ftp server
ls
227 Entering Passive Mode (10,21,131,105,76,56)
150 Accepted data connection
drwxr-xr-x 6 100 ftpgroup 7 Oct 20 19:57 .
drwxr-xr-x 6 100 ftpgroup 7 Oct 20 19:57 ..
-r-------- 1 100 ftpgroup 84 Oct 21 11:15 .banner
drwxrwxrwx 3 100 ftpgroup 4 Oct 20 18:28 backup
drwxrwxrwx 2 100 ftpgroup 3 Oct 20 19:45 dailybackup
drwxrwxr-x 2 100 ftpgroup 3 Oct 20 19:57 hi5songs
drwxrwxr-x 2 100 ftpgroup 3 Oct 20 19:49 whole
226-Options: -a -l
226 7 matches total
i tried :
ftp> mget backup``
mget .? y
227 Entering Passive Mode (10,21,131,105,62,8)
550 I can only retrieve regular files
mget ..? y
Warning: embedded .. in .. (changing to !!)
227 Entering Passive Mode (10,21,131,105,46,39)
550 Can't open !!: No such file or directory
mget backup? y
227 Entering Passive Mode (10,21,131,105,72,24)
550 I can only retrieve regular files
mget cpanelbackup? y
227 Entering Passive Mode (10,21,131,105,73,69)
550 Can't open cpanelbackup: No such file or directory
while
i use (get backup home)
it successfully retrieve but as files shown below
server:
'root#azar [/home]# ls
./ backup.2* .cpan/ dailybackup hi5songs.4 oldeserver
../ backup.3* cPanelInstall/ hi5songs/ hi5songs.5 oldserver/
0_README_BEFORE_DELETING_VIRTFS backup.4* .cpanm/ hi5songs.1 home quota.user
backup/ backup.5* .cpcpan/ hi5songs.2 latest virtfs/
backup.1* .banner cpeasyapache/ hi5songs.3 lost+found/ whole'
i got that backup with green color executable file like backup.1* ( note: i cant open those file and extract those files) what to do
how to get my .tar.gz file back
please guide me,,
advance thanks,,
Updated Answer
If you want to get all files from /some/place on your server, to /home/here on your local machine, you would either do this:
cd /home/here # change directory before starting FTP
ftp server ... # connect
cd /some/place # go to desired folder on server
bi # ensure no funny business with line-endings
mget * # get all files
or you can change directory locally, within FTP like this:
ftp server ... # connect
cd /some/place # go to desired folder on server
lcd /home/here # LOCALLY change directory to where you want the files to 'land'
bi # ensure no funny business
mget * # get all files
Original Answer
I cannot understand your question at all, but you are doing some things wrong.
You cannot use GET or MGET to get a folder (directory) like you are trying to do with mget backup. You can only GET a file. Now your file may be a tar-file with more than one file in it, but it is still a file.
If you are getting tar-files and binary files, you should use BINARY mode to ensure line-end characters that may occur in binary files are not translated between Windows and Unix line-endings. So, as a matter of course, you should issue BI command before you get files.
If you have several files in your backup directory, you should probably do cd backup then bi
then mget *

Resources