repo stringlengths 5 67 | sha stringlengths 40 40 | path stringlengths 4 234 | url stringlengths 85 339 | language stringclasses 6 values | split stringclasses 3 values | doc stringlengths 3 51.2k | sign stringlengths 5 8.01k | problem stringlengths 13 51.2k | output stringlengths 0 3.87M |
|---|---|---|---|---|---|---|---|---|---|
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/signals.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/signals.go#L53-L152 | go | train | // WaitForSignals waits for system signals and processes them.
// Should not be called twice by the process. | func (process *TeleportProcess) WaitForSignals(ctx context.Context) error | // WaitForSignals waits for system signals and processes them.
// Should not be called twice by the process.
func (process *TeleportProcess) WaitForSignals(ctx context.Context) error | {
sigC := make(chan os.Signal, 1024)
signal.Notify(sigC,
syscall.SIGQUIT, // graceful shutdown
syscall.SIGTERM, // fast shutdown
syscall.SIGINT, // fast shutdown
syscall.SIGKILL, // fast shutdown
syscall.SIGUSR1, // log process diagnostic info
syscall.SIGUSR2, // initiate process restart procedure
syscall.SIGHUP, // graceful restart procedure
syscall.SIGCHLD, // collect child status
)
doneContext, cancel := context.WithCancel(ctx)
defer cancel()
serviceErrorsC := make(chan Event, 10)
process.WaitForEvent(ctx, ServiceExitedWithErrorEvent, serviceErrorsC)
// Block until a signal is received or handler got an error.
// Notice how this handler is serialized - it will only receive
// signals in sequence and will not run in parallel.
for {
select {
case signal := <-sigC:
switch signal {
case syscall.SIGQUIT:
go process.printShutdownStatus(doneContext)
process.Shutdown(ctx)
process.Infof("All services stopped, exiting.")
return nil
case syscall.SIGTERM, syscall.SIGKILL, syscall.SIGINT:
process.Infof("Got signal %q, exiting immediately.", signal)
process.Close()
return nil
case syscall.SIGUSR1:
// All programs placed diagnostics on the standard output.
// This had always caused trouble when the output was redirected into a file, but became intolerable
// when the output was sent to an unsuspecting process.
// Nevertheless, unwilling to violate the simplicity of the standard-input-standard-output model,
// people tolerated this state of affairs through v6. Shortly thereafter Dennis Ritchie cut the Gordian
// knot by introducing the standard error file.
// That was not quite enough. With pipelines diagnostics could come from any of several programs running simultaneously.
// Diagnostics needed to identify themselves.
// - Doug McIllroy, "A Research UNIX Reader: Annotated Excerpts from the Programmer’s Manual, 1971-1986"
process.Infof("Got signal %q, logging diagostic info to stderr.", signal)
writeDebugInfo(os.Stderr)
case syscall.SIGUSR2:
log.Infof("Got signal %q, forking a new process.", signal)
if err := process.forkChild(); err != nil {
process.Warningf("Failed to fork: %v", err)
} else {
process.Infof("Successfully started new process.")
}
case syscall.SIGHUP:
process.Infof("Got signal %q, performing graceful restart.", signal)
if err := process.forkChild(); err != nil {
process.Warningf("Failed to fork: %v", err)
continue
}
process.Infof("Successfully started new process, shutting down gracefully.")
go process.printShutdownStatus(doneContext)
process.Shutdown(ctx)
log.Infof("All services stopped, exiting.")
return nil
case syscall.SIGCHLD:
process.collectStatuses()
default:
process.Infof("Ignoring %q.", signal)
}
case <-process.ReloadContext().Done():
process.Infof("Exiting signal handler: process has started internal reload.")
return ErrTeleportReloading
case <-process.ExitContext().Done():
process.Infof("Someone else has closed context, exiting.")
return nil
case <-ctx.Done():
process.Close()
process.Wait()
process.Info("Got request to shutdown, context is closing")
return nil
case event := <-serviceErrorsC:
se, ok := event.Payload.(ServiceExit)
if !ok {
process.Warningf("Failed to decode service exit event, %T", event.Payload)
continue
}
if se.Service.IsCritical() {
process.Errorf("Critical service %v has exited with error %v, aborting.", se.Service, se.Error)
if err := process.Close(); err != nil {
process.Errorf("Error when shutting down teleport %v.", err)
}
return trace.Wrap(se.Error)
} else {
process.Warningf("Non-critical service %v has exited with error %v, continuing to operate.", se.Service, se.Error)
}
}
}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/signals.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/signals.go#L186-L199 | go | train | // closeImportedDescriptors closes imported but unused file descriptors,
// what could happen if service has updated configuration | func (process *TeleportProcess) closeImportedDescriptors(prefix string) error | // closeImportedDescriptors closes imported but unused file descriptors,
// what could happen if service has updated configuration
func (process *TeleportProcess) closeImportedDescriptors(prefix string) error | {
process.Lock()
defer process.Unlock()
var errors []error
for i := range process.importedDescriptors {
d := process.importedDescriptors[i]
if strings.HasPrefix(d.Type, prefix) {
process.Infof("Closing imported but unused descriptor %v %v.", d.Type, d.Address)
errors = append(errors, d.File.Close())
}
}
return trace.NewAggregate(errors...)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/signals.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/signals.go#L203-L214 | go | train | // importOrCreateListener imports listener passed by the parent process (happens during live reload)
// or creates a new listener if there was no listener registered | func (process *TeleportProcess) importOrCreateListener(listenerType, address string) (net.Listener, error) | // importOrCreateListener imports listener passed by the parent process (happens during live reload)
// or creates a new listener if there was no listener registered
func (process *TeleportProcess) importOrCreateListener(listenerType, address string) (net.Listener, error) | {
l, err := process.importListener(listenerType, address)
if err == nil {
process.Infof("Using file descriptor %v %v passed by the parent process.", listenerType, address)
return l, nil
}
if !trace.IsNotFound(err) {
return nil, trace.Wrap(err)
}
process.Infof("Service %v is creating new listener on %v.", listenerType, address)
return process.createListener(listenerType, address)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/signals.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/signals.go#L233-L251 | go | train | // importListener imports listener passed by the parent process, if no listener is found
// returns NotFound, otherwise removes the file from the list | func (process *TeleportProcess) importListener(listenerType, address string) (net.Listener, error) | // importListener imports listener passed by the parent process, if no listener is found
// returns NotFound, otherwise removes the file from the list
func (process *TeleportProcess) importListener(listenerType, address string) (net.Listener, error) | {
process.Lock()
defer process.Unlock()
for i := range process.importedDescriptors {
d := process.importedDescriptors[i]
if d.Type == listenerType && d.Address == address {
l, err := d.ToListener()
if err != nil {
return nil, trace.Wrap(err)
}
process.importedDescriptors = append(process.importedDescriptors[:i], process.importedDescriptors[i+1:]...)
process.registeredListeners = append(process.registeredListeners, RegisteredListener{Type: listenerType, Address: address, Listener: l})
return l, nil
}
}
return nil, trace.NotFound("no file descriptor for type %v and address %v has been imported", listenerType, address)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/signals.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/signals.go#L254-L264 | go | train | // createListener creates listener and adds to a list of tracked listeners | func (process *TeleportProcess) createListener(listenerType, address string) (net.Listener, error) | // createListener creates listener and adds to a list of tracked listeners
func (process *TeleportProcess) createListener(listenerType, address string) (net.Listener, error) | {
listener, err := net.Listen("tcp", address)
if err != nil {
return nil, trace.Wrap(err)
}
process.Lock()
defer process.Unlock()
r := RegisteredListener{Type: listenerType, Address: address, Listener: listener}
process.registeredListeners = append(process.registeredListeners, r)
return listener, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/signals.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/signals.go#L267-L279 | go | train | // ExportFileDescriptors exports file descriptors to be passed to child process | func (process *TeleportProcess) ExportFileDescriptors() ([]FileDescriptor, error) | // ExportFileDescriptors exports file descriptors to be passed to child process
func (process *TeleportProcess) ExportFileDescriptors() ([]FileDescriptor, error) | {
var out []FileDescriptor
process.Lock()
defer process.Unlock()
for _, r := range process.registeredListeners {
file, err := utils.GetListenerFile(r.Listener)
if err != nil {
return nil, trace.Wrap(err)
}
out = append(out, FileDescriptor{File: file, Type: r.Type, Address: r.Address})
}
return out, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/signals.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/signals.go#L282-L299 | go | train | // importFileDescriptors imports file descriptors from environment if there are any | func importFileDescriptors() ([]FileDescriptor, error) | // importFileDescriptors imports file descriptors from environment if there are any
func importFileDescriptors() ([]FileDescriptor, error) | {
// These files may be passed in by the parent process
filesString := os.Getenv(teleportFilesEnvVar)
if filesString == "" {
return nil, nil
}
files, err := filesFromString(filesString)
if err != nil {
return nil, trace.BadParameter("child process has failed to read files, error %q", err)
}
if len(files) != 0 {
log.Infof("Child has been passed files: %v", files)
}
return files, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/service/signals.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/service/signals.go#L491-L508 | go | train | // collectStatuses attempts to collect exit statuses from
// forked teleport child processes.
// If forked teleport process exited with an error during graceful
// restart, parent process has to collect the child process status
// otherwise the child process will become a zombie process.
// Call Wait4(-1) is trying to collect status of any child
// leads to warnings in logs, because other parts of the program could
// have tried to collect the status of this process.
// Instead this logic tries to collect statuses of the processes
// forked during restart procedure. | func (process *TeleportProcess) collectStatuses() | // collectStatuses attempts to collect exit statuses from
// forked teleport child processes.
// If forked teleport process exited with an error during graceful
// restart, parent process has to collect the child process status
// otherwise the child process will become a zombie process.
// Call Wait4(-1) is trying to collect status of any child
// leads to warnings in logs, because other parts of the program could
// have tried to collect the status of this process.
// Instead this logic tries to collect statuses of the processes
// forked during restart procedure.
func (process *TeleportProcess) collectStatuses() | {
pids := process.getForkedPIDs()
if len(pids) == 0 {
return
}
for _, pid := range pids {
var wait syscall.WaitStatus
rpid, err := syscall.Wait4(pid, &wait, syscall.WNOHANG, nil)
if err != nil {
process.Errorf("Wait call failed: %v.", err)
continue
}
if rpid == pid {
process.popForkedPID(pid)
process.Warningf("Forked teleport process %v has exited with status: %v.", pid, wait.ExitStatus())
}
}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/events/recorder.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/recorder.go#L112-L139 | go | train | // NewForwardRecorder returns a new instance of session recorder | func NewForwardRecorder(cfg ForwardRecorderConfig) (*ForwardRecorder, error) | // NewForwardRecorder returns a new instance of session recorder
func NewForwardRecorder(cfg ForwardRecorderConfig) (*ForwardRecorder, error) | {
if err := cfg.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
// Always write sessions to local disk first, then forward them to the Auth
// Server later.
auditLog, err := NewForwarder(ForwarderConfig{
SessionID: cfg.SessionID,
ServerID: teleport.ComponentUpload,
DataDir: cfg.DataDir,
RecordSessions: cfg.RecordSessions,
Namespace: cfg.Namespace,
ForwardTo: cfg.ForwardTo,
})
if err != nil {
return nil, trace.Wrap(err)
}
sr := &ForwardRecorder{
ForwardRecorderConfig: cfg,
Entry: logrus.WithFields(logrus.Fields{
trace.Component: cfg.Component,
}),
AuditLog: auditLog,
}
return sr, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/events/recorder.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/recorder.go#L147-L169 | go | train | // Write takes a chunk and writes it into the audit log | func (r *ForwardRecorder) Write(data []byte) (int, error) | // Write takes a chunk and writes it into the audit log
func (r *ForwardRecorder) Write(data []byte) (int, error) | {
// we are copying buffer to prevent data corruption:
// io.Copy allocates single buffer and calls multiple writes in a loop
// our PostSessionSlice is async and sends reader wrapping buffer
// to the channel. This can lead to cases when the buffer is re-used
// and data is corrupted unless we copy the data buffer in the first place
dataCopy := make([]byte, len(data))
copy(dataCopy, data)
// post the chunk of bytes to the audit log:
chunk := &SessionChunk{
EventType: SessionPrintEvent,
Data: dataCopy,
Time: time.Now().UTC().UnixNano(),
}
if err := r.AuditLog.PostSessionSlice(SessionSlice{
Namespace: r.Namespace,
SessionID: string(r.SessionID),
Chunks: []*SessionChunk{chunk},
}); err != nil {
r.Error(trace.DebugReport(err))
}
return len(data), nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/events/recorder.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/recorder.go#L172-L191 | go | train | // Close closes audit log session recorder | func (r *ForwardRecorder) Close() error | // Close closes audit log session recorder
func (r *ForwardRecorder) Close() error | {
var errors []error
err := r.AuditLog.Close()
errors = append(errors, err)
// wait until all events from recorder get flushed, it is important
// to do so before we send SessionEndEvent to advise the audit log
// to release resources associated with this session.
// not doing so will not result in memory leak, but could result
// in missing playback events
context, cancel := context.WithTimeout(context.TODO(), defaults.ReadHeadersTimeout)
defer cancel() // releases resources if slowOperation completes before timeout elapses
err = r.AuditLog.WaitForDelivery(context)
if err != nil {
errors = append(errors, err)
r.Warnf("Timeout waiting for session to flush events: %v", trace.DebugReport(err))
}
return trace.NewAggregate(errors...)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/proto/auth.pb.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/proto/auth.pb.go#L266-L281 | go | train | // XXX_OneofFuncs is for the internal use of the proto package. | func (*Event) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) | // XXX_OneofFuncs is for the internal use of the proto package.
func (*Event) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{}) | {
return _Event_OneofMarshaler, _Event_OneofUnmarshaler, _Event_OneofSizer, []interface{}{
(*Event_ResourceHeader)(nil),
(*Event_CertAuthority)(nil),
(*Event_StaticTokens)(nil),
(*Event_ProvisionToken)(nil),
(*Event_ClusterName)(nil),
(*Event_ClusterConfig)(nil),
(*Event_User)(nil),
(*Event_Role)(nil),
(*Event_Namespace)(nil),
(*Event_Server)(nil),
(*Event_ReverseTunnel)(nil),
(*Event_TunnelConnection)(nil),
}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/backend/helpers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/helpers.go#L30-L51 | go | train | // AcquireLock grabs a lock that will be released automatically in TTL | func AcquireLock(ctx context.Context, backend Backend, lockName string, ttl time.Duration) (err error) | // AcquireLock grabs a lock that will be released automatically in TTL
func AcquireLock(ctx context.Context, backend Backend, lockName string, ttl time.Duration) (err error) | {
if lockName == "" {
return trace.BadParameter("missing parameter lock name")
}
key := []byte(filepath.Join(locksPrefix, lockName))
for {
// Get will clear TTL on a lock
backend.Get(ctx, key)
// CreateVal is atomic:
_, err = backend.Create(ctx, Item{Key: key, Value: []byte{1}, Expires: backend.Clock().Now().UTC().Add(ttl)})
if err == nil {
break // success
}
if trace.IsAlreadyExists(err) { // locked? wait and repeat:
backend.Clock().Sleep(250 * time.Millisecond)
continue
}
return trace.ConvertSystemError(err)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/backend/helpers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/backend/helpers.go#L54-L63 | go | train | // ReleaseLock forces lock release | func ReleaseLock(ctx context.Context, backend Backend, lockName string) error | // ReleaseLock forces lock release
func ReleaseLock(ctx context.Context, backend Backend, lockName string) error | {
if lockName == "" {
return trace.BadParameter("missing parameter lockName")
}
key := []byte(filepath.Join(locksPrefix, lockName))
if err := backend.Delete(ctx, key); err != nil {
return trace.Wrap(err)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L57-L71 | go | train | // Check checks parameters for errors | func (c *HostCertParams) Check() error | // Check checks parameters for errors
func (c *HostCertParams) Check() error | {
if c.HostID == "" && len(c.Principals) == 0 {
return trace.BadParameter("HostID [%q] or Principals [%q] are required",
c.HostID, c.Principals)
}
if c.ClusterName == "" {
return trace.BadParameter("ClusterName [%q] is required", c.ClusterName)
}
if err := c.Roles.Check(); err != nil {
return trace.Wrap(err)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L133-L139 | go | train | // MarshalCertRoles marshal roles list to OpenSSH | func MarshalCertRoles(roles []string) (string, error) | // MarshalCertRoles marshal roles list to OpenSSH
func MarshalCertRoles(roles []string) (string, error) | {
out, err := json.Marshal(CertRoles{Version: V1, Roles: roles})
if err != nil {
return "", trace.Wrap(err)
}
return string(out), err
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L142-L148 | go | train | // UnmarshalCertRoles marshals roles list to OpenSSH | func UnmarshalCertRoles(data string) ([]string, error) | // UnmarshalCertRoles marshals roles list to OpenSSH
func UnmarshalCertRoles(data string) ([]string, error) | {
var certRoles CertRoles
if err := utils.UnmarshalWithSchema(CertRolesSchema, &certRoles, []byte(data)); err != nil {
return nil, trace.BadParameter(err.Error())
}
return certRoles.Roles, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L217-L234 | go | train | // CertPoolFromCertAuthorities returns certificate pools from TLS certificates
// set up in the certificate authorities list | func CertPoolFromCertAuthorities(cas []CertAuthority) (*x509.CertPool, error) | // CertPoolFromCertAuthorities returns certificate pools from TLS certificates
// set up in the certificate authorities list
func CertPoolFromCertAuthorities(cas []CertAuthority) (*x509.CertPool, error) | {
certPool := x509.NewCertPool()
for _, ca := range cas {
keyPairs := ca.GetTLSKeyPairs()
if len(keyPairs) == 0 {
continue
}
for _, keyPair := range keyPairs {
cert, err := tlsca.ParseCertificatePEM(keyPair.Cert)
if err != nil {
return nil, trace.Wrap(err)
}
certPool.AddCert(cert)
}
return certPool, nil
}
return certPool, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L255-L262 | go | train | // TLSCerts returns TLS certificates from CA | func TLSCerts(ca CertAuthority) [][]byte | // TLSCerts returns TLS certificates from CA
func TLSCerts(ca CertAuthority) [][]byte | {
pairs := ca.GetTLSKeyPairs()
out := make([][]byte, len(pairs))
for i, pair := range pairs {
out[i] = append([]byte{}, pair.Cert...)
}
return out
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L265-L282 | go | train | // NewCertAuthority returns new cert authority | func NewCertAuthority(caType CertAuthType, clusterName string, signingKeys, checkingKeys [][]byte, roles []string) CertAuthority | // NewCertAuthority returns new cert authority
func NewCertAuthority(caType CertAuthType, clusterName string, signingKeys, checkingKeys [][]byte, roles []string) CertAuthority | {
return &CertAuthorityV2{
Kind: KindCertAuthority,
Version: V2,
SubKind: string(caType),
Metadata: Metadata{
Name: clusterName,
Namespace: defaults.Namespace,
},
Spec: CertAuthoritySpecV2{
Roles: roles,
Type: caType,
ClusterName: clusterName,
CheckingKeys: checkingKeys,
SigningKeys: signingKeys,
},
}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L285-L298 | go | train | // CertAuthoritiesToV1 converts list of cert authorities to V1 slice | func CertAuthoritiesToV1(in []CertAuthority) ([]CertAuthorityV1, error) | // CertAuthoritiesToV1 converts list of cert authorities to V1 slice
func CertAuthoritiesToV1(in []CertAuthority) ([]CertAuthorityV1, error) | {
out := make([]CertAuthorityV1, len(in))
type cav1 interface {
V1() *CertAuthorityV1
}
for i, ca := range in {
v1, ok := ca.(cav1)
if !ok {
return nil, trace.BadParameter("could not transform object to V1")
}
out[i] = *(v1.V1())
}
return out, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L321-L333 | go | train | // Clone returns a copy of the cert authority object. | func (c *CertAuthorityV2) Clone() CertAuthority | // Clone returns a copy of the cert authority object.
func (c *CertAuthorityV2) Clone() CertAuthority | {
out := *c
out.Spec.CheckingKeys = utils.CopyByteSlices(c.Spec.CheckingKeys)
out.Spec.SigningKeys = utils.CopyByteSlices(c.Spec.SigningKeys)
for i, kp := range c.Spec.TLSKeyPairs {
out.Spec.TLSKeyPairs[i] = TLSKeyPair{
Key: utils.CopyByteSlice(kp.Key),
Cert: utils.CopyByteSlice(kp.Cert),
}
}
out.Spec.Roles = utils.CopyStrings(c.Spec.Roles)
return &out
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L336-L341 | go | train | // GetRotation returns rotation state. | func (c *CertAuthorityV2) GetRotation() Rotation | // GetRotation returns rotation state.
func (c *CertAuthorityV2) GetRotation() Rotation | {
if c.Spec.Rotation == nil {
return Rotation{}
}
return *c.Spec.Rotation
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L349-L354 | go | train | // TLSCA returns TLS certificate authority | func (c *CertAuthorityV2) TLSCA() (*tlsca.CertAuthority, error) | // TLSCA returns TLS certificate authority
func (c *CertAuthorityV2) TLSCA() (*tlsca.CertAuthority, error) | {
if len(c.Spec.TLSKeyPairs) == 0 {
return nil, trace.BadParameter("no TLS key pairs found for certificate authority")
}
return tlsca.New(c.Spec.TLSKeyPairs[0].Cert, c.Spec.TLSKeyPairs[0].Key)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L372-L374 | go | train | // SetExpiry sets expiry time for the object | func (c *CertAuthorityV2) SetExpiry(expires time.Time) | // SetExpiry sets expiry time for the object
func (c *CertAuthorityV2) SetExpiry(expires time.Time) | {
c.Metadata.SetExpiry(expires)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L402-L404 | go | train | // String returns human readable version of the CertAuthorityV2. | func (c *CertAuthorityV2) String() string | // String returns human readable version of the CertAuthorityV2.
func (c *CertAuthorityV2) String() string | {
return fmt.Sprintf("CA(name=%v, type=%v)", c.GetClusterName(), c.GetType())
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L407-L414 | go | train | // V1 returns V1 version of the object | func (c *CertAuthorityV2) V1() *CertAuthorityV1 | // V1 returns V1 version of the object
func (c *CertAuthorityV2) V1() *CertAuthorityV1 | {
return &CertAuthorityV1{
Type: c.Spec.Type,
DomainName: c.Spec.ClusterName,
CheckingKeys: c.Spec.CheckingKeys,
SigningKeys: c.Spec.SigningKeys,
}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L417-L424 | go | train | // AddRole adds a role to ca role list | func (ca *CertAuthorityV2) AddRole(name string) | // AddRole adds a role to ca role list
func (ca *CertAuthorityV2) AddRole(name string) | {
for _, r := range ca.Spec.Roles {
if r == name {
return
}
}
ca.Spec.Roles = append(ca.Spec.Roles, name)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L432-L435 | go | train | // SetSigningKeys sets signing keys | func (ca *CertAuthorityV2) SetSigningKeys(keys [][]byte) error | // SetSigningKeys sets signing keys
func (ca *CertAuthorityV2) SetSigningKeys(keys [][]byte) error | {
ca.Spec.SigningKeys = keys
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L438-L441 | go | train | // SetCheckingKeys sets SSH public keys | func (ca *CertAuthorityV2) SetCheckingKeys(keys [][]byte) error | // SetCheckingKeys sets SSH public keys
func (ca *CertAuthorityV2) SetCheckingKeys(keys [][]byte) error | {
ca.Spec.CheckingKeys = keys
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L445-L447 | go | train | // GetID returns certificate authority ID -
// combined type and name | func (ca *CertAuthorityV2) GetID() CertAuthID | // GetID returns certificate authority ID -
// combined type and name
func (ca *CertAuthorityV2) GetID() CertAuthID | {
return CertAuthID{Type: ca.Spec.Type, DomainName: ca.Metadata.Name}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L487-L492 | go | train | // CombinedMapping is used to specify combined mapping from legacy property Roles
// and new property RoleMap | func (ca *CertAuthorityV2) CombinedMapping() RoleMap | // CombinedMapping is used to specify combined mapping from legacy property Roles
// and new property RoleMap
func (ca *CertAuthorityV2) CombinedMapping() RoleMap | {
if len(ca.Spec.Roles) != 0 {
return RoleMap([]RoleMapping{{Remote: Wildcard, Local: ca.Spec.Roles}})
}
return RoleMap(ca.Spec.RoleMap)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L500-L502 | go | train | // SetRoleMap sets role map | func (c *CertAuthorityV2) SetRoleMap(m RoleMap) | // SetRoleMap sets role map
func (c *CertAuthorityV2) SetRoleMap(m RoleMap) | {
c.Spec.RoleMap = []RoleMapping(m)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L505-L510 | go | train | // FirstSigningKey returns first signing key or returns error if it's not here | func (ca *CertAuthorityV2) FirstSigningKey() ([]byte, error) | // FirstSigningKey returns first signing key or returns error if it's not here
func (ca *CertAuthorityV2) FirstSigningKey() ([]byte, error) | {
if len(ca.Spec.SigningKeys) == 0 {
return nil, trace.NotFound("%v has no signing keys", ca.Metadata.Name)
}
return ca.Spec.SigningKeys[0], nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L514-L516 | go | train | // ID returns id (consisting of domain name and type) that
// identifies the authority this key belongs to | func (ca *CertAuthorityV2) ID() *CertAuthID | // ID returns id (consisting of domain name and type) that
// identifies the authority this key belongs to
func (ca *CertAuthorityV2) ID() *CertAuthID | {
return &CertAuthID{DomainName: ca.Spec.ClusterName, Type: ca.Spec.Type}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L519-L529 | go | train | // Checkers returns public keys that can be used to check cert authorities | func (ca *CertAuthorityV2) Checkers() ([]ssh.PublicKey, error) | // Checkers returns public keys that can be used to check cert authorities
func (ca *CertAuthorityV2) Checkers() ([]ssh.PublicKey, error) | {
out := make([]ssh.PublicKey, 0, len(ca.Spec.CheckingKeys))
for _, keyBytes := range ca.Spec.CheckingKeys {
key, _, _, _, err := ssh.ParseAuthorizedKey(keyBytes)
if err != nil {
return nil, trace.BadParameter("invalid authority public key (len=%d): %v", len(keyBytes), err)
}
out = append(out, key)
}
return out, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L532-L542 | go | train | // Signers returns a list of signers that could be used to sign keys | func (ca *CertAuthorityV2) Signers() ([]ssh.Signer, error) | // Signers returns a list of signers that could be used to sign keys
func (ca *CertAuthorityV2) Signers() ([]ssh.Signer, error) | {
out := make([]ssh.Signer, 0, len(ca.Spec.SigningKeys))
for _, keyBytes := range ca.Spec.SigningKeys {
signer, err := ssh.ParsePrivateKey(keyBytes)
if err != nil {
return nil, trace.Wrap(err)
}
out = append(out, signer)
}
return out, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L545-L566 | go | train | // Check checks if all passed parameters are valid | func (ca *CertAuthorityV2) Check() error | // Check checks if all passed parameters are valid
func (ca *CertAuthorityV2) Check() error | {
err := ca.ID().Check()
if err != nil {
return trace.Wrap(err)
}
_, err = ca.Checkers()
if err != nil {
return trace.Wrap(err)
}
_, err = ca.Signers()
if err != nil {
return trace.Wrap(err)
}
// This is to force users to migrate
if len(ca.Spec.Roles) != 0 && len(ca.Spec.RoleMap) != 0 {
return trace.BadParameter("should set either 'roles' or 'role_map', not both")
}
if err := RoleMap(ca.Spec.RoleMap).Check(); err != nil {
return trace.Wrap(err)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L569-L581 | go | train | // CheckAndSetDefaults checks and set default values for any missing fields. | func (ca *CertAuthorityV2) CheckAndSetDefaults() error | // CheckAndSetDefaults checks and set default values for any missing fields.
func (ca *CertAuthorityV2) CheckAndSetDefaults() error | {
err := ca.Metadata.CheckAndSetDefaults()
if err != nil {
return trace.Wrap(err)
}
err = ca.Check()
if err != nil {
return trace.Wrap(err)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L585-L592 | go | train | // RemoveCASecrets removes secret values and keys
// from the certificate authority | func RemoveCASecrets(ca CertAuthority) | // RemoveCASecrets removes secret values and keys
// from the certificate authority
func RemoveCASecrets(ca CertAuthority) | {
ca.SetSigningKeys(nil)
keyPairs := ca.GetTLSKeyPairs()
for i := range keyPairs {
keyPairs[i].Key = nil
}
ca.SetTLSKeyPairs(keyPairs)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L641-L643 | go | train | // Matches returns true if this state rotation matches
// external rotation state, phase and rotation ID should match,
// notice that matches does not behave like Equals because it does not require
// all fields to be the same. | func (s *Rotation) Matches(rotation Rotation) bool | // Matches returns true if this state rotation matches
// external rotation state, phase and rotation ID should match,
// notice that matches does not behave like Equals because it does not require
// all fields to be the same.
func (s *Rotation) Matches(rotation Rotation) bool | {
return s.CurrentID == rotation.CurrentID && s.State == rotation.State && s.Phase == rotation.Phase
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L646-L651 | go | train | // LastRotatedDescription returns human friendly description. | func (r *Rotation) LastRotatedDescription() string | // LastRotatedDescription returns human friendly description.
func (r *Rotation) LastRotatedDescription() string | {
if r.LastRotated.IsZero() {
return "never updated"
}
return fmt.Sprintf("last rotated %v", r.LastRotated.Format(teleport.HumanDateFormatSeconds))
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L654-L669 | go | train | // PhaseDescription returns human friendly description of a current rotation phase. | func (r *Rotation) PhaseDescription() string | // PhaseDescription returns human friendly description of a current rotation phase.
func (r *Rotation) PhaseDescription() string | {
switch r.Phase {
case RotationPhaseInit:
return "initialized"
case RotationPhaseStandby, "":
return "on standby"
case RotationPhaseUpdateClients:
return "rotating clients"
case RotationPhaseUpdateServers:
return "rotating servers"
case RotationPhaseRollback:
return "rolling back"
default:
return fmt.Sprintf("unknown phase: %q", r.Phase)
}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L672-L689 | go | train | // String returns user friendly information about certificate authority. | func (r *Rotation) String() string | // String returns user friendly information about certificate authority.
func (r *Rotation) String() string | {
switch r.State {
case "", RotationStateStandby:
if r.LastRotated.IsZero() {
return "never updated"
}
return fmt.Sprintf("rotated %v", r.LastRotated.Format(teleport.HumanDateFormatSeconds))
case RotationStateInProgress:
return fmt.Sprintf("%v (mode: %v, started: %v, ending: %v)",
r.PhaseDescription(),
r.Mode,
r.Started.Format(teleport.HumanDateFormatSeconds),
r.Started.Add(r.GracePeriod.Duration()).Format(teleport.HumanDateFormatSeconds),
)
default:
return "unknown"
}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L692-L720 | go | train | // CheckAndSetDefaults checks and sets default rotation parameters. | func (r *Rotation) CheckAndSetDefaults(clock clockwork.Clock) error | // CheckAndSetDefaults checks and sets default rotation parameters.
func (r *Rotation) CheckAndSetDefaults(clock clockwork.Clock) error | {
switch r.Phase {
case "", RotationPhaseRollback, RotationPhaseUpdateClients, RotationPhaseUpdateServers:
default:
return trace.BadParameter("unsupported phase: %q", r.Phase)
}
switch r.Mode {
case "", RotationModeAuto, RotationModeManual:
default:
return trace.BadParameter("unsupported mode: %q", r.Mode)
}
switch r.State {
case "":
r.State = RotationStateStandby
case RotationStateStandby:
case RotationStateInProgress:
if r.CurrentID == "" {
return trace.BadParameter("set 'current_id' parameter for in progress rotation")
}
if r.Started.IsZero() {
return trace.BadParameter("set 'started' parameter for in progress rotation")
}
default:
return trace.BadParameter(
"unsupported rotation 'state': %q, supported states are: %q, %q",
r.State, RotationStateStandby, RotationStateInProgress)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L724-L733 | go | train | // GenerateSchedule generates schedule based on the time period, using
// even time periods between rotation phases. | func GenerateSchedule(clock clockwork.Clock, gracePeriod time.Duration) (*RotationSchedule, error) | // GenerateSchedule generates schedule based on the time period, using
// even time periods between rotation phases.
func GenerateSchedule(clock clockwork.Clock, gracePeriod time.Duration) (*RotationSchedule, error) | {
if gracePeriod <= 0 {
return nil, trace.BadParameter("invalid grace period %q, provide value > 0", gracePeriod)
}
return &RotationSchedule{
UpdateClients: clock.Now().UTC().Add(gracePeriod / 3).UTC(),
UpdateServers: clock.Now().UTC().Add((gracePeriod * 2) / 3).UTC(),
Standby: clock.Now().UTC().Add(gracePeriod).UTC(),
}, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L736-L753 | go | train | // CheckAndSetDefaults checks and sets default values of the rotation schedule. | func (s *RotationSchedule) CheckAndSetDefaults(clock clockwork.Clock) error | // CheckAndSetDefaults checks and sets default values of the rotation schedule.
func (s *RotationSchedule) CheckAndSetDefaults(clock clockwork.Clock) error | {
if s.UpdateServers.IsZero() {
return trace.BadParameter("phase %q has no time switch scheduled", RotationPhaseUpdateServers)
}
if s.Standby.IsZero() {
return trace.BadParameter("phase %q has no time switch scheduled", RotationPhaseStandby)
}
if s.Standby.Before(s.UpdateServers) {
return trace.BadParameter("phase %q can not be scheduled before %q", RotationPhaseStandby, RotationPhaseUpdateServers)
}
if s.UpdateServers.Before(clock.Now()) {
return trace.BadParameter("phase %q can not be scheduled in the past", RotationPhaseUpdateServers)
}
if s.Standby.Before(clock.Now()) {
return trace.BadParameter("phase %q can not be scheduled in the past", RotationPhaseStandby)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L860-L875 | go | train | // V2 returns V2 version of the resource | func (c *CertAuthorityV1) V2() *CertAuthorityV2 | // V2 returns V2 version of the resource
func (c *CertAuthorityV1) V2() *CertAuthorityV2 | {
return &CertAuthorityV2{
Kind: KindCertAuthority,
Version: V2,
Metadata: Metadata{
Name: c.DomainName,
Namespace: defaults.Namespace,
},
Spec: CertAuthoritySpecV2{
Type: c.Type,
ClusterName: c.DomainName,
CheckingKeys: c.CheckingKeys,
SigningKeys: c.SigningKeys,
},
}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L878-L880 | go | train | // String returns human readable version of the CertAuthorityV1. | func (c *CertAuthorityV1) String() string | // String returns human readable version of the CertAuthorityV1.
func (c *CertAuthorityV1) String() string | {
return fmt.Sprintf("CA(name=%v, type=%v)", c.DomainName, c.Type)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L912-L914 | go | train | // GetCertAuthoritySchema returns JSON Schema for cert authorities | func GetCertAuthoritySchema() string | // GetCertAuthoritySchema returns JSON Schema for cert authorities
func GetCertAuthoritySchema() string | {
return fmt.Sprintf(V2SchemaTemplate, MetadataSchema, fmt.Sprintf(CertAuthoritySpecV2Schema, RotationSchema, RoleMapSchema), DefaultDefinitions)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L926-L965 | go | train | // UnmarshalCertAuthority unmarshals cert authority from JSON | func (*TeleportCertAuthorityMarshaler) UnmarshalCertAuthority(bytes []byte, opts ...MarshalOption) (CertAuthority, error) | // UnmarshalCertAuthority unmarshals cert authority from JSON
func (*TeleportCertAuthorityMarshaler) UnmarshalCertAuthority(bytes []byte, opts ...MarshalOption) (CertAuthority, error) | {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
var h ResourceHeader
err = utils.FastUnmarshal(bytes, &h)
if err != nil {
return nil, trace.Wrap(err)
}
switch h.Version {
case "":
var ca CertAuthorityV1
err := json.Unmarshal(bytes, &ca)
if err != nil {
return nil, trace.Wrap(err)
}
return ca.V2(), nil
case V2:
var ca CertAuthorityV2
if cfg.SkipValidation {
if err := utils.FastUnmarshal(bytes, &ca); err != nil {
return nil, trace.BadParameter(err.Error())
}
} else {
if err := utils.UnmarshalWithSchema(GetCertAuthoritySchema(), &ca, bytes); err != nil {
return nil, trace.BadParameter(err.Error())
}
}
if err := ca.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
if cfg.ID != 0 {
ca.SetResourceID(cfg.ID)
}
return &ca, nil
}
return nil, trace.BadParameter("cert authority resource version %v is not supported", h.Version)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/authority.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/authority.go#L968-L1005 | go | train | // MarshalCertAuthority marshalls cert authority into JSON | func (*TeleportCertAuthorityMarshaler) MarshalCertAuthority(ca CertAuthority, opts ...MarshalOption) ([]byte, error) | // MarshalCertAuthority marshalls cert authority into JSON
func (*TeleportCertAuthorityMarshaler) MarshalCertAuthority(ca CertAuthority, opts ...MarshalOption) ([]byte, error) | {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
type cav1 interface {
V1() *CertAuthorityV1
}
type cav2 interface {
V2() *CertAuthorityV2
}
version := cfg.GetVersion()
switch version {
case V1:
v, ok := ca.(cav1)
if !ok {
return nil, trace.BadParameter("don't know how to marshal %v", V1)
}
return utils.FastMarshal(v.V1())
case V2:
v, ok := ca.(cav2)
if !ok {
return nil, trace.BadParameter("don't know how to marshal %v", V2)
}
v2 := v.V2()
if !cfg.PreserveResourceID {
// avoid modifying the original object
// to prevent unexpected data races
copy := *v2
copy.SetResourceID(0)
v2 = ©
}
return utils.FastMarshal(v2)
default:
return nil, trace.BadParameter("version %v is not supported", version)
}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/events/fields.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/fields.go#L32-L50 | go | train | // UpdateEventFields updates passed event fields with additional information
// common for all event types such as unique IDs, timestamps, codes, etc.
//
// This method is a "final stop" for various audit log implementations for
// updating event fields before it gets persisted in the backend. | func UpdateEventFields(event Event, fields EventFields, clock clockwork.Clock, uid utils.UID) (err error) | // UpdateEventFields updates passed event fields with additional information
// common for all event types such as unique IDs, timestamps, codes, etc.
//
// This method is a "final stop" for various audit log implementations for
// updating event fields before it gets persisted in the backend.
func UpdateEventFields(event Event, fields EventFields, clock clockwork.Clock, uid utils.UID) (err error) | {
additionalFields := make(map[string]interface{})
if fields.GetType() == "" {
additionalFields[EventType] = event.Name
}
if fields.GetID() == "" {
additionalFields[EventID] = uid.New()
}
if fields.GetTimestamp().IsZero() {
additionalFields[EventTime] = clock.Now().UTC().Round(time.Second)
}
if event.Code != "" {
additionalFields[EventCode] = event.Code
}
for k, v := range additionalFields {
fields[k] = v
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/reversetunnel/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/reversetunnel/api.go#L54-L63 | go | train | // CheckAndSetDefaults makes sure the minimal parameters are set. | func (d *DialParams) CheckAndSetDefaults() error | // CheckAndSetDefaults makes sure the minimal parameters are set.
func (d *DialParams) CheckAndSetDefaults() error | {
if d.From == nil {
return trace.BadParameter("parameter From required")
}
if d.To == nil {
return trace.BadParameter("parameter To required")
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L71-L81 | go | train | // NewTrustedCluster is a convenience wa to create a TrustedCluster resource. | func NewTrustedCluster(name string, spec TrustedClusterSpecV2) (TrustedCluster, error) | // NewTrustedCluster is a convenience wa to create a TrustedCluster resource.
func NewTrustedCluster(name string, spec TrustedClusterSpecV2) (TrustedCluster, error) | {
return &TrustedClusterV2{
Kind: KindTrustedCluster,
Version: V2,
Metadata: Metadata{
Name: name,
Namespace: defaults.Namespace,
},
Spec: spec,
}, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L131-L141 | go | train | // Equals checks if the two role maps are equal. | func (r RoleMap) Equals(o RoleMap) bool | // Equals checks if the two role maps are equal.
func (r RoleMap) Equals(o RoleMap) bool | {
if len(r) != len(o) {
return false
}
for i := range r {
if !r[i].Equals(o[i]) {
return false
}
}
return true
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L144-L153 | go | train | // String prints user friendly representation of role mapping | func (r RoleMap) String() string | // String prints user friendly representation of role mapping
func (r RoleMap) String() string | {
values, err := r.parse()
if err != nil {
return fmt.Sprintf("<failed to parse: %v", err)
}
if len(values) != 0 {
return fmt.Sprintf("%v", values)
}
return "<empty>"
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L187-L224 | go | train | // Map maps local roles to remote roles | func (r RoleMap) Map(remoteRoles []string) ([]string, error) | // Map maps local roles to remote roles
func (r RoleMap) Map(remoteRoles []string) ([]string, error) | {
_, err := r.parse()
if err != nil {
return nil, trace.Wrap(err)
}
var outRoles []string
// when no remote roles is specified, assume that
// there is a single empty remote role (that should match wildcards)
if len(remoteRoles) == 0 {
remoteRoles = []string{""}
}
for _, mapping := range r {
expression := mapping.Remote
for _, remoteRole := range remoteRoles {
// never map default implicit role, it is always
// added by default
if remoteRole == teleport.DefaultImplicitRole {
continue
}
for _, replacementRole := range mapping.Local {
replacement, err := utils.ReplaceRegexp(expression, replacementRole, remoteRole)
switch {
case err == nil:
// empty replacement can occur when $2 expand refers
// to non-existing capture group in match expression
if replacement != "" {
outRoles = append(outRoles, replacement)
}
case trace.IsNotFound(err):
continue
default:
return nil, trace.Wrap(err)
}
}
}
}
return outRoles, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L227-L230 | go | train | // Check checks RoleMap for errors | func (r RoleMap) Check() error | // Check checks RoleMap for errors
func (r RoleMap) Check() error | {
_, err := r.parse()
return trace.Wrap(err)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L233-L241 | go | train | // Equals checks if the two role mappings are equal. | func (r RoleMapping) Equals(o RoleMapping) bool | // Equals checks if the two role mappings are equal.
func (r RoleMapping) Equals(o RoleMapping) bool | {
if r.Remote != o.Remote {
return false
}
if !utils.StringSlicesEqual(r.Local, r.Local) {
return false
}
return true
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L244-L275 | go | train | // Check checks validity of all parameters and sets defaults | func (c *TrustedClusterV2) CheckAndSetDefaults() error | // Check checks validity of all parameters and sets defaults
func (c *TrustedClusterV2) CheckAndSetDefaults() error | {
// make sure we have defaults for all fields
if err := c.Metadata.CheckAndSetDefaults(); err != nil {
return trace.Wrap(err)
}
// This is to force users to migrate
if len(c.Spec.Roles) != 0 && len(c.Spec.RoleMap) != 0 {
return trace.BadParameter("should set either 'roles' or 'role_map', not both")
}
// we are not mentioning Roles parameter because we are deprecating it
if len(c.Spec.Roles) == 0 && len(c.Spec.RoleMap) == 0 {
if err := modules.GetModules().EmptyRolesHandler(); err != nil {
return trace.Wrap(err)
}
// OSS teleport uses 'admin' by default:
c.Spec.RoleMap = RoleMap{
RoleMapping{
Remote: teleport.AdminRoleName,
Local: []string{teleport.AdminRoleName},
},
}
}
// Imply that by default proxy listens on the same port for
// web and reverse tunnel connections
if c.Spec.ReverseTunnelAddress == "" {
c.Spec.ReverseTunnelAddress = c.Spec.ProxyAddress
}
if err := c.Spec.RoleMap.Check(); err != nil {
return trace.Wrap(err)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L309-L314 | go | train | // CombinedMapping is used to specify combined mapping from legacy property Roles
// and new property RoleMap | func (c *TrustedClusterV2) CombinedMapping() RoleMap | // CombinedMapping is used to specify combined mapping from legacy property Roles
// and new property RoleMap
func (c *TrustedClusterV2) CombinedMapping() RoleMap | {
if len(c.Spec.Roles) != 0 {
return []RoleMapping{{Remote: Wildcard, Local: c.Spec.Roles}}
}
return c.Spec.RoleMap
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L332-L334 | go | train | // SetExpiry sets expiry time for the object | func (c *TrustedClusterV2) SetExpiry(expires time.Time) | // SetExpiry sets expiry time for the object
func (c *TrustedClusterV2) SetExpiry(expires time.Time) | {
c.Metadata.SetExpiry(expires)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L408-L433 | go | train | // CanChangeState checks if the state change is allowed or not. If not, returns
// an error explaining the reason. | func (c *TrustedClusterV2) CanChangeStateTo(t TrustedCluster) error | // CanChangeState checks if the state change is allowed or not. If not, returns
// an error explaining the reason.
func (c *TrustedClusterV2) CanChangeStateTo(t TrustedCluster) error | {
if c.GetToken() != t.GetToken() {
return trace.BadParameter("can not update token for existing trusted cluster")
}
if c.GetProxyAddress() != t.GetProxyAddress() {
return trace.BadParameter("can not update proxy address for existing trusted cluster")
}
if c.GetReverseTunnelAddress() != t.GetReverseTunnelAddress() {
return trace.BadParameter("can not update proxy address for existing trusted cluster")
}
if !utils.StringSlicesEqual(c.GetRoles(), t.GetRoles()) {
return trace.BadParameter("can not update roles for existing trusted cluster")
}
if !c.GetRoleMap().Equals(t.GetRoleMap()) {
return trace.BadParameter("can not update role map for existing trusted cluster")
}
if c.GetEnabled() == t.GetEnabled() {
if t.GetEnabled() == true {
return trace.AlreadyExists("trusted cluster is already enabled")
}
return trace.AlreadyExists("trusted cluster state is already disabled")
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L436-L439 | go | train | // String represents a human readable version of trusted cluster settings. | func (c *TrustedClusterV2) String() string | // String represents a human readable version of trusted cluster settings.
func (c *TrustedClusterV2) String() string | {
return fmt.Sprintf("TrustedCluster(Enabled=%v,Roles=%v,Token=%v,ProxyAddress=%v,ReverseTunnelAddress=%v)",
c.Spec.Enabled, c.Spec.Roles, c.Spec.Token, c.Spec.ProxyAddress, c.Spec.ReverseTunnelAddress)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L480-L488 | go | train | // GetTrustedClusterSchema returns the schema with optionally injected
// schema for extensions. | func GetTrustedClusterSchema(extensionSchema string) string | // GetTrustedClusterSchema returns the schema with optionally injected
// schema for extensions.
func GetTrustedClusterSchema(extensionSchema string) string | {
var trustedClusterSchema string
if extensionSchema == "" {
trustedClusterSchema = fmt.Sprintf(TrustedClusterSpecSchemaTemplate, RoleMapSchema, "")
} else {
trustedClusterSchema = fmt.Sprintf(TrustedClusterSpecSchemaTemplate, RoleMapSchema, ","+extensionSchema)
}
return fmt.Sprintf(V2SchemaTemplate, MetadataSchema, trustedClusterSchema, DefaultDefinitions)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L514-L547 | go | train | // Unmarshal unmarshals role from JSON or YAML. | func (t *TeleportTrustedClusterMarshaler) Unmarshal(bytes []byte, opts ...MarshalOption) (TrustedCluster, error) | // Unmarshal unmarshals role from JSON or YAML.
func (t *TeleportTrustedClusterMarshaler) Unmarshal(bytes []byte, opts ...MarshalOption) (TrustedCluster, error) | {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
var trustedCluster TrustedClusterV2
if len(bytes) == 0 {
return nil, trace.BadParameter("missing resource data")
}
if cfg.SkipValidation {
if err := utils.FastUnmarshal(bytes, &trustedCluster); err != nil {
return nil, trace.BadParameter(err.Error())
}
} else {
err := utils.UnmarshalWithSchema(GetTrustedClusterSchema(""), &trustedCluster, bytes)
if err != nil {
return nil, trace.BadParameter(err.Error())
}
}
err = trustedCluster.CheckAndSetDefaults()
if err != nil {
return nil, trace.Wrap(err)
}
if cfg.ID != 0 {
trustedCluster.SetResourceID(cfg.ID)
}
if !cfg.Expires.IsZero() {
trustedCluster.SetExpiry(cfg.Expires)
}
return &trustedCluster, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L550-L568 | go | train | // Marshal marshals role to JSON or YAML. | func (t *TeleportTrustedClusterMarshaler) Marshal(c TrustedCluster, opts ...MarshalOption) ([]byte, error) | // Marshal marshals role to JSON or YAML.
func (t *TeleportTrustedClusterMarshaler) Marshal(c TrustedCluster, opts ...MarshalOption) ([]byte, error) | {
cfg, err := collectOptions(opts)
if err != nil {
return nil, trace.Wrap(err)
}
switch resource := c.(type) {
case *TrustedClusterV2:
if !cfg.PreserveResourceID {
// avoid modifying the original object
// to prevent unexpected data races
copy := *resource
copy.SetResourceID(0)
resource = ©
}
return utils.FastMarshal(resource)
default:
return nil, trace.BadParameter("unrecognized resource version %T", c)
}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L579-L581 | go | train | // Less compares items by name. | func (s SortedTrustedCluster) Less(i, j int) bool | // Less compares items by name.
func (s SortedTrustedCluster) Less(i, j int) bool | {
return s[i].GetName() < s[j].GetName()
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/services/trustedcluster.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/services/trustedcluster.go#L584-L586 | go | train | // Swap swaps two items in a list. | func (s SortedTrustedCluster) Swap(i, j int) | // Swap swaps two items in a list.
func (s SortedTrustedCluster) Swap(i, j int) | {
s[i], s[j] = s[j], s[i]
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/profile.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/profile.go#L72-L83 | go | train | // Name returns the name of the profile. | func (c *ClientProfile) Name() string | // Name returns the name of the profile.
func (c *ClientProfile) Name() string | {
if c.ProxyHost != "" {
return c.ProxyHost
}
addr, _, err := net.SplitHostPort(c.WebProxyAddr)
if err != nil {
return c.WebProxyAddr
}
return addr
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/profile.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/profile.go#L88-L100 | go | train | // FullProfilePath returns the full path to the user profile directory.
// If the parameter is empty, it returns expanded "~/.tsh", otherwise
// returns its unmodified parameter | func FullProfilePath(pDir string) string | // FullProfilePath returns the full path to the user profile directory.
// If the parameter is empty, it returns expanded "~/.tsh", otherwise
// returns its unmodified parameter
func FullProfilePath(pDir string) string | {
if pDir != "" {
return pDir
}
// get user home dir:
home := os.TempDir()
u, err := user.Current()
if err == nil {
home = u.HomeDir
}
return filepath.Join(home, ProfileDir)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/profile.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/profile.go#L103-L105 | go | train | // If there's a current profile symlink, remove it | func UnlinkCurrentProfile() error | // If there's a current profile symlink, remove it
func UnlinkCurrentProfile() error | {
return trace.Wrap(os.Remove(filepath.Join(FullProfilePath(""), CurrentProfileSymlink)))
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/profile.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/profile.go#L111-L118 | go | train | // ProfileFromDir reads the user (yaml) profile from a given directory. The
// default is to use the ~/<dir-path>/profile symlink unless another profile
// is explicitly asked for. It works by looking for a "profile" symlink in
// that directory pointing to the profile's YAML file first. | func ProfileFromDir(dirPath string, proxyName string) (*ClientProfile, error) | // ProfileFromDir reads the user (yaml) profile from a given directory. The
// default is to use the ~/<dir-path>/profile symlink unless another profile
// is explicitly asked for. It works by looking for a "profile" symlink in
// that directory pointing to the profile's YAML file first.
func ProfileFromDir(dirPath string, proxyName string) (*ClientProfile, error) | {
profilePath := filepath.Join(dirPath, CurrentProfileSymlink)
if proxyName != "" {
profilePath = filepath.Join(dirPath, proxyName+".yaml")
}
return ProfileFromFile(profilePath)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/profile.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/profile.go#L121-L131 | go | train | // ProfileFromFile loads the profile from a YAML file | func ProfileFromFile(filePath string) (*ClientProfile, error) | // ProfileFromFile loads the profile from a YAML file
func ProfileFromFile(filePath string) (*ClientProfile, error) | {
bytes, err := ioutil.ReadFile(filePath)
if err != nil {
return nil, trace.Wrap(err)
}
var cp *ClientProfile
if err = yaml.Unmarshal(bytes, &cp); err != nil {
return nil, trace.Wrap(err)
}
return cp, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/profile.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/profile.go#L145-L171 | go | train | // SaveTo saves the profile into a given filename, optionally overwriting it. | func (cp *ClientProfile) SaveTo(loc ProfileLocation) error | // SaveTo saves the profile into a given filename, optionally overwriting it.
func (cp *ClientProfile) SaveTo(loc ProfileLocation) error | {
bytes, err := yaml.Marshal(&cp)
if err != nil {
return trace.Wrap(err)
}
if err = ioutil.WriteFile(loc.Path, bytes, 0660); err != nil {
return trace.Wrap(err)
}
if loc.AliasPath != "" && filepath.Base(loc.AliasPath) != filepath.Base(loc.Path) {
if err := os.Remove(loc.AliasPath); err != nil {
log.Warningf("Failed to remove symlink alias: %v", err)
}
err := os.Symlink(filepath.Base(loc.Path), loc.AliasPath)
if err != nil {
log.Warningf("Failed to create profile alias: %v", err)
}
}
// set 'current' symlink:
if loc.Options&ProfileMakeCurrent != 0 {
symlink := filepath.Join(filepath.Dir(loc.Path), CurrentProfileSymlink)
if err := os.Remove(symlink); err != nil {
log.Warningf("Failed to remove symlink: %v", err)
}
err = os.Symlink(filepath.Base(loc.Path), symlink)
}
return trace.Wrap(err)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/helpers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L61-L75 | go | train | // CheckAndSetDefaults checks and sets defaults | func (cfg *TestAuthServerConfig) CheckAndSetDefaults() error | // CheckAndSetDefaults checks and sets defaults
func (cfg *TestAuthServerConfig) CheckAndSetDefaults() error | {
if cfg.ClusterName == "" {
cfg.ClusterName = "localhost"
}
if cfg.Dir == "" {
return trace.BadParameter("missing parameter Dir")
}
if cfg.Clock == nil {
cfg.Clock = clockwork.NewFakeClockAt(time.Now())
}
if len(cfg.CipherSuites) == 0 {
cfg.CipherSuites = utils.DefaultCipherSuites()
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/helpers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L78-L86 | go | train | // CreateUploaderDir creates directory for file uploader service | func CreateUploaderDir(dir string) error | // CreateUploaderDir creates directory for file uploader service
func CreateUploaderDir(dir string) error | {
err := os.MkdirAll(filepath.Join(dir, teleport.LogsDir, teleport.ComponentUpload,
events.SessionLogsDir, defaults.Namespace), teleport.SharedDirMode)
if err != nil {
return trace.ConvertSystemError(err)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/helpers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L251-L293 | go | train | // GenerateCertificate generates certificate for identity,
// returns private public key pair | func GenerateCertificate(authServer *AuthServer, identity TestIdentity) ([]byte, []byte, error) | // GenerateCertificate generates certificate for identity,
// returns private public key pair
func GenerateCertificate(authServer *AuthServer, identity TestIdentity) ([]byte, []byte, error) | {
switch id := identity.I.(type) {
case LocalUser:
user, err := authServer.GetUser(id.Username)
if err != nil {
return nil, nil, trace.Wrap(err)
}
roles, err := services.FetchRoles(user.GetRoles(), authServer, user.GetTraits())
if err != nil {
return nil, nil, trace.Wrap(err)
}
if identity.TTL == 0 {
identity.TTL = time.Hour
}
priv, pub, err := authServer.GenerateKeyPair("")
if err != nil {
return nil, nil, trace.Wrap(err)
}
certs, err := authServer.generateUserCert(certRequest{
publicKey: pub,
user: user,
roles: roles,
ttl: identity.TTL,
usage: identity.AcceptedUsage,
})
if err != nil {
return nil, nil, trace.Wrap(err)
}
return certs.tls, priv, nil
case BuiltinRole:
keys, err := authServer.GenerateServerKeys(GenerateServerKeysRequest{
HostID: id.Username,
NodeName: id.Username,
Roles: teleport.Roles{id.Role},
})
if err != nil {
return nil, nil, trace.Wrap(err)
}
return keys.TLSCert, keys.Key, nil
default:
return nil, nil, trace.BadParameter("identity of unknown type %T is unsupported", identity)
}
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/helpers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L296-L306 | go | train | // NewCertificate returns new TLS credentials generated by test auth server | func (a *TestAuthServer) NewCertificate(identity TestIdentity) (*tls.Certificate, error) | // NewCertificate returns new TLS credentials generated by test auth server
func (a *TestAuthServer) NewCertificate(identity TestIdentity) (*tls.Certificate, error) | {
cert, key, err := GenerateCertificate(a.AuthServer, identity)
if err != nil {
return nil, trace.Wrap(err)
}
tlsCert, err := tls.X509KeyPair(cert, key)
if err != nil {
return nil, trace.Wrap(err)
}
return &tlsCert, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/helpers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L314-L339 | go | train | // Trust adds other server host certificate authority as trusted | func (a *TestAuthServer) Trust(remote *TestAuthServer, roleMap services.RoleMap) error | // Trust adds other server host certificate authority as trusted
func (a *TestAuthServer) Trust(remote *TestAuthServer, roleMap services.RoleMap) error | {
remoteCA, err := remote.AuthServer.GetCertAuthority(services.CertAuthID{
Type: services.HostCA,
DomainName: remote.ClusterName,
}, false)
if err != nil {
return trace.Wrap(err)
}
err = a.AuthServer.UpsertCertAuthority(remoteCA)
if err != nil {
return trace.Wrap(err)
}
remoteCA, err = remote.AuthServer.GetCertAuthority(services.CertAuthID{
Type: services.UserCA,
DomainName: remote.ClusterName,
}, false)
if err != nil {
return trace.Wrap(err)
}
remoteCA.SetRoleMap(roleMap)
err = a.AuthServer.UpsertCertAuthority(remoteCA)
if err != nil {
return trace.Wrap(err)
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/helpers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L362-L374 | go | train | // NewRemoteClient creates new client to the remote server using identity
// generated for this certificate authority | func (a *TestAuthServer) NewRemoteClient(identity TestIdentity, addr net.Addr, pool *x509.CertPool) (*Client, error) | // NewRemoteClient creates new client to the remote server using identity
// generated for this certificate authority
func (a *TestAuthServer) NewRemoteClient(identity TestIdentity, addr net.Addr, pool *x509.CertPool) (*Client, error) | {
tlsConfig := utils.TLSConfig(a.CipherSuites)
cert, err := a.NewCertificate(identity)
if err != nil {
return nil, trace.Wrap(err)
}
tlsConfig.Certificates = []tls.Certificate{*cert}
tlsConfig.RootCAs = pool
addrs := []utils.NetAddr{{
AddrNetwork: addr.Network(),
Addr: addr.String()}}
return NewTLSClient(ClientConfig{Addrs: addrs, TLS: tlsConfig})
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/helpers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L416-L431 | go | train | // CheckAndSetDefaults checks and sets limiter defaults | func (cfg *TestTLSServerConfig) CheckAndSetDefaults() error | // CheckAndSetDefaults checks and sets limiter defaults
func (cfg *TestTLSServerConfig) CheckAndSetDefaults() error | {
if cfg.APIConfig == nil {
return trace.BadParameter("missing parameter APIConfig")
}
if cfg.AuthServer == nil {
return trace.BadParameter("missing parameter AuthServer")
}
// use very permissive limiter configuration by default
if cfg.Limiter == nil {
cfg.Limiter = &limiter.LimiterConfig{
MaxConnections: 1000,
MaxNumberOfUsers: 1000,
}
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/helpers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L513-L525 | go | train | // NewClientFromWebSession returns new authenticated client from web session | func (t *TestTLSServer) NewClientFromWebSession(sess services.WebSession) (*Client, error) | // NewClientFromWebSession returns new authenticated client from web session
func (t *TestTLSServer) NewClientFromWebSession(sess services.WebSession) (*Client, error) | {
tlsConfig, err := t.Identity.TLSConfig(t.AuthServer.CipherSuites)
if err != nil {
return nil, trace.Wrap(err)
}
tlsCert, err := tls.X509KeyPair(sess.GetTLSCert(), sess.GetPriv())
if err != nil {
return nil, trace.Wrap(err, "failed to parse TLS cert and key")
}
tlsConfig.Certificates = []tls.Certificate{tlsCert}
addrs := []utils.NetAddr{utils.FromAddr(t.Listener.Addr())}
return NewTLSClient(ClientConfig{Addrs: addrs, TLS: tlsConfig})
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/helpers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L528-L534 | go | train | // CertPool returns cert pool that auth server represents | func (t *TestTLSServer) CertPool() (*x509.CertPool, error) | // CertPool returns cert pool that auth server represents
func (t *TestTLSServer) CertPool() (*x509.CertPool, error) | {
tlsConfig, err := t.Identity.TLSConfig(t.AuthServer.CipherSuites)
if err != nil {
return nil, trace.Wrap(err)
}
return tlsConfig.RootCAs, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/helpers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L537-L554 | go | train | // ClientTLSConfig returns client TLS config based on the identity | func (t *TestTLSServer) ClientTLSConfig(identity TestIdentity) (*tls.Config, error) | // ClientTLSConfig returns client TLS config based on the identity
func (t *TestTLSServer) ClientTLSConfig(identity TestIdentity) (*tls.Config, error) | {
tlsConfig, err := t.Identity.TLSConfig(t.AuthServer.CipherSuites)
if err != nil {
return nil, trace.Wrap(err)
}
if identity.I != nil {
cert, err := t.AuthServer.NewCertificate(identity)
if err != nil {
return nil, trace.Wrap(err)
}
tlsConfig.Certificates = []tls.Certificate{*cert}
} else {
// this client is not authenticated, which means that auth
// server should apply Nop builtin role
tlsConfig.Certificates = nil
}
return tlsConfig, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/helpers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L558-L565 | go | train | // CloneClient uses the same credentials as the passed client
// but forces the client to be recreated | func (t *TestTLSServer) CloneClient(clt *Client) *Client | // CloneClient uses the same credentials as the passed client
// but forces the client to be recreated
func (t *TestTLSServer) CloneClient(clt *Client) *Client | {
addr := []utils.NetAddr{{Addr: t.Addr().String(), AddrNetwork: t.Addr().Network()}}
newClient, err := NewTLSClient(ClientConfig{Addrs: addr, TLS: clt.TLSConfig()})
if err != nil {
panic(err)
}
return newClient
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/helpers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L568-L575 | go | train | // NewClient returns new client to test server authenticated with identity | func (t *TestTLSServer) NewClient(identity TestIdentity) (*Client, error) | // NewClient returns new client to test server authenticated with identity
func (t *TestTLSServer) NewClient(identity TestIdentity) (*Client, error) | {
tlsConfig, err := t.ClientTLSConfig(identity)
if err != nil {
return nil, trace.Wrap(err)
}
addrs := []utils.NetAddr{utils.FromAddr(t.Listener.Addr())}
return NewTLSClient(ClientConfig{Addrs: addrs, TLS: tlsConfig})
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/helpers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L583-L593 | go | train | // Start starts TLS server on loopback address on the first lisenting socket | func (t *TestTLSServer) Start() error | // Start starts TLS server on loopback address on the first lisenting socket
func (t *TestTLSServer) Start() error | {
var err error
if t.Listener == nil {
t.Listener, err = net.Listen("tcp", "127.0.0.1:0")
if err != nil {
return trace.Wrap(err)
}
}
go t.TLSServer.Serve(t.Listener)
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/helpers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L596-L605 | go | train | // Close closes the listener and HTTP server | func (t *TestTLSServer) Close() error | // Close closes the listener and HTTP server
func (t *TestTLSServer) Close() error | {
err := t.TLSServer.Close()
if t.Listener != nil {
t.Listener.Close()
}
if t.AuthServer.Backend != nil {
t.AuthServer.Backend.Close()
}
return err
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/helpers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L608-L614 | go | train | // Stop stops listening server, but does not close the auth backend | func (t *TestTLSServer) Stop() error | // Stop stops listening server, but does not close the auth backend
func (t *TestTLSServer) Stop() error | {
err := t.TLSServer.Close()
if t.Listener != nil {
t.Listener.Close()
}
return err
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/helpers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L617-L627 | go | train | // NewServerIdentity generates new server identity, used in tests | func NewServerIdentity(clt *AuthServer, hostID string, role teleport.Role) (*Identity, error) | // NewServerIdentity generates new server identity, used in tests
func NewServerIdentity(clt *AuthServer, hostID string, role teleport.Role) (*Identity, error) | {
keys, err := clt.GenerateServerKeys(GenerateServerKeysRequest{
HostID: hostID,
NodeName: hostID,
Roles: teleport.Roles{teleport.RoleAuth},
})
if err != nil {
return nil, trace.Wrap(err)
}
return ReadIdentityFromKeyPair(keys)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/helpers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L637-L654 | go | train | // CreateUserAndRole creates user and role and assignes role to a user, used in tests | func CreateUserAndRole(clt clt, username string, allowedLogins []string) (services.User, services.Role, error) | // CreateUserAndRole creates user and role and assignes role to a user, used in tests
func CreateUserAndRole(clt clt, username string, allowedLogins []string) (services.User, services.Role, error) | {
user, err := services.NewUser(username)
if err != nil {
return nil, nil, trace.Wrap(err)
}
role := services.RoleForUser(user)
role.SetLogins(services.Allow, []string{user.GetName()})
err = clt.UpsertRole(role)
if err != nil {
return nil, nil, trace.Wrap(err)
}
user.AddRole(role.GetName())
err = clt.UpsertUser(user)
if err != nil {
return nil, nil, trace.Wrap(err)
}
return user, role, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/auth/helpers.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/auth/helpers.go#L657-L680 | go | train | // CreateUserAndRoleWithoutRoles creates user and role, but does not assign user to a role, used in tests | func CreateUserAndRoleWithoutRoles(clt clt, username string, allowedLogins []string) (services.User, services.Role, error) | // CreateUserAndRoleWithoutRoles creates user and role, but does not assign user to a role, used in tests
func CreateUserAndRoleWithoutRoles(clt clt, username string, allowedLogins []string) (services.User, services.Role, error) | {
user, err := services.NewUser(username)
if err != nil {
return nil, nil, trace.Wrap(err)
}
role := services.RoleForUser(user)
set := services.MakeRuleSet(role.GetRules(services.Allow))
delete(set, services.KindRole)
role.SetRules(services.Allow, set.Slice())
role.SetLogins(services.Allow, []string{user.GetName()})
err = clt.UpsertRole(role)
if err != nil {
return nil, nil, trace.Wrap(err)
}
user.AddRole(role.GetName())
err = clt.UpsertUser(user)
if err != nil {
return nil, nil, trace.Wrap(err)
}
return user, role, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/events/uploader.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/uploader.go#L80-L106 | go | train | // CheckAndSetDefaults checks and sets default values of UploaderConfig | func (cfg *UploaderConfig) CheckAndSetDefaults() error | // CheckAndSetDefaults checks and sets default values of UploaderConfig
func (cfg *UploaderConfig) CheckAndSetDefaults() error | {
if cfg.ServerID == "" {
return trace.BadParameter("missing parameter ServerID")
}
if cfg.AuditLog == nil {
return trace.BadParameter("missing parameter AuditLog")
}
if cfg.DataDir == "" {
return trace.BadParameter("missing parameter DataDir")
}
if cfg.Namespace == "" {
return trace.BadParameter("missing parameter Namespace")
}
if cfg.ConcurrentUploads <= 0 {
cfg.ConcurrentUploads = defaults.UploaderConcurrentUploads
}
if cfg.ScanPeriod <= 0 {
cfg.ScanPeriod = defaults.UploaderScanPeriod
}
if cfg.Context == nil {
cfg.Context = context.TODO()
}
if cfg.Clock == nil {
cfg.Clock = clockwork.NewRealClock()
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/events/uploader.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/uploader.go#L109-L126 | go | train | // NewUploader creates new disk based session logger | func NewUploader(cfg UploaderConfig) (*Uploader, error) | // NewUploader creates new disk based session logger
func NewUploader(cfg UploaderConfig) (*Uploader, error) | {
if err := cfg.CheckAndSetDefaults(); err != nil {
return nil, trace.Wrap(err)
}
ctx, cancel := context.WithCancel(cfg.Context)
uploader := &Uploader{
UploaderConfig: cfg,
Entry: log.WithFields(log.Fields{
trace.Component: teleport.ComponentAuditLog,
}),
cancel: cancel,
ctx: ctx,
semaphore: make(chan struct{}, cfg.ConcurrentUploads),
scanDir: filepath.Join(cfg.DataDir, cfg.ServerID, SessionLogsDir, cfg.Namespace),
}
return uploader, nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/events/uploader.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/events/uploader.go#L272-L309 | go | train | // Scan scans the directory and uploads recordings | func (u *Uploader) Scan() error | // Scan scans the directory and uploads recordings
func (u *Uploader) Scan() error | {
df, err := os.Open(u.scanDir)
err = trace.ConvertSystemError(err)
if err != nil {
return trace.Wrap(err)
}
defer df.Close()
entries, err := df.Readdir(-1)
if err != nil {
return trace.ConvertSystemError(err)
}
var count int
for i := range entries {
fi := entries[i]
if fi.IsDir() {
continue
}
if !strings.HasSuffix(fi.Name(), "completed") {
continue
}
parts := strings.Split(fi.Name(), ".")
if len(parts) < 2 {
u.Debugf("Uploader, skipping unknown file: %v", fi.Name())
continue
}
sessionID := session.ID(parts[0])
lockFilePath := filepath.Join(u.scanDir, fi.Name())
if err := u.uploadFile(lockFilePath, sessionID); err != nil {
if trace.IsCompareFailed(err) {
u.Debugf("Uploader detected locked file %v, another process is uploading it.", lockFilePath)
continue
}
return trace.Wrap(err)
}
count += 1
}
return nil
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L89-L96 | go | train | // ToString returns a string representation of a forwarded port spec, compatible
// with OpenSSH's -L flag, i.e. "src_host:src_port:dest_host:dest_port". | func (p *ForwardedPort) ToString() string | // ToString returns a string representation of a forwarded port spec, compatible
// with OpenSSH's -L flag, i.e. "src_host:src_port:dest_host:dest_port".
func (p *ForwardedPort) ToString() string | {
sport := strconv.Itoa(p.SrcPort)
dport := strconv.Itoa(p.DestPort)
if utils.IsLocalhost(p.SrcIP) {
return sport + ":" + net.JoinHostPort(p.DestHost, dport)
}
return net.JoinHostPort(p.SrcIP, sport) + ":" + net.JoinHostPort(p.DestHost, dport)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L115-L121 | go | train | // ToString returns a string representation of a dynamic port spec, compatible
// with OpenSSH's -D flag, i.e. "src_host:src_port". | func (p *DynamicForwardedPort) ToString() string | // ToString returns a string representation of a dynamic port spec, compatible
// with OpenSSH's -D flag, i.e. "src_host:src_port".
func (p *DynamicForwardedPort) ToString() string | {
sport := strconv.Itoa(p.SrcPort)
if utils.IsLocalhost(p.SrcIP) {
return sport
}
return net.JoinHostPort(p.SrcIP, sport)
} |
gravitational/teleport | d5243dbe8d36bba44bf640c08f1c49185ed2c8a4 | lib/client/api.go | https://github.com/gravitational/teleport/blob/d5243dbe8d36bba44bf640c08f1c49185ed2c8a4/lib/client/api.go#L255-L261 | go | train | // MakeDefaultConfig returns default client config | func MakeDefaultConfig() *Config | // MakeDefaultConfig returns default client config
func MakeDefaultConfig() *Config | {
return &Config{
Stdout: os.Stdout,
Stderr: os.Stderr,
Stdin: os.Stdin,
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.