[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

How to add debci user in a specific group? or use sudo in a autopkgtest script?



Hello,

I try to run tests for my package python3-pykcs11
I work in progress is available at https://salsa.debian.org/rousseau/pykcs11-debug/-/blob/master/debian/tests/unittest

I am also the upstream developer and some tests are already present in the archive. I just need to run them.
https://salsa.debian.org/rousseau/pykcs11-debug/-/tree/master/test

Before I can run the tests I need to install the package softhsm2 to have a software PKCS#11 token.

My problem is that the configuration files for softhsm2 are in the directory /etc/softhsm/ and this directory is accessible only by root and the users from the group softhsm:
$ ls -ld /etc/softhsm/
drwxr-x--- 2 root softhsm 4096  2 avril 17:49 /etc/softhsm/

If the user is not in the group softhsm then the softhsm2 command fails with:
$ softhsm2-util --init-token
ERROR: Could not load the SoftHSM configuration.
ERROR: Please verify that the SoftHSM configuration is correct.

The complete log is at https://salsa.debian.org/rousseau/pykcs11-debug/-/jobs/4106192


What is the best way using autopkgtest to solve my problem?
- Maybe adding the user debci to the group softhsm is enough but I would need to use sudo or be root.
- Another option is to change the access rights of the directory /etc/softhsm/ so the user can access the files in it.

I think that something like "Restrictions: needs-root" can help.
But I do not want to run all the test script as root. I just want to change some files configuration in the virtual machine.

Adding user debci in sudoers would solve my problem.
I use something like "sudo chmod o+rx /etc/softhsm/" and problem solved.
Since the VM is not reused it should be harmless. And it is safer than running the full script as root.

Any ideas of the best solution?

Thanks

--
Dr. Ludovic Rousseau


Reply to: