Setting permissions with CPack/WiX installer

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Setting permissions with CPack/WiX installer

Cook, Steven (G&I)

Hi all,

 

I would like to set the permissions on some files and directories in my WiX installer. It looks like the CPACK_WIX_ACL property should be suitable, but I can’t get it to work. There are examples of its usage in this project:

https://github.com/ngladitz/cmake-wix-testsuite/tree/master/properties

 

Typically something like this:

  set_property(INSTALL

    empty_directory_with_property

    non_empty_directory_with_property

    PROPERTY CPACK_WIX_ACL “Everyone=GenericRead,GenericWrite,CreateFile”

  )

 

but this example doesn’t work for me with cmake 3.14.0. None of the .wxs files that are produced contain the expected Permission property. After adding some debugging to cmake, I found that cmCPackWIXGenerator::AddDirectoryAndFileDefinitions calls GetInstalledFile, which always returns NULL. This prevents the ACL from being applied.

 

As an alternative, I’ve tried to use CPACK_WIX_PATCH_FILE to specify the Permission property for the relevant fragments, but the patch does not get applied to the fragments where directories are created. In any case, I think CPACK_WIX_ACL would be preferable if I could get it to work.

 

Can anyone provide a minimal working example that uses CPACK_WIX_ACL?

 

Thanks

Steve


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Setting permissions with CPack/WiX installer

Nils Gladitz-2


On Fri, Apr 5, 2019 at 5:25 AM Cook, Steven (G&I) <[hidden email]> wrote:

Hi all,

 

I would like to set the permissions on some files and directories in my WiX installer. It looks like the CPACK_WIX_ACL property should be suitable, but I can’t get it to work. There are examples of its usage in this project:

https://github.com/ngladitz/cmake-wix-testsuite/tree/master/properties

 

Typically something like this:

  set_property(INSTALL

    empty_directory_with_property

    non_empty_directory_with_property

    PROPERTY CPACK_WIX_ACL “Everyone=GenericRead,GenericWrite,CreateFile”

  )

 

but this example doesn’t work for me with cmake 3.14.0. None of the .wxs files that are produced contain the expected Permission property. After adding some debugging to cmake, I found that cmCPackWIXGenerator::AddDirectoryAndFileDefinitions calls GetInstalledFile, which always returns NULL. This prevents the ACL from being applied.


Been a while since I looked at this but it still seems to work for me in 3.14.0.
Corresponding <Permission> elements are generated in files.wxs:

        <DirectoryRef Id="CM_DP_empty_directory_with_property">
            <Component Id="CM_C_EMPTY_CM_DP_empty_directory_with_property" Guid="3D2461E6-022E-462E-BE97-3DE14D7DFEBE">
                <CreateFolder>
                    <Permission User="Everyone" GenericRead="yes" GenericWrite="yes" CreateFile="yes"/>
                </CreateFolder>
            </Component>
        </DirectoryRef>

        <DirectoryRef Id="CM_DP_non_empty_directory_with_property">
            <Component Id="CM_C_EMPTY_CM_DP_non_empty_directory_with_property" Guid="20B69238-5353-4C30-A001-3A106A0B1737">
                <CreateFolder>
                    <Permission User="Everyone" GenericRead="yes" GenericWrite="yes" CreateFile="yes"/>
                </CreateFolder>
            </Component>
        </DirectoryRef>

Nils

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Setting permissions with CPack/WiX installer

Cook, Steven (G&I)

Hi Nils,

 

> Been a while since I looked at this but it still seems to work for me in 3.14.0.

> Corresponding <Permission> elements are generated in files.wxs:

 

Can you please tell me the commands you used to run cpack? I did the following, which didn’t give the Permission elements.

 

cd cmake-wix-testsuite-master\properties

cmake -DCPACK_GENERATOR=WIX .

cpack -DCPACK_GENERATOR=WIX .

 

Full output is below.

 

Thanks,

Steve

 

 

Steven.Cook@AUPERWL01583 C:\dev\GI

> cd cmake-wix-testsuite-master\properties

 

 

Steven.Cook@AUPERWL01583 C:\dev\GI\cmake-wix-testsuite-master\properties

> cmake -DCPACK_GENERATOR=WIX .

-- Building for: Visual Studio 15 2017

-- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.15063.

-- The C compiler identification is MSVC 19.16.27030.1

-- The CXX compiler identification is MSVC 19.16.27030.1

-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe

-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works

-- Detecting C compiler ABI info

-- Detecting C compiler ABI info - done

-- Detecting C compile features

-- Detecting C compile features - done

-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe

-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x86/cl.exe -- works

-- Detecting CXX compiler ABI info

-- Detecting CXX compiler ABI info - done

-- Detecting CXX compile features

