Skip to content
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

Permissions with SGID flag, does not respect umask ? #121

Open
teluq-pbrideau opened this issue Nov 30, 2023 · 0 comments
Open

Permissions with SGID flag, does not respect umask ? #121

teluq-pbrideau opened this issue Nov 30, 2023 · 0 comments

Comments

@teluq-pbrideau
Copy link

I’m trying to have a puppet git repository owned by a group, so every user might run librarian-puppet on the environment folder without having to switch to a service user…

But look to me librarian-puppet does not respect the umask for this…

:~$ mkdir /tmp/foo
:~$ chown :bar /tmp/foo
:~$ chmod 2775 /tmp/foo
:~$ umask
0002

I can create content in this directory with the correct ownership

:~$ cd /tmp/foo
:/tmp/foo$ mkdir baz
:/tmp/foo$ ls -ld baz
drwxrwsr-x 2 vagrant bar 6 Nov 30 12:31 baz
:/tmp/foo$ git clone 'https://github.com/voxpupuli/librarian-puppet.git'
:/tmp/foo$ ls -ld librarian-puppet
drwxrwsr-x 9 vagrant bar 4096 Nov 30 12:32 librarian-puppet/

But using librarian-puppet, the permissions does not follow:

:/tmp/foo$ echo "forge 'https://forgeapi.puppetlabs.com'" > Puppetfile
:/tmp/foo$ echo "mod 'saz-timezone'" >> Puppetfile
:/tmp/foo$ librarian-puppet install
:/tmp/foo$ ls -ld modules/timezone
drwxr-sr-x 5 vagrant bar 163 May 27  2023 modules/timezone/

permissions are 2755 instead of 2775 on the downloaded modules. Therefore, another user cannot update at a later date:

:/tmp/foo$ librarian-puppet install
Traceback (most recent call last):                                                                                             
        37: from /usr/local/bin/librarian-puppet:23:in `<main>'                                                                
        36: from /usr/local/bin/librarian-puppet:23:in `load'                                                                  
        35: from /usr/local/share/gems/gems/librarian-puppet-5.0.0/bin/librarian-puppet:7:in `<top (required)>'                
        34: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/cli.rb:26:in `bin!'                                 
        33: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/cli.rb:47:in `with_environment'                     
        32: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/cli.rb:26:in `block in bin!'                        
        31: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/cli.rb:31:in `returning_status'                     
        30: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/cli.rb:26:in `block (2 levels) in bin!'             
        29: from /usr/local/share/gems/gems/thor-1.3.0/lib/thor/base.rb:584:in `start'                                         
        28: from /usr/local/share/gems/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch'                                           
        27: from /usr/local/share/gems/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command'                          
        26: from /usr/local/share/gems/gems/thor-1.3.0/lib/thor/command.rb:28:in `run'                                        
        25: from /usr/local/share/gems/gems/librarian-puppet-5.0.0/lib/librarian/puppet/cli.rb:70:in `install'                
        24: from /usr/local/share/gems/gems/librarian-puppet-5.0.0/lib/librarian/puppet/cli.rb:108:in `install!'              
        23: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/action/install.rb:12:in `run'                      
        22: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/action/install.rb:39:in `perform_installation'     
        21: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/action/install.rb:48:in `install_manifests'        
        20: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/action/install.rb:48:in `each'                     
        19: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/action/install.rb:49:in `block in install_manifests'
        18: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/manifest.rb:73:in `install!'                       
        17: from /usr/local/share/gems/gems/librarian-puppet-5.0.0/lib/librarian/puppet/source/forge.rb:94:in `install!'      
        16: from /usr/local/share/gems/gems/librarian-puppet-5.0.0/lib/librarian/puppet/source/forge/repo.rb:59:in `install_version!'
        15: from /usr/share/ruby/pathname.rb:589:in `rmtree'
        14: from /usr/share/ruby/fileutils.rb:626:in `rm_r'
        13: from /usr/share/ruby/fileutils.rb:626:in `each'
        12: from /usr/share/ruby/fileutils.rb:630:in `block in rm_r'                                                          
        11: from /usr/share/ruby/fileutils.rb:778:in `remove_entry'                                                           
        10: from /usr/share/ruby/fileutils.rb:1502:in `postorder_traverse'                                                    
         9: from /usr/share/ruby/fileutils.rb:1502:in `each'
         8: from /usr/share/ruby/fileutils.rb:1503:in `block in postorder_traverse'                                           
         7: from /usr/share/ruby/fileutils.rb:1509:in `postorder_traverse'                                                    
         6: from /usr/share/ruby/fileutils.rb:1504:in `block (2 levels) in postorder_traverse'                                
         5: from /usr/share/ruby/fileutils.rb:780:in `block in remove_entry'                                                  
         4: from /usr/share/ruby/fileutils.rb:1454:in `remove'
         3: from /usr/share/ruby/fileutils.rb:1465:in `remove_file'                                                           
         2: from /usr/share/ruby/fileutils.rb:1471:in `platform_support'                                                      
         1: from /usr/share/ruby/fileutils.rb:1466:in `block in remove_file'                                                  
/usr/share/ruby/fileutils.rb:1466:in `unlink': Permission denied @ apply2files - /tmp/foo/modules/debconf/CHANGELOG.md (Errno::EACCES)
        34: from /usr/local/bin/librarian-puppet:23:in `<main>'                                                               
        33: from /usr/local/bin/librarian-puppet:23:in `load'
        32: from /usr/local/share/gems/gems/librarian-puppet-5.0.0/bin/librarian-puppet:7:in `<top (required)>'               
        31: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/cli.rb:26:in `bin!'                                
        30: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/cli.rb:47:in `with_environment'                    
        29: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/cli.rb:26:in `block in bin!'                       
        28: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/cli.rb:31:in `returning_status'                    
        27: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/cli.rb:26:in `block (2 levels) in bin!'            
        26: from /usr/local/share/gems/gems/thor-1.3.0/lib/thor/base.rb:584:in `start'                                        
        25: from /usr/local/share/gems/gems/thor-1.3.0/lib/thor.rb:527:in `dispatch'                                          
        24: from /usr/local/share/gems/gems/thor-1.3.0/lib/thor/invocation.rb:127:in `invoke_command'                         
        23: from /usr/local/share/gems/gems/thor-1.3.0/lib/thor/command.rb:28:in `run'                                        
        22: from /usr/local/share/gems/gems/librarian-puppet-5.0.0/lib/librarian/puppet/cli.rb:70:in `install'                
        21: from /usr/local/share/gems/gems/librarian-puppet-5.0.0/lib/librarian/puppet/cli.rb:108:in `install!'              
        20: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/action/install.rb:12:in `run'                      
        19: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/action/install.rb:39:in `perform_installation'     
        18: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/action/install.rb:48:in `install_manifests'        
        17: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/action/install.rb:48:in `each'                     
        16: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/action/install.rb:49:in `block in install_manifests'
        15: from /usr/local/share/gems/gems/librarianp-1.1.2/lib/librarian/manifest.rb:73:in `install!'                       
        14: from /usr/local/share/gems/gems/librarian-puppet-5.0.0/lib/librarian/puppet/source/forge.rb:94:in `install!'      
        13: from /usr/local/share/gems/gems/librarian-puppet-5.0.0/lib/librarian/puppet/source/forge/repo.rb:59:in `install_version!'
        12: from /usr/share/ruby/pathname.rb:589:in `rmtree'
        11: from /usr/share/ruby/fileutils.rb:626:in `rm_r'
        10: from /usr/share/ruby/fileutils.rb:626:in `each'
         9: from /usr/share/ruby/fileutils.rb:630:in `block in rm_r'                                                          
         8: from /usr/share/ruby/fileutils.rb:778:in `remove_entry'                                                           
         7: from /usr/share/ruby/fileutils.rb:1509:in `postorder_traverse'                                                    
         6: from /usr/share/ruby/fileutils.rb:1509:in `ensure in postorder_traverse'                                          
         5: from /usr/share/ruby/fileutils.rb:780:in `block in remove_entry'                                                  
         4: from /usr/share/ruby/fileutils.rb:1452:in `remove'
         3: from /usr/share/ruby/fileutils.rb:1459:in `remove_dir1'                                                           
         2: from /usr/share/ruby/fileutils.rb:1471:in `platform_support'                                                      
         1: from /usr/share/ruby/fileutils.rb:1460:in `block in remove_dir1'                                                  
