[Gambas-user] Program to use different group rights

Rolf-Werner Eilert rwe-sse at osnanet.de
Mon Nov 26 17:30:44 CET 2018


Good idea, Lee, but now I found that this will work only in a real 
shell, interactively. If I want to use it from a GUI program written in 
Gambas, I would at least have to offer a shell where the user can type 
in the password.

Is there really no chance for a test which runs completely in background 
other than using PAM libraries?

Regards
Rolf


Am 26.11.2018 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