samuong / alpaca

A local HTTP proxy for command-line tools. Supports PAC scripts and NTLM authentication.
Apache License 2.0
184 stars 31 forks source link

Alpaca does not work with Systemd #48

Closed arashmo closed 4 years ago

arashmo commented 4 years ago

I created a systemd service unit file and started Alpaca as service and passed all the argument like username and password, for direct connection it works fine for proxied connection i get site unavailable error on browser, the app does not show any error or or logs

camh- commented 4 years ago

Only Darwin (MacOS) supports getting credentials from a keyring. Other platforms prompt for your password on the terminal, so this will not work from a systemd unit as there is no terminal on which to read the password.

I'm not sure what you meant by passing the password as an argument, because it does not have one.

arashmo commented 4 years ago

Basically I created a module for alpaca that will store the password in such secure format using AES encryption and will share it here , it works just fine but when i run alpaca as binary but when it comes to systemd it does not , the issue is not the password I'll share the logs tomorrow

arashmo commented 4 years ago

found the issue, I was reading the current user whoam function in main.go now i need to implement a method to pass user from configuration file

arashmo commented 4 years ago

why it does not work :( i just saved my username in a plane text file and passwd it to the flag.String but it didn't work while whoAmI() works

func Getusername() string { content, err := ioutil.ReadFile(ufile) text = string(text) return text }

username := flag.String("u", Getusername(), "username of the proxy account (for NTLM auth)")

camh- commented 4 years ago

This is not really the right forum for you to debug your private changes to alpaca. Do you have a repo you can share perhaps? If you want to upstream the changes later in a PR, I may be able to help. There is also the #alpaca channel on the gophers slack (https://app.slack.com/client/T029RQSE6/CQWGVQ0RG) if you want to chat there.

My initial suspicion of your problem is that there is a newline at the end of your username in the file. You may want to do text := string(content).TrimSpace().

arashmo commented 4 years ago

yes you were right ioutil adds a blank space, when i was debugging it on my local terminal it was not obvious, trimed that this way

bb, _ := ioutil.ReadFile(ufile) dd := string(bb) text := strings.TrimSuffix(dd, "\n") return text

camh- commented 4 years ago

Glad you've got it working. I'm going to close this issue now, as there is nothing to fix/change in alpaca.