8000 Revert "lookup username/group-name for longname" · etherscan-io/sftp@1073df2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1073df2

Browse files
committed
Revert "lookup username/group-name for longname"
This reverts commit 5bf2a17 and commit 6d8540e. Fixes pkg#249
1 parent 1bad494 commit 1073df2

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

server_unix.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package sftp
66
import (
77
"fmt"
88
"os"
9-
"os/user"
109
"path"
1110
"syscall"
1211
"time"
@@ -20,14 +19,12 @@ func runLsStatt(dirent os.FileInfo, statt *syscall.Stat_t) string {
2019

2120
typeword := runLsTypeWord(dirent)
2221
numLinks := statt.Nlink
23-
username := fmt.Sprintf("%d", statt.Uid)
24-
if usr, err := user.LookupId(username); err == nil {
25-
username = usr.Username
26-
}
27-
groupname := fmt.Sprintf("%d", statt.Gid)
28-
if grp, err := user.LookupGroupId(groupname); err == nil {
29-
groupname = grp.Name
30-
}
22+
uid := statt.Uid
23+
gid := statt.Gid
24+
username := fmt.Sprintf("%d", uid)
25+
groupname := fmt.Sprintf("%d", gid)
26+
// TODO FIXME: uid -> username, gid -> groupname lookup for ls -l format output
27+
3128
mtime := dirent.ModTime()
3229
monthStr := mtime.Month().String()[0:3]
3330
day := mtime.Day()
@@ -40,9 +37,7 @@ func runLsStatt(dirent os.FileInfo, statt *syscall.Stat_t) string {
4037
yearOrTime = fmt.Sprintf("%d", year)
4138
}
4239

43-
return fmt.Sprintf("%s %4d %-8s %-8s %8d %s %2d %5s %s", typeword,
44-
numLinks, username, groupname, dirent.Size(), monthStr, day,
45-
yearOrTime, dirent.Name())
40+
return fmt.Sprintf("%s %4d %-8s %-8s %8d %s %2d %5s %s", typeword, numLinks, username, groupname, dirent.Size(), monthStr, day, yearOrTime, dirent.Name())
4641
}
4742

4843
// ls -l style output for a file, which is in the 'long output' section of a readdir response packet

0 commit comments

Comments
 (0)
0