|
|
@ -80,7 +80,7 @@ func LoadUserProfile(token windows.Token, u *user.User) (up *UserProfile, err er
|
|
|
|
|
|
|
|
|
|
|
|
var roamingProfilePath *uint16
|
|
|
|
var roamingProfilePath *uint16
|
|
|
|
if winenv.IsDomainJoined() {
|
|
|
|
if winenv.IsDomainJoined() {
|
|
|
|
roamingProfilePath, err = getRoamingProfilePath(nil, computerName, userName)
|
|
|
|
roamingProfilePath, err = getRoamingProfilePath(nil, token, computerName, userName)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -134,7 +134,7 @@ func (up *UserProfile) Close() error {
|
|
|
|
return nil
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func getRoamingProfilePath(logf logger.Logf, computerName, userName *uint16) (path *uint16, err error) {
|
|
|
|
func getRoamingProfilePath(logf logger.Logf, token windows.Token, computerName, userName *uint16) (path *uint16, err error) {
|
|
|
|
// logf is for debugging/testing.
|
|
|
|
// logf is for debugging/testing.
|
|
|
|
if logf == nil {
|
|
|
|
if logf == nil {
|
|
|
|
logf = logger.Discard
|
|
|
|
logf = logger.Discard
|
|
|
@ -152,19 +152,18 @@ func getRoamingProfilePath(logf logger.Logf, computerName, userName *uint16) (pa
|
|
|
|
if profilePath == nil {
|
|
|
|
if profilePath == nil {
|
|
|
|
return nil, nil
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if *profilePath == 0 {
|
|
|
|
var sz int
|
|
|
|
// Empty string
|
|
|
|
for ptr := unsafe.Pointer(profilePath); *(*uint16)(ptr) != 0; sz++ {
|
|
|
|
return nil, nil
|
|
|
|
ptr = unsafe.Pointer(uintptr(ptr) + unsafe.Sizeof(*profilePath))
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if sz == 0 {
|
|
|
|
var expanded [windows.MAX_PATH + 1]uint16
|
|
|
|
return nil, nil
|
|
|
|
if err := expandEnvironmentStringsForUser(token, profilePath, &expanded[0], uint32(len(expanded))); err != nil {
|
|
|
|
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
buf := unsafe.Slice(profilePath, sz+1)
|
|
|
|
// This buffer is only used briefly, so we don't bother copying it into a shorter slice.
|
|
|
|
cp := append([]uint16{}, buf...)
|
|
|
|
return &expanded[0], nil
|
|
|
|
return unsafe.SliceData(cp), nil
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func getComputerAndUserName(token windows.Token, u *user.User) (computerName *uint16, userName *uint16, err error) {
|
|
|
|
func getComputerAndUserName(token windows.Token, u *user.User) (computerName *uint16, userName *uint16, err error) {
|
|
|
|