When pushed, this commit will replace hard-coded values with calls to LookupMQM

This commit is contained in:
Stephen Marshall
2018-04-25 14:09:23 +01:00
parent bf36f8bb2c
commit 3aa46e0793
6 changed files with 42 additions and 33 deletions

View File

@@ -60,7 +60,7 @@ func Run(name string, arg ...string) (string, int, error) {
func RunAsMQM(name string, arg ...string) (string, int, error) {
cmd := exec.Command(name, arg...)
cmd.SysProcAttr = &syscall.SysProcAttr{}
uid, gid, err := lookupMQM()
uid, gid, err := LookupMQM()
if err != nil {
return "", 0, err
}
@@ -68,8 +68,8 @@ func RunAsMQM(name string, arg ...string) (string, int, error) {
return RunCmd(cmd)
}
// TODO: Duplicated code
func lookupMQM() (int, int, error) {
// LookupMQM looks up the UID & GID of the mqm user
func LookupMQM() (int, int, error) {
mqm, err := user.Lookup("mqm")
if err != nil {
return -1, -1, err