When editing an HTML file, the <head> section is preserved.
Added a link in the HTML editor window to swich to plain text mode.
Files in the right-hand list are now sorted case-insensitively.
+When uploading a file, you can now select which Unix user it gets uploaded as.
$canperms = 1;
$canusers = 1;
$contents = 1;
+ $running_as_root = 0;
}
else {
# Webmin gets the list of allowed directories from the ACL
$canperms = $access{'noperms'} ? 0 : 1;
$canusers = $access{'nousers'} ? 0 : 1;
$contents = $access{'contents'};
+ $running_as_root = !$access{'uid'};
}
%disallowed_buttons = map { $_, 1 } @disallowed_buttons;
$st[9], $f ? "" : $islink && !$rl ? "???" : $rl);
}
-# switch_acl_uid()
+# switch_acl_uid([user])
sub switch_acl_uid
{
-if (!$module_info{'usermin'} && $access{'uid'}) {
- local @u = $access{'uid'} < 0 ? getpwnam($remote_user)
- : getpwuid($access{'uid'});
+local ($user) = @_;
+return if ($module_info{'usermin'}); # Always already switched
+local @u = $user ? getpwnam($user) :
+ $access{'uid'} < 0 ? getpwnam($remote_user) :
+ getpwuid($access{'uid'});
+if ($u[2]) {
@u || &error($text{'switch_euser'});
$( = $u[3]; $) = "$u[3] ".join(" ", $u[3], &other_groups($u[0]));
($>, $<) = ($u[2], $u[2]);
<script>
function upload(dir)
{
-open("upform.cgi?dir="+escape(dir)+"&trust=$trust", "upload", "toolbar=no,menubar=no,scrollbar=no,width=450,height=200");
+open("upform.cgi?dir="+escape(dir)+"&trust=$trust", "upload", "toolbar=no,menubar=no,scrollbar=no,width=550,height=230");
}
function htmledit(file, dir)
{
upload_conv=Convert DOS newlines?
upload_efile=No file selected to upload.
upload_edir=Upload directory does not exist.
+upload_euser=Selected user does not exist.
upload_eperm=You are not allowed to create $1
upload_ewrite=Failed to write to $1 : $2.
upload_already=The file $1 already exists. Are you sure that you want to overwrite it?
upload_elink=Cannot upload to a symbolic link
upload_zip=Uncompress ZIP or TAR file?
upload_yes=Yes, then delete
+upload_user=Upload as user
find_eaccess=You are not allowed to access $1
find_eexist=$1 does not exist in $2
&ui_submit($text{'upload_ok'}));
if ($dostounix == 1) {
+ # Do DOS conversion?
print &ui_table_row($text{'upload_conv'},
&ui_yesno_radio("dos", 0));
}
if ($unarchive == 1) {
+ # Unzip file?
print &ui_table_row($text{'upload_zip'},
&ui_radio("zip", 0,
[ [ 2, $text{'upload_yes'} ],
[ 0, $text{'no'} ] ]));
}
+if ($running_as_root) {
+ # Upload as user
+ print &ui_table_row($text{'upload_user'},
+ &ui_user_textbox("user", "root"));
+ }
+
print &ui_table_end();
print &ui_form_end();
&popup_footer();
elsif (!-d $realdir) {
print "<p><b>$text{'upload_edir'}</b><p>\n";
}
+elsif ($running_as_root && !defined(getpwnam($in{'user'}))) {
+ print "<p><b>$text{'upload_euser'}</b><p>\n";
+ }
else {
$in{'file_filename'} =~ /([^\\\/]+)$/;
$path = "$in{'dir'}/$1";
$realpath = "$realdir/$1";
if (-e $realpath) {
# File exists .. ask the user if he is sure
- &switch_acl_uid();
+ &switch_acl_uid($running_as_root ? $in{'user'} : undef);
$temp = &tempname();
&open_tempfile(TEMP, ">$temp");
if ($dostounix == 1 && $in{'dos'}) {
print "<input type=hidden name=$i value='",
&html_escape($prein{$i}),"'>\n";
}
- print "<input type=hidden name=dir value='",
- &html_escape($in{'dir'}),"'>\n";
- print "<input type=hidden name=path value='",
- &html_escape($path),"'>\n";
- print "<input type=hidden name=temp value='",
- &html_escape($temp),"'>\n";
- print "<input type=hidden name=zip value='",
- &html_escape($in{'zip'}),"'>\n";
+ print &ui_hidden("dir", $in{'dir'});
+ print &ui_hidden("path", $path);
+ print &ui_hidden("temp", $temp);
+ print &ui_hidden("zip", $in{'zip'});
+ print &ui_hidden("user", $in{'user'});
print "<center>\n";
print &text('upload_already', "<tt>$path</tt>"),"<p>\n";
print "<input type=submit name=yes value='$text{'yes'}'>\n";
else {
# Go ahread and do it!
&webmin_log("upload", undef, $path);
- &switch_acl_uid();
+ &switch_acl_uid($running_as_root ? $in{'user'} : undef);
if ($access{'ro'} || !&can_access($path)) {
print "<p><b>",&text('upload_eperm', $path),"</b><p>\n";
}
if ($in{'yes'}) {
# Put it in place, overwriting any other file
&webmin_log("upload", undef, $in{'path'});
- &switch_acl_uid();
+ &switch_acl_uid($running_as_root ? $in{'user'} : undef);
if ($access{'ro'} || !&can_access($in{'path'})) {
print "<p><b>",&text('upload_eperm', $in{'path'}),"</b><p>\n";
}