New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPM's with non-root owners doesn't set ownership of directories #245

Closed
justintime opened this Issue Aug 6, 2012 · 10 comments

Comments

Projects
None yet
4 participants
@justintime
Contributor

justintime commented Aug 6, 2012

When building an RPM with FPM and using the --rpm-user command line option, it properly sets the ownership on all files, but not on all directories. This stackoverflow post explains the situation and a possible fix:
http://stackoverflow.com/questions/9963488/how-to-set-owner-for-directory-in-the-files

There's also a bit of explanation over here: http://www.spinics.net/lists/rpm/msg07233.html

@justintime

This comment has been minimized.

Contributor

justintime commented Aug 6, 2012

After speaking with @jordansissel in IRC, we came up with this:

The problem with not including all directories as %dir attributes in the SPEC file is also the cause for #199, where directories aren't removed when the package is.

The problem with adding all directories to the SPEC file was defined by Jordan:

it used to list all files, directories inlcuded
but that made it list "/" and "/usr" and such, which confused deb/rpm greatly
"/ is already provided by "
so then I told fpm to only include 'empty' directories in the package, so only files, symlinks, and empty dirs
which helped, but caused a problem in your case

We came up with the idea that a command line option --base-dir could be created that would essentially say, "This package is the exclusive owner of all files and directories under this base directory." Furthermore, when using a source type of directory, the --base-dir should implicitly be set to the directory being packaged.

Now all it needs is code :)

@justintime

This comment has been minimized.

Contributor

justintime commented Aug 6, 2012

Just a note that when I manually edited the spec file (using -e) to include each directory as a %dir attribute, it did indeed fix both the owner and the removal of the directory on package removal.

I did get a non-fatal warning for each %dir attribute warning: File listed twice: /opt/bea/wlserver_10.3/server/bin/international, I'm pretty sure it's because it was being created earlier in the spec file via a mkdir command. Either way, the RPM was just fine.

@jordansissel

This comment has been minimized.

Owner

jordansissel commented Aug 7, 2012

@justintime - awesome, thanks for testing that! It should be easy to make fpm do what we need here.

@ajf8

This comment has been minimized.

Contributor

ajf8 commented Sep 11, 2012

My attempt at solving this: #260

@justintime

This comment has been minimized.

Contributor

justintime commented Nov 26, 2012

#260 does indeed fix the ownership problem, but it doesn't quite do it in a manageable manner.

If I have a package foo, and it has this structure:

/opt/foo
/opt/foo/bar
/opt/foo/bar/baz

If I run fpm with the new option set to '--directories /opt/foo', then /opt/foo will have the proper permissions, but /opt/foo/bar and /opt/foo/bar/baz will not. We could explicitly add each subdirectory to the directories option, but that gets impossible when packaging something like Weblogic that has hundreds of directories.

Also, upon removal, it leaves all directories behind, because the RPM doesn't "own" the subdirectories, it leaves the parent directory.

@astrostl

This comment has been minimized.

astrostl commented Nov 26, 2012

Others have suggested a post-uninstall rm -rf /opt/dir.

Here's what I do for complicated /opt installs, as part of an fpm 'framework' script:

while read dir; do
  directories+="--directories /${dir} "
done < <(find opt/ -mindepth 1 -type d)

...

fpm $directories ...

with 'opt/' being a reference to the distfiles in the cwd.

@justintime

This comment has been minimized.

Contributor

justintime commented Nov 27, 2012

I think I've got this resolved with #293 and #294 which have just been merged. I'd love to hear if it works for people or not. It works for me and Weblogic, which seems to be quite the acid test.

@astrostl

This comment has been minimized.

astrostl commented Nov 27, 2012

Nice! Will check it out.

@jordansissel

This comment has been minimized.

Owner

jordansissel commented Nov 27, 2012

Prepping for a new release right now. SHould be up on rubygems shortly!

@jordansissel

This comment has been minimized.

Owner

jordansissel commented Nov 27, 2012

done. 0.4.23 released

gerbercj pushed a commit to gerbercj/fpm that referenced this issue Feb 27, 2014

Improve the documentation.
The --directories flag marks a directory recursively owned by the package (jordansissel#245, jordansissel#293, jordansissel#294)

gerbercj pushed a commit to gerbercj/fpm that referenced this issue Mar 11, 2014

Improve the documentation.
The --directories flag marks a directory recursively owned by the package (jordansissel#245, jordansissel#293, jordansissel#294)

gerbercj pushed a commit to gerbercj/fpm that referenced this issue Apr 25, 2014

Improve the documentation.
The --directories flag marks a directory recursively owned by the package (jordansissel#245, jordansissel#293, jordansissel#294)

prof-milki pushed a commit to prof-milki/xpm that referenced this issue Dec 18, 2014

KetanPadegaonkar KetanPadegaonkar
Improve the documentation.
The --directories flag marks a directory recursively owned by the package (jordansissel#245, jordansissel#293, jordansissel#294)

prof-milki pushed a commit to prof-milki/xpm that referenced this issue Dec 27, 2014

Improve the documentation.
The --directories flag marks a directory recursively owned by the package (jordansissel#245, jordansissel#293, jordansissel#294)

jordansissel pushed a commit that referenced this issue Apr 24, 2015

Improve the documentation.
The --directories flag marks a directory recursively owned by the package (#245, #293, #294)

jordansissel pushed a commit that referenced this issue Jun 20, 2016

Improve the documentation.
The --directories flag marks a directory recursively owned by the package (#245, #293, #294)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment