Hello,
In order to protect the machine from "Hard shutdown" or "cold reset", several options are made possible.
One way is to physically (hardware) make small modifs.
Another one is to use scripts.
Here an example.
If you are using others, please feel free to post.
Greetings
Code:
int main(int argc, char *argv[]) {
FILE *fp;
int c ;
printf(" Anti Hard Shutdown \n");
chdir ( getenv( "HOME"));
printf(" File %d exists \n ", filexist( "/etc/antishutdown" ) );
if ( argc > 1 ) {
printf(" Argument %s \n ", argv[1] );
if ( strcmp ( argv[1] , "0" ) == 0 ){
if ( filexist( "/etc/antishutdown" ) == 1 ){
printf(" Remove file" );
rmfile( "/etc/antishutdown");
}
}
if ( strcmp ( argv[1] , "1" ) == 0 ){
if ( filexist( "/etc/antishutdown" ) == 0 ){
printf(" Create file" );
fp = fopen( "/etc/antishutdown" , "ab+" ) ;
fputs( "test" , fp ) ;
fclose( fp ) ;
}
}
if ( strcmp ( argv[1] , "2" ) == 0 ){
if ( filexist( "/etc/antishutdown" ) == 1 ){
while ( 1 == 1 ) {
printf(" \n");
printf(" \n");
printf(" +-+-+-+- BAD OPERATION / CRITICAL USE +-+-+\n");
printf(" You did a cold reset or shutdown ? \n" );
printf(" Hard Shutdown and Cold Reset are prohibited \n");
printf(" Please contact your admin to fix this \n");
printf(" Press A Key \n ");
printf("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n");
printf(" \n");
printf(" \n");
c = getchar();
}
}
if ( filexist( "/etc/antishutdown" ) == 0 ){
printf(" Create file" );
fp = fopen( "/etc/antishutdown" , "ab+" ) ;
fputs( "test" , fp ) ;
fclose( fp ) ;
}
}
if ( strcmp ( argv[1] , "3" ) == 0 ){
printf(" test only \n");
}
printf(" File %d exists \n ", filexist( "/etc/antishutdown" ) );
}
else
printf(" No argument \n ");
return 0 ;
}