aboutsummaryrefslogtreecommitdiffstats
path: root/sh/lib.sh
blob: 64ba3f735c9e7b8929aa14140c1a3d71438796fc (plain) (blame)
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
#!/bin/sh

# copy_glibc_deps $STASH $DEST_VM
copy_glibc_deps() {
  for GLIBC_LIB in $GLIBC_LIST; do
    if [ ! -f $1/$GLIBC_LIB ]; then
      echo "GLIBC_LIB: "$LINUX_LIB_PATH/$GLIBC_LIB
      $zscp $2:$LINUX_LIB_PATH/$GLIBC_LIB $1
    fi
  done
}

# copy_deps_to_stash $DEPENDENCY_LIST $STASH $SRC_VM
copy_deps_to_stash() {
  echo copy_deps_to_stash
  for DEP in $1; do
    echo "DEP: "$DEP
    if [ ! -f $2/$(basename $DEP) ]; then
      $zscp $3:$DEP $2
    fi

    L2_DEP_LIST=$($zssh $3 "ldd $DEP" | awk '{print $3}')
    for DEP2 in $L2_DEP_LIST; do
      echo "DEP2: "$DEP2
      if [ ! -f $2/$(basename $DEP2) ]; then
        $zscp $3:$DEP2 $2
      fi
    done
  done
}

# copy_to_stash $ABS_PATH_TO_EXECUTALE $DEPENDENCY_LIST $STASH $SRC_VM
copy_to_stash() {
  $zscp $4:$1 $3
  copy_deps_to_stash "$2" $3 $4
}

# copy_from_stash $STASH $DEST
copy_from_stash() {
  $zscp $1 $ROUTER:$2
}

# copy_pam_mod_deps $PAM_SERVICE $STASH $SRC_VM
copy_pam_mod_deps() {
  MODS=$($zssh $ROUTER "cat /etc/pam.d/$1 | grep -o 'pam_.*\.so'")
  echo MODS": "$MODS

  for MOD in $MODS; do
    MOD_ABS=$LIB_SECURITY_PATH/$MOD
    echo $MOD_ABS
    DEP_LIST=$($zssh $3 "ldd $MOD_ABS" | awk '{print $3}')
    echo DEPS": "$DEP_LIST
    copy_to_stash $MOD_ABS "$DEP_LIST" $2 $3
  done
}

dig() {
  globalholecounter=0
  if test "$("ls" -A "/home/devi/devi/abbatoir")"; then
    while [ 1 ]; do
      if [ -d "/home/devi/devi/abbatoir/hole$globalholecounter" ]; then
        # if its not empty
        if test "$("ls" -A "/home/devi/devi/abbatoir/hole$globalholecounter")"; then
          :
        # if its empty
        else
          cd /home/devi/devi/abbatoir/hole$globalholecounter
          break
        fi
      else
        mkdir /home/devi/devi/abbatoir/hole$globalholecounter
        cd /home/devi/devi/abbatoir/hole$globalholecounter
        echo $globalholecounter
        break
      fi
      $((globalholecounter=globalholecounter+1))
    done
  else
    mkdir /home/devi/devi/abbatoir
    mkdir /home/devi/devi/abbatoir/hole$globalholecounter
    cd /home/devi/devi/abbatoir/hole$globalholecounter
  fi
}