grant privileges to PUBLIC cause Stado to fail restart

Bug #1158098 reported by Alvin Peng
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Stado
Fix Committed
Undecided
Unassigned

Bug Description

Stado -> grant all on info to public;
SQLException: ERROR: Failed to commit transaction

Though this SQL got exception, there is a new record with useried(null) inserted in Metadata database.

XDBSYS=# select * from xsystabprivs;
 privid | userid | tableid | selectpriv | insertpriv | updatepriv | deletepriv | referencespriv | indexpriv | alterpriv
--------+--------+---------+------------+------------+------------+------------+----------------+-----------+-----------
      1 | 1 | 31 | Y | Y | Y | Y | Y | Y | Y
      2 | | 31 | Y | Y | Y | Y | Y | Y | Y

When trying to restart Stado, ./gs-server.sh failed due to the NullPointer caused by the null user;

Also, revoke will get exception.

Stado -> revoke update on info from public;
SQLException: ERROR: Failed to commit transaction

Related branches

Revision history for this message
Alvin Peng (pengalvin) wrote :

The cause may be:

SqlGrant.java:
    /**
     * Grammar production:
     * f0 -> <PUBLIC_>
     * | Identifier(prn)
     */
    @Override
    public Object visit(Grantee n, Object argu) {
        if (n.f0.which == 0) {
            granteeList.add(null);
        }
...
    }

For "public", n.f0.which==0, so null is added to granteeList.
Then,

public void prepare() throws Exception {
...
            for (String granteeName : granteeList) {
                iGranteeList.add(granteeName == null ? null : database.getSysUser(granteeName));
            }
...
}

null is added to iGranteeList.

When Stado starts up,
SysTable.java:
void readPermissionsInfo() throws XDBServerException {
...
                sysPermissions.put(user, aSysPermission);
                user.addGranted(this); <-- this will cause exception because user is null
...

Revision history for this message
Alvin Peng (pengalvin) wrote :

In /src/org/postgresql/stado/parser/SqlGrant.java:

public void prepare() throws Exception {
...
            for (String granteeName : granteeList) {
                  iGranteeList.add(granteeName == null ? null : database.getSysUser(granteeName));
            }
...

updated to:

            for (String granteeName : granteeList) {
             if(granteeName == null){
              iGranteeList.addAll(database.getSysUsers());
             }else{
              iGranteeList.add(database.getSysUser(granteeName));
             }
            }

Changed in stado:
status: New → Fix Committed
Revision history for this message
Alvin Peng (pengalvin) wrote :

Hi Andre,

Stado -> revoke update on info from public;
SQLException: ERROR: Failed to rollback transaction

We still got ERROR for the revoke operation.

Seems the problem is caused by:

SyncRevoke.java:

public void refresh() throws Exception {
        //final String method = "refresh";
        //logger.entering(method, new Object[] {});
        try {

            for (SysTable table : parent.getTableList()) {
                for (SysUser user : parent.getGranteeList()) {
                    user.removeGranted(table); <-----------------user is null
                }
                table.readPermissionsInfo();
            }

        } finally {
            //logger.exiting(method);
        }
    }

Add if(user!=null) check can fix this issue.

Revision history for this message
Andrei Martsinchyk (andrei-martsinchyk) wrote :

Fixed. Thanks for pointing it out.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.