Glu uninstall follows symlinks and delete files outside of mountPoint

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Glu uninstall follows symlinks and delete files outside of mountPoint

sodul
This post was updated on .
Hi,

This was first reported to me yesterday when one of our products that has a symlink to an other directory deleted the content of that directory which is outside of the mount point!

This morning I created a recursive symlink accidentally and since symlinks are followed on deletes it ended up generating an error.

Uninstall script for [/ed/pserver] on [i-073bbd34] - 4s
* Internal Server Error (500) - Internal Server Error
* class: org.apache.tools.ant.BuildException, message: Unable to delete file /mnt/ig/ed/pserver/dev.ed-pserver-trunk-s7394-j272/rserver/maintenance_page/rserver/maintenance_page/rserver/maintenance_page/rserver/maintenance_page/rserver/maintenance_page/rserver/maintenance_page

I will probably protect against this behavior by having my groovy script call shell.exec("rm -rf $mountPoint").

This is with Glu 4.4.0, we will probably switch to 4.5.x in the next couple of weeks.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Glu uninstall follows symlinks and delete files outside of mountPoint

frenchyan
Administrator
There has not been any change in that regard with glu 4.5.0

If you do rm yourself, do it this way:

def mountPointFile = shell.toResource(mountPoint).file
shell.exec("rm -rf ${mountPointFile}")

otherwise you will not delete the directory you are intending to delete (shell makes everything relative to the app folder)

Do you think this is a bug that it is following symlink? It could imagine that in some cases it is actually a desired behavior...

Yan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Glu uninstall follows symlinks and delete files outside of mountPoint

sodul
I did this which worked like a charm:
  def base_apps_path = '/ig'
   [... snip ...]
  def uninstall = {
    log.info "Uninstall."
    shell.exec("rm -rf '${base_apps_path}${mountPoint}'")
  }

Note the single quotes around the paths, just in case a space would have snuck in one of the vars.

I was not aware of the 'shell.toResource(mountPoint).file' feature. I should probably rewrite my script to use that, seems cleaner.

I really think that following symlinks on delete should not be the default behavior. I don't even see that behavior as an option for rm in the man pages. It is not a big deal since there is an easy workaround.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Glu uninstall follows symlinks and delete files outside of mountPoint

frenchyan
Administrator
Note that another way (less hacky than hardcoding :) would be to use shell.env (http://linkedin.github.com/glu/docs/latest/html/agent.html#agent-capabilities-shell-env)

as you can get access to any values used during configuration.

def base_apps_path = shell.env('glu.agent.scriptRootDir')

Yan

On Thu, Aug 16, 2012 at 10:26 AM, sodul [via glu] <[hidden email]> wrote:
I did this which worked like a charm:
  def base_apps_path = '/ig'
   [... snip ...]
  def uninstall = {
    log.info "Uninstall."
    shell.exec("rm -rf '${base_apps_path}${mountPoint}'")
  }

Note the single quotes around the paths, just in case a space would have snuck in one of the vars.

I was not aware of the 'shell.toResource(mountPoint).file' feature. I should probably rewrite my script to use that, seems cleaner.

I really think that following symlinks on delete should not be the default behavior. I don't even see that behavior as an option for rm in the man pages. It is not a big deal since there is an easy workaround.



To start a new topic under glu, email [hidden email]
To unsubscribe from glu, click here.
NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Glu uninstall follows symlinks and delete files outside of mountPoint

sodul
Linking to the GitHub ticket tracking this issue: https://github.com/pongasoft/glu/issues/304
Loading...