code: func getLoginShell(username string) (string, error) {
  	// See if the username is valid.
  	_, err := user.Lookup(username)
  	if err != nil {
  		return "", trace.Wrap(err)
  	}
  
  	// Based on stdlib user/lookup_unix.go packages which does not return
  	// user shell: https://golang.org/src/os/user/lookup_unix.go
  	var pwd C.struct_passwd
  	var result *C.struct_passwd
  
  	bufSize := C.sysconf(C._SC_GETPW_R_SIZE_MAX)
  	if bufSize == -1 {
  		bufSize = 1024
  	}
  	if bufSize <= 0 || bufSize > 1<<20 {
  		return "", trace.BadParameter("lookupPosixShell: unreasonable _SC_GETPW_R_SIZE_MAX of %d", bufSize)
  	}
  	buf := C.malloc(C.size_t(bufSize))
  	defer C.free(buf)
  	var rv C.int
  	nameC := C.CString(username)
  	defer C.free(unsafe.Pointer(nameC))
  	rv = C.mygetpwnam_r(nameC,
  		&pwd,
  		(*C.char)(buf),
  		C.size_t(bufSize),
  		&result)
  	if rv != 0 || result == nil {
  		log.Errorf("lookupPosixShell: lookup username %s: %s", username, syscall.Errno(rv))
  		return "", trace.BadParameter("cannot determine shell for %s", username)
  	}
  
  	// If no shell was found, return trace.NotFound to allow the caller to set
  	// the default shell.
  	shellCmd := strings.TrimSpace(C.GoString(pwd.pw_shell))
  	if len(shellCmd) == 0 {
  		return "", trace.NotFound("no shell specified for %v", username)
  	}
  
  	return shellCmd, nil
  }
docs: // getLoginShell determines the login shell for a given username