Akopia Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

[mv] [PATCH] option umask for tag value-extended



******    message to minivend-users from Stefan Hornburg <racke@linuxia.de>     ******


Description: This patch allows you to temporarily changing 
             the umask for uploaded files.
Motivation:  My catalog directory usually contains a subdirectory
             images, where images for the Webserver are stored.
             With this patch, files can be uploaded with read
             permission for anyone. 
Future:      If Mike likes it, this can be added to MiniVend
             with appropriate documentation supplied by
             me. 
Comments:    Greatly appreciated.

diff -u -r1.10 Interpolate.pm
--- Interpolate.pm	2000/04/16 00:18:43	1.10
+++ Interpolate.pm	2000/05/12 13:28:31
@@ -1894,7 +1894,7 @@
 # Returns the text of a user entered field named VAR.
 sub tag_value_extended {
     my($var, $opt) = @_;
-
+	
 	my $yes = $opt->{yes} || 1;
 	my $no = $opt->{'no'} || '';
 
@@ -1939,7 +1939,7 @@
 				$CGI::file{$var} =~ s/\n/$replace/g;
 			}
 		}
-		Vend::Util::writefile(">$file", \$CGI::file{$var})
+		Vend::Util::writefile(">$file", \$CGI::file{$var}, $opt->{umask})
 			and return $opt->{yes} || '';
 		return $opt->{'no'} || '';
 	}
diff -u -r1.4 Util.pm
--- Util.pm	2000/04/12 15:07:04	1.4
+++ Util.pm	2000/05/12 13:29:34
@@ -487,10 +487,12 @@
 *uneval      = defined $Pretty_uneval     ? $Pretty_uneval     : \&uneval_it;
 
 sub writefile {
-    my($file, $data) = @_;
+    my($file, $data, $umask) = @_;
 
 	$file = ">>$file" unless $file =~ /^[|>]/;
-
+	if (defined $umask) {
+		$umask = umask oct($umask);
+	}
     eval {
 		unless($file =~ s/^[|]\s*//) {
 			open(MVLOGDATA, "$file") or die "open\n";
@@ -516,6 +518,9 @@
 		}
 		close(MVLOGDATA) or die "close\n";
     };
+	if (defined $umask) {
+		$umask = umask oct($umask);
+	}
     if ($@) {
 		::logError ("Could not %s file '%s': %s\nto write this data:\n%s",
 				$@,
 
-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: