Wednesday, April 13, 2022

[SOLVED] RPM command repeatedly asking for password

Issue

I am signing a big set of RPM packages (50000) using the below command

find $1 -name \*.rpm |xargs rpm --resign

As part of the RPM command structure, it asks for password. I am using expect script for supplying the password, like this.

expect -c "
spawn $1
expect \"Enter pass phrase: \"
send $2\r
interact

This is working very well for the first 1400 odd files. After that I am again thrown a prompt for password. This time I have to manually provide it. Like that, for every 1400 odd files this keeps happening.

I need help in understanding

  1. If this password is thrown from RPM, if so, why? Does RPM store the password in cache only for a stipulated time period?
  2. Assuming that so, I have manually copied the 'expect' code to provide password multiple times in my second file to provide password, still didn't work
  3. Is 'interact' playing foul?

Your help is highly appreciated. Thanks


Solution

I think the problem is in xargs. xargs would try to provide as many arguments to the command until the whole command line would exceed the limit. So when you have many files, xargs may need to invoke rpm for multiple times. GNU xargs's --show-limits can "display the limits on the command-line length which are imposed by the operating system". For example on my system:

# xargs --show-limits < /dev/null
Your environment variables take up 1689 bytes
POSIX lower and upper limits on argument length: 2048, 2094592
Maximum length of command we could actually use: 2092903
Size of command buffer we are actually using: 132761
#



Answered By - pynexj
Answer Checked By - Mary Flores (WPSolving Volunteer)