Arquivo sudoers editado sem motivo aparente

Iniciado por Anderson_Coelho, 28 de Março de 2014, 16:53

tópico anterior - próximo tópico

Anderson_Coelho

Pessoal

Tenho uma dúvida. Percebi essa semana que ao digitar sudo no terminal não era pedida a senha para executar o comando. Aí olhei o /etc/sudoers e estava assim:

Código (/etc/sudoers) Selecionar
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root ALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d
ALL ALL=(ALL) NOPASSWD:ALL
ALL ALL=(ALL) NOPASSWD:ALL
ALL ALL=(ALL) NOPASSWD:ALL
ALL ALL=(ALL) NOPASSWD:ALL


Então, apaguei as linhas abaixo de #includedir /etc/sudoers.d e as coisas voltaram a serem como eram antes.

Pesquisando, encontrei alguns casos em que esse arquivo também aparecia de modo semelhante ao que eu encontrei sem causa aparente.

A dúvida é que não encontrei o porquê disso ter ocorrido, já que não alterei o arquivo manualmente e apenas eu uso o computador. Li duas páginas que me deixaram um pouco preocupado:

http://tuxvermelho.blogspot.com.br/2007/07/sudo-voltando-sua-segurana.html
http://www.tecdicas.com/2013/08/linux-e-vulneravel-virus.html

Então, alguém já viu esse problema e sabe o porquê?

Obrigado

irtigor

O mais provavevel é que recentemente você seguiu um tutorial que fazia isso, e não percebeu.

Anderson_Coelho

Eu andei dando uma olhada com mais calma no que eu tinha instalado no PC nos últimos dias e acabei descobrindo a causa do problema: um modem da claro que eu vinha tentando instalar o discador para usar no Ubuntu.