/usr/share/ruby/fileutils.rb:1460:in `rmdir': Directory not empty @ dir_s_rmdir - /tmp/foo/modules/debconf (Errno::ENOTEMPTY) 

I’ve searched in the upstream librarian repository, that appears to use the Process.spawn() to execute a command:

https://github.com/applicationsonline/librarian/blob/b968cd91a3955657bf6ea728b922f2cb74843264/lib/librarian/source/git/repository.rb#L48
https://github.com/applicationsonline/librarian/blob/b968cd91a3955657bf6ea728b922f2cb74843264/lib/librarian/source/git/repository.rb#L138
https://github.com/applicationsonline/librarian/blob/b968cd91a3955657bf6ea728b922f2cb74843264/lib/librarian/posix.rb#L146
https://github.com/applicationsonline/librarian/blob/b968cd91a3955657bf6ea728b922f2cb74843264/lib/librarian/posix.rb#L123

and running manuall the command seems to give the correct permissions:

:/tmp/foo$ irb
irb(main):001:0> Process.spawn('git clone https://github.com/voxpupuli/librarian-puppet.git')
[...]
^D
:/tmp/foo$ ls -ld librarian-puppet/
drwxrwsr-x 9 vagrant bar 4096 Nov 30 12:58 librarian-puppet/

I’m a bit out of my leage here… Is it a bug in Librarian? Is it a bug in Librarian-Puppet? Is it an intended feature? Is there a config I can set for this to work?

I’m not sure if this issue is the right place for my problem… Should I create a stackoverflow account to ask this question?

Tested on Rocky8
librarian-puppet installed with gem install librarian-puppet

:~$ librarian-puppet --version
librarian-puppet v5.0.0
:~$ ruby --version
ruby 2.7.8p225 (2023-03-30 revision 1f4d455848) [x86_64-linux]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant