Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set os.ModePerm permission for unix sockets #1320

Merged
merged 5 commits into from
Jul 12, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pkg/tools/grpcutils/listen_and_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//
// Copyright (c) 2020-2021 Doc.ai and/or its affiliates.
//
// Copyright (c) 2022 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -21,6 +23,7 @@ package grpcutils

import (
"context"
"fmt"
"net"
"net/url"
"os"
Expand Down Expand Up @@ -70,6 +73,15 @@ func ListenAndServe(ctx context.Context, address *url.URL, server *grpc.Server)
*address = *AddressToURL(ln.Addr())
}

if network == unixScheme {
if _, err = os.Stat(target); os.IsExist(err) {
NikitaSkrynnik marked this conversation as resolved.
Show resolved Hide resolved
err = os.Chmod(target, os.ModePerm)
if err != nil {
errCh <- errors.Wrap(err, fmt.Sprintf("Cannot change the mode of %s", target))
Copy link
Member

@denis-tingaikin denis-tingaikin Jul 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
errCh <- errors.Wrap(err, fmt.Sprintf("Cannot change the mode of %s", target))
errCh <- errors.Wrap(err, fmt.Sprintf("%v: сannot change mod", target))

}
}
}

// Serve
go func() {
if err != nil {
Expand Down