Commit 1019428c authored by Frank Denis's avatar Frank Denis

username -> user_name

in case we want to add user_group and whatnot.

Remove the command-line option as it hides the caveats documented
in the configuration file.

Remove TODO. TODO statements always remain in that state forever.
parent 6cb43f8e
...@@ -26,7 +26,7 @@ type Config struct { ...@@ -26,7 +26,7 @@ type Config struct {
ServerNames []string `toml:"server_names"` ServerNames []string `toml:"server_names"`
ListenAddresses []string `toml:"listen_addresses"` ListenAddresses []string `toml:"listen_addresses"`
Daemonize bool Daemonize bool
Username string `toml:"username"` UserName string `toml:"user_name"`
ForceTCP bool `toml:"force_tcp"` ForceTCP bool `toml:"force_tcp"`
Timeout int `toml:"timeout"` Timeout int `toml:"timeout"`
KeepAlive int `toml:"keepalive"` KeepAlive int `toml:"keepalive"`
...@@ -189,7 +189,6 @@ func ConfigLoad(proxy *Proxy, svcFlag *string) error { ...@@ -189,7 +189,6 @@ func ConfigLoad(proxy *Proxy, svcFlag *string) error {
jsonOutput := flag.Bool("json", false, "output list as JSON") jsonOutput := flag.Bool("json", false, "output list as JSON")
check := flag.Bool("check", false, "check the configuration file and exit") check := flag.Bool("check", false, "check the configuration file and exit")
configFile := flag.String("config", DefaultConfigFileName, "Path to the configuration file") configFile := flag.String("config", DefaultConfigFileName, "Path to the configuration file")
username := flag.String("username", "", "After binding to the port user privileges are dropped")
child := flag.Bool("child", false, "Invokes program as a child process") child := flag.Bool("child", false, "Invokes program as a child process")
flag.Parse() flag.Parse()
...@@ -241,10 +240,6 @@ func ConfigLoad(proxy *Proxy, svcFlag *string) error { ...@@ -241,10 +240,6 @@ func ConfigLoad(proxy *Proxy, svcFlag *string) error {
proxy.logMaxAge = config.LogMaxAge proxy.logMaxAge = config.LogMaxAge
proxy.logMaxBackups = config.LogMaxBackups proxy.logMaxBackups = config.LogMaxBackups
proxy.username = config.Username
if len(*username) > 0 {
proxy.username = *username
}
proxy.child = *child proxy.child = *child
proxy.xTransport = NewXTransport() proxy.xTransport = NewXTransport()
proxy.xTransport.tlsDisableSessionTickets = config.TLSDisableSessionTickets proxy.xTransport.tlsDisableSessionTickets = config.TLSDisableSessionTickets
......
...@@ -50,7 +50,7 @@ max_clients = 250 ...@@ -50,7 +50,7 @@ max_clients = 250
## Note (1): this feature is currently unsupported on Windows. ## Note (1): this feature is currently unsupported on Windows.
## Note (2): this feature is not compatible with systemd socket activation. ## Note (2): this feature is not compatible with systemd socket activation.
# username = 'nobody' # user_name = 'nobody'
## Require servers (from static + remote sources) to satisfy specific properties ## Require servers (from static + remote sources) to satisfy specific properties
......
...@@ -16,7 +16,7 @@ import ( ...@@ -16,7 +16,7 @@ import (
) )
type Proxy struct { type Proxy struct {
username string userName string
child bool child bool
proxyPublicKey [32]byte proxyPublicKey [32]byte
proxySecretKey [32]byte proxySecretKey [32]byte
...@@ -85,8 +85,8 @@ func (proxy *Proxy) StartProxy() { ...@@ -85,8 +85,8 @@ func (proxy *Proxy) StartProxy() {
dlog.Fatal(err) dlog.Fatal(err)
} }
// if 'username' is not set, continue as before (Todo: refactor for DRYniss) // if 'userName' is not set, continue as before
if !(len(proxy.username) > 0) { if !(len(proxy.userName) > 0) {
if err := proxy.udpListenerFromAddr(listenUDPAddr); err != nil { if err := proxy.udpListenerFromAddr(listenUDPAddr); err != nil {
dlog.Fatal(err) dlog.Fatal(err)
} }
...@@ -94,7 +94,7 @@ func (proxy *Proxy) StartProxy() { ...@@ -94,7 +94,7 @@ func (proxy *Proxy) StartProxy() {
dlog.Fatal(err) dlog.Fatal(err)
} }
} else { } else {
// if 'username' is set and we are the parent process // if 'userName' is set and we are the parent process
if !proxy.child { if !proxy.child {
// parent // parent
listenerUDP, err := net.ListenUDP("udp", listenUDPAddr) listenerUDP, err := net.ListenUDP("udp", listenUDPAddr)
...@@ -119,7 +119,7 @@ func (proxy *Proxy) StartProxy() { ...@@ -119,7 +119,7 @@ func (proxy *Proxy) StartProxy() {
FileDescriptors = append(FileDescriptors, fdUDP) FileDescriptors = append(FileDescriptors, fdUDP)
FileDescriptors = append(FileDescriptors, fdTCP) FileDescriptors = append(FileDescriptors, fdTCP)
// if 'username' is set and we are the child process // if 'userName' is set and we are the child process
} else { } else {
// child // child
listenerUDP, err := net.FilePacketConn(os.NewFile(uintptr(3+FileDescriptorNum), "listenerUDP")) listenerUDP, err := net.FilePacketConn(os.NewFile(uintptr(3+FileDescriptorNum), "listenerUDP"))
...@@ -143,9 +143,9 @@ func (proxy *Proxy) StartProxy() { ...@@ -143,9 +143,9 @@ func (proxy *Proxy) StartProxy() {
} }
} }
// if 'username' is set and we are the parent process drop privilege and exit // if 'userName' is set and we are the parent process drop privilege and exit
if len(proxy.username) > 0 && !proxy.child { if len(proxy.userName) > 0 && !proxy.child {
proxy.dropPrivilege(proxy.username, FileDescriptors) proxy.dropPrivilege(proxy.userName, FileDescriptors)
} }
if err := proxy.SystemDListeners(); err != nil { if err := proxy.SystemDListeners(); err != nil {
dlog.Fatal(err) dlog.Fatal(err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment