Skip to content

Commit

Permalink
ftpd: stop using -g flag for /bin/ls
Browse files Browse the repository at this point in the history
In 3bfbb52 the behaviour of ls was changed such that -g was no longer
a noop for compatibility with BSD 4.3, but instead changed the output
of long mode to exclude the owner of the file and display only the
group.

Update how FTPd invokes ls to restore the previous behaviour

Reported-by:	Andrew Fengler <andrew.fengler@scaleengine.com>
Reviewed-by:	jrtc27, des, imp
MFC after:	3 days
Sponsored-by:	ScaleEngine Inc.
Fixes:		3bfbb52 ("ls: Improve POSIX compatibility for -g and -n.")
  • Loading branch information
allanjude committed May 21, 2024
1 parent a4be1eb commit e209715
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions libexec/ftpd/ftpcmd.y
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,12 @@ cmd
| LIST check_login CRLF
{
if ($2)
retrieve(_PATH_LS " -lgA", "");
retrieve(_PATH_LS " -lA", "");
}
| LIST check_login SP pathstring CRLF
{
if ($2)
retrieve(_PATH_LS " -lgA %s", $4);
retrieve(_PATH_LS " -lA %s", $4);
free($4);
}
| STAT check_login SP pathname CRLF
Expand Down
2 changes: 1 addition & 1 deletion libexec/ftpd/ftpd.8
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ is specified.
.It EPSV Ta "prepare for server-to-server transfer, multiprotocol"
.It FEAT Ta "give information on extended features of server"
.It HELP Ta "give help information"
.It LIST Ta "give list files in a directory" Pq Dq Li "ls -lgA"
.It LIST Ta "give list files in a directory" Pq Dq Li "ls -lA"
.It LPRT Ta "specify data connection port, multiprotocol"
.It LPSV Ta "prepare for server-to-server transfer, multiprotocol"
.It MDTM Ta "show last modification time of file"
Expand Down
2 changes: 1 addition & 1 deletion libexec/ftpd/ftpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2321,7 +2321,7 @@ statfilecmd(char *filename)
struct stat st;

code = lstat(filename, &st) == 0 && S_ISDIR(st.st_mode) ? 212 : 213;
(void)snprintf(line, sizeof(line), _PATH_LS " -lgA %s", filename);
(void)snprintf(line, sizeof(line), _PATH_LS " -lA %s", filename);
fin = ftpd_popen(line, "r");
if (fin == NULL) {
perror_reply(551, filename);
Expand Down

0 comments on commit e209715

Please sign in to comment.