parent
9e8010279b
commit
a4c4fef01b
4 changed files with 9 additions and 11 deletions
|
@ -4,7 +4,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"os/user"
|
"os/user"
|
||||||
|
@ -128,7 +127,7 @@ func (b *tCertificateBuilder) MustWrite(force bool) bool {
|
||||||
if force || sys_stat.Size != int64(len(b.text)) {
|
if force || sys_stat.Size != int64(len(b.text)) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
existing, err := ioutil.ReadFile(b.Config.Path)
|
existing, err := os.ReadFile(b.Config.Path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -143,7 +142,7 @@ func (b *tCertificateBuilder) MustWrite(force bool) bool {
|
||||||
// Write the file's data
|
// Write the file's data
|
||||||
func (b *tCertificateBuilder) WriteFile() error {
|
func (b *tCertificateBuilder) WriteFile() error {
|
||||||
log.WithField("file", b.Config.Path).Info("Writing certificate data to file")
|
log.WithField("file", b.Config.Path).Info("Writing certificate data to file")
|
||||||
err := ioutil.WriteFile(b.Config.Path, b.text, b.Config.FileMode())
|
err := os.WriteFile(b.Config.Path, b.text, b.Config.FileMode())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
b.changed = true
|
b.changed = true
|
||||||
}
|
}
|
||||||
|
@ -262,7 +261,7 @@ func (b *tCertificateBuilder) appendPemFiles(files []string) error {
|
||||||
|
|
||||||
// Append a PEM file to the current list of data chunks
|
// Append a PEM file to the current list of data chunks
|
||||||
func (b *tCertificateBuilder) appendPem(input string) error {
|
func (b *tCertificateBuilder) appendPem(input string) error {
|
||||||
data, err := ioutil.ReadFile(input)
|
data, err := os.ReadFile(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Could not load '%s': %w", input, err)
|
return fmt.Errorf("Could not load '%s': %w", input, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -153,7 +152,7 @@ func (c *tLdapConnectionConfig) Validate() error {
|
||||||
return fmt.Errorf("Invalid TLS mode '%s' (valid values are 'yes', 'starttls' and 'no'", c.TLS)
|
return fmt.Errorf("Invalid TLS mode '%s' (valid values are 'yes', 'starttls' and 'no'", c.TLS)
|
||||||
}
|
}
|
||||||
if c.CaChain != "" {
|
if c.CaChain != "" {
|
||||||
data, err := ioutil.ReadFile(c.CaChain)
|
data, err := os.ReadFile(c.CaChain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Unable to read CA chain from '%s': %w", c.CaChain, err)
|
return fmt.Errorf("Unable to read CA chain from '%s': %w", c.CaChain, err)
|
||||||
}
|
}
|
||||||
|
@ -351,7 +350,7 @@ func defaultConfiguration() tConfiguration {
|
||||||
// Load and check the configuration file
|
// Load and check the configuration file
|
||||||
func LoadConfiguration(file string) (tConfiguration, error) {
|
func LoadConfiguration(file string) (tConfiguration, error) {
|
||||||
cfg := defaultConfiguration()
|
cfg := defaultConfiguration()
|
||||||
cfgData, err := ioutil.ReadFile(file)
|
cfgData, err := os.ReadFile(file)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cfg, fmt.Errorf("Could not load configuration: %w", err)
|
return cfg, fmt.Errorf("Could not load configuration: %w", err)
|
||||||
}
|
}
|
||||||
|
|
4
ldap.go
4
ldap.go
|
@ -5,7 +5,7 @@ import (
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/pem"
|
"encoding/pem"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
|
|
||||||
ldap "github.com/go-ldap/ldap/v3"
|
ldap "github.com/go-ldap/ldap/v3"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
@ -68,7 +68,7 @@ func getLdapServerConnection(cfg tLdapConfig, server int) *tLdapConn {
|
||||||
}
|
}
|
||||||
if scfg.TLS != "no" && scfg.CaChain != "" {
|
if scfg.TLS != "no" && scfg.CaChain != "" {
|
||||||
log := log.WithField("cachain", scfg.CaChain)
|
log := log.WithField("cachain", scfg.CaChain)
|
||||||
data, err := ioutil.ReadFile(scfg.CaChain)
|
data, err := os.ReadFile(scfg.CaChain)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithField("error", err).Error("Failed to read CA certificate chain")
|
log.WithField("error", err).Error("Failed to read CA certificate chain")
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log/syslog"
|
"log/syslog"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ func configureLogging(flags tCliFlags) error {
|
||||||
log.Logger.AddHook(hook)
|
log.Logger.AddHook(hook)
|
||||||
}
|
}
|
||||||
if flags.quiet {
|
if flags.quiet {
|
||||||
log.Logger.SetOutput(ioutil.Discard)
|
log.Logger.SetOutput(io.Discard)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue