我可以以非特权用户身份执行 yum 查询吗?

我可以以非特权用户身份执行 yum 查询吗?

我猜想,作为非特权用户,我无法执行yum installyum update,这是可以理解的。但我本以为我可以执行yum searchyum whatprovides。这些命令不会对我的本地系统进行任何更改,只会查询存储库中的内容。

但是,当尝试运行yum searchyum whatprovides以非特权用户身份运行时,我收到以下错误:

bash-4.2$ yum search openssh-server
ovl: Error while doing RPMdb copy-up:                                           
[Errno 13] Permission denied: '/var/lib/rpm/.dbenv.lock'                        


 One of the configured repositories failed (Unknown),                           
 and yum doesn't have enough cached data to continue. At this point the only    
 safe thing yum can do is fail. There are a few ways to work "fix" this:        

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working  
        upstream. This is most often useful if you are using a newer            
        distribution release than is supported by the repository (and the       
        packages for the previous distribution release still work).             

     3. Run the command with the repository temporarily disabled                
            yum --disablerepo=<repoid> ...                                      

     4. Disable the repository permanently, so yum won't use it by default. Yum 
        will then just ignore the repository until you permanently enable it    
        again or use --enablerepo for temporary usage:                          

            yum-config-manager --disable <repoid>                               
        or                                                                      
            subscription-manager repos --disable=<repoid>                       

     5. Configure the failing repository to be skipped, if it is unavailable.   
        Note that yum will try to contact the repo. when it runs most commands, 
        so will have to try and fail each time (and thus. yum will be be much   
        slower). If it is a very temporary problem though, this is often a nice 
        compromise:                                                             

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Cannot find repomd.xml file for rhel7-x86_64-730                                
bash-4.2$

以 root 身份登录并将其模式更改.dbenv.lock为 666 后,现在我的非特权用户可以yum search但不能yum whatprovides

bash-4.2$ yum search openssh-server
Loaded plugins: ovl, product-id, search-disabled-repos
ovl: Error while doing RPMdb copy-up:
[Errno 13] Permission denied: '/var/lib/rpm/__db.002'
========================= N/S matched: openssh-server ==========================
gsi-openssh-server.x86_64 : SSH server daemon with GSI authentication
openssh-server.x86_64 : An open source SSH server daemon
openssh-server-sysvinit.x86_64 : The SysV initscript to manage the OpenSSH
                               : server.

  Name and summary matches only, use "search all" for everything.
bash-4.2$  

bash-4.2$ yum whatprovides sshd                                                 
Loaded plugins: ovl, product-id, search-disabled-repos                          
ovl: Error while doing RPMdb copy-up:                                           
[Errno 13] Permission denied: '/var/lib/rpm/__db.002'                           


 One of the configured repositories failed (Unknown),                           
 and yum doesn't have enough cached data to continue. At this point the only    
 safe thing yum can do is fail. There are a few ways to work "fix" this:        

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working  
        upstream. This is most often useful if you are using a newer            
        distribution release than is supported by the repository (and the       
        packages for the previous distribution release still work).             

     3. Run the command with the repository temporarily disabled
            yum --disablerepo=<repoid> ...

     4. Disable the repository permanently, so yum won't use it by default. Yum
        will then just ignore the repository until you permanently enable it
        again or use --enablerepo for temporary usage:

            yum-config-manager --disable <repoid>
        or
            subscription-manager repos --disable=<repoid>

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Caching enabled but no local cache of /var/cache/yum/x86_64/7Server/rhel7-x86_64
-730/856d5d541d62809b07538e7b8b666e115e9871a9-filelists.sqlite.bz2 from rhel7-x8
6_64-730
bash-4.2$  

这是因为 yum 会在这样的查询操作期间自动将内容提取到缓存中,如果缓存不可写,则会失败吗?我(作为 root)需要向非特权用户授予哪些文件权限,以便他们可以运行这些 yum 查询(例如,对某些缓存文件夹的写访问权限)?

附言:root 可以yum install正常操作,因此与 yum 存储库服务器本身的连接没有问题。

编辑:将目录中的所有文件的权限更改/var/lib/rpm为 666,并禁用ovl插件后,运行时我没有收到初始错误yum,但仍然无法运行yum whatprovides

bash-4.2$ yum --disableplugin=ovl whatprovides apropos                          
Loaded plugins: product-id, search-disabled-repos                               


 One of the configured repositories failed (Unknown),                           
 and yum doesn't have enough cached data to continue. At this point the only    
 safe thing yum can do is fail. There are a few ways to work "fix" this:        

     1. Contact the upstream for the repository and get them to fix the problem.

     2. Reconfigure the baseurl/etc. for the repository, to point to a working  
        upstream. This is most often useful if you are using a newer            
        distribution release than is supported by the repository (and the       
        packages for the previous distribution release still work).             

     3. Run the command with the repository temporarily disabled                
            yum --disablerepo=<repoid> ...                                      

     4. Disable the repository permanently, so yum won't use it by default. Yum 
        will then just ignore the repository until you permanently enable it    
        again or use --enablerepo for temporary usage:                          

            yum-config-manager --disable <repoid>                               
        or                                                                      
            subscription-manager repos --disable=<repoid>                       

     5. Configure the failing repository to be skipped, if it is unavailable.
        Note that yum will try to contact the repo. when it runs most commands,
        so will have to try and fail each time (and thus. yum will be be much
        slower). If it is a very temporary problem though, this is often a nice
        compromise:

            yum-config-manager --save --setopt=<repoid>.skip_if_unavailable=true

Caching enabled but no local cache of /var/cache/yum/x86_64/7Server/rhel7-x86_64
-730/856d5d541d62809b07538e7b8b666e115e9871a9-filelists.sqlite.bz2 from rhel7-x8
6_64-730

答案1

新版本的 yum 允许您以普通用户身份执行非侵入式操作。使用旧版本时,您需要在软件包repoquery中使用yum-utils

此外,问题似乎是由 ovl 插件引起的,而不是 yum 本身。您可以--disableplugin=ovl暂时禁用它。

相关内容