[Gambas-user] Program to use different group rights
T Lee Davidson
t.lee.davidson at gmail.com
Mon Nov 26 17:21:23 CET 2018
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
More information about the User
mailing list