Re: How to force run tests as non-root?

2024-02-24 Thread Sergey Fedorov
Related PR: https://github.com/macports/macports-ports/pull/22796
(Tests still run only manually under a regular user though.)

On Sun, Feb 25, 2024 at 1:21 PM Sergey Fedorov  wrote:

> For some reason sudo is not allowed. For example, I try using *system
> "sudo -u svacchanda ./VidaliaTestSuite"* (just for the sake of testing,
> since it works when running manually), but get:
>
> [100%] Built target VidaliaTestSuite
>
> make[1]: Leaving directory
> `/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/build'
>
> /opt/local/bin/cmake -E cmake_progress_start
> /opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/build/CMakeFiles
> 0
>
> make: Leaving directory
> `/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/build'
>
> --->  Testing Vidalia
>
> sh: /usr/bin/sudo: Operation not permitted
>
> Command failed: sudo -u svacchanda ./VidaliaTestSuite
>
> Exit code: 126
>
>
> I tried a few other ways of adding *sudo -u* via the portfile, and get
> the same error.
>
> P. S. Both cmake 1.0 and cmake 1.1 fail identically with regard to running
> tests.
>
> On Sat, Feb 24, 2024 at 2:28 PM Joshua Root  wrote:
>
>> On 24/2/2024 17:27, Sergey Fedorov wrote:
>> > If Macports is running as root, but tests require non-root user, how to
>> > do that?
>> > There is no test.asroot no, apparently.
>>
>> All the usual ways you can run something as another user when you are
>> root. You could prefix your build.cmd with 'sudo -u $macportsuser' for
>> example.
>>
>> - Josh
>>
>


Re: How to force run tests as non-root?

2024-02-24 Thread Sergey Fedorov
For some reason sudo is not allowed. For example, I try using *system "sudo
-u svacchanda ./VidaliaTestSuite"* (just for the sake of testing, since it
works when running manually), but get:

[100%] Built target VidaliaTestSuite

make[1]: Leaving directory
`/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/build'

/opt/local/bin/cmake -E cmake_progress_start
/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/build/CMakeFiles
0

make: Leaving directory
`/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/build'

--->  Testing Vidalia

sh: /usr/bin/sudo: Operation not permitted

Command failed: sudo -u svacchanda ./VidaliaTestSuite

Exit code: 126


I tried a few other ways of adding *sudo -u* via the portfile, and get the
same error.

P. S. Both cmake 1.0 and cmake 1.1 fail identically with regard to running
tests.

On Sat, Feb 24, 2024 at 2:28 PM Joshua Root  wrote:

> On 24/2/2024 17:27, Sergey Fedorov wrote:
> > If Macports is running as root, but tests require non-root user, how to
> > do that?
> > There is no test.asroot no, apparently.
>
> All the usual ways you can run something as another user when you are
> root. You could prefix your build.cmd with 'sudo -u $macportsuser' for
> example.
>
> - Josh
>


Re: How to force run tests as non-root?

2024-02-24 Thread Sergio Had
Could you reproduce the issue? I tried a number of ways to fix that, but 
nothing worked.
Sudo anything does not work from the portfile code, and I am not sure how to 
otherwise emulate “sudo -u normal-non-root-user”.

(If you got no arm64 hardware, presumably things will be the same on 
recent-enough x86_64, though I cannot verify that. For the same reason I cannot 
try running tests with 2.x version, as there is no Qt5 support in it.)
On Feb 25, 2024 at 04:49 +0700, Ken Cunningham 
, wrote:
> You are completely right, and I was wrong about this.
>
> I am now not certain how it came to be that macports was installed under the 
> root user for the 10.6-ppc installation in the mentioned ticket (assuming I 
> got the part right).
>
> K
>
> > On Feb 24, 2024, at 13:07, Joshua Root  wrote:
> >
> > On 25/2/2024 03:07, Ken Cunningham wrote:
> > > Some of your macports installations are installed as the root user, 
> > > instead of the macports user.
> > > This happened because there is no installer for 10.6-ppc to automatically 
> > > create the macports user. You have an open ticket about this too, where I 
> > > pointed to the commands to be run to generate the macports user.
> > > Sooner or later you will probably have to fix this.
> >
> > It shouldn't make any difference to this whether you use the pkg installer 
> > or install from source, since the Makefile also creates the run user. 
> > Unless of course you specifically tell configure --with-macports-user=root 
> > (very not recommended).
> >
> > - Josh


Re: How to force run tests as non-root?

