[openssh-commits] [openssh] branch master updated: upstream: fix "ls -n", which was still displaying user/group names

git+noreply at mindrot.org git+noreply at mindrot.org
Mon Jun 29 18:51:55 AEST 2026


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

The following commit(s) were added to refs/heads/master by this push:
     new a9cb2e30d upstream: fix "ls -n", which was still displaying user/group names
a9cb2e30d is described below

commit a9cb2e30d3a50ba6a24047d87cd80e4b4a18b5ff
Author: djm at openbsd.org <djm at openbsd.org>
AuthorDate: Mon Jun 29 08:48:22 2026 +0000

    upstream: fix "ls -n", which was still displaying user/group names
    
    rather than numeric uids/gids. Based on patch from Tamilan in bz3953
    
    OpenBSD-Commit-ID: 65dd2ecb870b727e872cf9df544f8767426d2cc0
---
 sftp.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/sftp.c b/sftp.c
index 0b57e0833..bd4d91965 100644
--- a/sftp.c
+++ b/sftp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp.c,v 1.252 2026/06/29 01:47:21 djm Exp $ */
+/* $OpenBSD: sftp.c,v 1.253 2026/06/29 08:48:22 djm Exp $ */
 /*
  * Copyright (c) 2001-2004 Damien Miller <djm at openbsd.org>
  *
@@ -899,13 +899,16 @@ do_ls_dir(struct sftp_conn *conn, const char *path,
 			    sftp_can_get_users_groups_by_id(conn)) {
 				char *lname;
 				struct stat sb;
+				const char *user = NULL, *group = NULL;
 
+				if ((lflag & LS_NUMERIC_VIEW) == 0) {
+					user = ruser_name(sb.st_uid);
+					group = rgroup_name(sb.st_gid);
+				}
 				memset(&sb, 0, sizeof(sb));
 				attrib_to_stat(&d[n]->a, &sb);
 				lname = ls_file(fname, &sb, 1,
-				    (lflag & LS_SI_UNITS),
-				    ruser_name(sb.st_uid),
-				    rgroup_name(sb.st_gid));
+				    (lflag & LS_SI_UNITS), user, group);
 				mprintf("%s\n", lname);
 				free(lname);
 			} else
@@ -1038,15 +1041,19 @@ do_globbed_ls(struct sftp_conn *conn, const char *path,
 		i = indices[j];
 		fname = path_strip(g.gl_pathv[i], strip_path);
 		if (lflag & LS_LONG_VIEW) {
+			const char *user = NULL, *group = NULL;
+
 			if (g.gl_statv[i] == NULL) {
 				error("no stat information for %s", fname);
 				free(fname);
 				continue;
 			}
+			if ((lflag & LS_NUMERIC_VIEW) == 0) {
+				user = ruser_name(g.gl_statv[i]->st_uid);
+				group = rgroup_name(g.gl_statv[i]->st_gid);
+			}
 			lname = ls_file(fname, g.gl_statv[i], 1,
-			    (lflag & LS_SI_UNITS),
-			    ruser_name(g.gl_statv[i]->st_uid),
-			    rgroup_name(g.gl_statv[i]->st_gid));
+			    (lflag & LS_SI_UNITS), user, group);
 			mprintf("%s\n", lname);
 			free(lname);
 		} else {

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list