$OpenBSD: patch-cgi-bin_openwebmail_openwebmail-tool_pl,v 1.11 2005/03/01 03:52:45 kevlo Exp $
--- cgi-bin/openwebmail/openwebmail-tool.pl.orig	Mon Feb 28 08:58:27 2005
+++ cgi-bin/openwebmail/openwebmail-tool.pl	Tue Mar  1 10:53:51 2005
@@ -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! ) { local $1; $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*)/) { local $1; $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|/var/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/\n\n|;
    exit 0;
 }
 push (@INC, $SCRIPT_DIR);
@@ -170,10 +170,10 @@
 
 $>=$euid_to_use;
 
-load_owconf(\%config_raw, "$SCRIPT_DIR/etc/defaults/openwebmail.conf");
-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/defaults/openwebmail.conf");
+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();
@@ -280,7 +280,7 @@
 
    my $err=do_test(1);
    if ($err<0) {
-      print qq|And execute '$SCRIPT_DIR/openwebmail-tool.pl --init' again!\n\n|.
+      print qq|And execute '%%SYSCONFDIR%%/openwebmail/openwebmail-tool.pl --init' again!\n\n|.
             qq|ps: If you are running openwebmail in persistent mode,\n|.
             qq|    don't forget to 'touch openwebmail*.pl', so speedycgi\n|.
             qq|    will reload all scripts, modules and conf files in --init.\n\n|;
@@ -457,7 +457,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|.
@@ -467,7 +467,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|;
@@ -484,7 +484,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;
    }
@@ -698,10 +698,10 @@
       # REINIT %config for auth_module as each domain may use different auth_module!
 
       %config_raw=();
-      load_owconf(\%config_raw, "$SCRIPT_DIR/etc/defaults/openwebmail.conf");
-      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/defaults/openwebmail.conf");
+      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") {
@@ -773,16 +773,16 @@
       $>=$euid_to_use;
 
       %config_raw=();
-      load_owconf(\%config_raw, "$SCRIPT_DIR/etc/defaults/openwebmail.conf");
-      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/defaults/openwebmail.conf");
+      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!";
          }
       }
 
@@ -883,7 +883,7 @@
             my $domainhome=ow::tool::untaint("$config{'ow_usersdir'}/$domain");
             if (!-d $domainhome) {
                mkdir($domainhome, 0750) or die("Couldn't create domain homedir $domainhome");
-               my $mailgid=getgrnam('mail');
+               my $mailgid=getgrnam('_mail');
                chown($uuid, $mailgid, $domainhome);
             }
          }
@@ -905,7 +905,7 @@
 
       umask(0077);
       if ( $>==0 ) { # switch to uuid:mailgid if process is setuid to root
-         my $mailgid=getgrnam('mail');	# for better compatibility with other mail progs
+         my $mailgid=getgrnam('_mail');	# for better compatibility with other mail progs
          ow::suid::set_euid_egids($uuid, $mailgid, split(/\s+/,$ugid));
          if ( $)!~/\b$mailgid\b/) {	# group mail doesn't exist?
             print "Set effective gid to mail($mailgid) failed!"; openwebmail_exit(0);