2024-02-24 Thread Ken Cunningham
You are completely right, and I was wrong about this.

I am now not certain how it came to be that macports was installed under the 
root user for the 10.6-ppc installation in the mentioned ticket (assuming I got 
the part right).

K

> On Feb 24, 2024, at 13:07, Joshua Root  wrote:
> 
> On 25/2/2024 03:07, Ken Cunningham wrote:
>> Some of your macports installations are installed as the root user, instead 
>> of the macports user.
>> This happened because there is no installer for 10.6-ppc to automatically 
>> create the macports user. You have an open ticket about this too, where I 
>> pointed to the commands to be run to generate the macports user.
>> Sooner or later you will probably have to fix this.
> 
> It shouldn't make any difference to this whether you use the pkg installer or 
> install from source, since the Makefile also creates the run user. Unless of 
> course you specifically tell configure --with-macports-user=root (very not 
> recommended).
> 
> - Josh


Re: How to force run tests as non-root?

2024-02-24 Thread Joshua Root

On 25/2/2024 03:07, Ken Cunningham wrote:

Some of your macports installations are installed as the root user, instead of 
the macports user.

This happened because there is no installer for 10.6-ppc to automatically 
create the macports user. You have an open ticket about this too, where I 
pointed to the commands to be run to generate the macports user.

Sooner or later you will probably have to fix this.


It shouldn't make any difference to this whether you use the pkg 
installer or install from source, since the Makefile also creates the 
run user. Unless of course you specifically tell configure 
--with-macports-user=root (very not recommended).


- Josh


Re: How to force run tests as non-root?

2024-02-24 Thread Sergey Fedorov
P. S. And if after the build I just manually run
/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/vidalia-8240540188062a168a66b25ca61b852cc89140ad/src/tests/VidaliaTestSuite
– Vidalia client starts, all tests pass, no errors:

. . .

250 OK

QDEBUG : TorrcTestSuite::testRunningTor() torcontrol: Control Command:
GETCONF UseMicrodescriptors

QDEBUG : TorrcTestSuite::testRunningTor() torcontrol: Control Reply: 250
UseMicrodescriptors=auto

QDEBUG : TorrcTestSuite::testRunningTor() torcontrol: Control Command:
GETCONF FetchUselessDescriptors

QDEBUG : TorrcTestSuite::testRunningTor() torcontrol: Control Reply: 250
FetchUselessDescriptors=0

QDEBUG : TorrcTestSuite::testRunningTor() torcontrol: Control Command:
GETCONF UseMicrodescriptors

QSYSTEM: TorrcTestSuite::testRunningTor() Maximum amount of warnings
exceeded. Use -maxwarnings to override.

PASS   : TorrcTestSuite::testRunningTor()

PASS   : TorrcTestSuite::cleanupTestCase()

Totals: 6 passed, 0 failed, 0 skipped, 0 blacklisted, 12273ms

* Finished testing of TorrcTestSuite *



On Sun, Feb 25, 2024 at 12:06 AM Sergey Fedorov  wrote:

