Permission issues when changing path of files in Grade Copy Task - gradle

Wasn't really sure where best to ask this so, though the best place was here!
I have an issue with a Gradle Copy Task where I am unzipping a zip and then modifying the file paths to remove the root folder in the zip. This was a recommended workflow because the feature to elect certain sub-directories in a zip isn't available in Gradle: https://github.com/gradle/gradle/issues/1108
So here is my problem this is my Gradle Task:
task unpackTomcat( type: Copy ) {
from zipTree( "/Users/x/Downloads/tomcat-X.zip" )
into "/app/tomcat"
fileMode 0660
dirMode 0750
includeEmptyDirs = false
eachFile { details ->
def path = details.path
details.path = path.substring( path.indexOf( '/' ) + 1 )
}
}
This will unpack the zip and move all files out of the apache-tomcat-X folder and put them in my base folder. IE remove the first part of the path. However when it does this the permissions on the folders are incorrect:
drwxr-xr-x 3 X X 102B Oct 12 13:58 temp/
drwxr-xr-x 27 X X 918B Oct 12 13:58 lib/
drwxr-xr-x 12 X X 408B Oct 12 13:58 conf/
drwxr-xr-x 25 X X 850B Oct 12 13:58 bin/
-rw-rw---- 1 X X 1.7K Oct 12 13:58 NOTICE
-rw-rw---- 1 X X 57K Oct 12 13:58 LICENSE
drwxr-x--- 3 X X 102B Oct 12 13:58 ../
drwxr-x--- 8 X X 272B Oct 12 13:58 ./
Even setting a umask to 027 (Trying to remove other permissions from the files/directory) on the Gradle JVM doesn't even stop this (This should force the JVM to use the permissions of UMASK is there is no filemode set. If I remove the eachFile part of the above task the folders have the right permissions, but obviously would be in the apache-tomcat-X folder that gets created which I don't want to occur.
So I am at a lose as to why this is happening and would love people more experienced with Gradle to help me out here. It appears that the issue is that path change causes the folders to be created with my base UMASK instead of the UMASK that is supposed to be used and this appears to be a bug but thought I would check here.

Related

MacOS Catalina - Show all directories from root in Finder

As a reluctant Mac user, I am routinely frustrated by things that should be very simple. Finder is one of those. When trying to open an XML file from Firefox, I am asked what application I whish to open it with. Obviously MacVim. To do that, I need to navigate to /usr/local/bin/gvim which is a symlink to /Cellar, since it was installed with HomeBrew. However, when I select "Open with" and click "Choose", the Finder comes up and defaults to Applications. It's not in there, I just want to navigate directly to the symlink. Switching to "Macintosh HD" (also known as "/" to a more refined audience) only displays Application, Library, System, and Users. Where is everything else? Where is /usr, /bin, /etc? As a user, this seems disingenuous. It's not an accurate representation of my location in the filesystem. Sorry, this is a bit of a rant, but also a legitimate question. How do I display these all the time?
The UNIX (lowercase) directories are hidden from view, intentionally, through a special "hidden" flag. You can see those in ls -lO:
Chimera:~ morpheus$ ls -lO /
total 14
drwxrwxr-x+ 59 root admin sunlnk 1888 Sep 23 16:46 Applications
drwxr-xr-x+ 65 root wheel sunlnk 2080 Mar 20 2020 Library
drwxr-xr-x 2 root wheel hidden 64 Sep 30 2018 Network
drwxr-xr-x# 5 root wheel restricted 160 Sep 21 2018 System
drwxr-xr-x 7 root admin - 224 Mar 20 2020 Users
drwxr-xr-x# 8 root wheel hidden 256 Sep 23 21:17 Volumes
drwxr-xr-x# 37 root wheel restricted,hidden 1184 Mar 27 2019 bin
drwxrwxr-t# 2 root admin hidden 64 Feb 8 2019 cores
dr-xr-xr-x 3 root wheel hidden 4821 Aug 30 19:38 dev
lrwxr-xr-x# 1 root wheel restricted,hidden 11 Sep 30 2018 etc -> private/etc
dr-xr-xr-x 2 root wheel hidden 1 Sep 24 07:59 home
-rw-r--r-- 1 root wheel hidden,compressed 313 Aug 17 2018 installer.failurerequests
drwxr-xr-x 2 root wheel - 64 Oct 3 2018 mnt
drwxr-xr-x 2 root wheel - 64 Jan 21 2018 mnt1
dr-xr-xr-x 2 root wheel hidden 1 Sep 24 07:59 net
drwxr-xr-x 6 root wheel sunlnk,hidden 192 Sep 30 2018 private
drwxr-xr-x# 64 root wheel restricted,hidden 2048 Mar 27 2019 sbin
lrwxr-xr-x# 1 root wheel restricted,hidden 11 Sep 30 2018 tmp -> private/tmp
drwxr-xr-x# 9 root wheel restricted,hidden 288 Sep 21 2018 usr
lrwxr-xr-x# 1 root wheel restricted,hidden 11 Sep 30 2018 var -> private/var
Additionally, Finder will not display hidden "." files, the same way ls -l needs to be "persuaded" using -a (try "ls -lOa /", omitted here for brevity).
Pressing the apple key along with shift and '.' will display everything. To make this the default behavior:
defaults write com.apple.finder AppleShowAllFiles YES
In case you're interested in the rationale - it dates back to NeXTSTEP (the progenitor to MacOS X and later as we know it now), which wanted to provide a user interface to its own (Uppercase first letter) directories, while hiding those of the underlying UNIX (BSD layer), seeing as non-root users have nothing to look for there, anyway (and most users have no knowledge of terminal/shell).

Developing inside docker on WSL2-Ubuntu from vscode

I am trying run docker inside WSL (am running Ubuntu in WSL). Also am new to docker. The doc says:
To get the best out of the file system performance when bind-mounting files:
Store source code and other data that is bind-mounted into Linux containers (i.e., with docker run -v <host-path>:<container-path>) in the Linux filesystem, rather than the Windows filesystem.
Linux containers only receive file change events (“inotify events”) if the original files are stored in the Linux filesystem.
Performance is much higher when files are bind-mounted from the Linux filesystem, rather than remoted from the Windows host. Therefore avoid docker run -v /mnt/c/users:/users (where /mnt/c is mounted from Windows).
Instead, from a Linux shell use a command like docker run -v ~/my-project:/sources <my-image> where ~ is expanded by the Linux shell to $HOME.
I also came across following:
Run sudo docker run -v "$HOME:/host" --name "[name_work]" -it docker.repo/[name]. With, [$HOME:/host], you can access your home directory in /host dir in docker image. This allows you to access your files on the local machine inside the docker. So you can edit your source code in your local machine using your favourite editor and run them directly inside the docker. Make sure that you have done this correct. Otherwise, you may need to copy files from the local machine to docker, for each edit (a painful job).
I am not able to understand the format of parameter passed to -v option and what it does. I am thinking that it will allow to access Ubuntu directories inside docker. So $HOME:/host will map Ubuntu's home directory to /host inside.
Q1. But what is /host?
Q2. Can I do what is stated by above two quotes together? I mean what they are saying is compatible? I guess yes. What all its saying is I should not mount from windows director like /mnt/<driveletter>/.... If I am mounting linux directory like $USER/... then it will give better performance, right?
I tried out running it to understand it:
~$ docker run -v "$HOME:/host" --name "mydokr" -it docker.repo.in/dokrimg
root#f814974a1cfb:/home# ls
root#f814974a1cfb:/home# ll
total 8
drwxr-xr-x 2 root root 4096 Apr 15 11:09 ./
drwxr-xr-x 1 root root 4096 Sep 22 07:16 ../
root#f814974a1cfb:/home# pwd
/home
root#f814974a1cfb:/home# cd ..
root#f814974a1cfb:/# ll
total 64
drwxr-xr-x 1 root root 4096 Sep 22 07:16 ./
drwxr-xr-x 1 root root 4096 Sep 22 07:16 ../
-rwxr-xr-x 1 root root 0 Sep 22 07:16 .dockerenv*
lrwxrwxrwx 1 root root 7 Jul 3 01:56 bin -> usr/bin/
drwxr-xr-x 2 root root 4096 Apr 15 11:09 boot/
drwxr-xr-x 5 root root 360 Sep 22 07:16 dev/
drwxr-xr-x 1 root root 4096 Sep 22 07:16 etc/
drwxr-xr-x 2 root root 4096 Apr 15 11:09 home/
drwxr-xr-x 5 1000 1001 4096 Sep 22 04:52 host/
lrwxrwxrwx 1 root root 7 Jul 3 01:56 lib -> usr/lib/
lrwxrwxrwx 1 root root 9 Jul 3 01:56 lib32 -> usr/lib32/
lrwxrwxrwx 1 root root 9 Jul 3 01:56 lib64 -> usr/lib64/
lrwxrwxrwx 1 root root 10 Jul 3 01:56 libx32 -> usr/libx32/
drwxr-xr-x 2 root root 4096 Jul 3 01:57 media/
drwxr-xr-x 2 root root 4096 Jul 3 01:57 mnt/
drwxr-xr-x 2 root root 4096 Jul 3 01:57 opt/
dr-xr-xr-x 182 root root 0 Sep 22 07:16 proc/
drwx------ 1 root root 4096 Aug 24 03:54 root/
drwxr-xr-x 1 root root 4096 Aug 11 10:24 run/
lrwxrwxrwx 1 root root 8 Jul 3 01:56 sbin -> usr/sbin/
drwxr-xr-x 2 root root 4096 Jul 3 01:57 srv/
dr-xr-xr-x 11 root root 0 Sep 22 03:32 sys/
-rw-r--r-- 1 root root 1610 Aug 24 03:56 test_logPath.log
drwxrwxrwt 1 root root 4096 Aug 24 03:57 tmp/
drwxr-xr-x 1 root root 4096 Aug 11 10:24 usr/
drwxr-xr-x 1 root root 4096 Jul 3 02:00 var/
root#f814974a1cfb:/home# cd ../host
root#f814974a1cfb:/host# ll
total 36
drwxr-xr-x 5 1000 1001 4096 Sep 22 04:52 ./
drwxr-xr-x 1 root root 4096 Sep 22 07:16 ../
-rw-r--r-- 1 1000 1001 220 Sep 22 03:38 .bash_logout
-rw-r--r-- 1 1000 1001 3771 Sep 22 03:38 .bashrc
drwxr-xr-x 3 1000 1001 4096 Sep 22 04:56 .docker/
drwxr-xr-x 2 1000 1001 4096 Sep 22 03:38 .landscape/
-rw-r--r-- 1 1000 1001 0 Sep 22 03:38 .motd_shown
-rw-r--r-- 1 1000 1001 921 Sep 22 04:52 .profile
-rw-r--r-- 1 1000 1001 0 Sep 22 03:44 .sudo_as_admin_successful
drwxr-xr-x 5 1000 1001 4096 Sep 22 04:52 .vscode-server/
-rw-r--r-- 1 1000 1001 183 Sep 22 04:52 .wget-hsts
So I am not getting whats happening here. I know docker has its own file system.
Q3. Is is that, what am finding at /home and /host is indeed container's own file system?
Q4. Also, what happened to -v $HOME:/host here?
Q5. How can I do as stated by 2nd quote:
This allows you to access your files on the local machine inside the docker. So you can edit your source code in your local machine using your favourite editor and run them directly inside the docker.
Q6. How do I connect vscode to this container? From WSL-Ubuntu, I could just run code . to launch vscode. But the same does not seem to work here:
root#f814974a1cfb:/home# code .
bash: code: command not found
This link says:
A devcontainer.json file can be used to tell VS Code how to configure the development container, including the Dockerfile to use, ports to open, and extensions to install in the container. When VS Code finds a devcontainer.json in the workspace, it automatically builds (if necessary) the image, starts the container, and connects to it.
But I guess this says starting up creating new container form vscode. But not connecting to already existing container. I am not able to find my dockercontainer.json. I downloaded this container image using docker pull.

Cannot give myself root my permissions

I am trying to give myself root access to all the file in this folder and not have to sudo everything I want to run a command.
The file I am concerned with is pro
When I enter ls -l I get :
drwxr-xr-x+ 12 Guest _guest 384 13 Jan 14:56 Guest
drwxrwxrwt 9 root wheel 288 13 Jan 14:30 Shared
drwxr-xr-x+ 148 Santi staff 4736 1 Apr 17:13 pro
then I enter chmod 775 pro/
It doesnt seem to change the permssions. What can I do to fix this or why is the folder restricting permission even though I appear to be root?
drwxr-xr-x+ ...
the final + means that the file is governed by acl
see
apropos acl : give you the mans to consult
wikipedia
Access Control Lists on Arch wiki

Why does directory vanish when I do SSHFS? How to setup SSHFS share on Max OSX 10.9?

I'm running Max OSX 10.9.3 and I'm trying to setup an SSHFS file-share between my MacBook Pro and a remote file system. However, when I try to do it, it doesn't work.
Strangely enough, it makes the target directory disappear. Has anyone else seen this happen? Is it a bug?
First see that I can ssh normally into the target machine:
% ssh remoteuser#XXX.XXX.XXX.XXX # <--- SSH to remote system works! See below.
remoteuser#XXX.XXX.XXX.XXX % ls -altr remoteDir
total 8
drwxr-xr-x 26 remoteuser remoteuser 4096 Jun 22 01:00 ..
drwxrwxrwx 2 remoteuser remoteuser 4096 Jun 22 01:08 .
remoteuser#XXX.XXX.XXX.XXX % exit
% # <--- Logged out of remote system
Next, I create a directory locally and verify it was created:
% pwd
/mnt
% ls
total 0
drwxr-xr-x 31 root admin 1122 Jun 18 18:34 ../
drwxr-xr-x 2 root admin 68 Jun 23 08:11 ./
% sudo mkdir share1
% ls
drwxr-xr-x 31 root admin 1122 Jun 18 18:34 ../
drwxr-xr-x 4 root admin 136 Jun 23 08:50 ./
drwxr-xr-x 2 root admin 68 Jun 23 08:50 share/
Now I try to setup the SSHFS share:
% sudo sshfs remoteuser#XXX.XXX.XXX.XXX:remoteDir /mnt/share1
remoteuser#XXX.XXX.XXX.XXX's password:
%
Ok. It seems to have worked. No errors. So let's see the share we created, shall we?
% ls
ls: share1: No such file or directory
total 0
drwxr-xr-x 31 root admin 1122 Jun 18 18:34 ../
drwxr-xr-x 3 root admin 102 Jun 23 08:12 ./
What? Not only is the File Sharing not working, but the share1 directory seems to have vanished! (Although the file system seems to know it is missing, which is weird).
Where did /mnt/share1 go and how do I setup this SSHFS?
SSHFS doesn't come with OS X AFAIK, so you should mention how you installed it. But I'm guessing sshfs is designed to be used with fstab or mount rather than be called directly. Try something like:
mount -t sshfs remoteuser#XXX.XXX.XXX.XXX:remoteDir /mnt/share1

