Skip to content

Commit

Permalink
chore: remove security API ReadFile/WriteFile
Browse files Browse the repository at this point in the history
This seems to be unused completely, and they look scary enough at the
same time.

For better readability and to avoid any pitfalls, better to remove them.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
  • Loading branch information
smira authored and talos-bot committed Apr 27, 2021
1 parent 3803713 commit c3a4173
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 489 deletions.
22 changes: 0 additions & 22 deletions api/security/security.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ option java_package = "com.security.api";
// The security service definition.
service SecurityService {
rpc Certificate(CertificateRequest) returns (CertificateResponse);
rpc ReadFile(ReadFileRequest) returns (ReadFileResponse);
rpc WriteFile(WriteFileRequest) returns (WriteFileResponse);
}

// The request message containing the process name.
Expand All @@ -24,23 +22,3 @@ message CertificateResponse {
bytes ca = 1;
bytes crt = 2;
}

// The request message for reading a file on disk.
message ReadFileRequest {
string path = 1;
}

// The response message for reading a file on disk.
message ReadFileResponse {
bytes data = 1;
}

// The request message containing the process name.
message WriteFileRequest {
string path = 1;
bytes data = 2;
int32 perm = 3;
}

// The response message containing the requested logs.
message WriteFileResponse {}
36 changes: 0 additions & 36 deletions internal/app/trustd/internal/reg/reg.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ package reg

import (
"context"
"io/ioutil"
"log"
"os"
"path"

"github.com/talos-systems/crypto/x509"
"google.golang.org/grpc"
Expand Down Expand Up @@ -49,35 +45,3 @@ func (r *Registrator) Certificate(ctx context.Context, in *securityapi.Certifica

return resp, nil
}

// ReadFile implements the securityapi.SecurityServer interface.
func (r *Registrator) ReadFile(ctx context.Context, in *securityapi.ReadFileRequest) (resp *securityapi.ReadFileResponse, err error) {
var b []byte

if b, err = ioutil.ReadFile(in.Path); err != nil {
return nil, err
}

log.Printf("read file on disk: %s", in.Path)

resp = &securityapi.ReadFileResponse{Data: b}

return resp, nil
}

// WriteFile implements the securityapi.SecurityServer interface.
func (r *Registrator) WriteFile(ctx context.Context, in *securityapi.WriteFileRequest) (resp *securityapi.WriteFileResponse, err error) {
if err = os.MkdirAll(path.Dir(in.Path), os.ModeDir); err != nil {
return
}

if err = ioutil.WriteFile(in.Path, in.Data, os.FileMode(in.Perm)); err != nil {
return
}

log.Printf("wrote file to disk: %s", in.Path)

resp = &securityapi.WriteFileResponse{}

return resp, nil
}
Loading

0 comments on commit c3a4173

Please sign in to comment.