From a67478ed7c0b38454f3ef4e86f36d870c365c0d5 Mon Sep 17 00:00:00 2001
From: Iceber Gu <wei.cai-nat@daocloud.io>
Date: Thu, 18 May 2023 12:25:24 +0800
Subject: [PATCH 1/2] stub: update setIdentify to ensureIdentify

Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
---
 pkg/stub/stub.go | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pkg/stub/stub.go b/pkg/stub/stub.go
index 47009865..836b0536 100644
--- a/pkg/stub/stub.go
+++ b/pkg/stub/stub.go
@@ -290,7 +290,7 @@ func New(p interface{}, opts ...Option) (Stub, error) {
 		return nil, err
 	}
 
-	if err := stub.getIdentity(); err != nil {
+	if err := stub.ensureIdentity(); err != nil {
 		return nil, err
 	}
 
@@ -678,8 +678,8 @@ func (stub *stub) StateChange(ctx context.Context, evt *api.StateChangeEvent) (*
 	return &api.StateChangeResponse{}, err
 }
 
-// getIdentity gets plugin index and name from the binary if those are unset.
-func (stub *stub) getIdentity() error {
+// ensureIdentity sets plugin index and name from the binary if those are unset.
+func (stub *stub) ensureIdentity() error {
 	if stub.idx != "" && stub.name != "" {
 		return nil
 	}

From 4a4cea6142a5a34301b796a36355e3b38bb98522 Mon Sep 17 00:00:00 2001
From: Iceber Gu <wei.cai-nat@daocloud.io>
Date: Thu, 18 May 2023 13:42:40 +0800
Subject: [PATCH 2/2] fix the NRI_PLUGIN_NAME env value when launching a
 pre-installed plugin

Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
---
 pkg/adaptation/plugin.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pkg/adaptation/plugin.go b/pkg/adaptation/plugin.go
index c4be402e..9b2a487e 100644
--- a/pkg/adaptation/plugin.go
+++ b/pkg/adaptation/plugin.go
@@ -119,7 +119,7 @@ func (r *Adaptation) newLaunchedPlugin(dir, idx, base, cfg string) (p *plugin, r
 	cmd := exec.Command(filepath.Join(dir, name))
 	cmd.ExtraFiles = []*os.File{peerFile}
 	cmd.Env = []string{
-		api.PluginNameEnvVar + "=" + name,
+		api.PluginNameEnvVar + "=" + base,
 		api.PluginIdxEnvVar + "=" + idx,
 		api.PluginSocketEnvVar + "=3",
 	}