Best way to perform chmod to root:admin on an *.app file from a shell script as part of a Build Step?

As part of one of my xcode projects, the final build step involves creating a package to eventually output as an artifact. During this Command Line build step I need to set permissions on the .app file and files inside it.
The part of the Build Step custom script that calls this calls the .sh file like so -

sh Build/Deployment/setpermissions.sh

And the particular action that is causing issue inside that shell script is this one -

chown -R root:admin Binaries/Deployment/application.app

Which seems to result in a lot of 'Operation not permitted'. What would be the best way to resolve this? Sudo seems to be an issue due to the setup, at least from my understanding. Any advice would be much appreciated.


Apologies if I'm not explaining this in great detail, this is all pretty new to me and I'm trying to wrap my head around it all, let me know if you need any further context, etc.

0
1 comment

Hi Kyle,

the script will be run under the user that is running the TeamCity Agent's process. This user will need the required permissions to perform that action, and chmodding something to root usually requires root permissions. Because the process is not interactive, sudo is usually a problem, although there might be some ways.

As far as I know, sudo can be configured to automatically grant su access to specific commands, without requesting passwords, etc. You could try and check that approach, but you will need to check with your system/sudo help, as I'm not entirely sure how that is done.

Another option which we can't really recommend would be to run the process under root. Of course this would have the problem that everything on the scripts would be run under root which could pose a security risk, but the option exists should you want to consider it.

0

Please sign in to leave a comment.