forked from tildetown/town
		
	make sure user is root
This commit is contained in:
		
							parent
							
								
									955aeed8b5
								
							
						
					
					
						commit
						01b214b29f
					
				@ -7,6 +7,7 @@ import (
 | 
			
		||||
	"path"
 | 
			
		||||
	"os"
 | 
			
		||||
	"os/exec"
 | 
			
		||||
	"os/user"
 | 
			
		||||
 | 
			
		||||
	"git.tilde.town/tildetown/town/towndb"
 | 
			
		||||
)
 | 
			
		||||
@ -88,10 +89,20 @@ func main() {
 | 
			
		||||
		quit("usage: rename username new_username")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	confirmRename()
 | 
			
		||||
	old_name := os.Args[1]
 | 
			
		||||
	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 {
 | 
			
		||||
		quit(fmt.Sprintf("pkill failed: %v", err))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user