-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace busybox with internal copy binary and fix CVEs.
Replace the busybox image. Bump Golang version to v1.20. Signed-off-by: Xun Jiang <blackpiglet@gmail.com>
- Loading branch information
Xun Jiang
committed
Apr 15, 2023
1 parent
666f0a0
commit 07a2648
Showing
5 changed files
with
50 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Replace busybox with internal copy binary and fix CVEs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"io" | ||
"os" | ||
) | ||
|
||
func main() { | ||
if len(os.Args) != 3 { | ||
fmt.Println( | ||
`Error: This command requires two arguments. | ||
Usage: cp-plugin src dst`) | ||
os.Exit(1) | ||
} | ||
src, dst := os.Args[1], os.Args[2] | ||
fmt.Printf("Copying %s to %s ... ", src, dst) | ||
srcFile, err := os.Open(src) | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer srcFile.Close() | ||
if _, err := os.Stat(dst); errors.Is(err, os.ErrNotExist) { | ||
_, err = os.Create(dst) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
dstFile, err := os.OpenFile(dst, os.O_WRONLY, 0755) | ||
if err != nil { | ||
panic(err) | ||
} | ||
defer dstFile.Close() | ||
buf := make([]byte, 1024*128) | ||
_, err = io.CopyBuffer(dstFile, srcFile, buf) | ||
if err != nil { | ||
panic(err) | ||
} | ||
os.Chmod(dst, 0755) | ||
fmt.Println("done.") | ||
} |