summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2001-08-07 19:42:58 +0000
committerPascal Rigaux <pixel@mandriva.com>2001-08-07 19:42:58 +0000
commit6907585cf10bf56cc1d1124a6a909956c31e4139 (patch)
tree887178b034f92ac14aaa953ab4bafa1f488e52c2 /perl-install
parent99d9dfd2992113e3162d7bc259b301a355738c4b (diff)
downloaddrakx-backup-do-not-use-6907585cf10bf56cc1d1124a6a909956c31e4139.tar
drakx-backup-do-not-use-6907585cf10bf56cc1d1124a6a909956c31e4139.tar.gz
drakx-backup-do-not-use-6907585cf10bf56cc1d1124a6a909956c31e4139.tar.bz2
drakx-backup-do-not-use-6907585cf10bf56cc1d1124a6a909956c31e4139.tar.xz
drakx-backup-do-not-use-6907585cf10bf56cc1d1124a6a909956c31e4139.zip
add interactive_http
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/Makefile2
-rw-r--r--perl-install/Makefile.drakxtools16
-rw-r--r--perl-install/interactive_http.pm3
-rw-r--r--perl-install/standalone/interactive_http/Makefile16
-rwxr-xr-xperl-install/standalone/interactive_http/interactive_http.cgi92
-rw-r--r--perl-install/standalone/interactive_http/miniserv.conf13
-rw-r--r--perl-install/standalone/interactive_http/miniserv.init51
-rw-r--r--perl-install/standalone/interactive_http/miniserv.pam5
-rw-r--r--perl-install/standalone/interactive_http/miniserv.pl16
-rw-r--r--perl-install/standalone/interactive_http/miniserv.users1
10 files changed, 200 insertions, 15 deletions
diff --git a/perl-install/Makefile b/perl-install/Makefile
index 9e628f419..5810ebbe1 100644
--- a/perl-install/Makefile
+++ b/perl-install/Makefile
@@ -17,7 +17,7 @@ tar-drakxtools: clean
cd .. ; rm -rf drakxtools ; cp -af perl-install drakxtools ; cp -af tools/ddcprobe tools/serial_probe drakxtools
cd ../drakxtools ; perl -pi -e 's/^C_RPM.*/C_RPM=0/; s/^C_DRAKX.*/C_DRAKX=0/' c/Makefile
cd ../drakxtools ; rm -rf install* pkgs.pm help.pm ftp.pm t.pm */CVS ; mv Makefile.drakxtools Makefile ; mv -f standalone/* .
- cd .. ; tar cfj drakxtools.tar.bz2 --exclude CVS $(patsubst %,drakxtools/%,Makefile Makefile.config Newt c ddcprobe serial_probe share/po sbus_probing resize_fat share/diskdrake.rc share/wizard.rc $(STANDALONEPMS) icons pixmaps network *.pm)
+ cd .. ; tar cfj drakxtools.tar.bz2 --exclude CVS $(patsubst %,drakxtools/%,Makefile Makefile.config Newt c ddcprobe serial_probe share/po sbus_probing resize_fat share/diskdrake.rc share/wizard.rc $(STANDALONEPMS) icons pixmaps network interactive_http *.pm)
cd .. ; rm -rf drakxtools
$(DIRS):
diff --git a/perl-install/Makefile.drakxtools b/perl-install/Makefile.drakxtools
index c11afdd58..4ee04aade 100644
--- a/perl-install/Makefile.drakxtools
+++ b/perl-install/Makefile.drakxtools
@@ -1,6 +1,8 @@
include Makefile.config
-DIRS = ddcprobe serial_probe share/po Newt c resize_fat
+INLIBDEST_DIRS = Newt c resize_fat sbus_probing
+HAVEINST_DIRS = share/po interactive_http
+DIRS = $(INLIBDEST_DIRS) ddcprobe serial_probe
NAME = libDrakX
PREFIX =
LIBDIR = $(PREFIX)/usr/lib
@@ -21,11 +23,11 @@ $(DIRS):
install -d auto
rm standalone ; ln -s . standalone
rm -f share/po/DrakX.pot # force rebuild of po's
- $(MAKE) -C $@
+ [ ! -e $@/Makefile ] || $(MAKE) -C $@
install:
- install -d $(BINDEST) $(ETCDEST) $(SBINDEST) $(DATADIR) $(LIBDEST) $(NETLIBDEST) $(BINX11DEST) $(LIBX11DEST) $(PIXDIR) $(DIRS:%=$(LIBDEST)/%)
- install -d $(LIBDEST)/sbus_probing
+ install -d $(BINDEST) $(ETCDEST) $(SBINDEST) $(DATADIR) $(LIBDEST) $(NETLIBDEST) $(BINX11DEST) $(LIBX11DEST) $(PIXDIR)
+ install -d $(INLIBDEST_DIRS:%=$(LIBDEST)/%)
install $(STANDALONEPMS) $(SBINDEST)
install -s ddcprobe/ddcxinfos serial_probe/serial_probe $(SBINDEST)
ln -s ../../$(patsubst $(PREFIX)/usr%,%,$(SBINDEST))/XFdrake $(BINX11DEST)/Xdrakres
@@ -35,12 +37,16 @@ install:
install -m 644 pixmaps/* $(PIXDIR)
install -m 644 share/diskdrake.rc $(ETCDEST)
install -m 644 share/wizard.rc $(ETCDEST)
+
install -m 644 $(patsubst %,Newt/%.pm,Newt) $(LIBDEST)/Newt
install -m 644 $(patsubst %,c/%.pm,stuff) $(LIBDEST)/c
install -m 644 $(patsubst %,sbus_probing/%.pm,main) $(LIBDEST)/sbus_probing
install -m 644 $(patsubst %,resize_fat/%.pm,main any boot_sector c_rewritten dir_entry directory fat info_sector io) $(LIBDEST)/resize_fat
+
find $(LIBDEST) -name "*.pm" | xargs perl -pi -e '$$_ = "\n" if /\s*use\s+(diagnostics|vars|strict)/'
- $(MAKE) -C share/po install DATADIR=$(DATADIR) NAME=$(NAME)
+ for i in $(HAVEINST_DIRS); do \
+ $(MAKE) -C $$i install PREFIX=$(PREFIX) DATADIR=$(DATADIR) NAME=$(NAME) ; \
+ done
cp -rfL auto icons $(LIBDEST)
diff --git a/perl-install/interactive_http.pm b/perl-install/interactive_http.pm
index 2bf8ab616..a30b882f5 100644
--- a/perl-install/interactive_http.pm
+++ b/perl-install/interactive_http.pm
@@ -11,6 +11,7 @@ use interactive;
use common;
use log;
+my $script_name = $ENV{INTERACTIVE_HTTP};
my $no_header;
my $uid;
my $pipe_r = "/tmp/interactive_http_r";
@@ -63,7 +64,7 @@ sub ask_from_entries_refW {
# print $q->img({ -src => "/icons/$o->{icon}" }) if $o->{icon};
print @{$common->{messages}};
- print $q->start_form(-name => 'form', -action => '/cgi-bin/interactive_http', -method => 'get');
+ print $q->start_form(-name => 'form', -action => $script_name, -method => 'post');
print "<table>\n";
diff --git a/perl-install/standalone/interactive_http/Makefile b/perl-install/standalone/interactive_http/Makefile
new file mode 100644
index 000000000..535d06d99
--- /dev/null
+++ b/perl-install/standalone/interactive_http/Makefile
@@ -0,0 +1,16 @@
+NAME=libDrakX
+FNAME=$(NAME)/drakxtools_http
+PREFIX=
+DATADIR=$(PREFIX)/usr/share
+
+all:
+
+install:
+ install -D miniserv.init $(PREFIX)/etc/init.d/drakxtools_http
+ install -D -m 644 miniserv.conf $(PREFIX)/etc/drakxtools_http.conf
+ install -D -m 644 miniserv.pam $(PREFIX)/etc/pam.d/miniserv
+
+ install -d $(DATADIR)/$(FNAME)/www
+ install -m 644 miniserv.pl miniserv.pem miniserv.users $(DATADIR)/$(FNAME)
+ install -m 644 index.html $(DATADIR)/$(FNAME)/www
+ install interactive_http.cgi $(DATADIR)/$(FNAME)/www
diff --git a/perl-install/standalone/interactive_http/interactive_http.cgi b/perl-install/standalone/interactive_http/interactive_http.cgi
new file mode 100755
index 000000000..cb184300a
--- /dev/null
+++ b/perl-install/standalone/interactive_http/interactive_http.cgi
@@ -0,0 +1,92 @@
+#!/usr/bin/perl
+
+use lib qw(/usr/lib/libDrakX);
+use CGI;
+use common;
+use c;
+
+my $q = CGI->new;
+$| = 1;
+
+my $script_name = $q->url(-relative => 1);
+
+# name inversed (must be in sync with interactive_http.html)
+my $pipe_r = "/tmp/interactive_http_w";
+my $pipe_w = "/tmp/interactive_http_r";
+
+if ($q->param('state') eq 'new') {
+ force_exit_dead_prog();
+ mkfifo($pipe_r); mkfifo($pipe_w);
+
+ spawn_server($q->param('prog'));
+ first_step();
+
+} elsif ($q->param('state') eq 'next_step') {
+ next_step();
+} else {
+ error("booh...");
+}
+
+sub read_ {
+ local *F;
+ open F, "<$pipe_r" or error("Failed to connect to the prog");
+ my $t;
+ print $t while sysread F, $t, 1;
+}
+sub write_ {
+ local *F;
+ open F, ">$pipe_w" or die;
+ my $q = CGI->new;
+ $q->save(\*F);
+}
+
+sub first_step { read_() }
+sub next_step { write_(); read_() }
+
+
+sub force_exit_dead_prog {
+ -p $pipe_w or return;
+ {
+ local *F;
+ sysopen F, $pipe_w, 1 | c::O_NONBLOCK() or return;
+ syswrite F, "force_exit_dead_prog=1\n";
+ }
+
+ my $cnt = 10;
+ while (-p $pipe_w) {
+ sleep 1;
+ $cnt-- or error("Dead prog failed to exit");
+ }
+}
+
+sub spawn_server {
+ my ($prog) = @_;
+
+ fork and return;
+
+ $ENV{INTERACTIVE_HTTP} = $script_name;
+
+ open STDIN, "</dev/zero";
+ open STDOUT, ">/dev/null"; #tmp/log";
+ open STDERR, ">&STDOUT";
+
+ c::setsid();
+ exec $prog or die "prog $prog not found\n";
+}
+
+sub error {
+ my $msg = join '', @_;
+
+ print $q->header(), $q->start_html();
+ print $q->h1(_("Error")), @_;
+ print $q->end_html(), "\n";
+ exit 0;
+}
+
+sub mkfifo {
+ my ($f) = @_;
+ -p $f and return;
+ unlink $f;
+ syscall_('mknod', $f, c::S_IFIFO() | 0600, 0) or die "mkfifo failed";
+ chmod 0666, $f;
+}
diff --git a/perl-install/standalone/interactive_http/miniserv.conf b/perl-install/standalone/interactive_http/miniserv.conf
new file mode 100644
index 000000000..99f6a5172
--- /dev/null
+++ b/perl-install/standalone/interactive_http/miniserv.conf
@@ -0,0 +1,13 @@
+ssl=1
+log=1
+port=10001
+listen=10001
+forkcgis=1
+realm=Drakxtools Server
+
+addtype_cgi=internal/cgi
+logfile=/var/log/drakxtools_http.log
+pidfile=/var/run/drakxtools_http.pid
+root=/usr/share/libDrakX/drakxtools_http/www
+keyfile=/usr/share/libDrakX/drakxtools_http/miniserv.pem
+userfile=/usr/share/libDrakX/drakxtools_http/miniserv.users
diff --git a/perl-install/standalone/interactive_http/miniserv.init b/perl-install/standalone/interactive_http/miniserv.init
new file mode 100644
index 000000000..39c724dc7
--- /dev/null
+++ b/perl-install/standalone/interactive_http/miniserv.init
@@ -0,0 +1,51 @@
+#!/bin/sh
+# chkconfig: 235 99 00
+# description: Start or stop the miniserv administration server
+
+name=drakxtools_http
+server=/usr/share/libDrakX/$name/miniserv.pl
+
+case "$1" in
+'start')
+ echo -n "Starting $name: "
+ perl $server /etc/$name.conf
+ touch /var/lock/subsys/drakxtools_http
+ echo $name
+ ;;
+'stop')
+ echo -n "Shutting down $name: "
+ kill `cat /var/run/$name.pid`
+ rm -f /var/lock/subsys/drakxtools_http
+ echo $name
+ ;;
+'status')
+ if [ -s /var/run/$name.pid ]; then
+ pid=`cat /var/run/$name.pid`
+ kill -0 $pid >/dev/null 2>&1
+ if [ "$?" = "0" ]; then
+ echo "$name (pid $pid) is running"
+ else
+ echo "$name is stopped"
+ fi
+ else
+ echo "$name is stopped"
+ fi
+ ;;
+'restart')
+ $0 stop
+ $0 start
+ ;;
+'reload')
+ $0 stop
+ $0 start
+ ;;
+'condrestart')
+ if [ -f /var/lock/subsys/drakxtools_http ]; then
+ $0 restart
+ fi
+ ;;
+*)
+ echo "Usage: $0 {start|stop|restart|status|reload|condrestart}"
+ ;;
+esac
+exit 0
diff --git a/perl-install/standalone/interactive_http/miniserv.pam b/perl-install/standalone/interactive_http/miniserv.pam
new file mode 100644
index 000000000..37eae44e0
--- /dev/null
+++ b/perl-install/standalone/interactive_http/miniserv.pam
@@ -0,0 +1,5 @@
+#%PAM-1.0
+auth required /lib/security/pam_stack.so service=system-auth
+account required /lib/security/pam_stack.so service=system-auth
+password required /lib/security/pam_stack.so service=system-auth
+session required /lib/security/pam_stack.so service=system-auth
diff --git a/perl-install/standalone/interactive_http/miniserv.pl b/perl-install/standalone/interactive_http/miniserv.pl
index f866ee81a..b11ce26e2 100644
--- a/perl-install/standalone/interactive_http/miniserv.pl
+++ b/perl-install/standalone/interactive_http/miniserv.pl
@@ -58,7 +58,7 @@ if ($config{'syslog'}) {
eval "use Authen::PAM";
if (!$@) {
# check if the PAM authentication can be used by opening a handle
- if (! ref($pamh = new Authen::PAM("webmin", "root", \&pam_conv_func))) {
+ if (! ref($pamh = new Authen::PAM("miniserv", "root", \&pam_conv_func))) {
print STDERR "PAM module available, but error during init !\n";
print STDERR "Disabling PAM functions.\n";
}
@@ -159,7 +159,7 @@ if ($use_ssl) {
# Setup syslog support if possible and if requested
if ($use_syslog) {
- eval { openlog("webmin", "cons,pid,ndelay", "daemon") };
+ eval { openlog("miniserv", "cons,pid,ndelay", "daemon") };
$use_syslog = 0 if ($@);
}
@@ -268,7 +268,7 @@ die "Failed to bind port $config{port} : $!" if ($i == 5);
listen(MAIN, SOMAXCONN);
if ($config{'listen'}) {
- # Open the socket that allows other webmin servers to find this one
+ # Open the socket that allows other miniserv servers to find this one
$proto = getprotobyname('udp');
if (socket(LISTEN, PF_INET, SOCK_DGRAM, $proto)) {
setsockopt(LISTEN, SOL_SOCKET, SO_REUSEADDR, pack("l", 1));
@@ -507,7 +507,7 @@ while(1) {
}
if ($config{'listen'} && vec($rmask, fileno(LISTEN), 1)) {
- # Got UDP packet from another webmin server
+ # Got UDP packet from another miniserv server
local $rcvbuf;
local $from = recv(LISTEN, $rcvbuf, 1024, 0);
next if (!$from);
@@ -710,7 +710,7 @@ if (@deny && &ip_match($acptip, $localip, @deny) ||
if ($use_libwrap) {
# Check address with TCP-wrappers
- if (!hosts_ctl("webmin", STRING_UNKNOWN, $acptip, STRING_UNKNOWN)) {
+ if (!hosts_ctl("miniserv", STRING_UNKNOWN, $acptip, STRING_UNKNOWN)) {
&http_error(403, "Access denied for $acptip");
return 0;
}
@@ -739,8 +739,8 @@ if (%users) {
$blocked = 0;
# Session authentication is never used for connections by
- # another webmin server
- if ($header{'user-agent'} =~ /webmin/i) {
+ # another miniserv server
+ if ($header{'user-agent'} =~ /miniserv/i) {
$config{'session'} = 0;
}
@@ -1783,7 +1783,7 @@ return 0 if (!$_[0] || !$users{$_[0]});
if ($users{$_[0]} eq 'x' && $use_pam) {
$pam_username = $_[0];
$pam_password = $_[1];
- local $pamh = new Authen::PAM("webmin", $pam_username, \&pam_conv_func);
+ local $pamh = new Authen::PAM("miniserv", $pam_username, \&pam_conv_func);
if (!ref($pamh)) {
print STDERR "PAM init failed : $pamh\n";
return 0;
diff --git a/perl-install/standalone/interactive_http/miniserv.users b/perl-install/standalone/interactive_http/miniserv.users
new file mode 100644
index 000000000..f7338497a
--- /dev/null
+++ b/perl-install/standalone/interactive_http/miniserv.users
@@ -0,0 +1 @@
+root:x:0