OSSP CVS Repository

ossp - Difference in ossp-pkg/shiela/shiela.pl versions 1.45 and 1.46
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/shiela/shiela.pl 1.45 -> 1.46

--- shiela.pl    2002/12/23 13:10:56     1.45
+++ shiela.pl    2002/12/23 14:08:38     1.46
@@ -54,6 +54,7 @@
 $|++;
 umask(002);
 delete $ENV{TZ};
+$ENV{PATH} = "/bin:/usr/bin:/sbin:/usr/sbin";
 
 #   Generic program error handler
 $SIG{__DIE__} = sub {
@@ -98,7 +99,7 @@
     $rv = &hook_loginfo($PA, $RT, $CF);
 }
 else {
-    die "unknown hook (use --hook option)";
+    die "unknown processing stage (use --hook option)";
 }
 exit($rv);
 
@@ -163,11 +164,16 @@
     }
     $RT->{usergroups} = join(',', @G);
 
+    #   optionally set environment variables (like PATH)
+    foreach my $var (keys(%{$CF->{Environment}->{Setenv}})) {
+        $ENV{PATH} = $CF->{Environment}->{Setenv}->{$var};
+    }
+
     #   determine various program paths
     sub find_program {
         my ($name) = @_;
         my ($prog) = '';
-        foreach my $dir (split(/:/, "$ENV{PATH}:/bin:/usr/bin:/sbin:/usr/sbin")) {
+        foreach my $dir (split(/:/, $ENV{PATH})) {
             if (-x "$dir/$name") {
                 $prog = "$dir/$name";
                 last;
@@ -393,7 +399,8 @@
             'Report' => {}
         },
         'Environment' => {
-            'Program' => {}
+            'Program' => {},
+            'Setenv'  => {}
         }
     };
     my $cf = &parse_config($t, \&parse_config_callback, $CF);
@@ -452,6 +459,9 @@
         elsif ($action eq 'CMD' and $cf->[0] eq 'Program') {
             $CF->{Environment}->{Program}->{$cf->[1]} = $cf->[2];
         }
+        elsif ($action eq 'CMD' and $cf->[0] eq 'Setenv') {
+            $CF->{Environment}->{Setenv}->{$cf->[1]} = $cf->[2];
+        }
         return $cf;
     }
     return $CF;
@@ -2148,10 +2158,10 @@
                 my $branch;
                 foreach $branch (sort(keys(%{$list}))) {
                     if ($branch eq 'HEAD') {
-                        $O .= $prefix."$header:\n";
+                        $O .= sprintf("%s%s\n", $prefix, "$header:");
                     }
                     else {
-                        $O .= $prefix.sprintf("%-25s %s\n", "$header:", "(Branch: $branch)");
+                        $O .= sprintf("%s%-25s %s\n", $prefix, "$header:", "(Branch: $branch)");
                     }
                     $O .= &format_branch($prefix, $header, $branch, $list->{$branch});
                 }
@@ -2173,27 +2183,28 @@
                 my $first = 1;
                 my $col = 0;
                 foreach $file (sort(@{$list})) {
-                    if ($col+length($file)+1 > 78) {
+                    if (($col + 1 + length($file)) > 78) {
                         $O .= "\n";
                         $col = 0;
                     }
                     if ($col == 0) {
                         if ($first) {
-                            if (length($dir) > 25) {
-                                $O .= $prefix.sprintf("%s\n$prefix%-25s", "  $dir", "");
+                            if ((2+length($dir)) > 25) {
+                                $O .= sprintf("%s%s\n", $prefix, "  " . $dir);
+                                $O .= sprintf("%s%-25s", $prefix, "");
                             }
                             else {
-                                $O .= $prefix.sprintf("%-25s", "  $dir");
+                                $O .= sprintf("%s%-25s", $prefix, "  " . $dir);
                             }
                             $first = 0;
                         }
                         else {
-                            $O .= $prefix.sprintf("%-25s", "");
+                            $O .= sprintf("%s%-25s", $prefix, "");
                         }
-                        $col += length($prefix)+25;
+                        $col += length($prefix) + 25;
                     }
-                    $O .= " $file";
-                    $col += length($file)+1;
+                    $O .= " " . $file;
+                    $col += 1 + length($file);
                 }
                 $O .= "\n" if ($O !~ m|\n$|s);
                 return $O;

CVSTrac 2.0.1