]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: fill UID column with the process's uid
authorMasatake YAMATO <yamato@redhat.com>
Mon, 11 Oct 2021 21:27:58 +0000 (06:27 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Mon, 11 Oct 2021 21:44:34 +0000 (06:44 +0900)
The original code fills the column with the owner id of the executable
file. Because lsfd fills USER column field by decoding UID column, the
USER in lsfd meant the owner name of the executable.

On the other hand, lsof fills the USER column with the process's user
name.

To avoid users confusing, this change makes lsfd do the same lsof;
filling UID column with the process's uid.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
misc-utils/lsfd.c

index d586b551414a65c21fc23a323d1cbda91742ab8b..cf2a1497db27ec0695732dca8b980c473c46c8cf 100644 (file)
@@ -139,7 +139,7 @@ static struct colinfo infos[] = {
        [COL_TYPE]    = { "TYPE",     0, SCOLS_FL_RIGHT, SCOLS_JSON_STRING,
                N_("file type") },
        [COL_UID]     = { "UID",      0, SCOLS_FL_RIGHT, SCOLS_JSON_NUMBER,
-               N_("user ID number") },
+               N_("user ID number of the process") },
        [COL_USER]    = { "USER",     0, SCOLS_FL_RIGHT, SCOLS_JSON_STRING,
                N_("user of the process") },
 };
@@ -443,8 +443,6 @@ static struct file *collect_file_symlink(struct path_cxt *pc,
 
        file_init_content(f);
 
-       if (is_association(f, EXE))
-               proc->uid = sb.st_uid;
        if (is_association(f, NS_MNT))
                proc->ns_mnt = sb.st_ino;
 
@@ -857,6 +855,7 @@ static void read_process(struct lsfd_control *ctl, struct path_cxt *pc,
        proc = new_process(pid, leader);
        proc->command = procfs_process_get_cmdname(pc, buf, sizeof(buf)) > 0 ?
                        xstrdup(buf) : xstrdup(_("(unknown)"));
+       procfs_process_get_uid(pc, &proc->uid);
 
        collect_execve_file(pc, proc);