Mailinglist Archive: opensuse (783 mails)

< Previous Next >
Re: [opensuse] Run command as another user

On 30/09/17 00:33, Carlos E. R. wrote:
On 2017-09-29 22:36, David T-G wrote:

The more detail you can give us, the better we can provide ideas :-)
He said he wants to do this in C:

system("command", username, password);

Plain simple :-)


I don't know of a way to call a command giving user and password in its
command line. Except expect. Or ssh with key pairs, not password.
SSH is rather unnecessary as it only needs access to the local machine.

Is there a way of logging into a local shell as a user in C to run the commands?
He is not root, he can not configure sudo. He has sudo access and the
target user password. But sudo stops the script and asks for the
password. He wants the script to not ask, just provide the password
automatically.
Exactly!
Any method such as expect would store the password in a file in the
clear, so it is a security risk. Correct method I think would be ssh and
key pairs. The login session can store the password to the keys.

Unless I could save the password as something like an md5 string? Then decrypt that in the C program.

--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse+owner@xxxxxxxxxxxx

< Previous Next >
List Navigation