- 
                Notifications
    
You must be signed in to change notification settings  - Fork 3.1k
 
jail(8): implement NUL-terminated output #1836
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            kraken-jim
  wants to merge
  3
  commits into
  freebsd:main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
kraken-jim:jail-nul-patch
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
                
     Open
            
            
          Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    specifiying an empty string as the argument to "-e". Update man page to reflect the change in behavior.
| 
           Thank you for taking the time to contribute to FreeBSD! Please review CONTRIBUTING.md, then update and push your branch again.  | 
    
| 
           Sample output scenarios: # cat /etc/jail.conf.d/test.conf 
test {
    host.hostname = "test.example.edu";
    ip4.addr  = "vlan3|192.168.1.50/32";
    ip4.addr += "private|192.168.1.95-99/32";
    allow.raw_sockets   = 1;
    mount  = "/filesystem-a   $path/mnt/a nullfs  ro  0   0";
    mount += "/filesystem-b   $path/mnt/b nullfs  ro  0   0";
    mount += "/filesystem-c   $path/mnt/c nullfs  ro  0   0";
    mount += "/filesystem-d   $path/mnt/d nullfs  ro  0   0";
    mount += "/filesystem-e   $path/mnt/e nullfs  ro  0   0";
}Existing behavior: # jail.old -e $'\n'; jail.old -e $'\n' | sha256sum
name=test
exec.start="/bin/sh /etc/rc"
exec.stop="/bin/sh /etc/rc.shutdown"
exec.consolelog=/var/log/jail_test.log
host.hostname=test.example.edu
path=/jail/test
interface=private
linux.osname=FreeBSD
mount.devfs
ip4.addr=vlan3|192.168.1.50/32,private|192.168.1.95-99/32
allow.raw_sockets=1
mount="/filesystem-a    /jail/test/mnt/a    nullfs  ro  0   0","/filesystem-b   /jail/test/mnt/b    nullfs  ro  0   0","/filesystem-c    /jail/test/mnt/c    nullfs  ro  0   0","/filesystem-d   /jail/test/mnt/d    nullfs  ro  0   0","/filesystem-e   /jail/test/mnt/e nullfs  ro  0   0"
1078af124c2a887aed44377860543a96e656f6213e492430d646727c3beb8670  -New behavior (unchanged): # jail -e $'\n'; jail -e $'\n' | sha256sum
name=test
exec.start="/bin/sh /etc/rc"
exec.stop="/bin/sh /etc/rc.shutdown"
exec.consolelog=/var/log/jail_test.log
host.hostname=test.example.edu
path=/jail/test
interface=private
linux.osname=FreeBSD
mount.devfs
ip4.addr=vlan3|192.168.1.50/32,private|192.168.1.95-99/32
allow.raw_sockets=1
mount="/filesystem-a    /jail/test/mnt/a    nullfs  ro  0   0","/filesystem-b   /jail/test/mnt/b    nullfs  ro  0   0","/filesystem-c    /jail/test/mnt/c    nullfs  ro  0   0","/filesystem-d   /jail/test/mnt/d    nullfs  ro  0   0","/filesystem-e   /jail/test/mnt/e nullfs  ro  0   0"
1078af124c2a887aed44377860543a96e656f6213e492430d646727c3beb8670  -New behavior (NUL-delimited): # jail -e '' | xargs -0 -Ixx echo xx
name=test
exec.start=/bin/sh /etc/rc
exec.stop=/bin/sh /etc/rc.shutdown
exec.consolelog=/var/log/jail_test.log
host.hostname=test.example.edu
path=/jail/test
interface=private
linux.osname=FreeBSD
mount.devfs
ip4.addr=vlan3|192.168.1.50/32
private|192.168.1.95-99/32
allow.raw_sockets=1
mount=/filesystem-a /jail/test/mnt/a    nullfs  ro  0   0
/filesystem-b   /jail/test/mnt/b    nullfs  ro  0   0
/filesystem-c   /jail/test/mnt/c    nullfs  ro  0   0
/filesystem-d   /jail/test/mnt/d    nullfs  ro  0   0
/filesystem-e   /jail/test/mnt/e    nullfs  ro  0   0
# jail -e '' | hexdump -Cv
00000000  6e 61 6d 65 3d 74 65 73  74 00 65 78 65 63 2e 73  |name=test.exec.s|
00000010  74 61 72 74 3d 2f 62 69  6e 2f 73 68 20 2f 65 74  |tart=/bin/sh /et|
00000020  63 2f 72 63 00 65 78 65  63 2e 73 74 6f 70 3d 2f  |c/rc.exec.stop=/|
00000030  62 69 6e 2f 73 68 20 2f  65 74 63 2f 72 63 2e 73  |bin/sh /etc/rc.s|
00000040  68 75 74 64 6f 77 6e 00  65 78 65 63 2e 63 6f 6e  |hutdown.exec.con|
00000050  73 6f 6c 65 6c 6f 67 3d  2f 76 61 72 2f 6c 6f 67  |solelog=/var/log|
00000060  2f 6a 61 69 6c 5f 74 65  73 74 2e 6c 6f 67 00 68  |/jail_test.log.h|
00000070  6f 73 74 2e 68 6f 73 74  6e 61 6d 65 3d 74 65 73  |ost.hostname=tes|
00000080  74 2e 65 78 61 6d 70 6c  65 2e 65 64 75 00 70 61  |t.example.edu.pa|
00000090  74 68 3d 2f 6a 61 69 6c  2f 74 65 73 74 00 69 6e  |th=/jail/test.in|
000000a0  74 65 72 66 61 63 65 3d  70 72 69 76 61 74 65 00  |terface=private.|
000000b0  6c 69 6e 75 78 2e 6f 73  6e 61 6d 65 3d 46 72 65  |linux.osname=Fre|
000000c0  65 42 53 44 00 6d 6f 75  6e 74 2e 64 65 76 66 73  |eBSD.mount.devfs|
000000d0  00 69 70 34 2e 61 64 64  72 3d 76 6c 61 6e 33 7c  |.ip4.addr=vlan3||
000000e0  31 39 32 2e 31 36 38 2e  31 2e 35 30 2f 33 32 0a  |192.168.1.50/32.|
000000f0  70 72 69 76 61 74 65 7c  31 39 32 2e 31 36 38 2e  |private|192.168.|
00000100  31 2e 39 35 2d 39 39 2f  33 32 00 61 6c 6c 6f 77  |1.95-99/32.allow|
00000110  2e 72 61 77 5f 73 6f 63  6b 65 74 73 3d 31 00 6d  |.raw_sockets=1.m|
00000120  6f 75 6e 74 3d 2f 66 69  6c 65 73 79 73 74 65 6d  |ount=/filesystem|
00000130  2d 61 09 2f 6a 61 69 6c  2f 74 65 73 74 2f 6d 6e  |-a./jail/test/mn|
00000140  74 2f 61 09 6e 75 6c 6c  66 73 09 72 6f 09 30 09  |t/a.nullfs.ro.0.|
00000150  30 0a 2f 66 69 6c 65 73  79 73 74 65 6d 2d 62 09  |0./filesystem-b.|
00000160  2f 6a 61 69 6c 2f 74 65  73 74 2f 6d 6e 74 2f 62  |/jail/test/mnt/b|
00000170  09 6e 75 6c 6c 66 73 09  72 6f 09 30 09 30 0a 2f  |.nullfs.ro.0.0./|
00000180  66 69 6c 65 73 79 73 74  65 6d 2d 63 09 2f 6a 61  |filesystem-c./ja|
00000190  69 6c 2f 74 65 73 74 2f  6d 6e 74 2f 63 09 6e 75  |il/test/mnt/c.nu|
000001a0  6c 6c 66 73 09 72 6f 09  30 09 30 0a 2f 66 69 6c  |llfs.ro.0.0./fil|
000001b0  65 73 79 73 74 65 6d 2d  64 09 2f 6a 61 69 6c 2f  |esystem-d./jail/|
000001c0  74 65 73 74 2f 6d 6e 74  2f 64 09 6e 75 6c 6c 66  |test/mnt/d.nullf|
000001d0  73 09 72 6f 09 30 09 30  0a 2f 66 69 6c 65 73 79  |s.ro.0.0./filesy|
000001e0  73 74 65 6d 2d 65 09 2f  6a 61 69 6c 2f 74 65 73  |stem-e./jail/tes|
000001f0  74 2f 6d 6e 74 2f 65 09  6e 75 6c 6c 66 73 09 72  |t/mnt/e.nullfs.r|
00000200  6f 09 30 09 30 00 00                              |o.0.0..|
00000207 | 
    
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Specifiying an empty string as the argument to
"-e"will cause this version ofjail(8)to output NUL-terminated lines, to make string quoting unambiguous. The NUL-terminated lines are the exact verbatim values of the variables defined injail.conf(5). man pagejail(8)is also updated to reflect the change in behavior.