ANYPARM logonstr # VALID.XEQ # Jeff Vance, CSY # Validates syntactically and semantically a logon string ("logonstr") # without the HELLO and without any of the other logon options. # Expects 'logonstr' to be of the form: # [jsname,]user[/pass].acct[/pass][,group[/pass]] # Note: passwords are not validated to be correct, just checked syntactically. # # There is also an internal ENTRY= point used by this script that is # parsed out of the anypar value. This syntax is: # token_var "error msg insert" pass_ok_bool ENTRY=syntax # # parse for the entry point, if used. setvar _chk_str ups('!logonstr') if setvar(_chk_pos,pos("ENTRY=",_chk_str)) > 0 then # last argument is the entry name setvar _chk_entry word(_chk_str,"=",-1) setvar _chk_str lft(_chk_str,_chk_pos-1) endif if not bound(_chk_entry) then # MAIN entry point errclear setvar _chk_js '' setvar _chk_g '' setvar _chk_name word(_chk_str,",") if len(_chk_name) = len(_chk_str) then # no jsname and no group name setvar _chk_ua _chk_name else # either jsname, groupname or both if pos('.',_chk_name) = 0 then # got a jsname...keep parsing setvar _chk_js _chk_name setvar _chk_ua word(_chk_str,",",2) if pos(",",_chk_str,-1) > pos(",",_chk_str,1) then # have gname setvar _chk_g word(_chk_str,",",-1) endif else # usr.acct name + gname setvar _chk_ua _chk_name setvar _chk_g word(_chk_str,",",-1) endif endif # have extracted jsname, user.acct name and grp name. Apply MPE rules. # note: the continue's below trap escapes from the alt entry if len(_chk_js) > 0 then continue xeq !hpfile _chk_js "job/session" false ENTRY=syntax endif setvar _chk_u word(_chk_ua,".") setvar _chk_a word(_chk_ua,".",-1) continue xeq !hpfile _chk_u "user" true ENTRY=SYNTAX continue xeq !hpfile _chk_a "account" true ENTRY=SYNTAX if len(_chk_g) > 0 then continue xeq !hpfile _chk_g "group" true ENTRY=SYNTAX endif # check for any syntax errors. if cierror <> 0 then deletevar _chk_@ return endif # remember that user,acct,group passwords could be present, if so # the 'syntax' entry has removed them. But we need to reform the # _chk_ua variable. setvar _chk_ua _chk_u+'.'+_chk_a # Now ensure that the user,account and group actually exist if not finfo('/'+_chk_a,'exists') then echo account (!_chk_a) does not exist deletevar _chk_@ return endif if len(_chk_g) > 0 then if not finfo('/'+_chk_a+'/'+_chk_g,'exists') then echo group (!_chk_g) does not exist deletevar _chk_@ return endif endif setvar cierror 0 continue listuser !_chk_ua ;format=brief >$null if cierror <> 0 then echo user (!_chk_ua) does not exist deletevar _chk_@ return endif # if we made it this far we have a valid logon id echo ***valid deletevar _chk_@ return elseif _chk_entry = 'SYNTAX' then # alt entry point for MPE syntax validation. # entry syntax: token_var "insert_msg" passwd_boolean # note the token_var is the name of the var in the main entry, eg. # the token_var could be '_chk_js'. This impacts dereferencing below. # note: the entry modifies its caller's vars if passwords are present!! # # parse the anyparm arguments for this entry setvar _chk_tok word(_chk_str,' ') setvar _chk_msg word(_chk_str,'"',2) setvar _chk_passok word(_chk_str,'"',-1) if !_chk_passok then # /password is ok for this token, split token if passwd present if pos('/',!_chk_tok) > 0 then setvar _chk_pass word(!_chk_tok,"/",-1) setvar !_chk_tok word(!_chk_tok,"/") else setvar _chk_passok "FALSE" endif endif if len(!_chk_tok) > 8 then echo !_chk_msg name (!"!_chk_tok") too long escape 1 endif if not alpha(lft(!_chk_tok,1)) then echo !_chk_msg name (!"!_chk_tok") must begin with a letter escape 2 endif if not alphanum(!_chk_tok) then echo !_chk_msg name (!"!_chk_tok") contains invalid characters escape 3 endif # validate pasword if supplied and ok if !_chk_passok then if len(_chk_pass) > 8 then echo !_chk_msg password (!_chk_pass) too long escape 4 endif if not alpha(lft(_chk_pass,1)) then echo !_chk_msg password (!_chk_pass) must begin with a letter escape 5 endif if not alphanum(_chk_pass) then echo !_chk_msg password (!_chk_pass) contains invalid characters escape 6 endif endif endif