[MacPorts] #68043: MacPorts 2.8.0 in non-sudo mode, creates source files as `root` and work files as `macports` on M1 Mac
MacPorts
noreply at macports.org
Sun Aug 27 03:32:47 UTC 2023
#68043: MacPorts 2.8.0 in non-sudo mode, creates source files as `root` and work
files as `macports` on M1 Mac
---------------------+--------------------
Reporter: lukaso | Owner: (none)
Type: defect | Status: new
Priority: Normal | Milestone:
Component: base | Version: 2.8.0
Resolution: | Keywords:
Port: |
---------------------+--------------------
Comment (by ryandesign):
MacPorts base doesn't use `sudo`. Instead, it uses the opposite approach
of privilege dropping and elevation.
If you start MacPorts with `sudo` or as root, it immediately drops
privileges to those of the macports user so that most operations have no
more access than they need. Then, only for those steps that actually need
root access (like `install` or `sync` or `selfupdate`), it elevates
privileges back to the root user.
If you start MacPorts as a regular user, MacPorts only has the abilities
of the regular user so it's impossible for it to change the owner of
anything to any other user, including root.
Trying it myself:
{{{
% cd /tmp
% mv ~/Downloads/MacPorts-2.8.1.tar.bz2 .
% tar xjf MacPorts-2.8.1.tar.bz2
% cd MacPorts-2.8.1
% export PATH=/usr/bin:/bin:/usr/sbin:/sbin
% PREFIX=/tmp/prefix
% ./configure --prefix=$PREFIX --with-applications-
dir=$PREFIX/Applications --without-startupitems --with-install-
user=${USER} --with-install-group=staff --with-no-root-privileges
...
% make -j8
...
% make install
...
% ls -l $PREFIX/var/macports/
total 0
drwxr-xr-x 2 rschmidt staff 64 Aug 26 22:26 build
drwxr-xr-x 2 rschmidt staff 64 Aug 26 22:26 distfiles
drwxr-xr-x 3 rschmidt staff 96 Aug 26 22:26 home
drwxr-xr-x 2 rschmidt staff 64 Aug 26 22:26 logs
drwxr-xr-x 5 rschmidt staff 160 Aug 26 22:26 registry
drwxrwxrwt 2 rschmidt staff 64 Aug 26 22:26 sip-workaround
drwxr-xr-x 2 rschmidt staff 64 Aug 26 22:26 software
% $PREFIX/bin/port sync
---> Updating the ports tree
% ls -l $PREFIX/var/macports/
total 0
drwxr-xr-x 2 rschmidt staff 64 Aug 26 22:26 build
drwxr-xr-x 2 rschmidt staff 64 Aug 26 22:26 distfiles
drwxr-xr-x 3 rschmidt staff 96 Aug 26 22:26 home
drwxr-xr-x 2 rschmidt staff 64 Aug 26 22:26 logs
-rw-r--r-- 1 rschmidt staff 0 Aug 26 22:27 pingtimes
drwxr-xr-x 5 rschmidt staff 160 Aug 26 22:26 registry
drwxrwxrwt 2 rschmidt staff 64 Aug 26 22:26 sip-workaround
drwxr-xr-x 2 rschmidt staff 64 Aug 26 22:26 software
drwxr-xr-x 3 rschmidt staff 96 Aug 26 22:27 sources
}}}
Note that a source install of MacPorts does not create the sources
directory; it's created when you first `sync` or `selfupdate`. Are you
inadvertently using `sudo` when you're running `port sync`?
--
Ticket URL: <https://trac.macports.org/ticket/68043#comment:6>
MacPorts <https://www.macports.org/>
Ports system for macOS
More information about the macports-tickets
mailing list