Debugging in XCode as root

后端 未结 6 2043
一生所求
一生所求 2020-12-03 04:59

In my program I need to create sockets and bind them to listen HTTP port (80). The program works fine when I launch it from command line with sudo, escalating permissions to

6条回答
  •  时光取名叫无心
    2020-12-03 05:16

    Xcode is able to run the debugging application as root. For this purpose the following steps should be done:

    1. Enable the root user for local machine.

      a. Run “Directory Utility” (/System/Library/CoreServices/ Directory Utility.app)

      b. Choose “Enable Root User” from the Edit menu and enter the root password.

    2. Enable remote loging.

      a. In System Preferences… -> Sharing, check Remote Login. This option turns on the ssh demon.

    3. Create ssh public/private keys and copy public key in the .ssh/authorized_keys folder for root user.

      a. Open terminal on local machine and type ssh-keygen -t rsa

      b. Accept the default location and type password for the root.

      c. Login as root su - and create ~/.ssh directory. (~ == /var/root)

      d. Copy the public key to the root: cat ~/.ssh/id_rsa.pub | ssh root@localhost "cat - >> ~/.ssh/authorized_keys"

      e. Check whether everything is Ok. Type ssh root@localhost. It shouldn’t ask for the root password.

    4. Enable remote debugging via ssh in Xcode.

      a. Select «Get Info» from drop-down menu on «Executables».

      b. In the "Debugging" settings check «Debug executable remotely via ssh» and put root@localhost as the «Connect to» info.

    5. Everything should be Ok now ☺

    From blog

提交回复
热议问题