Re: lug-bg: exec na script prez web
- Subject: Re: lug-bg: exec na script prez web
- From: "MafiaInc" <mafiainc@xxxxxxx>
- Date: Sat, 9 Jul 2005 12:03:17 +0300
- Delivered-to: lug-bg-list@xxxxxxxxxxxxxxxxxx
- Delivered-to: lug-bg@xxxxxxxxxxxxxxxxxx
Преди правех нещо подобно за контролиране на firewall-а:
Ето пример :
============= su_exec.c ======================
#include<stdio.h>
#include<unistd.h>
#include<string.h>
int main(int argc, char ** argv) {
char *action = "/etc/rc.d/firewall/firewall";
if (argc != 2) return 0;
setuid(0); // Here we go as root
if ( strcmp(argv[1], "start_masq") == 0 ) {
execv(action, argv);
}
else if ( strcmp(argv[1], "stop") == 0 ) {
execv(action, argv);
}
else if ( strcmp(argv[1], "stop_nat") == 0 ) {
execv(action, argv);
}
else {
printf("%s \n", "Bad params!");
}
return 0;
}
======================================
компилира се с: gcc su_exec.c
Ето пример за използването в PHP:
...
// opredeliane na tekushtia status
$full_net = "0";
$half_net = "0";
$stop_net = "0";
if ( isset($_GET['full']) ) {
exec("/usr/local/bin/su_exec start_masq");
}
if ( isset($_GET['half']) ) {
exec("/usr/local/bin/su_exec stop");
}
if ( isset($_GET['stop']) ) {
exec("/usr/local/bin/su_exec stop_nat");
}
$status_file = "/var/log/net_status";
$status = file($status_file);
if ( $status[0] == "full" ) { $full_net = "1"; }
if ( $status[0] == "half" ) { $half_net = "1"; }
if ( $status[0] == "stop" ) { $stop_net = "1"; }
...
--
MafiaInc (c) 1983 - 2005 http://www.kotarak.info
---------- Original Message -----------
From: gggg ggg <gashti_dolu@xxxxxxxxx>
To: LUG <lug-bg@xxxxxxxxxxxxxxxxxx>
Sent: Fri, 8 Jul 2005 17:03:26 -0700 (PDT)
Subject: lug-bg: exec na script prez web
> zdraveite,
> imam 2 scripta : edinia diga interfeisi i prenastroiva
> rutingi i t.n., a drugia pravi to4no obratnoto, t.e.
> edinia puska neshtata , a drugia gi spira.
>
> iskam da moje ot web da se puskat scriptovete, bez
> zna4enie dali s PHP,Perl,CGI-niakakuv, SH ili kakvoto
> i da e.
>
> problema mi e 4e ne moga da izvikam scriptowete ot
> web,apache gi stopira.razrovih mu po4ti vsi4koto
> secure i podiviah ve4e. daite malko help za tova
> ,kolkoto i prosto da izglejda.
>
> g.
>
> P.S. Slack 10.1
>
>
> ____________________________________________________
> Sell on Yahoo! Auctions – no fees. Bid on great items.
> http://auctions.yahoo.com/
------- End of Original Message -------
|