@@ -29,7 +29,7 @@ import (
29
29
"github.com/hyperledger/fabric/common/util"
30
30
"github.com/hyperledger/fabric/core/common/ccprovider"
31
31
"github.com/hyperledger/fabric/core/common/sysccprovider"
32
- ccintf "github.com/hyperledger/fabric/core/container/ccintf"
32
+ "github.com/hyperledger/fabric/core/container/ccintf"
33
33
"github.com/hyperledger/fabric/core/ledger"
34
34
"github.com/hyperledger/fabric/core/ledger/ledgerconfig"
35
35
"github.com/hyperledger/fabric/core/peer"
@@ -238,12 +238,20 @@ func (handler *Handler) deleteQueryIterator(txContext *transactionContext, txid
238
238
}
239
239
240
240
// Check if the transactor is allow to call this chaincode on this channel
241
- func (handler * Handler ) checkACL (signedProp * pb.SignedProposal , proposal * pb.Proposal , calledCC * ccParts ) * pb.ChaincodeMessage {
242
- // TODO: Decide what to pass in to verify that this transactor can access this
243
- // channel (chID) and chaincode (ccID). Very likely we need the signedProposal
244
- // which contains the sig and creator cert
241
+ func (handler * Handler ) checkACL (signedProp * pb.SignedProposal , proposal * pb.Proposal , calledCC * ccParts ) error {
242
+ // ensure that we don't invoke a system chaincode
243
+ // that is not invokable through a cc2cc invocation
244
+ if sysccprovider .GetSystemChaincodeProvider ().IsSysCCAndNotInvokableCC2CC (calledCC .name ) {
245
+ return fmt .Errorf ("System chaincode %s cannot be invoked with a cc2cc invocation" , calledCC .name )
246
+ }
247
+
248
+ // if we are here, all we know is that the invoked chaincode is either
249
+ // - a system chaincode that *is* invokable through a cc2cc
250
+ // (but we may still have to determine whether the invoker
251
+ // can perform this invocation)
252
+ // - an application chaincode (and we still need to determine
253
+ // whether the invoker can invoke it)
245
254
246
- // If error, return ChaincodeMessage with type ChaincodeMessage_ERROR
247
255
return nil
248
256
}
249
257
@@ -1269,8 +1277,12 @@ func (handler *Handler) enterBusyState(e *fsm.Event, state string) {
1269
1277
shorttxid (msg .Txid ), calledCcParts .name , calledCcParts .suffix )
1270
1278
}
1271
1279
1272
- triggerNextStateMsg = handler .checkACL (txContext .signedProp , txContext .proposal , calledCcParts )
1273
- if triggerNextStateMsg != nil {
1280
+ err := handler .checkACL (txContext .signedProp , txContext .proposal , calledCcParts )
1281
+ if err != nil {
1282
+ chaincodeLogger .Errorf ("[%s] C-call-C %s on channel %s failed check ACL [%v]: [%s]" ,
1283
+ shorttxid (msg .Txid ), calledCcParts .name , calledCcParts .suffix , txContext .signedProp , err )
1284
+ triggerNextStateMsg = & pb.ChaincodeMessage {Type : pb .ChaincodeMessage_ERROR ,
1285
+ Payload : []byte (err .Error ()), Txid : msg .Txid }
1274
1286
return
1275
1287
}
1276
1288
0 commit comments