Page MenuHomeFreeBSD

Capsicumize fsdb
Needs ReviewPublic

Authored by shubh on Aug 2 2020, 12:45 AM.
Referenced Files
Unknown Object (File)
Dec 27 2023, 12:27 PM
Unknown Object (File)
Nov 21 2023, 5:57 PM
Unknown Object (File)
Nov 13 2023, 3:29 PM
Unknown Object (File)
Nov 12 2023, 2:25 AM
Unknown Object (File)
Nov 11 2023, 7:57 AM
Unknown Object (File)
Nov 10 2023, 3:49 PM
Unknown Object (File)
Nov 9 2023, 7:08 AM
Unknown Object (File)
Nov 8 2023, 10:55 PM
Subscribers

Details

Reviewers
oshogbo
markj
Summary

Where and why did I enter the capability mode?

  • fsdb calls setup() from the fsck_ffs directory, which opens the arg device
  • doing cap_enter() inside wouldn't allow el_init() to open termcap.db and el_source() to open ~/.editrc
  • Hence, I did a cap_enter after el_source() inside cmdloop()

Why did I use cap_pwd and cap_grp casper services

  • printactive() from fsdbutil.c calls getpwuid() and getgrgid()
  • printactive() is called before entering the capabality mode, hence I checked if the casper service is opened or not in fsdbutil.c
  • printactive() is also called after entering the capability mode, for fsdb commands such as *active*. Hence, casper service was needed here
Test Plan

ktrace fsdb /dev/<device_ffs>
kdump | grep cap. //to see if cap_enter() is called

fsdb /dev/<device_ffs>
active //to see if casper functions work or not

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

shubh requested review of this revision.Aug 2 2020, 12:45 AM
sbin/fsdb/fsdb.c
67

New line after this.

253

Some ident are broken in this block.

sbin/fsdb/fsdb.h
36

Why we are including this in the fsdb header?

sbin/fsdb/fsdbutil.c
187–188

Why u are checking cappwd, capgrp and so on?

sbin/fsdb/fsdbutil.c
187–188

So, as you can see inside fsdb.c, inside the cmdloop(), printactive() and hence printstat() is called before I open the casper servcies. So, here I checked if the casper services are opened or not, if they are then use the casper functions, otherwise use the normal functions.

I have this constraint where I have to enter the capability mode after the el_source() function

sbin/fsdb/fsdbutil.c
187–188

Gatcha. Thats ok.

sbin/fsdb/fsdb.c
253

Unfortunately, this file doesn't conform to our usual code style. Here, indentation is by four spaces, and eight consecutive spaces are converted into a tab.

sbin/fsdb/fsdbutil.c
187–188

I would suggest adding a comment explaining this.

sbin/fsdb/fsdb.h
36

I need to include <libcasper.h> atleast, because I am defining cappwd and capgrp as extern variables in this file. I can move the cap_pwd include to fsdbutil.c

  • Fixed indents
  • Added 2 comments
sbin/fsdb/fsdbutil.c
187–188

We have to comment explaining that we call this function in sandbox and without sandbox.