[CMake] Specifying a file owner

Domen Vrankar domen.vrankar at gmail.com
Wed Jan 7 15:54:09 EST 2015


> Hi,
>
> I was looking at https://www.cmake.org/Bug/view.php?id=3602 "Add
> possibility to change file owner into install macro".

I am also interested in this feature but mostly because of packaging
limitations - implementing this feature would give CPackRPM the
ability to set user and group for every file/directory/link that
generated RPM will contain. This can already be done by a workaround -
providing the file with user and group in
CPACK_RPM_<component>_USER_FILELIST- but extending install command
would be a more elegant solution.

> I believe we should in fact support specifying the file owner, and
> handle the case where that owner does not exist in the same way (from a
> user experience) as we handle platforms that don't support SETUID - i.e.
> do nothing (logging some kind of non-fatal error would be good).

I am usually using install target for installing the entire project
locally for testing and in such cases I prefer to have everything
installed as current user in a subdirectory of my build directory.
I believe that this use case should be solved by providing a new
target - rootless_install - which ignores USER and GROUP setting in
INSTALL commands.

On the other hand when I want to install something permanently on my
system after building the project I would prefer that user and group
settings are applied and in such case I would prefer a fatal error if
user/group permission can not be applied (preferably with CMake
rolling back the changes that it already made on the file system - new
feature?). This could be part of current install target.

> Automatically creating a non-existing user would also be nice but is
> orthogonal and should be handled as a separate feature request rather
> than muddying the waters around this feature discussion.

Not certain if I'd like this feature or not but I agree that it should
be discussed as a separate feature.

There was also a third case provided by Brad:
3.) What if installing into a DESTDIR that exists on a mount point and
the user names should be translated to uids with $(DESTDIR)/etc/passwd
instead of /etc/passwd? How should this be specified?

I've already encountered a situation where I mounted a partition that
had files with users and groups that were present in /etc/passwd but
under different uids and gids so ls -l was showing numbers instead of
names. In such case only root user may create new files since they
will have a different uids and gids so nothing changes... I'd say that
different uids for the same user name is users problem and should be
ignored by CMake.

Regards,
Domen


More information about the CMake mailing list