Skip to content

Commit

Permalink
hadoop: user root in sdk as normal user
Browse files Browse the repository at this point in the history
  • Loading branch information
tangyoupeng committed Feb 6, 2023
1 parent 7db5227 commit f703609
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions sdk/java/libjfs/guid.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,16 @@ func (m *mapping) lookupUser(name string) uint32 {
if !m.local {
return m.genGuid(name)
}
u, _ := user.Lookup(name)
if u != nil {
id_, _ := strconv.ParseUint(u.Uid, 10, 32)
id = uint32(id_)
} else {
if name == "root" { // root in hdfs sdk is a normal user
id = m.genGuid(name)
} else {
u, _ := user.Lookup(name)
if u != nil {
id_, _ := strconv.ParseUint(u.Uid, 10, 32)
id = uint32(id_)
} else {
id = m.genGuid(name)
}
}
m.usernames[name] = id
m.userIDs[id] = name
Expand All @@ -90,12 +94,16 @@ func (m *mapping) lookupGroup(name string) uint32 {
if !m.local {
return m.genGuid(name)
}
g, _ := user.LookupGroup(name)
if g == nil {
if name == "root" {
id = m.genGuid(name)
} else {
id_, _ := strconv.ParseUint(g.Gid, 10, 32)
id = uint32(id_)
g, _ := user.LookupGroup(name)
if g == nil {
id = m.genGuid(name)
} else {
id_, _ := strconv.ParseUint(g.Gid, 10, 32)
id = uint32(id_)
}
}
m.groups[name] = id
m.groupIDs[id] = name
Expand Down

0 comments on commit f703609

Please sign in to comment.