Skip to content

Commit

Permalink
Fix missing SEC_ACL_MAP entries for freespacemgrs
Browse files Browse the repository at this point in the history
  • Loading branch information
rp- committed Sep 3, 2018
1 parent be94383 commit 6c8c803
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.linbit.linstor.dbcp.migration;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

@Migration(
version = "2018.09.03.14.30",
description = "Fix FreeSpaceMgr SEC_ACL_MAP entries."
)
public class Migration_2018_09_03_FreeSpaceMgr_ACL extends LinstorMigration
{
@Override
public void migrate(Connection connection) throws Exception
{
Statement stmt = connection.createStatement();
stmt.executeUpdate(
"INSERT INTO SEC_ACL_MAP SELECT CONCAT('/freespacemgrs/', sp.FREE_SPACE_MGR_NAME), acl_map.ROLE_NAME, " +
"acl_map.ACCESS_TYPE FROM NODE_STOR_POOL sp JOIN SEC_ACL_MAP acl_map ON " +
"CONCAT('/nodes/', sp.NODE_NAME) = acl_map.OBJECT_PATH AND " +
"CONCAT('/freespacemgrs/', sp.FREE_SPACE_MGR_NAME) NOT IN (SELECT object_path FROM SEC_ACL_MAP)"
);

stmt.executeUpdate(
"UPDATE SEC_OBJECT_PROTECTION SET OWNER_ROLE_NAME='SYSADM', SECURITY_TYPE_NAME='SHARED' " +
"WHERE OBJECT_PATH='/sys/controller/freeSpaceMgrMap'"
);

stmt.close();
}
}

0 comments on commit 6c8c803

Please sign in to comment.