bugJailkit - Bugs: bug #61130, jk_lib.py calculates incorrect...

 
 

bug #61130: jk_lib.py calculates incorrect device major number

Submitter:  Jesse Norell <jnorell>
Submitted:  Wed 08 Sep 2021 09:26:12 PM UTC
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment (Rich Markup)
   

Comment Type & Canned Response:
       No canned response available

 

Thu 09 Sep 2021 12:39:24 PM UTC, comment #1: 

thanks, fixed in revision 1.104

Olivier Sessink <oli4>
Project Administrator
Wed 08 Sep 2021 09:26:12 PM UTC, original submission:  

jk_lib.py uses the division operator to obtain the major device number, and the division operator always returns a floating point, not an integer.  It should use the floor division operator:

--- /usr/share/jailkit/jk_lib.py.orig   2021-09-08 14:52:21.196000000 -0600
+++ /usr/share/jailkit/jk_lib.py        2021-09-08 15:01:07.748000000 -0600
@@ -578,18 +578,18 @@
        sb = os.stat(path)
        try:
                if (sys.platform[:5] == 'linux'):
-                       major = sb.st_rdev / 256 #major = st_rdev divided by 256 (8bit reserved for the minor number)
+                       major = sb.st_rdev // 256 #major = st_rdev divided by 256 (8bit reserved for the minor number)
                        minor = sb.st_rdev % 256 #minor = remainder of st_rdev divided by 256
                elif (sys.platform == 'sunos5'):
                        if (sys.maxint == 2147483647):
-                               major = sb.st_rdev / 262144 #major = st_rdev divided by 256 (18 bits reserved for the minor number)
+                               major = sb.st_rdev // 262144 #major = st_rdev divided by 256 (18 bits reserved for the minor number)
                                minor = sb.st_rdev % 262144 #minor = remainder of st_rdev divided by 256
                        else:
                                #64 bit solaris has 32 bit minor/32bit major
-                               major = sb.st_rdev / 2147483647
+                               major = sb.st_rdev // 2147483647
                                minor =  sb.st_rdev % 2147483647
                else:
-                       major = sb.st_rdev / 256 #major = st_rdev divided by 256
+                       major = sb.st_rdev // 256 #major = st_rdev divided by 256
                        minor = sb.st_rdev % 256 #minor = remainder of st_rdev divided by 256
                if (stat.S_ISCHR(sb.st_mode)):
                        mode = 'c'

Jesse Norell <jnorell>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by oli4 (Posted a comment)
  • -email is unavailable- added by jnorell (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

     

     

     

    Follows 1 latest change.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-09-09 oli4 StatusNone Fixed

    Back to the top


    Powered by Savane 3.9