PVCS VM PreGet event trigger

We've just migrated from an environment in which all PVCS activity (client/server) is on a Solaris 11 system. We now have separate RHEL  client and server systems. Interactivity between the client and server seem fine as expected. But we're consistently failing on a PreGet trigger. The trigger is pretty simple. A Perl wrapper script used for checkout touches a unique filename (ex. /tmp/app_prac_appr.pkbz0hncmsdget , which is just a concatenation of the filename, username, and 'get' ) and chmod's the file 777. And then the PreGet trigger checks for the existence of that file. Unfortunately, it doesn't see the file as readable or as present. Here's the simple code for the PreGet trigger.

#!/bin/csh -f
alias echo /usr/bin/echo

if ( $?EVENTLOCK ) then

 /usr/tools/bin/group_member -u $EVENTUSERID capplprd                          

 if ! ( $status == 1 ) then
   echo "EVENTLOCK=$EVENTLOCK"
   echo "/tmp/${EVENTWORKFILE}${EVENTUSERID}get"                               

  if ! ( -f /tmp/${EVENTWORKFILE}${EVENTUSERID}get ) then                      
   echo "\nPVCS ERROR:  You are attempting to directly lock code via vget."    
   echo "             A mail message reporting this event is being sent "      
   echo "             to the proper authorities."                              
   mail pvcs_adm <<EOF
   $EVENTUSERID attempted to get $EVENTWORKFILE directly.                      
EOF
   echo "status = ", $?
   exit 1;
  else
     rm /tmp/${EVENTWORKFILE}${EVENTUSERID}get                                 
  endif
 endif
endif


