This file is indexed.

/usr/lib/oar/oarsh_shell is in oar-common 2.5.7-3.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
# $Id$
# This is the shell program used with the oarsh script.
# It adds its own process in the cpuset OAR_CPUSET and launches
# the shell or the script of the user OAR_JOB_USER.

DEFAULT_SHELL=/bin/bash
XAUTH_LOCATION="/usr/bin/xauth"
CPUSET_MOUNT_POINT="/dev/oar_cgroups_links"
OARDIR="/usr/lib/oar"
OAR_RUNTIME_DIRECTORY="/tmp/oar_runtime"

export PATH=$OARDIR/oardodo:$PATH

source /etc/oar/oar.conf

# File generated by job resource manager on all job nodes
JOBENVFILE="$OAR_RUNTIME_DIRECTORY/${OAR_CPUSET##*/}.env"

OLDUMASK=$(umask)
umask 0022

# $1 = Name of the cpuset
# $2,$3,... = PIDs to add
# Add PIDS into the cpuset $1
function add_process_to_cpuset() {
    [ "$1" = "undef" ] && return
    ######################
    # CPUSET assignation #
    ###########################################################################
    CPUSETNAME=$1
    if [ ! -w /dev/cpuset/$CPUSETNAME/tasks ]; then
        echo "oarsh: Cannot find cpuset file : /dev/cpuset/$CPUSETNAME/tasks" 1>&2
        exit 61
    fi
    shift

    # Add each processes to the right OAR cgroups
    for p in $@; do
        if [ -r $CPUSET_MOUNT_POINT/cpuset/$CPUSETNAME/tasks ]; then
            # Feed at least cpuset (security)
            $OARDIR/oardodo/oardodo sh -c "echo $p > $CPUSET_MOUNT_POINT/cpuset/$CPUSETNAME/tasks" || return 1
            for c in $CPUSET_MOUNT_POINT/*; do
                if [ "$c" != "$CPUSET_MOUNT_POINT/cpuset" -a -r "$c/$CPUSETNAME/tasks" ]; then
                    $OARDIR/oardodo/oardodo sh -c "echo $p > $c/$CPUSETNAME/tasks" || return 1
                fi
            done
        else
            # Old behaviour without cgroups (just cpuset)
            $OARDIR/oardodo/oardodo sh -c "echo $p > /dev/cpuset/$CPUSETNAME/tasks" || return 1
        fi
    done
    ###########################################################################
}

if [ "$OAR_JOB_USER" = "" ]
then
    if [ "$SSH_CLIENT" != ""  ] && [ "$OAR_KEY" != "1" ]
    then
        echo "oarsh: The OAR_KEY environment variable is not defined and this seems to be a oar user connection." 1>&2
        exit 65
    fi
    # It must be oar
    if [ "$OAR_CPUSET" != "" ]
    then
        add_process_to_cpuset $OAR_CPUSET $$ $PPID || exit 62
        [ -r "$JOBENVFILE" ] && source $JOBENVFILE
    fi
    $OARDIR/oardodo/oardodo renice 0 $$ $PPID > /dev/null 2>&1
    export SHELL=$DEFAULT_SHELL
    
    umask $OLDUMASK
    exec $DEFAULT_SHELL "$@"
    echo "oarsh: exec failed" 1>&2
    exit 66
else
    if [ "$OAR_CPUSET" = "" ]
    then
        echo "oarsh: OAR_CPUSET variable is empty; Is your sshd right configured with 'AcceptEnv OAR_CPUSET OAR_JOB_USER' on all computing nodes?" 1>&2
        exit 63
    fi
    add_process_to_cpuset $OAR_CPUSET $$ $PPID || exit 62
    
    #Manage display
    if [ -n "$DISPLAY" ]
    then
        if [ -x "$XAUTH_LOCATION" ]
        then
            $XAUTH_LOCATION -q extract - ${DISPLAY#localhost} | OARDO_BECOME_USER=${OAR_JOB_USER} $OARDIR/oardodo/oardodo $XAUTH_LOCATION merge -
            [ "${OAR_JOB_USER}" != "$OAR_JOB_USER" ] && OARDO_BECOME_USER=${OAR_JOB_USER} $OARDIR/oardodo/oardodo bash --noprofile --norc -c 'chmod 660 $HOME/.Xauthority'
        fi
    fi
    #Change tty owner
    TTY=$(tty) && test -e $TTY && $OARDIR/oardodo/oardodo chown $OAR_JOB_USER:oar $TTY && $OARDIR/oardodo/oardodo chmod 660 $TTY
    $OARDIR/oardodo/oardodo renice 0 $$ $PPID > /dev/null 2>&1
    [ -r "$JOBENVFILE" ] && source $JOBENVFILE
    if [ "$1" = "" ]
    then
        # Simulate initial login
        export OARDO_BECOME_USER=$OAR_JOB_USER
        umask $OLDUMASK
        exec $OARDIR/oardodo/oardodo
        #exec oardodo su - $OAR_JOB_USER
        echo "oarsh: exec failed" 1>&2
        exit 66
    else
        export OARDO_BECOME_USER=$OAR_JOB_USER
        export OARDO_USE_USER_SHELL=1
        umask $OLDUMASK
        exec $OARDIR/oardodo/oardodo "$@"
        echo "oarsh: exec failed" 1>&2
        exit 66
    fi
fi

echo "oarsh: Really bad error" 1>&2
exit 67