[Gambas-user] Program to use different group rights

Rolf-Werner Eilert rwe-sse at osnanet.de
Mon Dec 3 18:12:24 CET 2018


That works great, even under Mate. Thank you T Lee!

I could change it so it runs in a graphical application.

Regards
Rolf


Am 03.12.18 um 00:51 schrieb T Lee Davidson:
> As pointed out by Tobi, the solution I suggested previously (quoted below) is insecure.
> 
> I have tested another solution that works on openSUSE. Whether or not it will work on Ubuntu, I don't know. Perhaps the use of
> "For Input Output" (again, credit to Tobi) will satisfy su's need for a terminal.
> 
> ' Gambas module file
> 
> Public $thePassword As String = "badpass"
> 
> Public Sub Main()
> 
>    Dim Proc As Process
> 
>    Proc = Shell "su -c true $USER" Wait For Input Output As "Proc"
>    'Respond based on process exit code
>    Print IIf(Proc.Value = 0, "You passed.", "Not authorized: " & Proc.Value)
> 
> End
> 
> Public Sub Proc_Read()
> 
>    Dim sInput As String
> 
>    sInput = Read #Last, -256
>    If InStr(sInput, "Password:") Then
>      Print "Checking password..."
>      Write #Last, $thePassword & "\n"
>    Endif
> 
> End
> 
> 
> ___
> Lee
> 
> 
> On 12/2/18 7:37 AM, Rolf-Werner Eilert wrote:
>> 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
> 
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
> 
> 



More information about the User mailing list