Magellan Linux

Diff of /mcore-src/trunk/mcore-tools/src/include/sessionauth.global.class.in

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2243 by niro, Mon Jan 13 09:27:41 2014 UTC revision 2425 by niro, Thu Sep 3 07:53:30 2015 UTC
# Line 90  validate_auth() Line 90  validate_auth()
90   fi   fi
91  }  }
92    
93    validate_auth_certificate()
94    {
95     local cert_fingerprint="$1"
96     local key_fingerprint
97    
98     # return 0 if ${valid_auth=yes} - user alread authenticated
99     valid_session && return 0
100    
101     if [[ ! -e ${MCORE_KEY_FILE} ]]
102     then
103     eecho "MCORE_KEY_FILE '${MCORE_KEY_FILE}' does not exist"
104     fi
105    
106     if [[ -z ${cert} ]]
107     then
108     eecho "no certificate fingerprint given"
109     return 1
110     fi
111    
112     key_fingerprint=$(openssl rsa -noout -modulus -in "${MCORE_KEY_FILE}" | openssl sha1 | sed 's:(stdin)=\ ::')
113    
114     if [[ ${cert_fingerprint} == ${key_fingerprint} ]]
115     then
116     mecho "certificate fingerprint is valid!"
117     mecho "Successfully logged in. Type 'help' for more information."
118     export valid_session="yes"
119     return 0
120     else
121     mecho "certificate fingerprint is invalid!"
122     export valid_session="no"
123     return 1
124     fi
125    }
126    
127  valid_session()  valid_session()
128  {  {
129   if [[ ${valid_session} = yes ]]   if [[ ${valid_session} = yes ]]

Legend:
Removed from v.2243  
changed lines
  Added in v.2425