summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Baulig <baulig@Stud.Informatik.uni-trier.de>1998-07-14 20:06:37 +0000
committerMartin Baulig <martin@src.gnome.org>1998-07-14 20:06:37 +0000
commit61f887fc673995d6d5ec0c3032deef854c20e29d (patch)
treeddaec411a7f08a381de9cc6373a52b9451093df3
parent9fd8936e9325e2e2e17361c49d26b8cbc1b87a16 (diff)
downloadlibgtop-61f887fc673995d6d5ec0c3032deef854c20e29d.tar.gz
Added some comments.
1998-07-14 Martin Baulig <baulig@Stud.Informatik.uni-trier.de> * src/daemon/server_config.h.in: Added some comments. * src/daemon/server_config.pl: New file. This is a script you can use to create `server_config.h'. It will query you for some configuration options.
-rw-r--r--ChangeLog6
-rw-r--r--src/daemon/server_config.h.in42
-rwxr-xr-xsrc/daemon/server_config.pl111
3 files changed, 151 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index f2168116..a679b801 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
1998-07-14 Martin Baulig <baulig@Stud.Informatik.uni-trier.de>
+ * src/daemon/server_config.h.in: Added some comments.
+
+ * src/daemon/server_config.pl: New file. This is a script you can use
+ to create `server_config.h'. It will query you for some configuration
+ options.
+
* configure.in (AC_PROG_AWK): Replaced this test with explicit test
for `gawk' and `awk' since `mawk' doesn't work.
diff --git a/src/daemon/server_config.h.in b/src/daemon/server_config.h.in
index 9a563865..06f2f308 100644
--- a/src/daemon/server_config.h.in
+++ b/src/daemon/server_config.h.in
@@ -1,14 +1,40 @@
-#define SERVER_PORT 42800
+/* This is a sample config file.
+ *
+ * Copy this file to 'server_config.h' and edit it to fix your needs !
+ *
+ * You can also use the 'server_config.pl' script to create 'server_config.h'.
+ *
+/
-#define SERVER_UID 99
-#define SERVER_GID 99
+#define SERVER_PORT 42800 /* Port the server should listen on. */
-#define HOST_TABLE_ENTRIES 3
+/* NOTE: On RedHat 5.1 nobody is UID 99 and GID 99.
+ *
+ * The 'server_config.pl' script will use the real UID and GID of 'nobody'
+ * on your system as default.
+ *
+ * NOTE: This only works if the server is started as root or SUID to root.
+ */
+
+#define SERVER_UID 99 /* User ID the server should run as. */
+#define SERVER_GID 99 /* Group ID the server should run as. */
+
+#define HOST_TABLE_ENTRIES 1 /* Number of entries in the host table. */
+
+/* List of hosts that should be authorized to connect to the server.
+ *
+ * SECURITY WARNING:
+ * Enabling access for a particular hosts means the ALL USERS on this host will
+ * be allowed to connect to the server !
+ *
+ * If you want security, let this table empty and use the 'xauth' method instead.
+ * Look at the manpage of gnuserv (1) as shipped with GNU Emacs for more details
+ * about security. The server uses the same security mechanisms like gnuserv from
+ * XEmacs 20.3.
+ */
const char *permitted_host_names [HOST_TABLE_ENTRIES] =
-{ "localhost",
- "voyager.home-of-linux.com",
- "einstein.home-of-linux.com",
-};
+{ "localhost" };
unsigned long permitted_hosts [HOST_TABLE_ENTRIES];
+
diff --git a/src/daemon/server_config.pl b/src/daemon/server_config.pl
new file mode 100755
index 00000000..3e78ca8f
--- /dev/null
+++ b/src/daemon/server_config.pl
@@ -0,0 +1,111 @@
+#!/usr/bin/perl -w
+
+require 5.004;
+use strict;
+
+print "Enter port the server should listen on [42800]: ";
+
+my $port = <stdin>; chop $port;
+$port = 42800 unless $port =~ /^\d+$/;
+
+print "\nUser name or UID to run as [nobody]: ";
+
+my $user = <stdin>; chop $user; $user = 'nobody' if $user eq '';
+
+my ($login, $pass, $uid, $gid);
+
+unless ($user =~ /^\d+$/) {
+ ($login, $pass, $uid, $gid) = getpwnam ($user) or
+ die "User '$user' not in passwd file.";
+}
+
+my $g_default = (defined $gid) ? $gid : 'nogroup';
+
+print "Group name or GID to run as [$g_default]: ";
+
+my $group = <stdin>; chop $group; $group = $g_default if $group eq '';
+
+unless ($group =~ /^\d+$/) {
+ $gid = getgrnam ($group) or
+ die "Group '$group' not in group file.";
+}
+
+print "\nEnter list of hosts which should be authorized to";
+print "\nconnect to the server (terminate with a blank line):\n\n";
+
+print "SECURITY WARNING:\n";
+print " Enabling access for a particular hosts means the ALL USERS on this host will\n";
+print " be allowed to connect to the server !\n\n";
+
+print " If you want security, let this table empty and use the 'xauth' method instead.\n";
+print " Look at the manpage of gnuserv (1) as shipped with GNU Emacs for more details\n";
+print " about security. The server uses the same security mechanisms like gnuserv from\n";
+print " XEmacs 20.3\n\n";
+
+my @hosts = ();
+my @host_addrs = ();
+my @host_names = ();
+
+while (1) {
+ print "Host: ";
+
+ my $host = <stdin>; chop $host;
+ last if $host eq '';
+
+ my ($name,$aliases,$addrtype,$length,@addrs) = gethostbyname ($host) or
+ die "gethostbyname (): Can't resolve '$host'";
+
+ my ($a,$b,$c,$d) = unpack('C4',$addrs[0]);
+
+ push @hosts, sprintf ("0x%02X%02X%02X%02X", $d, $c, $b, $a);
+ push @host_addrs, sprintf ("%d.%d.%d.%d", $a, $b, $c, $d);
+ push @host_names, $name;
+};
+
+print "\n";
+print "This is your config:\n";
+print "====================\n\n";
+
+printf qq[%-30s: %d\n\n], 'Port', $port;
+printf qq[%-30s: %d\n], 'UID', $uid;
+printf qq[%-30s: %d\n\n], 'GID', $gid;
+
+foreach (0..$#hosts) {
+ printf qq[%-30s (%s - %s)\n], $host_names[$_], $hosts[$_], $host_addrs [$_];
+}
+
+print "\n";
+
+print "Accept? (yes/no) ";
+
+my $accept = <stdin>; chop $accept;
+
+exit unless $accept eq 'yes';
+
+print "\n";
+
+open CONFIG, "> server_config.h" or
+ die "open (server_config.h): $!";
+select CONFIG;
+
+printf qq[\#define SERVER_PORT\t\t%d\n\n], $port;
+
+printf qq[\#define SERVER_UID\t\t%d\n], $uid;
+printf qq[\#define SERVER_GID\t\t%d\n\n], $gid;
+
+printf qq[\#define HOST_TABLE_ENTRIES\t%d\n\n], $#hosts + 1;
+
+foreach (@host_names) {
+ $_ = qq["$_"];
+}
+
+printf qq[const char *permitted_host_names [HOST_TABLE_ENTRIES] = \n];
+printf qq[{ %s };\n\n], join (', ', @host_names);
+
+printf qq[unsigned long permitted_hosts [HOST_TABLE_ENTRIES];\n];
+
+close CONFIG;
+
+select STDOUT;
+
+print "Your config has successfully been written to 'server_config.h'.\n";