mirror of
				https://gogs.blitter.com/RLabs/xs
				synced 2024-08-14 10:26:42 +00:00 
			
		
		
		
	Correct implicit username for MSYS2 eg. xs @server.com
Signed-off-by: Russ Magee <rmagee@gmail.com>
This commit is contained in:
		
							parent
							
								
									cf63c5a239
								
							
						
					
					
						commit
						7f87225e34
					
				
					 1 changed files with 19 additions and 6 deletions
				
			
		
							
								
								
									
										15
									
								
								xs/xs.go
									
										
									
									
									
								
							
							
						
						
									
										15
									
								
								xs/xs.go
									
										
									
									
									
								
							|  | @ -769,7 +769,7 @@ func main() { | |||
| 	var uname string | ||||
| 	if remoteUser == "" { | ||||
| 		u, _ := user.Current() // nolint: gosec | ||||
| 		uname = u.Username | ||||
| 		uname = localUserName(u) | ||||
| 	} else { | ||||
| 		uname = remoteUser | ||||
| 	} | ||||
|  | @ -1037,6 +1037,19 @@ func main() { | |||
| 	exitWithStatus(int(rec.Status())) | ||||
| } | ||||
| 
 | ||||
| // currentUser returns the current username minus any OS-specific prefixes | ||||
| // such as MS Windows workgroup prefixes (eg. workgroup\user). | ||||
| func localUserName(u *user.User) string { | ||||
| 	if u == nil { | ||||
| 		log.Fatal("null User?!") | ||||
| 	} | ||||
| 
 | ||||
| 	// WinAPI: username may have CIFS prefix %USERDOMAIN%\ | ||||
| 	userspec := strings.Split(u.Username, `\`) | ||||
| 	username := userspec[len(userspec)-1] | ||||
| 	return username | ||||
| } | ||||
| 
 | ||||
| func restoreTermState(oldState *xs.State) { | ||||
| 	_ = xs.Restore(os.Stdin.Fd(), oldState) // nolint: errcheck,gosec | ||||
| } | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue