LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-15-2009, 05:04 AM   #1
amkh
LQ Newbie
 
Registered: Feb 2009
Posts: 2

Rep: Reputation: 0
apache configuration to connect to network adapter via a web application


Hi, all.
please help me with this problem.

I want to run snort through a web application with exec("snort -v -i eth0 ") php function.
for example when start button was pressed snort should be run,
but the execution failed with this error:

Running in packet dump mode

--== Initializing Snort ==--
Initializing Output Plugins!
Verifying Preprocessor Configurations!

Initializing Network Interface eth0
ERROR: OpenPcap() device eth0 open:
socket: Operation not permitted
Fatal Error, Quitting..

but when I run snort command via command line as root it will execute successfully.

I think this problem is for that apache user haven't access to network adapter, is my guess correct? I have no experience with apache, should I change apache configuration? what is the configuration for this problem.

I apply below command:

chown -R wwwrun:www /srv/www/htdocs/myprogram/snort

and changed my snort run command like this:
<?php

exec(/srv/www/htdocs/mywebprogram/snort/bin/snort -u wwwrun -g www -v -i eth0)
?>

but my problem didn't solve,I also test this:

chown -R root:www /srv/www/htdocs/mywebprogram/snort

but no difference,
I think I should find a way to allow apache to access but I don't know how?
 
Old 02-15-2009, 10:51 AM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Apache was designed to run with very limited permissions, that is why it is so safe.

You don't want to increase the permissions from a point of security, let alone let it run as root.

If you really want to make your system insecure, you might try to set setuid on snort. (man setuid) But again, I warn you it is a bad idea.

There are other ways to accomplish this, but slightly more complicated. For example, build a script which runs in the background with root privileges, and checks for the contents of a certain flag file. This flag file contains '0' or '1'. When it is '1', the background script executes your snort. The output of snort goes into a temporary file. Your web page displays the contents of this file. You php script only writes '0' or '1' in the flag file. This is perfectly safe.

Most information which is shown to you thru a web page is based on a background process gathering information and storing it somewhere. When the information is retrieved over the web, this information is what you see.

jlinkels
 
Old 02-17-2009, 01:58 AM   #3
amkh
LQ Newbie
 
Registered: Feb 2009
Posts: 2

Original Poster
Rep: Reputation: 0
yes, you are perfectly right. thanks for your ideas.
 
  


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
Configuration of web based application in linux mobassir Linux - Networking 4 04-23-2009 02:25 AM
Can't connect to internet. Using linksys wireless-g usb network adapter. Please help. gordohumphrey Linux - Newbie 6 08-04-2008 11:41 PM
wusg54gc wifi network adapter configuration. glore2002 Slackware 16 07-09-2008 02:46 PM
network adapter configuration in fedora core 4 karellen Fedora 3 03-20-2006 04:25 PM
Can't Connect Via Belkin Network Adapter (F5D7051uk) TCK-OCR Linux - Wireless Networking 0 12-16-2005 01:50 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:28 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