O modem já veio com o instalador .exe para Windows e também com um arquivo install para Linux. Acabou que a instalação não tinha sido bem sucedida, mas analisando o código do arquivo install, percebi que ele mexe no /etc/sudoers. Jamais imaginei que isso iria alterar as permissões do meu SO. >:(

Só uma pergunta boba: será que tem algum problema eu postar o código do install aqui no fórum?

irtigor


Anderson_Coelho

Ok, só por curiosidade aí vai então (tive que dividir em duas partes porque o código é bem extenso):

#!/bin/bash
#
###############################################################################
#                                                                             #
#              »ªÎªÖÕ¶ËÊýŸÝ¿šlinux ºóÌš×¢²áÈíŒþ                               #
#              °æÈšÊôÓÚ»ªÎªŒŒÊõÓÐÏÞ¹«ËŸ£¬²»µÃµÁÓã¬Î¥Õ߱؟¿                   #
#              Huawei linux MobilePartner licensed software                   #
#              Copyright (c) 2007-2008 by Huawei Tech. Corp. Ltd..            #
#              ×÷ÕߣºÕÅǬŽº 2008.7.8                                          #
#                                                                             #
###############################################################################
#

BAKCURRENTPATH=`pwd`
SOFTWARENAME="Mobile Partner"
# g122020 2010.01.11 modify AJ2D15737
INSTALLWORKPATH="$(dirname "$0")"
CONFIG_FILE="/etc/datacard_config"
HOOK_FILE="/etc/pm/sleep.d"
USERDATA_PATH="/usr/local/hw_mp_userdata"
# g122020 2010.01.29 AJ2D15962
PPPD_PATH="/usr/local/hw_pppd"

FULLVERSION=21.005.22.02.150

SOFTWARENAMEINDESKTOP=$SOFTWARENAME
SOFTWARENAME=$(echo $SOFTWARENAME | sed s\#\ \#_\#g)

INSTALLPATH="/usr/local/${SOFTWARENAME}"
TEMPWORKPATH="/tmp/${SOFTWARENAME}_$$"
TEMPFILE="${SOFTWARENAME}_install_$PPID"

# add by zkf20747 for printing install log  DTS2010111102824 begin
PRINTDAY=`date +%m/%d/%Y`
PRINTDETAILTIME=`date +%H:%M:%S`
PRINTWEEK=`date +%A`
PRINTTIME=`echo Date=$PRINTDAY '('$PRINTWEEK')' Time=$PRINTDETAILTIME`
INSTALLLOGFILE="/tmp/UTPSInstall.log"
#System Language
SYSLANG="$(echo $LANG | cut -d '.' -f 1)"
# add by zkf20747 for printing install log  DTS2010111102824 end
#Language String
LANGUAGESTRING[0]="zh"
LANGUAGESTRING[1]="en_US"
LANGUAGECODE[0]=0
LANGUAGECODE[1]=1


LANGCODE=${LANGUAGECODE[1]}
i=0
while [ ".${LANGUAGESTRING[${i}]}" != "." ]
do
   if [ ${LANGUAGESTRING[${i}]} = "${SYSLANG}" ] # modify by zkf20747 for printing install log DTS2010111102824
   then
       LANGCODE=${LANGUAGECODE[${i}]}
       break
   fi
   i=`expr ${i} + 1`
done
unset i

# add by zkf20747 for printing install log DTS2010111102824 begin
BEGININSTALL="Install..."
CREATETEMPWORKSPACE="Create temp work directory..."
SOFTINSTALLPATH="Installation Path is :"
EXTRACTDATABIN="Extract data.bin to install directory..."
EXTRACTDATABINRESULT="Extract data.bin success!"
EXTRACTMPBIN="Extract MobilePartner.bin to install directory..."
EXTRACTMPBINRESULT="Extract MobilePartner.bin success!"
INSTALLINGVERSION="PC will install new version is"
INSTALLHIGHVERSION="An old version  has been installed."
INSTALLSAMEVERSION="An same version has been installed."
INSTALLOLDERVERSION="An new version new has been installed."
CREATEINSTALLDIR="Create install directory ..."
PREPARECOPYFILES="Copy MobilePartner.bin,data.bin,7zr..."
PREPARECOPYFILESRESULT="Copy files success!"
EXECUTEDRIVER="Execute driver..."
CREATEDESKTOP="Create Desktop Shortcut..."
CREATEPROGRAMDESKTOP="Create ProgramGroup Shortcut..."
DELETEALLLOCALFILES="Delete all local files (tempfiles,tempdirectory)..."
ENDINSTALL="Install Success!"
# add by zkf20747 for printing install log DTS2010111102824 end
LYouMustBeRoot[0]="Äú±ØÐëÒÔrootÓû§ÔËÐбŸ°²×°³ÌÐò"
LYouMustBeRoot[1]="You must run the process by root"

LPlsInputInstallPath[0]="ÇëÊäÈë°²×°µÄŸø¶Ô·Ÿ¶"
LPlsInputInstallPath[1]="Please input the absolute path for install"

LInstallPath[0]="°²×°Â·Ÿ¶"
LInstallPath[1]="install path"

LIllegal[0]="·Ç·š"
LIllegal[1]="illegal"

LNoFile[0]="ÕÒ²»µœÎÄŒþ£º"
LNoFile[1]="Can not find file: "

LCanNotCreateDir[0]="ÎÞ·šŽŽœšÄ¿ÂŒ"
LCanNotCreateDir[1]="Can not create dir"

LMobilePartnerInstall[0]="${SOFTWARENAMEINDESKTOP}°²×°³ÌÐò"
LMobilePartnerInstall[1]="${SOFTWARENAMEINDESKTOP} installer"

LStartInstallPartner[0]="¿ªÊŒ°²×°ºóÌš, ÇëÉÔºó..."
LStartInstallPartner[1]="Installing ${SOFTWARENAMEINDESKTOP}..."

LCompleteInstallPartner[0]="ÒÑŸ­Íê³ÉºóÌš°²×°"
LCompleteInstallPartner[1]="install have completed, local path is"

LLocalPath[0]="±ŸµØ°²×°Â·Ÿ¶"
LLocalPath[1]="Local path is"

LOverwriteInstalled[0]="ÒÑŸ­°²×°ÓкóÌš, ÊÇ·ñž²žÇ"
LOverwriteInstalled[1]="The software is exist. Do you want overwrite it"

LInstallJRE[0]="°²×°JRE"
LInstallJRE[1]="install JRE"

LInstallMP[0]="°²×°ºóÌš"
LInstallMP[1]="install ${SOFTWARENAMEINDESKTOP}"

LInstallAll[0]="°²×°JREºÍºóÌš"
LInstallAll[1]="install JRE and ${SOFTWARENAMEINDESKTOP}"

LQuitInstall[0]="Í˳ö"
LQuitInstall[1]="Exit"

LPlsSelect[0]="ÇëÑ¡Ôñ£º"
LPlsSelect[1]="Please select: "

LYouMustSelect[0]="Äã±ØÐëÑ¡Ôñ£º"
LYouMustSelect[1]="You must select: "

LInstallEnd[0]="œáÊø, °ŽÈÎÒâŒüÍ˳ö"
LInstallEnd[1]="Finished, press any key to exit"

LInstallingVersionOlderThenInstalled[0]="Ÿ¯žæ£ºÕýÔÚ°²×°µÄ°æ±Ÿ±ÈϵͳÖеİ江ŸÉ¡£ÊÇ·ñž²žÇ£¿"
LInstallingVersionOlderThenInstalled[1]="WARNING: The installing version is older than installed. Do you want to overwrite it"

LInstallingVersionLaterThenInstalled[0]="ϵͳÖÐŽæÔڟɰ江¡£ÊÇ·ñÉýŒ¶£¿"
LInstallingVersionLaterThenInstalled[1]="There is a older version in your system. Do you want to update it"

LInstalledVersion[0]="ÒÑ°²×°°æ±Ÿ:"
LInstalledVersion[1]="Installed version:"

LInstallingVersion[0]="ÕýÔÚ°²×°°æ±Ÿ:"
LInstallingVersion[1]="Installing version:"

LProgramRunning[0]="ÇëÏȹرճÌÐòÔÙœøÐÐжÔØ¡£"
LProgramRunning[1]="Program is running, you need close it before uninstalling."

# add by zkf20747 for printing install log DTS2010111102824 begin
LCheckRun[0]="Program is running, you need close it before installing.";
LCheckRun[1]="³ÌÐòÕýÔÚÔËÐУ¬°²×°Ö®Ç°ÇëÏȹرÕ."
# add by zkf20747 for printing install log DTS2010111102824 end

# /*yes or no ¹«¹²º¯Êý, yes·µ»Ø0, no·µ»Ø1*/
yes_or_no()
{
   if [ ${#} -ne 2 ]
   then
       echo -e "yes_or_or: ${ErrorPara[${LANGCODE}]}"
       return 1
   fi
   if [ "${2}" = "Y" ]
   then
       DEFPMPT="([Y]/N):\c "
       DEFVAL="Y"
   else
       DEFPMPT="(Y/[N]):\c "
       DEFVAL="N"
   fi
   echo -e "${1} ${DEFPMPT}"
   read ANS
   while [ "${ANS}" != "Y" -a "${ANS}" != "y" -a "${ANS}" != "N" -a "${ANS}" != "n" -a ! -z "${ANS}" ]
   do
       echo -e "${1} ${DEFPMPT}"
       read ANS
   done
   : ${ANS:="${DEFVAL}"}
   if [ "${ANS}" != "Y" -a "${ANS}" != "y" ]
   then
       unset ANS
       return 1
   fi
   unset ASN
   return 0
}

#Œì²éÆô¶¯°²×°œÅ±ŸµÄÓû§ÊÇ·ñΪrootÓû§
CheckID()
{
   if [ `id | awk '{print $1}'` != "uid=0(root)" ]
   then
       echo -e "${LYouMustBeRoot[${LANGCODE}]}"
       echo -e "\n${LInstallEnd[${LANGCODE}]}"
       read -n 1
clear
       exit
   fi
}

#Œì²éµ±Ç°ÊÇ·ñÓкóÌšÕýÔÚÔËÐÐ
CheckRunning()
{
   RUNJAR=`ps -ef |grep -v grep |grep MobilePartner.jar | awk '{print $2}'`
   RUNBIN=`ps -ef |grep -v grep |grep MobilePartner.bin | awk '{print $2}'`
   if [ "x${RUNJAR}" != "x" ]
   then
       echo -e "${LCheckRun[${LANGCODE}]}" # modify by zkf20747 for printing install log DTS2010111102824
       read RESP
       exit
   fi

   if [ "x${RUNBIN}" != "x" ]
   then
       echo -e "${LCheckRun[${LANGCODE}]}" # modify by zkf20747 for printing install log DTS2010111102824
       read RESP
       exit
   fi
}

#Œì²éÏà¹ØÎÄŒþ£¬ÔÚÓ²ÅÌÉÏœšÁ¢Žæ·Å°²×°ÎÄŒþµÄÁÙʱĿŒ£¬²¢¿œ±Ž°²×°ÎÄŒþµœžÃÄ¿ÂŒ
PreInstall()
{
   # add by zkf20747 for printing install log DTS2010111102824 begin
   echo -e "========================================================" >> ${INSTALLLOGFILE}
   echo -e $PRINTTIME '    ' ${BEGININSTALL} >> ${INSTALLLOGFILE}
   # add by zkf20747 for printing install log DTS2010111102824 end
   #Œì²é°²×°°üÎÄŒþ
   if [ ! -f "${INSTALLWORKPATH}"/MobilePartner.bin ]
   then
       echo -e "${LNoFile[${LANGCODE}]}MobilePartner.bin"
       exit
   fi
   if [ ! -f "${INSTALLWORKPATH}"/data.bin ]
   then
       echo -e "${LNoFile[${LANGCODE}]}data.bin"
       exit
   fi
   if [ ! -f "${INSTALLWORKPATH}"/7zr ]
   then
       echo -e "${LNoFile[${LANGCODE}]}7zr"
       exit
   fi

   if [ ! -d "${TEMPWORKPATH}" ]
   then
       mkdir ${TEMPWORKPATH}
       echo -e $PRINTTIME '    ' ${CREATETEMPWORKSPACE} >> ${INSTALLLOGFILE}  #add by zkf20747 for printing install log DTS2010111102824
   fi
   if [ ! -d "${TEMPWORKPATH}" ]
   then
       echo -e "\n${LCanNotCreateDir[${LANGCODE}]}: ${TEMPWORKPATH}"
       exit
   fi
   
   #¿œ±ŽºóÌš°²×°ÎÄŒþ
   echo -e $PRINTTIME '    ' ${PREPARECOPYFILES} >> ${INSTALLLOGFILE}  #add by zkf20747 for printing install log DTS2010111102824
   cp -f "${INSTALLWORKPATH}"/MobilePartner.bin ${TEMPWORKPATH}
   cp -f "${INSTALLWORKPATH}"/data.bin ${TEMPWORKPATH}
   cp -f "${INSTALLWORKPATH}"/7zr ${TEMPWORKPATH}
   echo -e $PRINTTIME '    ' ${PREPARECOPYFILESRESULT} >> ${INSTALLLOGFILE}  #add by zkf20747 for printing install log DTS2010111102824
   chmod +x ${TEMPWORKPATH}/7zr

   #¿œ±Ž°²×°œÅ±ŸµœÓ²ÅÌÉÏ
   cp -f "${INSTALLWORKPATH}"/install ${TEMPWORKPATH}
   chmod a+x ${TEMPWORKPATH}/install    
   

   #add by liuzhiqiang... begin
   if [ -f $CONFIG_FILE ]
   then
       #»ñÈ¡°æ±ŸÐÅÏ¢
       . $CONFIG_FILE

       #»ñȡϵͳÖÐÒÑŸ­°²×°µÄ°æ±ŸºÅ
       VRVERSIONINSTALLED=`echo $FullVersion | cut -d '.' -f1`
       BUILDVERSIONINSTALLED=`echo $FullVersion | cut -d '.' -f2`
       DEVELOPVERSIONINSTALLED=`echo $FullVersion | cut -d '.' -f3`
       SPVERSIONINSTALLED=`echo $FullVersion | cut -d '.' -f4`
       CUSTOMIZEVERSIONINSTALLED=`echo $FullVersion | cut -d '.' -f5`
       
       #»ñÈ¡ÕýÔÚ°²×°µÄ°æ±ŸºÅ
       VRVERSIONINSTALLING=`echo $FULLVERSION | cut -d '.' -f1`
       BUILDVERSIONINSTALLING=`echo $FULLVERSION | cut -d '.' -f2`
       DEVELOPVERSIONINSTALLING=`echo $FULLVERSION | cut -d '.' -f3`
       SPVERSIONINSTALLING=`echo $FULLVERSION | cut -d '.' -f4`
       CUSTOMIZEVERSIONINSTALLING=`echo $FULLVERSION | cut -d '.' -f5`
       
       #ŽòÓ¡°æ±ŸÐÅÏ¢
       echo "${LInstalledVersion[${LANGCODE}]} ${FullVersion}"
       echo "${LInstallingVersion[${LANGCODE}]} ${FULLVERSION}"
       
        # add by zkf20747 for printing install log DTS2010111102824 begin
        echo -e $PRINTTIME '    ' "the installed version is  " $FullVersion >> ${INSTALLLOGFILE}
        echo -e $PRINTTIME '    ' "the installing version is  " $FULLVERSION >> ${INSTALLLOGFILE}
        # add by zkf20747 for printing install log DTS2010111102824 end
       #Œì²éÒÑŸ­°²×°µÄ°æ±ŸÊÇ·ñžüÐÂ
       while [ 1 ]
       do
           #±ÈœÏVR°æ±ŸºÅ£¬²»ÏàͬÔòÌáÊŸÓû§ž²žÇ°²×°
           if [ $VRVERSIONINSTALLED -ne $VRVERSIONINSTALLING ]
           then
               InstallDifferentVersionPrompt
               break
           fi
           
           #±ÈœÏC°æ±ŸºÅ£¬²»ÏàͬÔòÌáÊŸÓû§ž²žÇ°²×°
           if [ $CUSTOMIZEVERSIONINSTALLED -ne $CUSTOMIZEVERSIONINSTALLING ]
           then
               InstallDifferentVersionPrompt
               break
           fi
           
           #±ÈœÏB°æ±ŸºÅ
           if [ $BUILDVERSIONINSTALLED -gt $BUILDVERSIONINSTALLING ]
           then
               #Èç¹ûÒÑ°²×°µÄB°æ±ŸºÅœÏУ¬ÔòÌáÊŸÓû§ÒÑŸ­°²×°ÁËœÏеĺóÌš°æ±Ÿ£¬ÊÇ·ñŒÌÐø
               InstallOlderVersionPrompt
               break
           elif [ $BUILDVERSIONINSTALLED -lt $BUILDVERSIONINSTALLING ]
           then
               #Èç¹ûÒÑ°²×°µÄB°æ±ŸºÅœÏÀÏ£¬²»ÐèÒªŒÌÐø±ÈœÏD°æ±ŸºÍSP°æ±Ÿ£¬Ö±œÓž²žÇ°²×°
               InstallLaterVersionPrompt
               break
           fi
           
           #±ÈœÏD°æ±ŸºÅ
           if [ $DEVELOPVERSIONINSTALLED -gt $DEVELOPVERSIONINSTALLING ]
           then
               #Èç¹ûÒÑ°²×°µÄD°æ±ŸºÅœÏУ¬ÔòÌáÊŸÓû§ÒÑŸ­°²×°ÁËœÏеĺóÌš°æ±Ÿ£¬ÊÇ·ñŒÌÐø
               InstallOlderVersionPrompt
               break
           elif [ $DEVELOPVERSIONINSTALLED -lt $DEVELOPVERSIONINSTALLING ]
           then
               #Èç¹ûÒÑ°²×°µÄD°æ±ŸºÅœÏÀÏ£¬²»ÐèÒªŒÌÐø±ÈœÏSP°æ±Ÿ£¬Ö±œÓž²žÇ°²×°
               InstallLaterVersionPrompt
               break
           fi
           
           #±ÈœÏSP°æ±ŸºÅ
           if [ $SPVERSIONINSTALLED -gt $SPVERSIONINSTALLING ]
           then
               #Èç¹ûÒÑ°²×°µÄSP°æ±ŸºÅœÏУ¬ÔòÌáÊŸÓû§ÒÑŸ­°²×°ÁËœÏеĺóÌš°æ±Ÿ£¬ÊÇ·ñŒÌÐø
               InstallOlderVersionPrompt
               break
           elif [ $SPVERSIONINSTALLED -lt $SPVERSIONINSTALLING ]
           then
               #Èç¹ûÒÑ°²×°µÄSP°æ±ŸºÅœÏÀÏ£¬Ö±œÓž²žÇ°²×°
               InstallLaterVersionPrompt
               break
           fi
           
           #×ßµœÕâ±íÊŸËùÓа江ºÅÒ»Ö£¬žø³öÌáÊŸÊÇ·ñž²žÇ
           InstallSameVersionPrompt
           break
       done

       INSTALLPATH=`egrep "^path=" $CONFIG_FILE | awk -F  '=' '{print $2}'`
       
   else
       #ÊäÈë°²×°Ä¿ÂŒ
       echo -e "\n ${LPlsInputInstallPath[${LANGCODE}]}[${INSTALLPATH}]: \c"
       read ANS
       : ${ANS:="${INSTALLPATH}"}
       INSTALLPATH=${ANS}
       
       #Œì²éÄ¿ÂŒµÄºÏ·šÐÔ
       if [[ ${INSTALLPATH} != /* ]]
       then
           echo -e "\n${LInstallPath[${LANGCODE}]} ${LIllegal[${LANGCODE}]}"
           DisplayEndMsg
           exit
       fi
       
       #ʹ°²×°Ä¿ÂŒºÏÀí»¯
       if [  -d "${INSTALLPATH}" ]
       then
           INSTALLPATH=${INSTALLPATH}/${SOFTWARENAME}
       fi
   fi
   
   #ŽŽœš°²×°Ä¿ÂŒ
   if [ ! -d "${INSTALLPATH}" ]
   then
       mkdir ${INSTALLPATH}
       echo -e $PRINTTIME '    ' ${CREATEINSTALLDIR} >> ${INSTALLLOGFILE}  #add by zkf20747 for printing install log DTS2010111102824
   fi
   if [ ! -d "${INSTALLPATH}" ]
   then
       echo -e "\n${LCanNotCreateDir[${LANGCODE}]}: ${INSTALLPATH}"
       DisplayEndMsg
       exit
   fi

   echo -e "\n${LLocalPath[${LANGCODE}]}: ${INSTALLPATH}"
   #add by zkf20747 for printing install log DTS2010111102824 begin
   echo -e $PRINTTIME '    ' ${SOFTINSTALLPATH} ${INSTALLPATH} >> ${INSTALLLOGFILE}
   echo -e $PRINTTIME '    ' ${INSTALLINGVERSION} ${FULLVERSION} >> ${INSTALLLOGFILE}
   #add by zkf20747 for printing install log DTS2010111102824 end
}

InstallLaterVersionPrompt()
{
   #а江£¬ÌáÊŸÊÇ·ñÉýŒ¶
   yes_or_no "\n${LInstallingVersionLaterThenInstalled[${LANGCODE}]}?" Y
   if [ ${?} -ne 0 ]
   then
       DisplayEndMsg
       exit
   fi
   echo -e $PRINTTIME '    ' $INSTALLHIGHVERSION >> ${INSTALLLOGFILE} # add by zkf20747 2010-8-5 DTS2010080302845  
}

InstallSameVersionPrompt()
{
   #Èç¹ûÒÔÇ°ÒÑŸ­°²×°¹ýºóÌšÔòÌáÊŸÊÇ·ñž²žÇ
   yes_or_no "\n${LOverwriteInstalled[${LANGCODE}]}?" Y
   if [ ${?} -ne 0 ]
   then
       DisplayEndMsg
       exit
   fi
   echo -e $PRINTTIME '    ' $INSTALLSAMEVERSION >> ${INSTALLLOGFILE} # add by zkf20747 2010-8-5 DTS2010080302845
}

InstallOlderVersionPrompt()
{
   #°²×°µÄ°æ±Ÿ±ÈϵͳÖеİ江ŸÉ£¬žø³öÌáÊŸ
   yes_or_no "\n${LInstallingVersionOlderThenInstalled[${LANGCODE}]}?" N
   if [ ${?} -ne 0 ]
   then
       DisplayEndMsg
       exit
   fi
   echo -e $PRINTTIME '    ' $INSTALLOLDERVERSION >> ${INSTALLLOGFILE} # add by zkf20747 2010-8-5 DTS2010080302845
}

InstallDifferentVersionPrompt()
{
   #Èç¹ûÒÔÇ°ÒÑŸ­°²×°¹ýºóÌšÔòÌáÊŸÊÇ·ñž²žÇ
   yes_or_no "\n${LOverwriteInstalled[${LANGCODE}]}?" Y
   if [ ${?} -ne 0 ]
   then
       DisplayEndMsg
       exit
   fi
}

#°²×°ºóÌš
InstallMobilePartner()
{
   #   Madhu added to set the library path
   # DTS2011042605304 2011-5-12 end
   unset LD_LIBRARY_PATH
   #echo -e "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${INSTALLPATH} \n export LD_LIBRARY_PATH \n" > ${HOME}/.bash_profile
   # DTS2011042605304 2011-5-12 end
   echo -e -n "\n${LStartInstallPartner[${LANGCODE}]}"
   
   cd "${INSTALLPATH}"
#ÔÚ°²×°Â·Ÿ¶ÏÂœâѹËõ°²×°°ü  
#    tar jxf ${TEMPWORKPATH}/MobilePartner.tar.bz2 >/dev/null 2>&1
    echo -e $PRINTTIME '    ' ${EXTRACTMPBIN} >> ${INSTALLLOGFILE} #add by zkf20747 for printing install log DTS2010111102824
   "${TEMPWORKPATH}/7zr" x -y ${TEMPWORKPATH}/MobilePartner.bin >/dev/null 2>&1
    echo -e $PRINTTIME '    ' ${EXTRACTMPBINRESULT} >> ${INSTALLLOGFILE} #add by zkf20747 for printing install log DTS2010111102824
    echo -e $PRINTTIME '    ' ${EXTRACTDATABIN} >> ${INSTALLLOGFILE}   #add by zkf20747 for printing install log DTS2010111102824
   "${TEMPWORKPATH}/7zr" x -y ${TEMPWORKPATH}/data.bin >/dev/null 2>&1
    echo -e $PRINTTIME '    ' ${EXTRACTDATABINRESULT} >> ${INSTALLLOGFILE}  #add by zkf20747 for printing install log DTS2010111102824
#    chmod -R a+w "${INSTALLPATH}"/userdata
#    chmod -R a+w "${INSTALLPATH}"/log
   chmod -R a+w "${INSTALLPATH}"/config
   
#DTS2010062201326 w00159557 2010-10-26 delete
#ÔËÐÐÇý¶¯¹€Ÿß°²×°œÅ±Ÿ
   chmod -R a+x ./driver/*
   #./driver/install ${INSTALLPATH} >/dev/null  2>&1
   echo -e $PRINTTIME '    ' ${EXECUTEDRIVER} >> ${INSTALLLOGFILE} #add by zkf20747 for printing install log DTS2010111102824
   ./driver/install ${INSTALLPATH} .bin

#Joven 2009.09.03 add
#°²×°CommMgr²¢ÉèÖÃΪϵͳ·þÎñ
#    chmod +x ./CommMgr/*
#    cd CommMgr
#    ./install_CommMgr ${INSTALLPATH} >/dev/null  2>&1
#    cd ..
   
#copyÏà¹ØÎÄŒþµœÏàÓŠÄ¿ÂŒ

   #¿œ±Ž²ŠºÅÏà¹ØÎÄŒþ
   chmod a+x ./sbin/*
   chmod -R a+w ./hw_pppd
   chmod -R a+x ./hw_pppd
# ubuntu10.10 cann't modem connect begin
   ./hw_pppd/sbin/install_pppd
   rm -rf ./hw_pppd/sbin/install_pppd
   rm -rf /usr/local/hw_pppd
# ubuntu10.10 cann't modem connect end
   cp -rf ./hw_pppd /usr/local/

   #copy QT libs to Mobile Partner directory
   cp -lrf ${INSTALLPATH}/qtlib/lib*.so* ${INSTALLPATH}

   #copyÔÚÏßÉýŒ¶ÐèÒªµÄ¶¯Ì¬¿âÎÄŒþµœÏàÓŠÄ¿ÂŒ
   #copy only when UpdateDog directory exists
   if [ -d ${INSTALLPATH}/UpdateDog ]
   then
       cp -lrf ${INSTALLPATH}/qtlib/lib*.so* ${INSTALLPATH}/UpdateDog
       cp -lrf ${INSTALLPATH}/plugins/imageformats/libqgif.so ${INSTALLPATH}/UpdateDog/plugins/imageformats
       cp -lrf ${INSTALLPATH}/plugins/imageformats/libqico.so ${INSTALLPATH}/UpdateDog/plugins/imageformats
   fi


Anderson_Coelho

#uncommenting this to create /usr/local/hw_mobile_userdata/Mobile_Partner   
    #¿œ±ŽÓû§ÊýŸÝÎÄŒþŒÐ
   if [ ! -d ${USERDATA_PATH} ]
   then
       mkdir $USERDATA_PATH
       mkdir ${USERDATA_PATH}/${SOFTWARENAME}
       #20091112 c00106366 add - create userdata folder
       mkdir ${USERDATA_PATH}/${SOFTWARENAME}/userdata
       # do not create userdata directory.
       # cp -rf ./userdata ${USERDATA_PATH}/${SOFTWARENAME}
       chmod -R a+w ${USERDATA_PATH}
       chmod -R a+r ${USERDATA_PATH}
   else
       #Èç¹ûŽæÔÚÏàͬÈíŒþÃû³ÆµÄÓû§ÊýŸÝ£¬²»ž²žÇ
       if [ ! -d ${USERDATA_PATH}/${SOFTWARENAME} ]
       then
           mkdir ${USERDATA_PATH}/${SOFTWARENAME}
           #20091112 c00106366 add - create userdata folder
           mkdir ${USERDATA_PATH}/${SOFTWARENAME}/userdata
           # do not create userdata directory.
           # cp -rf ./userdata ${USERDATA_PATH}/${SOFTWARENAME}
           chmod -R a+w ${USERDATA_PATH}
           chmod -R a+r ${USERDATA_PATH}
       fi
   fi

   #20091112 c00106366 add - set the permission of userdata folder
   chmod -R a+rwx ${USERDATA_PATH}/${SOFTWARENAME}
   
   # create userdata/log directory for ui.
   # mkdir -p ${USERDATA_PATH}/${SOFTWARENAME}/log     
     
    #ÐÞžÄsudoersÎÄŒþ
    grep -v "MobilePartner.sh" /etc/sudoers >/tmp/${TEMPFILE} 2>&1
    DELETECOMMENT="delete requiretty for hw_mobile"
    REQUIRETTY=`grep "${DELETECOMMENT}" /tmp/${TEMPFILE}`
    if [ "x${REQUIRETTY}" != "x" ]
    then
        REQUIRETTY=`echo "${REQUIRETTY}" | awk -F ',' '{printf $2}'`
    else
        REQUIRETTY=`grep "requiretty" /tmp/${TEMPFILE}`
        if [ "x${REQUIRETTY}" != "x" ]
        then
            sed -i "s/${REQUIRETTY}/# ,${REQUIRETTY},${DELETECOMMENT}/g" /tmp/${TEMPFILE} 2>/dev/null
        fi
    fi
    # Shashank: Defect fix AJ2D13470: Begin
    echo -e "ALL ALL=(ALL) NOPASSWD:ALL" >> /tmp/${TEMPFILE}

    # Madhu added a new batch file
    # Shashank [s72814] added to generate .bin file and to give access permissions in user mode: Begin
    # AJ2D14022 karthik exec ${INSTALLPATH}/MobilePartner.bin will now be put after the special steps for each distro.
    #echo -e "#!/bin/bash \n LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${INSTALLPATH} \n export LD_LIBRARY_PATH \n export PATH=/sbin:$PATH \n sudo LD_LIBRARY_PATH=${INSTALLPATH} \n exec ${INSTALLPATH}/MobilePartner.bin" > ${INSTALLPATH}/MobilePartner_Bat
    #DTS2010072902594 lkf26999 2010-8-9 Xserver path add to PATH
    echo -e "#!/bin/bash \n LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${INSTALLPATH} \n export LD_LIBRARY_PATH \n export PATH=/usr/bin/X11:/usr/X11R6/bin:/sbin:$PATH \n sudo LD_LIBRARY_PATH=${INSTALLPATH} \n" > ${INSTALLPATH}/MobilePartner_Bat
    #DTS2010072902594 modify end
    mv ${INSTALLPATH}/MobilePartner ${INSTALLPATH}/MobilePartner.bin
    mv ${INSTALLPATH}/MobilePartner_Bat ${INSTALLPATH}/MobilePartner

   chmod a+x ${INSTALLPATH}/MobilePartner
   chmod a+x ${INSTALLPATH}/MobilePartner.bin
   chmod 777 -R ${INSTALLPATH}/*

   # w00159557 2010-6-18 add for customization begin
   CURRENT_VERSION=$(grep VALUE "${INSTALLPATH}/SysConfig.dat" | head -n1 | cut -d = -f2 | tr -d "\015")
   VERSION_TO_REPLACE=$(grep version= "${INSTALLPATH}/RunInfo.ini" | head -n1)
   sed -e 's/'"${VERSION_TO_REPLACE}"'/version='"${CURRENT_VERSION}"'/' "${INSTALLPATH}/RunInfo.ini" > RunInfo.tmp
   mv -f RunInfo.tmp ${INSTALLPATH}/RunInfo.ini

   CURRENT_OPERATOR=$(grep operator "${INSTALLPATH}/SysConfig.dat" | head -n1 | cut -d = -f2 | tr -d "\015")
   OPERATOR_TO_REPLACE=$(grep operator= "${INSTALLPATH}/RunInfo.ini" | head -n1)
   sed -e 's/'"${OPERATOR_TO_REPLACE}"'/operator='"${CURRENT_OPERATOR}"'/' "${INSTALLPATH}/RunInfo.ini" > RunInfo.tmp
   mv -f RunInfo.tmp ${INSTALLPATH}/RunInfo.ini
   # w00159557 2010-6-18 add for customization end

   # Shashank [s72814] added to generate .bin file and to give access permissions in user mode: End
   # Shashank: Defect fix AJ2D13470: End
    cp -f /tmp/${TEMPFILE} /etc/sudoers
   
   echo -e $PRINTTIME '    ' "active language is " $SYSLANG >> ${INSTALLLOGFILE} #add by zkf20747 for printing install log DTS2010111102824

#±àŒ­²¢ŽŽœš×ÀÃæÆô¶¯ÍŒ±êºÍ¿ªÊŒ²Ëµ¥Æô¶¯ÍŒ±ê   
    sed "s#\${HW_SOFTWARENAME}#${SOFTWARENAMEINDESKTOP}#g" ./MobilePartner.desktop > /tmp/${TEMPFILE} 2>/dev/null
    sed "s#\${HW_INSTALLPATH}#${INSTALLPATH}#g" /tmp/${TEMPFILE} > ./MobilePartner.desktop 2>/dev/null
    echo -e $PRINTTIME '    ' ${CREATEDESKTOP} >> ${INSTALLLOGFILE} #add by zkf20747 for printing install log DTS2010111102824
    if [ -d /root/Desktop ]
    then
        cp -f ./MobilePartner.desktop /root/Desktop
       
    else
        cp -f ./MobilePartner.desktop /root
    fi 
    echo -e $PRINTTIME '    ' ${CREATEPROGRAMDESKTOP} >> ${INSTALLLOGFILE} #add by zkf20747 for printing install log DTS2010111102824
    cp -f ./MobilePartner.desktop /usr/share/applications
   
#±àŒ­²¢ŽŽœš¿ªÊŒ²Ëµ¥Ð¶ÔØÍŒ±ê 
    sed "s#\${HW_SOFTWARENAME}#${SOFTWARENAMEINDESKTOP}#g" ./UninstallMobilePartner.desktop > /tmp/${TEMPFILE} 2>/dev/null
    sed "s#\${HW_INSTALLPATH}#${INSTALLPATH}#g" /tmp/${TEMPFILE} > ./UninstallMobilePartner.desktop 2>/dev/null 
   
    cp -f ./UninstallMobilePartner.desktop /usr/share/applications
   
#±àŒ­²¢ŽŽœšÔËÐМűŸ
    echo -e "#!/bin/bash" > ./MobilePartner.sh

# for Ubuntu
    UBUNTURELEASE=`grep Ubuntu /etc/issue 2>&1 | awk -F ' ' '{printf $1}'`
    if [ "x${UBUNTURELEASE}" = "xUbuntu" ]
    then
    #DTS2010123003200 begin add by d00135750 2011-2-17 Refresh the ubuntu Menu Items After install
        if [ -f /usr/share/gnome-menus/update-gnome-menus-cache ]
        then
            UpdateMenuForUbunto
        fi
    #DTS2010123003200 end add by d00135750 2011-2-17
        if [ ! -d /usr/share/fonts/truetype/arphic ]
then
            mkdir -p /usr/share/fonts/truetype/arphic
fi
    fi
   
# for Debian
    DEBIANRELEASE=`grep Debian /etc/issue 2>&1 | awk -F ' ' '{printf $1}'`
    if [ "x${DEBIANRELEASE}" = "xDebian" ]
    then
        if [ ! -d /usr/share/fonts/truetype/arphic ]
then
            mkdir -p /usr/share/fonts/truetype/arphic
fi
    fi

# for OpenSuSE
    if [ -f /etc/SuSE-release ]
    then
        if [ ! -d /usr/share/fonts/truetype ]
then
            mkdir -p /usr/share/fonts/truetype
fi
        # AJ2D14022 karthik put this in our bat file.
        # echo -e "export DISPLAY=:0" >> ./MobilePartner.sh
#DTS2010062201326 w00159557 2010-10-26 modify begin
        echo -e "export DISPLAY=:0" >> ${INSTALLPATH}/MobilePartner
    fi
#DTS2010122702428 skf39948 2011-1-4 modify begin
# for ALTLinux
    if [ -f /etc/altlinux-release ]
    then
        echo -e "export DISPLAY=:0" >> ${INSTALLPATH}/MobilePartner
    fi
#DTS2010122702428 skf39948 2011-1-4 modify end
if [ ! -e /usr/bin/sudo ]
then
    echo "There is no sudo command in your system,you'd better run the software by root"
    echo "Press any key to continue..."
    read -n 1
    echo -e "#!/bin/bash \n ${INSTALLPATH}/MobilePartner \${DISPLAY}" > ${INSTALLPATH}/ReadDisplay
else
    echo -e "#!/bin/bash \n sudo ${INSTALLPATH}/MobilePartner \${DISPLAY}" > ${INSTALLPATH}/ReadDisplay
fi
chmod +x ${INSTALLPATH}/ReadDisplay
#DTS2010062201326 w00159557 2010-10-26 modify end

   
#insert hook
    if [ -d /etc/pm/sleep.d ]
    then
        cp -f ${INSTALLPATH}/sbin/67hw_hook /etc/pm/sleep.d
        chmod +x /etc/pm/sleep.d/67hw_hook
    fi


# for jre compatibility
    echo -e "export LIBXCB_ALLOW_SLOPPY_LOCK=1" >> ./MobilePartner.sh

    # Shashank [s72814]: added for executing MobilePartner.bin file from MobilePartner.sh file: Begin
    echo -e "APPDIR=${INSTALLPATH}" >> ./MobilePartner.sh
    echo -e "cd \${APPDIR}" >> ./MobilePartner.sh
    echo -e "\${APPDIR}/MobilePartner.bin &" >> ./MobilePartner.sh

    # AJ2D14022 karthik now put the executable
    echo -e "exec ${INSTALLPATH}/MobilePartner.bin" >> ${INSTALLPATH}/MobilePartner

    # Shashank [s72814]: added for executing MobilePartner.bin file from MobilePartner.sh file: End
    chmod +x ./MobilePartner.sh
    chmod a+x ./MobilePartner
       
#±àŒ­²¢ŽŽœšÐ¶Ô؜űŸ
    sed -i "s/{LYouMustBeRoot}/${LYouMustBeRoot[${LANGCODE}]}/g" ./UninstallMobilePartner
    sed -i "s/{LInstallEnd}/${LInstallEnd[${LANGCODE}]}/g" ./UninstallMobilePartner
    sed -i "s/{LProgramRunning}/${LProgramRunning[${LANGCODE}]}/g" ./UninstallMobilePartner
    sed -i "s#{HOOK_FILE}#${HOOK_FILE}#g" ./UninstallMobilePartner
    sed -i "s#{INSTALLPATH}#${INSTALLPATH}#g" ./UninstallMobilePartner
    sed -i "s#{CONFIG_FILE}#${CONFIG_FILE}#g" ./UninstallMobilePartner
    if [ "x${REQUIRETTY}" != "x" ]
    then
        sed -i "s/{REQUIRETTY}/${REQUIRETTY}/g" ./UninstallMobilePartner
sed -i "s/{DELETECOMMENT}/${DELETECOMMENT}/g" ./UninstallMobilePartner
    else
        grep -v {REQUIRETTY} ./UninstallMobilePartner > /tmp/${TEMPFILE}
cp -f /tmp/${TEMPFILE} ./UninstallMobilePartner
    fi
   
    chmod +x ./UninstallMobilePartner
   
    DonePrompt "${LStartInstallPartner[${LANGCODE}]}"

    #echo -e "\n${SOFTWARENAMEINDESKTOP} ${LCompleteInstallPartner[${LANGCODE}]} ${INSTALLPATH}"
   
    #20100104 c00106366 add
    #After install succeed, create a new file to let onlineupdate know it's finished
    #This file should be delete by onlineupdate program
    touch "${USERDATA_PATH}/${SOFTWARENAME}/userdata/install.flg"

    #Çå³ý±ŸµØÎÄŒþ
#    rm -rf ./userdata
    rm -rf ./hw_pppd
    rm -rf ./*.desktop

    rm -f /tmp/${TEMPFILE}
    rm -rf ${TEMPWORKPATH}
    echo -e $PRINTTIME '    ' ${DELETEALLLOCALFILES} >> ${INSTALLLOGFILE} #add by zkf20747 for printing install log DTS2010111102824
    #DTS2010062201326 w00159557 2010-10-26 add begin
    chmod 777 ${INSTALLPATH}
    #DTS2010062201326 w00159557 2010-10-26 add end
}

DonePrompt()
{
    LOGCHARNUM=`echo "$1" | wc -m`
    TERMCHARNUM=`stty size | awk -F ' ' '{printf $2}'`
    LOGCHARNUM=`expr $TERMCHARNUM - $LOGCHARNUM`
    echo "[ done ] " | awk '{printf "%"'"$LOGCHARNUM"'"s", $0}'
    echo -e ""
}


# /*ÌṩѡÔñÓïÑÔ*/
SelectLanguage()
{
    while :
    do
        case ${LANGCODE} in
            0)
                echo -e "\n\t1. ŒòÌåÖÐÎÄ"
                echo -e "\t2. Ó¢ÎÄ"
                echo -e "\n\tÇëÑ¡ÔñÓïÑÔ: [1]\c"
                read RESP
                : ${RESP:="1"}
            ;;
            *)
                echo -e "\n\t1. Simplified Chinese"
                echo -e "\t2. English"
                echo -e "\n\tPlease select Language: [2]\c"
                read RESP
                : ${RESP:="2"}
            ;;
        esac
        case ${RESP} in
            [1,2])
                LANGCODE=`expr ${RESP} - 1`
                return ${LANGCODE}
            ;;
            *)
                case ${LANGCODE} in
                    0)
                        echo -e - "\n\tÄã±ØÐëÑ¡Ôñ: 1, 2\n"
                    ;;
                    *)
                        echo -e "\n\tPlease select: 1, 2\n"
                    ;;
                esac
            ;;
        esac
    done
}

# /*ÏÔÊŸ³ÌÐòÆô¶¯Ê±µÄÐÅÏ¢*/
DisplayStartMsg()
{
    clear
}

# /*ÏÔÊŸ³ÌÐòœáÊøʱµÄÐÅÏ¢*/
DisplayEndMsg()
{
    cd "${BAKCURRENTPATH}"
    rm -rf "${TEMPWORKPATH}"
    echo -e "\n${LInstallEnd[${LANGCODE}]}"
    # add by zkf20747 for printing install log DTS2010111102824 begin
    echo -e $PRINTTIME '    ' ${ENDINSTALL} >> ${INSTALLLOGFILE}
    echo -e "========================================================" >> ${INSTALLLOGFILE}
    # add by zkf20747 for printing install log DTS2010111102824 end
    read -n 1
    clear
}



GenConfigFile()
{
    cd $INSTALLPATH
    echo "path=$INSTALLPATH"               > $CONFIG_FILE
    echo "name=MobilePartner"              >> $CONFIG_FILE
    echo "Exec=$INSTALLPATH/MobilePartner" >> $CONFIG_FILE
    echo "FullVersion=$FULLVERSION" >> $CONFIG_FILE
   
}

#DTS2010123003200 begin add by d00135750 2011-2-17 Refresh the ubuntu Menu Items After install

UpdateMenuForUbunto()
{
for CACHE_FILE in ls /usr/share/applications/desktop.*.cache
do
    if [ -f ${CACHE_FILE} ]; then
    a=`ls -l ${CACHE_FILE}|awk '{print substr($1, 2)}'|sed 's/-/0/g'|sed 's/r/1/g'|sed 's/w/1/g'|sed 's/x/1/g'`
    chmod 777 ${CACHE_FILE}    
    /usr/share/gnome-menus/update-gnome-menus-cache /usr/share/applications/ > ${CACHE_FILE}       
    bb=$(echo "obase=8;ibase=2;$a"|bc)
            chmod ${bb} ${CACHE_FILE}
fi
done
}
#DTS2010123003200 end add by d00135750 2011-2-17 Refresh the ubuntu Menu Items After install


clear
CheckID
CheckRunning
#SelectLanguage
DisplayStartMsg
#µ±ÈÃÓû§Ñ¡Ôñ°²×°Ê±£¬Èçϲ¿·ÖŽúÂ뵜ӊžÃ·ÅµœwhileÑ­»·ÖÐ
PreInstall
InstallMobilePartner
GenConfigFile
#luanying add 20081229
#echo "Download Programs finished!" > "$INSTALLPATH/lib/UpdateInstall/inputLog.txt"
DisplayEndMsg
exit 0

#²»ÈÃÓû§Ñ¡Ôñ°²×°£¬ÈçÏÂŽúÂëÎÞЧ
while :
do
    echo -e - "***\t\t${LMobilePartnerInstall[${LANGCODE}]}\t\t***\n"
    echo -e - "${LPlsSelect[${LANGCODE}]}\n"
    echo -e - "\t1) ${LInstallMP[${LANGCODE}]}"
    echo -e - "\t0) ${LQuitInstall[${LANGCODE}]}\n"
    echo -e - "Choice: [0]\c"
    read RESP
    : ${RESP:="0"}
    case ${RESP} in
        1)
             PreInstall
             InstallJRE
             InstallMobilePartner
             GenConfigFile
        ;;
        0)
            DisplayEndMsg
            exit 0
        ;;
        *)
            echo -e - "${LYouMustSelect[${LANGCODE}]}1, 0"
        ;;
    esac
done