LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 08-25-2013, 12:47 PM   #1
patrick295767
Member
 
Registered: Feb 2006
Distribution: FreeBSD, Linux, Slackware, LFS, Gparted
Posts: 664

Rep: Reputation: 138Reputation: 138
admin versus hard shutdown users


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 ; 
}

Last edited by patrick295767; 08-26-2013 at 02:35 AM.
 
Old 08-27-2013, 08:02 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653Reputation: 653
Sorry, I'm failing to see how a script can prevent this, maybe you're misusing "cold" in this case ?

A hard shutdown means to physically power off the system, holding the power button for 5 seconds for example.

A cold reset is similar in that it means to press the reset button, neither of these cases can be prevented by the OS.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Users in Domain Admin group (512) don't have admin rights on windows machine nandon Linux - Networking 2 01-21-2013 07:24 AM
Admin Users FNC Linux - Security 5 04-26-2012 08:45 AM
Samba - admin users only?!?!?! RBIaIS Linux - Server 7 01-06-2008 01:54 AM
Users admin problem mihalisla Linux - Newbie 2 09-24-2006 07:26 PM
Best way to remote admin: users? TruckStuff Linux - Security 6 06-01-2002 09:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 02:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration