make sure user is root
parent
955aeed8b5
commit
01b214b29f
|
@ -7,6 +7,7 @@ import (
|
||||||
"path"
|
"path"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"os/user"
|
||||||
|
|
||||||
"git.tilde.town/tildetown/town/towndb"
|
"git.tilde.town/tildetown/town/towndb"
|
||||||
)
|
)
|
||||||
|
@ -88,10 +89,20 @@ func main() {
|
||||||
quit("usage: rename username new_username")
|
quit("usage: rename username new_username")
|
||||||
}
|
}
|
||||||
|
|
||||||
confirmRename()
|
|
||||||
old_name := os.Args[1]
|
old_name := os.Args[1]
|
||||||
new_name := os.Args[2]
|
new_name := os.Args[2]
|
||||||
|
|
||||||
|
user, err := user.Current()
|
||||||
|
if err != nil {
|
||||||
|
quit(fmt.Sprintf("couldn't get user info: %v", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
if user.Uid != "0" {
|
||||||
|
quit("must be run as root")
|
||||||
|
}
|
||||||
|
|
||||||
|
confirmRename()
|
||||||
|
|
||||||
if err := killUser(old_name); err != nil {
|
if err := killUser(old_name); err != nil {
|
||||||
quit(fmt.Sprintf("pkill failed: %v", err))
|
quit(fmt.Sprintf("pkill failed: %v", err))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue