Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions lib/tbot/config/destination_directory.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ limitations under the License.
package config

import (
"errors"
"fmt"
"io/fs"
"os"
"os/user"
"path"
Expand Down Expand Up @@ -121,11 +123,18 @@ func mkdir(p string) error {
stat, err := os.Stat(p)
if trace.IsNotFound(err) {
if err := os.MkdirAll(p, botfs.DefaultDirMode); err != nil {
if errors.Is(err, fs.ErrPermission) {
return trace.Wrap(err, "Teleport does not have permission to write to %v. Ensure that you are running as a user with appropriate permissions.", p)
}
return trace.Wrap(err)
}

log.Infof("Created directory %q", p)
} else if err != nil {
// this can occur if we are unable to read the data dir
if errors.Is(err, fs.ErrPermission) {
return trace.Wrap(err, "Teleport does not have permission to access: %v. Ensure that you are running as a user with appropriate permissions.", p)
}
return trace.Wrap(err)
} else if !stat.IsDir() {
return trace.BadParameter("Path %q already exists and is not a directory", p)
Expand Down
8 changes: 6 additions & 2 deletions tool/tctl/common/tctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,13 @@ func applyConfig(ccf *GlobalCLIFlags, cfg *service.Config) (*authclient.Config,
cfg.HostUUID, err = utils.ReadHostUUID(cfg.DataDir)
if err != nil {
if errors.Is(err, fs.ErrNotExist) {
return nil, trace.Wrap(err, fmt.Sprintf("Could not load Teleport host UUID file at %s. "+
return nil, trace.Wrap(err, "Could not load Teleport host UUID file at %s. "+
"Please make sure that Teleport is up and running prior to using tctl.",
filepath.Join(cfg.DataDir, utils.HostUUIDFile)))
filepath.Join(cfg.DataDir, utils.HostUUIDFile))
} else if errors.Is(err, fs.ErrPermission) {
return nil, trace.Wrap(err, "Teleport does not have permission to read Teleport host UUID file at %s. "+
"Ensure that you are running as a user with appropriate permissions.",
filepath.Join(cfg.DataDir, utils.HostUUIDFile))
}
return nil, trace.Wrap(err)
}
Expand Down