From b5ad046f9519385786cb0faa8dbf165f6d733dee Mon Sep 17 00:00:00 2001 From: pcanterino <> Date: Wed, 27 Oct 2004 19:47:35 +0000 Subject: [PATCH] We are now using the `chgrp` system command to change the group of a file (see bug [1052335]) --- errors.dat | 1 + modules/Command.pm | 10 +++++++--- modules/File/Access.pm | 24 ++---------------------- templates/chprop.htm | 2 +- 4 files changed, 11 insertions(+), 26 deletions(-) diff --git a/errors.dat b/errors.dat index 606b336..93b5fc5 100644 --- a/errors.dat +++ b/errors.dat @@ -30,5 +30,6 @@ remove_root = You are not allowed to remove the root directory. rename_root = You are not allowed to move/rename the root directory. no_users = It seems that your system doesn't support users and groups. not_owner = You are not the owner of {FILE}, so you are not allowed to change the mode and the group. +invalid_group = '{GROUP}' seems to be an invalid group name. Please check it and try again. # End of configuration file \ No newline at end of file diff --git a/modules/Command.pm b/modules/Command.pm index d14fec1..451a183 100644 --- a/modules/Command.pm +++ b/modules/Command.pm @@ -6,7 +6,7 @@ package Command; # Execute Dev-Editor's commands # # Author: Patrick Canterino -# Last modified: 2004-10-23 +# Last modified: 2004-10-27 # use strict; @@ -223,7 +223,7 @@ sub exec_show($$) $tpl->fillin("URL",equal_url($config->{'httproot'},$virtual)); $tpl->fillin("SCRIPT",$script); - $tpl->parse_if_block("editable",-r $physical && -w $physical && -T $physical && not ($config->{'max_file_size'} && $size > $config->{'max_file_size'}) && $uselist->unused($virtual)); + $tpl->parse_if_block("editable",-r $physical && -w $physical && -T $physical && not ($config->{'max_file_size'} && $size > $config->{'max_file_size'}) && $uselist->unused($virtual)); $tpl->fillin("CONTENT",encode_entities($$content)); } @@ -772,7 +772,11 @@ sub exec_chprop($$) chmod($oct_mode,$physical); } - chgrp($group,$physical) if($group); + if($group) + { + return error($config->{'errors'}->{'invalid_group'},$dir,{GROUP => $group}) unless($group =~ /^[a-z0-9_]+[a-z0-9_-]*$/i); + system("chgrp",$group,$physical); + } return devedit_reload({command => 'show', file => $dir}); } diff --git a/modules/File/Access.pm b/modules/File/Access.pm index c649a2c..6ab193e 100644 --- a/modules/File/Access.pm +++ b/modules/File/Access.pm @@ -7,7 +7,7 @@ package File::Access; # with only one command # # Author: Patrick Canterino -# Last modified: 2004-08-05 +# Last modified: 2004-10-26 # use strict; @@ -20,32 +20,12 @@ use Fcntl; use base qw(Exporter); -@EXPORT = qw(chgrp - dir_read +@EXPORT = qw(dir_read file_create file_read file_save file_unlock); -# chgrp() -# -# Change the group of files or directories -# -# Params: 1. Group name or group ID -# 2. List of files -# -# Return: Number of files group successfully changed -# (or false) - -sub chgrp($@) -{ - my ($group,@files) = @_; - my $gid = ($group !~ /^\d+$/) ? getgrnam($group) : $group; - - return unless($gid); - return chown(-1,$gid,@files); -} - # dir_read() # # Collect the files and directories in a directory diff --git a/templates/chprop.htm b/templates/chprop.htm index 7d98801..e9df5b0 100644 --- a/templates/chprop.htm +++ b/templates/chprop.htm @@ -45,7 +45,7 @@
  • Change mode:
    Use an octal number to change the mode of the file. You may use the three or four number form. For this, SetUID, SetGID and Sticky Bit are also supported.
  • Change group:
    -Enter the group name or the group ID the file should be assigned to.
  • +Enter the group name or the group ID the file should be assigned to. If a group name is also a numeric group ID, the value is used as a group name.
    -- 2.34.1