Skip to content
Browse files

Add better ability to set file umask from various upload locations

Basic changes added to admin file_upload page to allow passing of umask more easily. Users trying to upload files for web viewing needed better control

Also modified slightly the uploadhelper widget to provide means to pass umask option, and subsequently altered process_filter where there were previously no means to pass umask through
  • Loading branch information...
1 parent 753e022 commit 93e95eb36037a1f1689f0144a26b4c252b1bf7e5 @perusiongreg perusiongreg committed Mar 30, 2011
View
7 code/Widget/uploadhelper.widget
@@ -16,6 +16,7 @@ sub {
my $name = $opt->{name};
my $val = $opt->{value};
+ my $umask = $opt->{umask} || '022';
my $path = $opt->{path} || $opt->{outboard};
my $size = $opt->{cols} || $opt->{width};
@@ -37,11 +38,13 @@ sub {
}
$out .= qq{&nbsp;<INPUT TYPE=file NAME="$name" VALUE="$val">
<INPUT TYPE=hidden NAME="ui_upload_file_path:$name" VALUE="$path">
-<INPUT TYPE=hidden NAME="$name" VALUE="$val">};
+<INPUT TYPE=hidden NAME="$name" VALUE="$val">
+<INPUT TYPE=hidden NAME="ui_upload_umask:$name" VALUE="$umask">};
}
else {
$out = qq{<INPUT TYPE=hidden NAME="ui_upload_file_path:$name" VALUE="$path">
-<INPUT TYPE=file NAME="$name"$size>};
+<INPUT TYPE=file NAME="$name"$size>
+<INPUT TYPE=hidden NAME="ui_upload_umask:$name" VALUE="$umask">};
}
return $out;
}
View
5 dist/lib/UI/pages/admin/upload_file.html
@@ -89,6 +89,9 @@
<INPUT NAME=ui_upload_ascii TYPE=radio VALUE=0>&nbsp;[L]Binary[/L]
[/else]
[/if]
+ <BR>
+ [L]Umask default (022)[/L]&nbsp;<INPUT NAME=ui_upload_umask TYPE=text VALUE='022' size=10>
+ <BR>
</BLOCKQUOTE>
<P>
<B>[L]Backup mode[/L]</B>
@@ -124,7 +127,7 @@
$regex = q{@_UI_CONST_IMAGE_REGEX_@} || '\.(?:gif|jpe?g|png)$';
if( $CGI->{ui_upload_fn} =~ m{$regex}i) {
- $CGI->{ui_upload_umask} = '022';
+ $CGI->{ui_upload_umask} ||= '022';
}
return;
[/calc]
View
6 dist/lib/UI/profiles/process_filter
@@ -98,9 +98,13 @@ __NAME__ process_filter
$fn =~ s,.*\\,,;
$fn = $Tag->filter('filesafe', $fn);
#Debug("cgi->$key now='$CGI->{$key}'");
+
+ my $umaskkey = 'ui_upload_umask:' . $key;
+ my $umask = $CGI->{$umaskkey};
+
$CGI->{$key} = $fn;
my $out = "$path/$fn";
- unless ($Tag->value_extended( { name => $key, outfile => $out , yes => 1} ) ) {
+ unless ($Tag->value_extended( { name => $key, outfile => $out , yes => 1, umask => $umask} ) ) {
$Scratch->{ui_failure} .= "\nFailed to write upload file $out";
}
}

0 comments on commit 93e95eb

Please sign in to comment.
Something went wrong with that request. Please try again.