[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
Re: [mv] [PATCH] option umask for tag value-extended
****** message to minivend-users from Mike Heins <mikeh@minivend.com> ******
Quoting Stefan Hornburg (racke@linuxia.de):
> ****** 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.
I like.
> Comments: Greatly appreciated.
Ditto.
>
> 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",
> $@,
>
The only thing I would do is pass the $opt variable so that future
improvements can be made while keeping the same API. (An auto-directory creation
feature comes to mind.)
my($file, $data, $opt) = @_;
if (ref $opt and $opt->{umask}) {
$opt->{umask} = umask oct($opt->{umask});
}
....
if (ref $opt and defined $opt->{umask}) {
$opt->{umask} = umask oct($opt->{umask});
}
The auto-directory would be something like:
if (ref $opt and $opt->{auto_create_dir}) {
my $dir = $file;
$dir =~ s/>+//;
## This is not available via normal tags, so may not be needed
if ($Global::NoAbsolute and file_name_is_absolute($dir) ) {
::logGlobal("NoAbsolute error: create file $dir");
return undef;
}
## Need to make this OS-independent, requires File::Spec support
$dir =~ s:.*/:: or $dir = '';
if($dir and ! -d $dir) {
File::Path::mkpath($dir);
}
}
> -
> 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
>
--
Internet Robotics, 131 Willow Lane, Floor 2, Oxford, OH 45056
phone +1.513.523.7621 fax 7501 <mikeh@minivend.com>
Fast, reliable, cheap. Pick two and we'll talk. -- unknown
-
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