[Gambas-user] Program to use different group rights
Rolf-Werner Eilert
rwe-sse at osnanet.de
Sun Dec 2 13:37:47 CET 2018
Me again, now on another system.
When we discussed this, I tried it on a Suse with KDE. Now I am on
Ubuntu Mate, and it doesn't run anymore. I get the error message "su:
only may be started from a terminal" (or something like that, it's in
German).
Is there a chance to fake a terminal environment in a shell?
Regards
Rolf
Am 26.11.18 um 17:21 schrieb T Lee Davidson:
> How about this:
>
> Public Sub Main()
>
> Dim sPass, sOutput As String
>
> sPass = "wrong"
> Shell "echo " & sPass & "|su -c True $USER 2>&1" To sOutput
> ' Print sOutput
> If InStr(sOutput, "failure") > 0 Then
> Print "Fail"
> Else
> Print "Pass"
> Endif
>
> End
>
>
> ___
> Lee
>
>
> On 11/26/18 7:02 AM, Rolf-Werner Eilert wrote:
>> Let me add this:
>>
>> I just found two solutions:
>>
>> 1. Commandline:
>>
>> if su -c true "$USER"; then
>> echo "Correct password"
>> fi
>>
>> How would I read the exit code if in a Gambas shell?
>>
>> 2. PAM call. This example is in Ruby, but very much like Gambas. BUT it needs a Ruby library called rpam, so if there is nothing
>> comparable in Gambas...
>>
>> It boils down to this line:
>>
>> if Rpam.auth(username, password, service: 'system-auth')
>>
>> So I would prefer the first way, but I need to know how to read exit codes from a shell.
>>
>> Regards
>> Rolf
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
>
More information about the User
mailing list