Skip to content

Commit

Permalink
skip uid 0 and gid 0 in uid/gid mapping tables
Browse files Browse the repository at this point in the history
endOfSet is 0, so sending uid or gid 0 breaks the protocol.
Uid 0 and gid 0 are supposed to be skipped (always mapped to root).

fixes #2
  • Loading branch information
stapelberg committed Sep 2, 2021
1 parent 34c5ca6 commit 569c4e7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/rsyncd/rsyncd.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (s *Server) sendFileList(c *rsyncConn, root string, opts rsyncOpts) ([]file
var uid int32
if st, ok := info.Sys().(*syscall.Stat_t); ok {
uid = int32(st.Uid)
if _, ok := uidMap[uid]; !ok {
if _, ok := uidMap[uid]; !ok && uid != 0 {
u, err := user.LookupId(strconv.Itoa(int(uid)))
if err != nil {
log.Printf("lookup(%d) = %v", uid, err)
Expand All @@ -120,7 +120,7 @@ func (s *Server) sendFileList(c *rsyncConn, root string, opts rsyncOpts) ([]file
var gid int32
if st, ok := info.Sys().(*syscall.Stat_t); ok {
gid = int32(st.Gid)
if _, ok := gidMap[gid]; !ok {
if _, ok := gidMap[gid]; !ok && gid != 0 {
g, err := user.LookupGroupId(strconv.Itoa(int(gid)))
if err != nil {
log.Printf("lookupgroup(%d) = %v", gid, err)
Expand Down

0 comments on commit 569c4e7

Please sign in to comment.