(I'm not a fan of CSH scripting.  But this is pretty simple. And the 'file existence' fails each time. I _did_ note that when I echo'd the /tmp filename, that it included a <cr>. But I think that is just a function of the echo statement. I also tested to see if such triggers are run on the server system (vs. the client), but I saw the same behavior when run on client or server. 

At this point, I'm considering rewriting the trigger in Perl or Python for the better functionality/debugging.

But does anyone have any idea why this might fail? Whether it be differences between Solaris 11 and RHEL 8.9, etc?

Thanks
Mark


  • 0

    It's the ( -f ) file existence test that fails to 'see' the file.

  • 0   in reply to 

    Hello Mark.

    There's nothing inherently wrong with that script (it's working for me).

    To debug, I would replace:

       echo "/tmp/${EVENTWORKFILE}${EVENTUSERID}get"

    with:

       ls -l "/tmp/${EVENTWORKFILE}${EVENTUSERID}get"

    to confirm the file exists when the trigger is executed.

    Combined with some other recommendations (in diff patch format):

    -- tst.csh.org    2024-12-17 11:26:39.412849053 -0800
    +++ tst.csh    2024-12-17 11:27:17.584087146 -0800
    @@ -1,25 +1,25 @@
     #!/bin/csh -f
    -alias echo /usr/bin/echo
    +alias echo /usr/bin/echo -e
     
     if ( $?EVENTLOCK ) then
     
     /usr/tools/bin/group_member -u $EVENTUSERID capplprd                          
     
      if ! ( $status == 1 ) then
        echo "EVENTLOCK=$EVENTLOCK"
    -   echo "/tmp/${EVENTWORKFILE}${EVENTUSERID}get"                               
    +   ls -l "/tmp/${EVENTWORKFILE}${EVENTUSERID}get"                               
     
    -  if ! ( -f /tmp/${EVENTWORKFILE}${EVENTUSERID}get ) then                      
    +  if ! ( -f "/tmp/${EVENTWORKFILE}${EVENTUSERID}get" ) then                      
        echo "\nPVCS ERROR:  You are attempting to directly lock code via vget."    
        echo "             A mail message reporting this event is being sent "      
        echo "             to the proper authorities."                              
        mail pvcs_adm <<EOF
        $EVENTUSERID attempted to get $EVENTWORKFILE directly.                      
     EOF
        echo "status = ", $?
        exit 1;
       else
    -     rm /tmp/${EVENTWORKFILE}${EVENTUSERID}get                                 
    +     rm "/tmp/${EVENTWORKFILE}${EVENTUSERID}get"
       endif
      endif
     endif

    If the file exits yet the tests fails, do you get an error?

    With kind regards,

    - Richard.

  • 0 in reply to   

    Thanks Richard.

    I made the recommended changes for debugging. And it appears that the file is seen, but still the trigger fails because the 

    if ! ( -f "/tmp/${EVENTWORKFILE}${EVENTUSERID}get" ) then 

    doesn't deem the file to be present.

    PVCS Version Manager (get) v8.6.3.0 (Build 421) for Linux/x86_64
    (C) Copyright 2021 Micro Focus or one of its affiliates. All Rights Reserved.
    get: operation cancelled; 'PreGet' event trigger could not be executed.
    0 'EVENTLOCK=YES
    '
    1 '-rwxrwxrwx. 1 t0rmsces cefmdev 0 Dec 17 19:46 /tmp/colcert.fmbt0rmscesget
    '

  • 0   in reply to 

    The plot thickens...

    Can you please insert the following after the first line:

    set echo
    set verbose

    Then re-run and show the output.

    Thanks in advance,

    - Richard.

  • 0 in reply to   

    Here is the log from those changes:

    PVCS Version Manager (get) v8.6.3.0 (Build 421) for Linux/x86_64
    (C) Copyright 2021 Micro Focus or one of its affiliates. All Rights Reserved.
    set verbose
    alias echo /usr/bin/echo
    alias echo /usr/bin/echo

    if ( $?EVENTLOCK ) then
    if ( 1 ) then

    /usr/tools/bin/group_member -u $EVENTUSERID capplprd
    /usr/tools/bin/group_member -u t0rmsces capplprd

    if ! ( $status == 1 ) then
    if ! ( 0 == 1 ) then
    echo "EVENTLOCK=$EVENTLOCK"
    /usr/bin/echo EVENTLOCK=YES
    ls -l "/tmp/${EVENTWORKFILE}${EVENTUSERID}get"
    ls -l /tmp/colcert.fmbt0rmscesget

    if ! ( -f "/tmp/${EVENTWORKFILE}${EVENTUSERID}get" ) then
    if ! ( -f /tmp/colcert.fmbt0rmscesget ) then

    rm "/tmp/${EVENTWORKFILE}${EVENTUSERID}get"
    rm /tmp/colcert.fmbt0rmscesget
    endif
    endif
    endif
    endif
    endif
    endif
    get: operation cancelled; 'PreGet' event trigger could not be executed.
    0 'EVENTLOCK=YES
    '
    1 '-rwxrwxrwx. 1 t0rmsces cefmdev 0 Dec 17 20:57 /tmp/colcert.fmbt0rmscesget

  • 0 in reply to 

    But wait, how can it determine that the  PreGet trigger failed if the output above doesn't show that this code snippet executed:

       echo "\nPVCS ERROR:  You are attempting to directly lock code via vget."    
       echo "             A mail message reporting this event is being sent "      
       echo "             to the proper authorities."                              
       mail pvcs_adm <<EOF
       $EVENTUSERID attempted to get $EVENTWORKFILE directly.                      
    EOF
       echo "status = ", $?
       exit 1;

    Is it now just being treated as a failure because it's not exiting with an explicit exit status value?  IOW, it might be taking the status of the last command executed in the trigger, which might be non-zero.

    I'll add an explicit 

    exit 0 

    at the bottom, to set an explicit status if it reaches that point.

  • 0 in reply to 

    This makes no sense to me now. It exits with a zero status, but still the PreGet trigger is determined to have failed. Not only does it not display the failure text, within the file existence test, I also removes the /tmp file because it was found to be present. That is a success within the PreGet script, but the outcome is still determined to be a failed PreGet trigger execution.

    set verbose
    alias echo /usr/bin/echo
    alias echo /usr/bin/echo

    if ( $?EVENTLOCK ) then
    if ( 1 ) then

    /usr/tools/bin/group_member -u $EVENTUSERID capplprd
    /usr/tools/bin/group_member -u t0rmsces capplprd

    if ! ( $status == 1 ) then
    if ! ( 0 == 1 ) then
    echo "EVENTLOCK=$EVENTLOCK"
    /usr/bin/echo EVENTLOCK=YES
    ls -l "/tmp/${EVENTWORKFILE}${EVENTUSERID}get"
    ls -l /tmp/colcert.fmbt0rmscesget

    if ! ( -f "/tmp/${EVENTWORKFILE}${EVENTUSERID}get" ) then
    if ! ( -f /tmp/colcert.fmbt0rmscesget ) then

    rm "/tmp/${EVENTWORKFILE}${EVENTUSERID}get"
    rm /tmp/colcert.fmbt0rmscesget
    endif
    endif
    endif
    endif
    endif
    endif

    exit 0 ;
    exit 0
    get: operation cancelled; 'PreGet' event trigger could not be executed.
    0 'EVENTLOCK=YES
    '
    1 '-rwxrwxrwx. 1 t0rmsces cefmdev 0 Dec 17 21:18 /tmp/colcert.fmbt0rmscesget
    '

  • 0 in reply to 

    And here is the get command execution, outside of any wrapper script. We call vget, which is symlink to the PVCS get command.

    I would not be opposed to replacing the PreGet script with one that is basically an 'exit 0' command. Just so we can pare things down to the bare minimum.

    ls -l ~pvcs/vget
    lrwxrwxrwx. 1 pvcs pvcs 25 Apr 25 2022 /home/pvcs/vget -> software/vm/linux/bin/get


    /home/pvcs/vget -r1.237 -l colcert.fmb
    PVCS Version Manager (get) v8.6.3.0 (Build 421) for Linux/x86_64
    (C) Copyright 2021 Micro Focus or one of its affiliates. All Rights Reserved.
    set verbose
    alias echo /usr/bin/echo
    alias echo /usr/bin/echo

    if ( $?EVENTLOCK ) then
    if ( 1 ) then

    /usr/tools/bin/group_member -u $EVENTUSERID capplprd
    /usr/tools/bin/group_member -u t0rmsces capplprd

    if ! ( $status == 1 ) then
    if ! ( 0 == 1 ) then
    echo "EVENTLOCK=$EVENTLOCK"
    /usr/bin/echo EVENTLOCK=YES
    EVENTLOCK=YES
    ls -l "/tmp/${EVENTWORKFILE}${EVENTUSERID}get"
    ls -l /tmp/colcert.fmbt0rmscesget
    -rwxrwxrwx. 1 t0rmsces cefmdev 0 Dec 17 21:30 /tmp/colcert.fmbt0rmscesget

    if ! ( -f "/tmp/${EVENTWORKFILE}${EVENTUSERID}get" ) then
    if ! ( -f /tmp/colcert.fmbt0rmscesget ) then

    rm "/tmp/${EVENTWORKFILE}${EVENTUSERID}get"
    rm /tmp/colcert.fmbt0rmscesget
    endif
    endif
    endif
    endif
    endif
    endif

    exit 0 ;
    exit 0
    get: operation cancelled; 'PreGet' event trigger could not be executed.

  • 0   in reply to 

    That's peculiar.

    Depending on whether your default shell is bash or csh, please execute:

    export PVCS_DEBUG_EXECS=/dev/tty

    or

    setenv PVCS_DEBUG_EXECS /dev/tty

    Now re-run your vget command and share the new output.

    Thanks,

    - Richard.

  • 0 in reply to   

    Here's the output after 
    export PVCS_DEBUG_EXECS=/dev/tty

    [t0rmsces@ashvw6kbaaa0802 mark]$ ls -l /tmp/*get
    -rwxrwxrwx. 1 z0hncmsd not26008 0 Dec 17 15:00 /tmp/app_prac_appr.pkbz0hncmsdget
    -rwxrwxrwx. 1 t0rmsces cefmdev 0 Dec 18 00:40 /tmp/colcert.fmbt0rmscesget



    [t0rmsces@ashvw6kbaaa0802 mark]$ /home/pvcs/vget -r1.237 -l colcert.fmb
    PVCS Version Manager (get) v8.6.3.0 (Build 421) for Linux/x86_64
    (C) Copyright 2021 Micro Focus or one of its affiliates. All Rights Reserved.
    QualifyAndGetAppType():
    -->cmdName=/home/pvcs/bin/preget/pg_trg.csh
    -->cmdTail=
    -->Command exists.
    -->Qualified as '/home/pvcs/bin/preget/pg_trg.csh'
    ExecSync():
    -->appType=2 ppEnv=0x0187efc0
    -->cmd='/home/pvcs/bin/preget/pg_trg.csh'
    Using sw_sys_exec()
    set verbose
    alias echo /usr/bin/echo
    alias echo /usr/bin/echo

    if ( $?EVENTLOCK ) then
    if ( 1 ) then

    /usr/tools/bin/group_member -u $EVENTUSERID capplprd
    /usr/tools/bin/group_member -u t0rmsces capplprd

    if ! ( $status == 1 ) then
    if ! ( 0 == 1 ) then
    echo "EVENTLOCK=$EVENTLOCK"
    /usr/bin/echo EVENTLOCK=YES
    EVENTLOCK=YES
    ls -l "/tmp/${EVENTWORKFILE}${EVENTUSERID}get"
    ls -l /tmp/colcert.fmbt0rmscesget
    -rwxrwxrwx. 1 t0rmsces cefmdev 0 Dec 18 00:40 /tmp/colcert.fmbt0rmscesget

    if ! ( -f "/tmp/${EVENTWORKFILE}${EVENTUSERID}get" ) then
    if ! ( -f /tmp/colcert.fmbt0rmscesget ) then

    ########  skips l code for case where the /tmp file doesn't exist

    ######## and only attempts to remove the /tmp file if it was found to exist

    rm "/tmp/${EVENTWORKFILE}${EVENTUSERID}get"
    rm /tmp/colcert.fmbt0rmscesget
    endif
    endif
    endif
    endif
    endif
    endif

    exit 0 ;
    exit 0
    ExecSync():
    -->returning rc=0, exitCode=0
    -->cmd was='/home/pvcs/bin/preget/pg_trg.csh'

    get: operation cancelled; 'PreGet' event trigger could not be executed.