-- Detecting CXX compile features - done

CMake Warning (dev) in CMakeLists.txt:

  No cmake_minimum_required command is present.  A line of code such as

 

    cmake_minimum_required(VERSION 3.14)

 

  should be added at the top of the file.  The version specified may be lower

  if you wish to support older CMake versions for this project.  For more

  information run "cmake --help-policy CMP0000".

This warning is for project developers.  Use -Wno-dev to suppress it.

 

-- Configuring done

-- Generating done

-- Build files have been written to: C:/dev/GI/cmake-wix-testsuite-master/properties

 

 

Steven.Cook@AUPERWL01583 C:\dev\GI\cmake-wix-testsuite-master\properties

> cpack -DCPACK_GENERATOR=WIX .

CPack: Create package using WIX

CPack: Install projects

CPack: - Install project: Project

CPack: Create package

CPack Warning: CPACK_WIX_UPGRADE_GUID implicitly set to 26D57C14-30E5-4837-95E3-5C5E9317CE0F . Please refer to the documentation on how and why you might want to set this explicitly.

CPack: - package: C:/dev/GI/cmake-wix-testsuite-master/properties/Project-0.1.1-win32.msi generated.

 

 

files.wxs contains the following, but no Permission elements:

        <DirectoryRef Id="CM_DP_empty_directory_with_property">

            <Component Id="CM_C_EMPTY_CM_DP_empty_directory_with_property" Guid="C8726921-C4BC-4796-9369-7745BD2FAE12">

                <CreateFolder/>

            </Component>

        </DirectoryRef>

 

 

> cmake --version

cmake version 3.14.0

 

CMake suite maintained and supported by Kitware (kitware.com/cmake).

 

 

> candle --version

Windows Installer XML Toolset Compiler version 3.11.1.2318

Copyright (c) .NET Foundation and contributors. All rights reserved.

 


--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Setting permissions with CPack/WiX installer

Nils Gladitz-2


On Mon, Apr 8, 2019 at 2:07 AM Cook, Steven (G&I) <[hidden email]> wrote:

Hi Nils,

 

> Been a while since I looked at this but it still seems to work for me in 3.14.0.

> Corresponding <Permission> elements are generated in files.wxs:

 

Can you please tell me the commands you used to run cpack? I did the following, which didn’t give the Permission elements.


Remove this line https://github.com/ngladitz/cmake-wix-testsuite/blob/master/CMakeLists.txt#L15 (I think it is superfluous/wrong and errors out when using newer cmake versions).
From a command line environment where your compiler is properly set up and ninja is in PATH configure the root of the project with the Ninja generator (currently hardcoded in the tests); use an out of source build directory and set the REFERENCE_CMAKE_BIN_DIR cache variable to the bin-Directory of the CMake installation you want to test.
Run e.g. "ctest -R properties" from the build directory.

Nils

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Setting permissions with CPack/WiX installer

Cook, Steven (G&I)
Hi Nils,

> From a command line environment where your compiler is properly set up and
> ninja is in PATH configure the root of the project with the Ninja generator
> (currently hardcoded in the tests); use an out of source build directory and
> set the REFERENCE_CMAKE_BIN_DIR cache variable to the bin-Directory of the
> CMake installation you want to test.
> Run e.g. "ctest -R properties" from the build directory.

Thanks, that helped but I am now stuck on a different error where it can't
find the rc command. I have modified PATH to include the rc directory
(C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64) but it still
can't find it.

RC Pass 1: command "rc /foCMakeFiles\cmTC_0bc1e.dir/manifest.res CMakeFiles\cmTC_0bc1e.dir/manifest.rc" failed (exit code 0) with the following output:
The system cannot find the file specified

I have made a very simple example that generates a WIX installer for a single
file but fails to set the permissions on the file. Do you have any suggestions
of why this isn't working?


cmake_minimum_required(VERSION 2.8.12)

install(
    FILES test.txt
    DESTINATION ./
)

set_property(INSTALL
    test.txt
    PROPERTY CPACK_WIX_ACL "Everyone=GenericRead,GenericWrite"
)

set( CPACK_GENERATOR WIX )
include(CPack)


Thanks
Steve
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake
Reply | Threaded
Open this post in threaded view
|

Re: Setting permissions with CPack/WiX installer

Cook, Steven (G&I)
> I have made a very simple example that generates a WIX installer for a
> single file but fails to set the permissions on the file. Do you have any
> suggestions of why this isn't working?

Problem solved - when cpack is run with no parameters, the permissions tags
are not generated, but when run with a -C parameter (eg cpack -C Debug) the
permissions are generated as expected. I don't know why this would be the
case, but I'm happy to have found the solution.

Thanks,
Steve



--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake