Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   Unix Intrusion (http://www.programmingforums.org/showthread.php?t=1309)

Da-Kid Nov 27th, 2004 2:09 AM

Hi, There is a program out called Tripwire for linux users. It checks for File permissions and if its been edited etc.. I wanted to know if anyone has anyidea on make a simple program to replicate Tripwire...by making a pop up window that shows when a user logs in/out and when a file is edited

Eggbert Nov 27th, 2004 8:04 AM

Checking file accesses and permissions is trivial:
:

#include <sys/stat.h>

time_t last = 0; /* Set to the previous modification */

int was_modified ( const char *path )
{
 struct stat buf;

 if ( stat ( path, &buf ) != -1 ) {
  if ( last == 0 ) {
  last = buf.st_mtime;
  return 1;
  }
  else if ( last != buf.st_mtime )
  return 1;
 }

 return 0;
}

int is_writable ( const char *path )
{
 struct stat buf;

 if ( stat ( path, &buf ) != -1 )
  return ( buf.st_mode & ( S_IWUSR | S_IWGRP ) ) != 0;

 return 0;
}

A window is probably a bad idea because it assumes the user is running in a windowed environment. There are many users who still prefer the command terminal. Since this program will be run as a background process anyway, it would be preferrable to write it as a command line program, then start it in whatever login script you use. If you really want to pop up a window then spawning a terminal window with information on which file was tripped would probably be easier (and more portable across distributions) than using a windowing API.

Da-Kid Nov 27th, 2004 6:36 PM

I understand, would it be easier if another terminal window opened..Thanks for your reply

Eggbert Nov 27th, 2004 6:44 PM

>would it be easier if another terminal window opened..
Is this a question or just poor word ordering? Yes, it would be easier because you wouldn't get bogged down in the details of creating and manipulating a window. You can simply use an existing program like xterm to do all of that for you, so that the end result is you simply write text to the standard output and everything will "just work".

Ade Nov 28th, 2004 6:33 AM

I think Eggbert is Dennis Ritchie in disguise!

Infinite Recursion Nov 28th, 2004 1:06 PM

Eggbert is the resident wizard! Btw, Stewey kicks ass ;)

kurifu Nov 28th, 2004 4:26 PM

Resident Wizard? lol

And as a follow-up, yes Stewie does kick ass :P


All times are GMT -5. The time now is 2:09 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC