Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 27th, 2004, 2:09 AM   #1
Da-Kid
Programmer
 
Join Date: Nov 2004
Posts: 47
Rep Power: 0 Da-Kid is on a distinguished road
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
Da-Kid is offline   Reply With Quote
Old Nov 27th, 2004, 8:04 AM   #2
Eggbert
Professional Programmer
 
Eggbert's Avatar
 
Join Date: Nov 2004
Posts: 250
Rep Power: 5 Eggbert is on a distinguished road
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.
Eggbert is offline   Reply With Quote
Old Nov 27th, 2004, 6:36 PM   #3
Da-Kid
Programmer
 
Join Date: Nov 2004
Posts: 47
Rep Power: 0 Da-Kid is on a distinguished road
I understand, would it be easier if another terminal window opened..Thanks for your reply
Da-Kid is offline   Reply With Quote
Old Nov 27th, 2004, 6:44 PM   #4
Eggbert
Professional Programmer
 
Eggbert's Avatar
 
Join Date: Nov 2004
Posts: 250
Rep Power: 5 Eggbert is on a distinguished road
>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".
Eggbert is offline   Reply With Quote
Old Nov 28th, 2004, 6:33 AM   #5
Ade
Hobbyist Programmer
 
Ade's Avatar
 
Join Date: Oct 2004
Location: England, UK
Posts: 139
Rep Power: 0 Ade is an unknown quantity at this point
I think Eggbert is Dennis Ritchie in disguise!
__________________
Don't wound what you can't kill
Ade is offline   Reply With Quote
Old Nov 28th, 2004, 1:06 PM   #6
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Eggbert is the resident wizard! Btw, Stewey kicks ass
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Nov 28th, 2004, 4:26 PM   #7
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
Resident Wizard? lol

And as a follow-up, yes Stewie does kick ass
__________________
Clifford Matthew Roche &lt;geek@cliffordroche.com&gt;
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:24 AM.

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