Skip to content

Commit

Permalink
v1.3.2 issue when password contains a single quote sign
Browse files Browse the repository at this point in the history
  • Loading branch information
nixargh committed Feb 19, 2024
1 parent f8b5cb4 commit 801e8f8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.3.2] - 2024-01-24
### Fixed
- `nmcli.go` issue when password contains a single quote sign.

## [1.3.1] - 2024-01-24
### Fixed
- `nmcli.go` fix the way NM VPN config is being updated.
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
// "github.com/pkg/profile"
)

var version string = "1.3.1"
var version string = "1.3.2"

var clog *log.Entry

Expand All @@ -38,7 +38,7 @@ func main() {
flag.StringVar(&password, "password", "", "VPN user password")
flag.StringVar(&otpSecret, "otpSecret", "", "VPN OTP secret")
flag.BoolVar(&debug, "debug", false, "Log debug messages")
flag.BoolVar(&showVersion, "version", false, "FunVPN version")
flag.BoolVar(&showVersion, "version", false, "Show version")

flag.Parse()

Expand Down
10 changes: 5 additions & 5 deletions nmcli.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func nmcliConnectionUpPasswd(password string, passcode string, config string) {
clog.WithFields(log.Fields{"config": config}).Info("Starting VPN connection.")

passwdFile := "/tmp/roly-poly-vpn.nmcli.passwd"
fullPassword := fmt.Sprintf("vpn.secrets.password:%v%v", password, passcode)
fullPassword := fmt.Sprintf("vpn.secrets.password:\"%v%v\"", password, passcode)

err := os.WriteFile(passwdFile, []byte(fullPassword), 0600)
if err != nil {
Expand All @@ -73,8 +73,8 @@ func nmcliConnectionUpAsk(password string, passcode string, config string) {
basher(cmd, "")

// Answer to password request interactively
fullpass := fmt.Sprintf("%v%v", password, passcode)
cmd = fmt.Sprintf("nmcli connection mod %v vpn.secrets 'password=%v'", config, fullpass)
fullpass := fmt.Sprintf("\"%v%v\"", password, passcode)
cmd = fmt.Sprintf("nmcli connection mod %v vpn.secrets password=%v", config, fullpass)
basher(cmd, fullpass)

clog.WithFields(log.Fields{"config": config}).Info("VPN is connected.")
Expand Down Expand Up @@ -108,8 +108,8 @@ func nmcliConnectionUpdatePassword(password string, passcode string, config stri
clog.WithFields(log.Fields{"config": config}).Info("Updating VPN connection with a new password.")

// Update VPN config with a newly generated password
fullpass := fmt.Sprintf("%v%v", password, passcode)
cmd = fmt.Sprintf("nmcli connection mod %v vpn.secrets 'password=%v'", config, fullpass)
fullpass := fmt.Sprintf("\"%v%v\"", password, passcode)
cmd = fmt.Sprintf("nmcli connection mod %v vpn.secrets password=%v", config, fullpass)
basher(cmd, fullpass)

clog.WithFields(log.Fields{"config": config}).Info("VPN config is updated.")
Expand Down

0 comments on commit 801e8f8

Please sign in to comment.