Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 602758 - app-admin/webapp-config: --copy doesn't handle symlinks
Summary: app-admin/webapp-config: --copy doesn't handle symlinks
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Web Application Packages Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-15 14:09 UTC by stathis
Modified: 2023-01-28 20:11 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info (emerge-info.txt,5.34 KB, text/plain)
2016-12-15 14:09 UTC, stathis
Details

Note You need to log in before you can comment on or make changes to this bug.
Description stathis 2016-12-15 14:09:29 UTC
Created attachment 456308 [details]
emerge --info

After emerging mail-client/roundcube-1.2.3 I tried to use webapp-config-1.54-r2 to utilize it:

webapp-config --copy -I roundcube 1.2.3 -h mail.example.org -u apache -g apache -d /  

Which fails with:

* 
* You may be installing into the website's root directory.
* Is this what you meant to do?
* 
*   Creating required directories
*   Linking in required files
*     This can take several minutes for larger apps
^o^ hiding /config/defaults.inc.php
Traceback (most recent call last):
  File "/usr/lib/python-exec/python2.7/webapp-config", line 42, in <module>
    main()
  File "/usr/lib/python-exec/python2.7/webapp-config", line 39, in main
    config.run()
  File "/usr/lib64/python2.7/site-packages/WebappConfig/config.py", line 1244, in run
    self.config.get('USER', 'pvr')).install()
  File "/usr/lib64/python2.7/site-packages/WebappConfig/server.py", line 240, in install
    self.__add.mkdirs()
  File "/usr/lib64/python2.7/site-packages/WebappConfig/worker.py", line 327, in mkdirs
    self.mkdirs(directory + '/' + i)
  File "/usr/lib64/python2.7/site-packages/WebappConfig/worker.py", line 327, in mkdirs
    self.mkdirs(directory + '/' + i)
  File "/usr/lib64/python2.7/site-packages/WebappConfig/worker.py", line 334, in mkdirs
    self.mkfile(directory + '/' + i)
  File "/usr/lib64/python2.7/site-packages/WebappConfig/worker.py", line 575, in mkfile
    shutil.copy(src_name, dst_name)
  File "/usr/lib64/python2.7/shutil.py", line 119, in copy
    copyfile(src, dst)
  File "/usr/lib64/python2.7/shutil.py", line 82, in copyfile
    with open(src, 'rb') as fsrc:
IOError: [Errno 21] Is a directory: u'/usr/share/webapps/roundcube/1.2.3/htdocs/public_html/program/js'



This seems to be due to the structure of the roundcube installation. When I drop the --copy parameter to webapp-config it works fine. 

Ideally the roundcube package should support --copy too through webapp-config, as it is less prone to error and potential issues when upgrading.

I tried different versions of python (2.7 and 3.4), as well as webapp-config (1.52-r1, 1.53-r2, 1.54-r1, 1.54-r2)

thanks
Comment 1 acmondor 2016-12-18 20:09:34 UTC
Just ran into this bug with roundcube 1.2.3. It is failing as shown below:

.
.
.

>>> COPYING FILE: 
>>> Source: /usr/share/webapps/roundcube/1.2.3/htdocs/public_html/program/js
>>> Destination: /var/www/mail.acmondor.ca/htdocs-secure/roundcube/public_html/program/js

* Failed to copy ([Errno 21] Is a directory: '/usr/share/webapps/roundcube/1.2.3/htdocs/public_html/program/js')

>>> COPYING FILE: 
>>> Source: /usr/share/webapps/roundcube/1.2.3/htdocs/public_html/program/js
>>> Destination: /var/www/mail.acmondor.ca/htdocs-secure/roundcube/public_html/program/js

Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.4/webapp-config", line 42, in <module>
    main()
  File "/usr/lib/python-exec/python3.4/webapp-config", line 39, in main
    config.run()
  File "/usr/lib64/python3.4/site-packages/WebappConfig/config.py", line 1509, in run
    self.config.get('USER', 'pvr'))
  File "/usr/lib64/python3.4/site-packages/WebappConfig/server.py", line 130, in upgrade
    self.install(True)
  File "/usr/lib64/python3.4/site-packages/WebappConfig/server.py", line 240, in install
    self.__add.mkdirs()
  File "/usr/lib64/python3.4/site-packages/WebappConfig/worker.py", line 210, in mkdirs
    self.mkdirs(directory + '/' + i)
  File "/usr/lib64/python3.4/site-packages/WebappConfig/worker.py", line 210, in mkdirs
    self.mkdirs(directory + '/' + i)
  File "/usr/lib64/python3.4/site-packages/WebappConfig/worker.py", line 217, in mkdirs
    self.mkfile(directory + '/' + i)
  File "/usr/lib64/python3.4/site-packages/WebappConfig/worker.py", line 458, in mkfile
    shutil.copy(src_name, dst_name)
  File "/usr/lib64/python3.4/shutil.py", line 229, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib64/python3.4/shutil.py", line 108, in copyfile
    with open(src, 'rb') as fsrc:
IsADirectoryError: [Errno 21] Is a directory: '/usr/share/webapps/roundcube/1.2.3/htdocs/public_html/program/js'
/root/glogs/20161218-135232-webapp-config lines 15464-15525/15525 (END)



As shown above, it is stumbling on /usr/share/webapps/roundcube/1.2.3/htdocs/public_html/program/js which is symlink to a directory:

$ ll /usr/share/webapps/roundcube/1.2.3/htdocs/public_html/program/js
lrwxrwxrwx 1 root root 16 Dec 18 12:21 /usr/share/webapps/roundcube/1.2.3/htdocs/public_html/program/js -> ../../program/js/