> Thank you.
>
> This branch adds a version with Qt5 for aarch64 and tests support:
> https://github.com/barracuda156/macports-ports/tree/vidalia
>
> If running via sudo port test, I get this:
>
> --->  Testing Vidalia
>
> Executing:  cd
> "/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/vidalia-8240540188062a168a66b25ca61b852cc89140ad/src/tests"
> && ./VidaliaTestSuite
>
> * Start testing of TorrcTestSuite *
>
> Config: Using QtTest library 5.15.12, Qt 5.15.12 (arm64-little_endian-lp64
> shared (dynamic) release build; by Clang 15.0.0 (clang-1500.1.0.2.5)
> (Apple)), osx 14.3
>
> PASS   : TorrcTestSuite::initTestCase()
>
> PASS   : TorrcTestSuite::testTorrcLine()
>
> PASS   : TorrcTestSuite::testTorrcParser()
>
> PASS   : TorrcTestSuite::testTorrc()
>
> QWARN  : TorrcTestSuite::testRunningTor() libpng warning: iCCP: known
> incorrect sRGB profile
>
> sh: line 1: 72551 Trace/BPT trap: 5   ./VidaliaTestSuite
>
> Command failed:  cd
> "/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/vidalia-8240540188062a168a66b25ca61b852cc89140ad/src/tests"
> && ./VidaliaTestSuite
>
> Exit code: 133
>
> Error: Failed to test Vidalia: command execution failed
>
> On Sat, Feb 24, 2024 at 11:56 PM Ken Cunningham <
> ken.cunningham.web...@gmail.com> wrote:
>
>> Oh, OK…. That’s different then, for sure.
>>
>> Let me see if I get the same result.
>>
>> K
>>
>> On Feb 24, 2024, at 08:32, Sergey Fedorov  wrote:
>>
>> 
>> Ken, you are right about 10.6-ppc, of course, but in this particular case
>> I am having an issue with Sonoma.
>> Specifically, I cannot get Vidalia tests run with *sudo port test*. At
>> the same time, they run fine if I launch the test binary manually without
>> sudo.
>>
>> What fails:
>> 1. sudo port test vidalia
>> 2. sudo
>> /opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/vidalia-8240540188062a168a66b25ca61b852cc89140ad/src/tests/VidaliaTestSuite
>> 3. sudo -u macports
>> /opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/vidalia-8240540188062a168a66b25ca61b852cc89140ad/src/tests/VidaliaTestSuite
>>
>> What works fine:
>> 1.
>> /opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/vidalia-8240540188062a168a66b25ca61b852cc89140ad/src/tests/VidaliaTestSuite
>> 2. sudo -u svacchanda 
>> /opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/vidalia-8240540188062a168a66b25ca61b852cc89140ad/src/tests/VidaliaTestSuite
>> (that is, from a current non-root user).
>>
>> (Portfile in the master has no support for tests, as of now, so running
>> it gonna fail anyway.)
>>
>> On Sat, Feb 24, 2024 at 11:24 PM Ken Cunningham <
>> ken.cunningham.web...@gmail.com> wrote:
>>
>>> Some of your macports installations are installed as the root user,
>>> instead of the macports user.
>>>
>>> This happened because there is no installer for 10.6-ppc to
>>> automatically create the macports user. You have an open ticket about this
>>> too, where I pointed to the commands to be run to generate the macports
>>> user.
>>>
>>> Sooner or later you will probably have to fix this.
>>
>>


Re: How to force run tests as non-root?

2024-02-24 Thread Sergey Fedorov
Thank you.

This branch adds a version with Qt5 for aarch64 and tests support:
https://github.com/barracuda156/macports-ports/tree/vidalia

If running via sudo port test, I get this:

--->  Testing Vidalia

Executing:  cd
"/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/vidalia-8240540188062a168a66b25ca61b852cc89140ad/src/tests"
&& ./VidaliaTestSuite

* Start testing of TorrcTestSuite *

Config: Using QtTest library 5.15.12, Qt 5.15.12 (arm64-little_endian-lp64
shared (dynamic) release build; by Clang 15.0.0 (clang-1500.1.0.2.5)
(Apple)), osx 14.3

PASS   : TorrcTestSuite::initTestCase()

PASS   : TorrcTestSuite::testTorrcLine()

PASS   : TorrcTestSuite::testTorrcParser()

PASS   : TorrcTestSuite::testTorrc()

QWARN  : TorrcTestSuite::testRunningTor() libpng warning: iCCP: known
incorrect sRGB profile

sh: line 1: 72551 Trace/BPT trap: 5   ./VidaliaTestSuite

Command failed:  cd
"/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/vidalia-8240540188062a168a66b25ca61b852cc89140ad/src/tests"
&& ./VidaliaTestSuite

Exit code: 133

Error: Failed to test Vidalia: command execution failed

On Sat, Feb 24, 2024 at 11:56 PM Ken Cunningham <
ken.cunningham.web...@gmail.com> wrote:

> Oh, OK…. That’s different then, for sure.
>
> Let me see if I get the same result.
>
> K
>
> On Feb 24, 2024, at 08:32, Sergey Fedorov  wrote:
>
> 
> Ken, you are right about 10.6-ppc, of course, but in this particular case
> I am having an issue with Sonoma.
> Specifically, I cannot get Vidalia tests run with *sudo port test*. At
> the same time, they run fine if I launch the test binary manually without
> sudo.
>
> What fails:
> 1. sudo port test vidalia
> 2. sudo
> /opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/vidalia-8240540188062a168a66b25ca61b852cc89140ad/src/tests/VidaliaTestSuite
> 3. sudo -u macports
> /opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/vidalia-8240540188062a168a66b25ca61b852cc89140ad/src/tests/VidaliaTestSuite
>
> What works fine:
> 1.
> /opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/vidalia-8240540188062a168a66b25ca61b852cc89140ad/src/tests/VidaliaTestSuite
> 2. sudo -u svacchanda 
> /opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/vidalia-8240540188062a168a66b25ca61b852cc89140ad/src/tests/VidaliaTestSuite
> (that is, from a current non-root user).
>
> (Portfile in the master has no support for tests, as of now, so running it
> gonna fail anyway.)
>
> On Sat, Feb 24, 2024 at 11:24 PM Ken Cunningham <
> ken.cunningham.web...@gmail.com> wrote:
>
>> Some of your macports installations are installed as the root user,
>> instead of the macports user.
>>
>> This happened because there is no installer for 10.6-ppc to automatically
>> create the macports user. You have an open ticket about this too, where I
>> pointed to the commands to be run to generate the macports user.
>>
>> Sooner or later you will probably have to fix this.
>
>


Re: How to force run tests as non-root?

2024-02-24 Thread Ken Cunningham
Oh, OK…. That’s different then, for sure.Let me see if I get the same result.KOn Feb 24, 2024, at 08:32, Sergey Fedorov  wrote:Ken, you are right about 10.6-ppc, of course, but in this particular case I am having an issue with Sonoma.Specifically, I cannot get Vidalia tests run with sudo port test. At the same time, they run fine if I launch the test binary manually without sudo.What fails:1. sudo port test vidalia2. sudo /opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/vidalia-8240540188062a168a66b25ca61b852cc89140ad/src/tests/VidaliaTestSuite3. sudo -u macports /opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/vidalia-8240540188062a168a66b25ca61b852cc89140ad/src/tests/VidaliaTestSuiteWhat works fine:1. /opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/vidalia-8240540188062a168a66b25ca61b852cc89140ad/src/tests/VidaliaTestSuite2. sudo -u svacchanda /opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/vidalia-8240540188062a168a66b25ca61b852cc89140ad/src/tests/VidaliaTestSuite (that is, from a current non-root user).(Portfile in the master has no support for tests, as of now, so running it gonna fail anyway.)On Sat, Feb 24, 2024 at 11:24 PM Ken Cunningham  wrote:Some of your macports installations are installed as the root user, instead of the macports user.

This happened because there is no installer for 10.6-ppc to automatically create the macports user. You have an open ticket about this too, where I pointed to the commands to be run to generate the macports user.

Sooner or later you will probably have to fix this.


Re: How to force run tests as non-root?

2024-02-24 Thread Sergey Fedorov
Ken, you are right about 10.6-ppc, of course, but in this particular case I
am having an issue with Sonoma.
Specifically, I cannot get Vidalia tests run with *sudo port test*. At the
same time, they run fine if I launch the test binary manually without sudo.

What fails:
1. sudo port test vidalia
2. sudo
/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/vidalia-8240540188062a168a66b25ca61b852cc89140ad/src/tests/VidaliaTestSuite
3. sudo -u macports
/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/vidalia-8240540188062a168a66b25ca61b852cc89140ad/src/tests/VidaliaTestSuite

What works fine:
1.
/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/vidalia-8240540188062a168a66b25ca61b852cc89140ad/src/tests/VidaliaTestSuite
2. sudo -u svacchanda
/opt/local/var/macports/build/_opt_svacchanda_SonomaPorts_security_Vidalia/Vidalia/work/vidalia-8240540188062a168a66b25ca61b852cc89140ad/src/tests/VidaliaTestSuite
(that is, from a current non-root user).

(Portfile in the master has no support for tests, as of now, so running it
gonna fail anyway.)

On Sat, Feb 24, 2024 at 11:24 PM Ken Cunningham <
ken.cunningham.web...@gmail.com> wrote:

> Some of your macports installations are installed as the root user,
> instead of the macports user.
>
> This happened because there is no installer for 10.6-ppc to automatically
> create the macports user. You have an open ticket about this too, where I
> pointed to the commands to be run to generate the macports user.
>
> Sooner or later you will probably have to fix this.


Re: How to force run tests as non-root?

2024-02-24 Thread Ken Cunningham
Some of your macports installations are installed as the root user, instead of 
the macports user.

This happened because there is no installer for 10.6-ppc to automatically 
create the macports user. You have an open ticket about this too, where I 
pointed to the commands to be run to generate the macports user.

Sooner or later you will probably have to fix this.

Re: How to force run tests as non-root?

2024-02-23 Thread Joshua Root

On 24/2/2024 17:27, Sergey Fedorov wrote:
If Macports is running as root, but tests require non-root user, how to 
do that?

There is no test.asroot no, apparently.


All the usual ways you can run something as another user when you are 
root. You could prefix your build.cmd with 'sudo -u $macportsuser' for 
example.


- Josh