$OpenBSD: patch-cgi-bin_openwebmail_openwebmail-tool_pl,v 1.7 2004/07/12 05:54:53 kevlo Exp $
--- cgi-bin/openwebmail/openwebmail-tool.pl.orig	Tue May 25 17:53:48 2004
+++ cgi-bin/openwebmail/openwebmail-tool.pl	Mon Jul 12 10:38:54 2004
@@ -1,4 +1,4 @@
-#!/usr/bin/suidperl -T
+#!/usr/bin/perl
 #
 # openwebmail-tool.pl - command tool for mail/event/notify/index...
 #
@@ -7,17 +7,17 @@
 #
 use vars qw($SCRIPT_DIR);
 if ( $0 =~ m!^(\S*)/[\w\d\-\.]+\.pl! ) { $SCRIPT_DIR=$1 }
-if ($SCRIPT_DIR eq '' && open(F, '/etc/openwebmail_path.conf')) {
+if ($SCRIPT_DIR eq '' && open(F, '%%SYSCONFDIR%%/openwebmail/openwebmail_path.conf')) {
    $_=<F>; close(F); if ( $_=~/^(\S*)/) { $SCRIPT_DIR=$1 }
 }
 if ($SCRIPT_DIR eq '') {
    print qq|\nOpen WebMail is unable to locate itself on this system,\n|.
          qq|please put 'the path of openwebmail CGI directory' to\n|.
-         qq|the first line of file /etc/openwebmail_path.conf\n\n|.
+         qq|the first line of file %%SYSCONFDIR%%/openwebmail/openwebmail_path.conf\n\n|.
          qq|For example, if the script is\n\n|.
-         qq|/usr/local/www/cgi-bin/openwebmail/openwebmail-tool.pl,\n\n|.
-         qq|then the content of /etc/openwebmail_path.conf should be:\n\n|.
-         qq|/usr/local/www/cgi-bin/openwebmail/\n\n|;
+         qq|/var/www/cgi-bin/openwebmail/openwebmail-tool.pl,\n\n|.
+         qq|then the content of %%SYSCONFDIR%%/openwebmail/openwebmail_path.conf should be:\n\n|.
+         qq|/var/www/cgi-bin/openwebmail/\n\n|;
    exit 0;
 }
 push (@INC, $SCRIPT_DIR);
@@ -306,10 +306,10 @@
    my $err=0;
    print "\n";
 
-   load_owconf(\%config_raw, "$SCRIPT_DIR/etc/openwebmail.conf.default");
-   if ( -f "$SCRIPT_DIR/etc/openwebmail.conf") {
-      read_owconf(\%config, \%config_raw, "$SCRIPT_DIR/etc/openwebmail.conf");
-      print "D readconf $SCRIPT_DIR/etc/openwebmail.conf\n" if ($opt{'debug'});
+   load_owconf(\%config_raw, "%%SYSCONFDIR%%/openwebmail/openwebmail.conf.default");
+   if ( -f "%%SYSCONFDIR%%/openwebmail/openwebmail.conf") {
+      read_owconf(\%config, \%config_raw, "%%SYSCONFDIR%%/openwebmail/openwebmail.conf");
+      print "D readconf %%SYSCONFDIR%%/openwebmail/openwebmail.conf\n" if ($opt{'debug'});
    }
 
    $logindomain=$default_logindomain||ow::tool::hostname();
@@ -409,7 +409,7 @@
    }
 
    if ($in_init && $err) {
-      print qq|Please change '$SCRIPT_DIR/etc/dbm.conf' from\n\n|.
+      print qq|Please change '%%SYSCONFDIR%%/openwebmail/dbm.conf' from\n\n|.
             qq|dbm_ext         \t$str{conf_dbm_ext}\n|.
             qq|dbmopen_ext     \t$str{conf_dbmopen_ext}\n|.
             qq|dbmopen_haslock \t$str{conf_dbmopen_haslock}\n|.
@@ -419,7 +419,7 @@
             qq|dbmopen_haslock \t$str{dbmopen_haslock}\n\n\n|;
    }
    if (!$in_init) {
-      print qq|'$SCRIPT_DIR/etc/dbm.conf' should be set as follows:\n\n|.
+      print qq|'%%SYSCONFDIR%%/openwebmail/dbm.conf' should be set as follows:\n\n|.
             qq|dbm_ext         \t$str{dbm_ext}\n|.
             qq|dbmopen_ext     \t$str{dbmopen_ext}\n|.
             qq|dbmopen_haslock \t$str{dbmopen_haslock}\n\n\n|;
@@ -436,7 +436,7 @@
    $>=0;
    if ($>!=0) {
       print qq|Your system didn't have saved suid support,\n|.
-            qq|please set the following option in $SCRIPT_DIR/etc/suid.conf\n\n|.
+            qq|please set the following option in %%SYSCONFDIR%%/openwebmail/suid.conf\n\n|.
             qq|\thas_savedsuid_support no\n\n\n|;
       return -1;
    }
@@ -520,10 +520,10 @@
    my $loaded_domain=0;
    my %userhash=();
 
-   load_owconf(\%config_raw, "$SCRIPT_DIR/etc/openwebmail.conf.default");
-   if ( -f "$SCRIPT_DIR/etc/openwebmail.conf") {
-      read_owconf(\%config, \%config_raw, "$SCRIPT_DIR/etc/openwebmail.conf");
-      print "D readconf $SCRIPT_DIR/etc/openwebmail.conf\n" if ($opt{'debug'});
+   load_owconf(\%config_raw, "%%SYSCONFDIR%%/openwebmail/openwebmail.conf.default");
+   if ( -f "%%SYSCONFDIR%%/openwebmail/openwebmail.conf") {
+      read_owconf(\%config, \%config_raw, "%%SYSCONFDIR%%/openwebmail/openwebmail.conf");
+      print "D readconf %%SYSCONFDIR%%/openwebmail/openwebmail.conf\n" if ($opt{'debug'});
    }
 
    # trap this once now.  Let usertool() test it at the domain level later
@@ -555,10 +555,10 @@
 
    foreach $logindomain (@domains) {
       %config_raw=();
-      load_owconf(\%config_raw, "$SCRIPT_DIR/etc/openwebmail.conf.default");
-      if ( -f "$SCRIPT_DIR/etc/openwebmail.conf") {
-         read_owconf(\%config, \%config_raw, "$SCRIPT_DIR/etc/openwebmail.conf");
-         print "D readconf $SCRIPT_DIR/etc/openwebmail.conf\n" if ($opt{'debug'});
+      load_owconf(\%config_raw, "%%SYSCONFDIR%%/openwebmail/openwebmail.conf.default");
+      if ( -f "%%SYSCONFDIR%%/openwebmail/openwebmail.conf") {
+         read_owconf(\%config, \%config_raw, "%%SYSCONFDIR%%/openwebmail/openwebmail.conf");
+         print "D readconf %%SYSCONFDIR%%/openwebmail/openwebmail.conf\n" if ($opt{'debug'});
       }
 
       if ( -f "$config{'ow_sitesconfdir'}/$logindomain") {
@@ -630,16 +630,16 @@
       $>=$euid_to_use;
 
       %config_raw=();
-      load_owconf(\%config_raw, "$SCRIPT_DIR/etc/openwebmail.conf.default");
-      if ( -f "$SCRIPT_DIR/etc/openwebmail.conf") {
-         read_owconf(\%config, \%config_raw, "$SCRIPT_DIR/etc/openwebmail.conf");
-         print "D readconf $SCRIPT_DIR/etc/openwebmail.conf\n" if ($opt{'debug'});
+      load_owconf(\%config_raw, "%%SYSCONFDIR%%/openwebmail/openwebmail.conf.default");
+      if ( -f "%%SYSCONFDIR%%/openwebmail/openwebmail.conf") {
+         read_owconf(\%config, \%config_raw, "%%SYSCONFDIR%%/openwebmail/openwebmail.conf");
+         print "D readconf %%SYSCONFDIR%%/openwebmail/openwebmail.conf\n" if ($opt{'debug'});
       }
 
       if ($config{'smtpauth'}) {	# load smtp auth user/pass
-         read_owconf(\%config, \%config_raw, "$SCRIPT_DIR/etc/smtpauth.conf");
+         read_owconf(\%config, \%config_raw, "%%SYSCONFDIR%%/openwebmail/smtpauth.conf");
          if ($config{'smtpauth_username'} eq "" || $config{'smtpauth_password'} eq "") {
-            die "Invalid username/password in $SCRIPT_DIR/etc/smtpauth.conf!";
+            die "Invalid username/password in %%SYSCONFDIR%%/openwebmail/smtpauth.conf!";
          }
       }
 
