From: mgandalf Date: Wed, 23 Sep 2009 15:39:08 +0000 (+0000) Subject: - If target-oriented access control mode is used, Default_ groups will first be created X-Git-Url: http://git.etherboot.org/mirror/scst/.git/commitdiff_plain/93c2c30af4e527ad760446b437dd389c05179150?hp=2b1bc710e700215b1c541ec314c484bdb08d2c1e - If target-oriented access control mode is used, Default_ groups will first be created as temporary groups and later renamed. git-svn-id: https://scst.svn.sourceforge.net/svnroot/scst/trunk@1133 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- diff --git a/scstadmin/ChangeLog b/scstadmin/ChangeLog index 844acb4..4f9cadc 100644 --- a/scstadmin/ChangeLog +++ b/scstadmin/ChangeLog @@ -4,6 +4,8 @@ Changes for 1.0.9 of deleting from one and adding to another the same user. - Replace a device on a given LUN when applying the configuration instead of removing the old device and assigning the new one. +- If target-oriented access control mode is used, Default_ groups will first be created + as temporary groups and later renamed. - Add the ability to specify options (ie: READ_ONLY) in assignments in scst.conf. - Remove unused references to handler IOs that don't exist and cleanup the write configuration function to only write vdisk and vcdrom devices. All other devices diff --git a/scstadmin/scstadmin b/scstadmin/scstadmin index 03d68dd..dfd718c 100755 --- a/scstadmin/scstadmin +++ b/scstadmin/scstadmin @@ -123,6 +123,9 @@ my $_FC_CLASS_ = '/sys/class/fc_host'; my $_SCSI_ISP_ = '/proc/scsi/isp'; my $_SCSITGT_QLAISP_ = '/proc/scsi_tgt/qla_isp'; +my $_TGT_DEF_PREFIX_ = 'Default_'; +my $_TGT_TMP_PREFIX_ = 'TMP_GRP'; + my $SCST; my $DEVICES; my $TARGETS; @@ -647,6 +650,8 @@ sub applyConfiguration { my %seen_users; + my %rename_group; + # Cache device/handler configuration foreach my $entry (keys %{$$config{'HANDLER'}}) { foreach my $device (@{$$config{'HANDLER'}->{$entry}->{'DEVICE'}}) { @@ -899,6 +904,17 @@ sub applyConfiguration { # Create new groups and add users.. foreach my $group (keys %used_users) { if (!defined($USERS{$group})) { + if ($group =~ /^$_TGT_DEF_PREFIX_/) { + my $rnd_id = randomGroupId(); + my $tmp_group = $_TGT_TMP_PREFIX_.$rnd_id; + + print "\t-> Using temporary group '$tmp_group' for group '$group'.\n"; + + $rename_group{$tmp_group} = $group; + $used_users{$tmp_group} = $used_users{$group}; + $group = $tmp_group; + } + if ($check) { print "\t-> New group definition '$group.'\n"; $GROUPS{$group}++; @@ -991,6 +1007,13 @@ sub applyConfiguration { } } + foreach my $tmp_group (keys %rename_group) { + my $group = $rename_group{$tmp_group}; + print "\t-> Processing temporary group '$tmp_group'.\n"; + + renameGroup($tmp_group, $group); + } + # Enable/Disable configured targets foreach my $type (keys %{$$config{'TARGETS'}}) { my $enable; @@ -1807,6 +1830,10 @@ sub validHandlerTypes { return $buffer; } +sub randomGroupId { + return int(rand(10000)); +} + # If we have an unread error from SCST, exit immediately sub immediateExit { my $error = shift;