go-hep.org/x/hep@v0.38.1/xrootd/xrdproto/auth/krb5/krb5_windows.go (about)

     1  // Copyright ©2018 The go-hep Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  //go:build windows
     6  
     7  package krb5
     8  
     9  import (
    10  	"fmt"
    11  	"os"
    12  	"os/user"
    13  	"path/filepath"
    14  	"strings"
    15  )
    16  
    17  const configPath = `c:\winnt\krb5.ini`
    18  
    19  func cachePath() string {
    20  	// FIXME: ask people for the popular windows krb5 client and use its cache path.
    21  	// MIT krb5 lacks fresh windows builds IIUC.
    22  	// As for now, hope that either KRB5CCNAME or %TEMP%\krb5cc_{uid} will work.
    23  	if v := os.Getenv("KRB5CCNAME"); v != "" {
    24  		if strings.HasPrefix(v, "FILE:") {
    25  			v = string(v[len("FILE:"):])
    26  		}
    27  		return v
    28  	}
    29  
    30  	usr, err := user.Current()
    31  	if err != nil {
    32  		return ""
    33  	}
    34  
    35  	v := filepath.Join(os.TempDir(), fmt.Sprintf("krb5cc_%s", usr.Uid))
    36  	return v
    37  }