Project

General

Profile

Actions

Bug #14779

closed

The function prtconf/prtconf.c:cleanup_path can be replaced by realpath(3C)

Added by Sachidananda Urs about 1 month ago. Updated 24 days ago.

Status:
Closed
Priority:
Low
Assignee:
-
Category:
-
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Bite-size
Tags:
Gerrit CR:

Description

The cleanup_path function in prtconf/prtconf.c sanitises the path. Which is essentially the same done by realpath(3C).
This function can be replaced by realpath(3C).

Actions #1

Updated by Electric Monk 29 days ago

  • Gerrit CR set to 2236
Actions #2

Updated by Sachidananda Urs 28 days ago

Some of the tests run:

# ./prtconf -a /dev/fbs/gfx0 
i86pc
    pci, instance #0
        display, instance #0

# ./prtconf -ad /dev/fbs/gfx0 
i86pc
    pci, instance #0
        display (pciex8086,412) [Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller], instance #0

# ./prtconf -adD /devices/pci\@0\,0/display\@2\:gfx0 
i86pc (driver name: rootnex)
    pci, instance #0 (driver name: npe)
        display (pciex8086,412) [Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller], instance #0 (driver name: i915)

# ./prtconf -a /dev/sad/admin 
i86pc
    pseudo, instance #0
        sad, instance #0

# ./prtconf -aD /devices/pseudo/sad\@0\:admin 
i86pc (driver name: rootnex)
    pseudo, instance #0 (driver name: pseudo)
        sad, instance #0 (driver name: sad)


I have tested both the symlinks to the devices and the path to the device file.
Actions #3

Updated by Electric Monk 24 days ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

git commit f73c681df5e443d3ae471c59776cbb44eb9eb90a

commit  f73c681df5e443d3ae471c59776cbb44eb9eb90a
Author: Sachidananda Urs <sacchi@gmail.com>
Date:   2022-07-16T01:08:37.000Z

    14779 The function prtconf/prtconf.c:cleanup_path can be replaced by realpath(3C)
    Reviewed by: Gergő Mihály Doma <domag02@gmail.com>
    Reviewed by: Andy Fiddaman <andy@omnios.org>
    Reviewed by: Garrett D'Amore <garrett@damore.org>
    Approved by: Robert Mustacchi <rm@fingolfin.org>

Actions #4

Updated by Sachidananda Urs 24 days ago

Further test results on directories.

# ./prtconf /devices/pci\@0\,0/
pci, instance #0

ln -s /devices/pci\@0\,0 /tmp/foo
$ ./prtconf /tmp/foo/
pci, instance #0

The above case is a behavioral change. Where as currently the result is:

$ prtconf /tmp/foo/
prtconf: invalid device path specified

The current version of prtconf fails when relative path is specified. For example:
$ cd /devices
$ prtconf pci\@0\,0/display\@2
prtconf: invalid device path specified

The patched version works in this case:
$ /work/illumos-gate/usr/src/cmd/prtconf/amd64/prtconf pci\@0\,0/display\@2
display, instance #0
$

This is another behavioral change caused by the patch.

Actions

Also available in: Atom PDF