[CMake] Permissions for new folders and files

Yuri V. Timenkov ytimenkov at parallels.com
Fri Aug 8 00:57:11 EDT 2008


On Thursday 07 August 2008 18:01:33 Брюков Юрий wrote:
> Hi.
>   I try to write installation steps for my application. I need create some
> folders and copy some files to this folders. I use next commands:
>     install(TARGETS myApp DESTINATION . PERMISSIONS WORLD_READ WORLD_WRITE
> WORLD_EXECUTE)
Installing into folder "." may have strange consequences.
>     install(FILES myFile DESTINATION myfolder)
>
>   I have troubles with permissions of directories which were created during
> my application installation. Command `make install` should be executed with
> root privileges because I need to copy some libraries to /usr/lib/. 
This depends on your packaging scheme. For example, I install CMake into 
/opt/cmake-2.[46], which is created under my user account.
> But in this case all necessary folders 
Intermediate. Necessary folders you specified explicitly with install() 
commands.
> also will be created with root permissions
> and my application can't create any files in this folders if it was
> executed without root privileges. 
Usually applications shouldn't write to any system locations. All data is 
placed on linux to /var directory (as Alan pointed to FHS standard), where 
applications' installers create folders with user accounts.

> For example folder from
> CMAKE_INSTALL_PREFIX variable also created with root privileges. And myApp
> try to create some log files in this directory and it failed because it
> hasn't necessary
> privileges.
All your logs should be in /var/log directory, but regular user can't write 
there. You can use syslog daemon to write logs. Or you can create custom 
folder which will be accessible under user account.

>   Have you any advance?
You should consider FHS standard and develop proper directory layout for your 
product. If you migrate from windows proprietary software, I (my personal 
preference) suggest put your app into (set CMAKE_INSTALL_PREFIX to) 
/opt/YourProduct/ and write logs into /var/log/YourProduct/. You can create 
these two dirs from root and next change ownership.

>
> Thanks,
> Yuri.


More information about the CMake mailing list