$ realpath /usr/share/webapps/roundcube/1.2.3/htdocs/public_html/program/js
/usr/share/webapps/roundcube/1.2.3/htdocs/program/js

So it appears the real problem is that webapp-config is not handling the source symlink properly (ie trying to copy it like a file, when it is in fact a directory).
Comment 2 acmondor 2016-12-18 20:35:00 UTC
Also note that the install/upgrade worked fine without the --copy option, as stathis mentioned, which is a bit odd since in my case the source and destination paths are on different partitions so even without the --copy option a copy does take place.

I started using the --copy option a while ago only to get rid of the huge flood of "Failed to hardlink" error messages. At the time I thought that option basically just suppressed these error messages, now it's obvious it is doing something more/different.
Comment 3 acmondor 2016-12-19 14:43:01 UTC
One more thing to note, webapp-config --copy had worked for roundcube 1.2.0 earlier this year so I checked and confirmed that version did not have any symlinks like 1.2.3 does:

# cd /usr/share/webapps/roundcube/
# ls -l
total 16
drwxr-xr-x 4 root root 4096 Dec 18 12:21 ./
drwxr-xr-x 4 root root 4096 Oct 30 18:53 ../
drwxr-xr-x 7 root root 4096 Jun 13  2016 1.2.0/
drwxr-xr-x 7 root root 4096 Dec 18 12:21 1.2.3/
# find . -type l
./1.2.3/htdocs/public_html/.htaccess
./1.2.3/htdocs/public_html/program/resources
./1.2.3/htdocs/public_html/program/js
./1.2.3/htdocs/public_html/skins
./1.2.3/htdocs/public_html/robots.txt
./1.2.3/htdocs/public_html/plugins
# find . -type l | xargs ls -ld
lrwxrwxrwx 1 root root 12 Dec 18 12:21 ./1.2.3/htdocs/public_html/.htaccess -> ../.htaccess
lrwxrwxrwx 1 root root 10 Dec 18 12:21 ./1.2.3/htdocs/public_html/plugins -> ../plugins
lrwxrwxrwx 1 root root 16 Dec 18 12:21 ./1.2.3/htdocs/public_html/program/js -> ../../program/js
lrwxrwxrwx 1 root root 23 Dec 18 12:21 ./1.2.3/htdocs/public_html/program/resources -> ../../program/resources
lrwxrwxrwx 1 root root 13 Dec 18 12:21 ./1.2.3/htdocs/public_html/robots.txt -> ../robots.txt
lrwxrwxrwx 1 root root  8 Dec 18 12:21 ./1.2.3/htdocs/public_html/skins -> ../skins

That /usr/share/webapps/roundcube/1.2.3/htdocs/public_html directory which contains the symlinks and comes from the distribution file does not seem to have any real purpose with the way the app is currently installed and should not be there in my opinion.

There is no mention of it in the CHANGELOG or INSTALL files (contained in the distribution file) but my guess is that this is a work in progress which would allow for a different install method whereby the bulk of the roundcube files reside outside the actual public_html directory.

As such, one possible solution to this  webapp-config --copy bug would be to have the ebuild for roundcube 1.2.3 just remove this public_html directory like it does for other files in the distribution file (eg CHANGELOG INSTALL). The alternative would be to modify webapp-config so that the --copy option is able to handle symlinks like is done when that option is not used.
Comment 4 Aaron W. Swenson gentoo-dev 2017-12-01 18:19:15 UTC
I've tested this myself a few days ago.

The issue is that symlinks are used to give clients access to otherwise restricted directories.

The upstream recommendation of making the DocumentRoot ${HTDOCSDIR}/public_html/ would restrict client resources in ${HTDOCSDIR}/plugins and ${HTDOCSDIR}/skins. So, upstream includes symlinks inside ${HTDOCSDIR}/public_html/ to those two directories.


@web-apps
--copy should handle symlinks.

I don't think this can be satisfactorily handled in the ebuild.
Comment 5 Jonathan Nicol 2020-03-13 17:19:01 UTC
Still happening.


 # webapp-config -d roundcube -h www.site.com -c -I roundcube 1.4.2
*   Creating required directories
*   Linking in required files
*     This can take several minutes for larger apps
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.6/webapp-config", line 42, in <module>
    main()
  File "/usr/lib/python-exec/python3.6/webapp-config", line 39, in main
    config.run()
  File "/usr/lib64/python3.6/site-packages/WebappConfig/config.py", line 1327, in run
    self.config.get('USER', 'pvr')).install()
  File "/usr/lib64/python3.6/site-packages/WebappConfig/server.py", line 241, in install
    self.__add.mkdirs()
  File "/usr/lib64/python3.6/site-packages/WebappConfig/worker.py", line 210, in mkdirs
    self.mkdirs(directory + '/' + i)
  File "/usr/lib64/python3.6/site-packages/WebappConfig/worker.py", line 210, in mkdirs
    self.mkdirs(directory + '/' + i)
  File "/usr/lib64/python3.6/site-packages/WebappConfig/worker.py", line 217, in mkdirs
    self.mkfile(directory + '/' + i)
  File "/usr/lib64/python3.6/site-packages/WebappConfig/worker.py", line 458, in mkfile
    shutil.copy(src_name, dst_name)
  File "/usr/lib64/python3.6/shutil.py", line 245, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib64/python3.6/shutil.py", line 120, in copyfile
    with open(src, 'rb') as fsrc:
IsADirectoryError: [Errno 21] Is a directory: '/usr/share/webapps/roundcube/1.4.2/htdocs/public_html/program/js'