Ignore:
Timestamp:
Apr 24, 2019, 4:12:25 PM (6 years ago)
Author:
Herwig Bauernfeind
Message:

Fix Ticket #324 in cltinit.vrs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/guitools/smbusers/SMBUSERS.VRX

    r1024 r1058  
    742742
    743743    /* Lets see if the credentials are good */
     744    /* 3 possible results:
     745       1. list of users, each user in one line
     746       2. first line is "Anonymous login successful", list of users afterwards
     747       3. Samba error NT_STATUS
     748       4. Other error
     749     */
    744750    ok = VRSet("Main", 'Pointer', 'Wait' )
    745751    say '  'samba.!netexe' rpc user 'DebugLevel' 'UserCred' 1>'samba.!msg
    746752    address cmd samba.!netexe' rpc user 'DebugLevel' 'UserCred' 1>'samba.!msg
    747     ok = VRSet("Main", 'Pointer', '<default>' )
     753
     754    login_ok = 0
    748755    do while lines(samba.!msg) > 0
    749         loginLine = linein(samba.!msg)
    750         if words(loginline) <> 1 then do
    751             if pos("NT_STATUS",loginline) > 0 then leave /* Bad login */
    752         end
    753         else leave /* Good login */
    754         /* retry - we read garbage - probably debug data */
     756        loginLine = strip(linein(samba.!msg))
     757        select
     758            when loginline = "Anonymous login successful" then do
     759                login_ok = 0
     760                leave
     761            end
     762            when pos("NT_STATUS",loginline) > 0 then do /* Bad login */
     763                Msg.Text = loginline
     764                Msg.Type = "E"
     765                call _ShowMsg
     766                login_ok = 0
     767                leave
     768            end
     769            when words(loginline) = 1 then do /* looks like an item from the list of users */
     770                if _UserIsValid(strip(loginLine)) then do
     771                    login_ok = 1
     772                end
     773                leave
     774            end
     775            otherwise nop /* we read garbage - probably debug data, let's retry */
     776        end
    755777    end
    756778    ok = stream(samba.!msg,'c','close')
    757779    ok = SysFileDelete(samba.!msg)
    758 
    759     /* If did not get a valid user back i.e. the first entry of the list, login was not successful */
    760     if \_UserIsValid(strip(loginLine)) then do
     780    ok = VRSet("Main", 'Pointer', '<default>' )
     781    if \login_ok then do
    761782        Msg.Title = NLVGetMessage(31)': 'Credentials.!username'@'copies('*',length(Credentials.!password))
    762         Msg.Text = substr(loginLine, pos("NT_STATUS",loginline))
     783        /* Make sure we do not crash in case there was no valid
     784           Samba error, but the user is not valid either */
     785        Msg.Text = substr(loginLine, max(pos("NT_STATUS",loginline),1))
    763786        Msg.Type = "E"
    764787        call _ShowMsg
Note: See TracChangeset for help on using the changeset viewer.