Use rsync to copy only hidden files

I want to back up all the hidden files and directories in my homedir using rsync, but not the non-hidden files and directories.
For example, given this directory listing:
drwxr-xr-x 7 sophie sophie 238 31 Mar 08:45 .
drwxr-xr-x 15 sophie sophie 510 31 Mar 08:14 ..
-rw-r--r-- 1 sophie sophie 4 31 Mar 08:12 .foo
drwxr-xr-x 3 sophie sophie 102 31 Mar 08:45 .hiddendir
drwxr-xr-x 4 sophie sophie 136 31 Mar 08:13 VisibleDirectory
-rw-r--r-- 1 sophie sophie 9 31 Mar 08:13 VisibleFile
I want to back up .foo, .hiddendir, and all the contents of .hiddendir whether they are hidden or not. I don't want to back up VisibleDirectory or VisibleFile.
All the incantations I have come up with back up ".", and therefore all its contents including VisibleFile and VisibleDirectory, and I can't figure out how to exclude it. Please help!
I'm using Mac OS X 10.5.6 (Leopard) and rsync version 2.6.9 protocol version 29.
A common pattern to match the hidden items is .[^.]*
rsync -a ~/.[^.]* /path/to/backup
This copies all files starting with a single dot. Note that it doesn't include files starting with more than one dot.
It's usually ".??*" to make sure you don't copy "." and ".."
(What if you had a file that was just ".a" ?)
Have you tried incarnations like ./.*?
Could you copy the hidden files to a temp directory, back up the temp directory, then remove it?

Resources