<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>41501</bug_id>
          
          <creation_ts>2021-12-04 03:02:02 +0300</creation_ts>
          <short_desc>share_network не читается из .hasher/config</short_desc>
          <delta_ts>2022-05-15 21:02:42 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>hasher</component>
          <version>unstable</version>
          <rep_platform>all</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>LATER</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P5</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Konstantin A Lepikhov (L.A. Kostis)">lakostis</reporter>
          <assigned_to name="Dmitry V. Levin">ldv</assigned_to>
          <cc>at</cc>
    
    <cc>glebfm</cc>
    
    <cc>ldv</cc>
    
    <cc>placeholder</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>205699</commentid>
    <comment_count>0</comment_count>
    <who name="Konstantin A Lepikhov (L.A. Kostis)">lakostis</who>
    <bug_when>2021-12-04 03:02:02 +0300</bug_when>
    <thetext>$ rpm -q hasher
hasher-1.4.7-alt1.noarch

$ cat ~/.hasher/config 
share_network=1
install_resolver_configuration_files=1

Однако

[lakostis@lks build (master)]$ hsh-run --rooter /opt/builds/tmp -- sh -c &quot;curl 192.168.1.1&quot;
curl: (7) Couldn&apos;t connect to server
[lakostis@lks build (master)]$ share_network=1 hsh-run --rooter /opt/builds/tmp -- sh -c &quot;curl 192.168.1.1&quot;
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1485  100  1485    0     0   361k      0 --:--:-- --:--:-- --:--:--  483k
&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;meta charset=utf-8&gt;&lt;meta http-equiv=Cache-Control

Более того, если сделать export share_network=1 так тоже работает:

[lakostis@lks build (master)]$ export share_network=1; hsh-run --rooter /opt/builds/tmp -- sh -c &quot;curl 192.168.1.1&quot;
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1485  100  1485    0     0   115k      0 --:--:-- --:--:-- --:--:--  120k
&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;meta charset=utf-8&gt;&lt;meta http-equiv=Cache-Control content=no-store&gt;&lt;meta http-equiv=cache-control content=no-cache&gt;&lt;meta http-equiv=cache-control content=&quot;max-age=0&quot;&gt;&lt;meta name=viewport content=&quot;width=device-width,initial-scaC
[lakostis@lks build (master)]$ hsh-run --rooter /opt/builds/tmp -- sh -c &quot;curl 192.168.1.1&quot;
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1485  100  1485    0     0   340k      0 --:--:-- --:--:-- --:--:--  362k
&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;meta charset=utf-8&gt;&lt;meta http-equiv=Cache-Control content=no-store&gt;&lt;meta http-equiv=cache-control content=no-cache&gt;&lt;meta http-equiv=cache-control content=&quot;max-age=0&quot;&gt;&lt;meta name=viewport content=&quot;width=device-width,initial-scaC
[lakostis@lks build (master)]$ unset share_network
[lakostis@lks build (master)]$ hsh-run --rooter /opt/builds/tmp -- sh -c &quot;curl 192.168.1.1&quot;
curl: (7) Couldn&apos;t connect to server

Предполагаю что это было сломано вот этим revert&apos;ом:

commit 3312e1ffb9d1ea098746168feaba82dfec208906
Author: Dmitry V. Levin &lt;ldv@altlinux.org&gt;
Date:   Sun Oct 30 18:05:44 2011 +0000

    Revert &quot;hsh-run: disable network isolation when X11 forwarding is requested&quot;
    
    I supposed that most of use cases where X11 forwarding is involved
    expect network access.  Apparently, they are not.
    
    This reverts commit e47a84f4b6efe889f970d827c7ea445a25e60d65.

diff --git a/hasher/hsh-run b/hasher/hsh-run
index 6be1b84..a9a3ee2 100755
--- a/hasher/hsh-run
+++ b/hasher/hsh-run
@@ -182,11 +182,6 @@ lock_workdir
 deduce_lock_hasher_priv
 
 prepare_x11_forwarding || x11_forwarding=
-if [ -n &quot;$x11_forwarding&quot; -a -z &quot;${share_network-}&quot; ]; then
-       message &apos;X11 forwarding requested, disabling network isolation.&apos;
-       share_network=1
-       export share_network
-fi

т.е. export share_network убрали совсем и навсегда.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>205700</commentid>
    <comment_count>1</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2021-12-04 03:22:07 +0300</bug_when>
    <thetext>(In reply to Konstantin A Lepikhov (L.A. Kostis) from comment #0)
&gt; $ cat ~/.hasher/config 
&gt; share_network=1

Я думаю, что если в этом месте написать
export share_network=1
то заработает так, как вам хотелось.

Просто hasher состоит из двух частей,
~/.hasher/config читает только клиентская,
а учитывает $share_network только &quot;серверная&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>205702</commentid>
    <comment_count>2</comment_count>
    <who name="Konstantin A Lepikhov (L.A. Kostis)">lakostis</who>
    <bug_when>2021-12-04 03:44:46 +0300</bug_when>
    <thetext>(In reply to Dmitry V. Levin from comment #1)
&gt; (In reply to Konstantin A Lepikhov (L.A. Kostis) from comment #0)
&gt; &gt; $ cat ~/.hasher/config 
&gt; &gt; share_network=1
&gt; 
&gt; Я думаю, что если в этом месте написать
&gt; export share_network=1
&gt; то заработает так, как вам хотелось.
&gt; 
&gt; Просто hasher состоит из двух частей,
&gt; ~/.hasher/config читает только клиентская,
&gt; а учитывает $share_network только &quot;серверная&quot;.

А чем плох вот такой патч?

diff --git a/hasher/hsh-run b/hasher/hsh-run
index 5e13e4c..1824e6f 100755
--- a/hasher/hsh-run
+++ b/hasher/hsh-run
@@ -171,6 +171,8 @@ deduce_lock_hasher_priv
 
 prepare_x11_forwarding || x11_forwarding=
 
+[ -z &quot;${share_network-}&quot; ] || export share_network
+
 [ -z &quot;$run_script&quot; ] ||</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>205703</commentid>
    <comment_count>3</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2021-12-04 04:12:19 +0300</bug_when>
    <thetext>(In reply to Konstantin A Lepikhov (L.A. Kostis) from comment #2)
&gt; А чем плох вот такой патч?
&gt; 
&gt; diff --git a/hasher/hsh-run b/hasher/hsh-run
&gt; index 5e13e4c..1824e6f 100755
&gt; --- a/hasher/hsh-run
&gt; +++ b/hasher/hsh-run
&gt; @@ -171,6 +171,8 @@ deduce_lock_hasher_priv
&gt;  
&gt;  prepare_x11_forwarding || x11_forwarding=
&gt;  
&gt; +[ -z &quot;${share_network-}&quot; ] || export share_network
&gt; +
&gt;  [ -z &quot;$run_script&quot; ] ||

Он не плох, но есть два вопроса:
- share_network - это не единственная переменная с таким свойством,
  hasher-priv ещё поддерживает share_ipc и share_uts;
- hsh-run - это не единственный скрипт, который запускает процессы в чруте,
  может быть, им тоже надо форвардить эти переменные.

Сейчас hsh-sh-functions явно поддерживает те переменные hasher-priv, которыми управляет,
см. комментарий &quot;variables used by hasher-priv&quot; в коде.
Кажется, что если форвардить share_* системно, то это тоже лучше делать в hsh-sh-functions.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>210714</commentid>
    <comment_count>4</comment_count>
    <who name="Konstantin A Lepikhov (L.A. Kostis)">lakostis</who>
    <bug_when>2022-05-15 21:02:42 +0300</bug_when>
    <thetext>(In reply to Dmitry V. Levin from comment #3)
&gt; (In reply to Konstantin A Lepikhov (L.A. Kostis) from comment #2)
&gt; &gt; А чем плох вот такой патч?
&gt; &gt; 
&gt; &gt; diff --git a/hasher/hsh-run b/hasher/hsh-run
&gt; &gt; index 5e13e4c..1824e6f 100755
&gt; &gt; --- a/hasher/hsh-run
&gt; &gt; +++ b/hasher/hsh-run
&gt; &gt; @@ -171,6 +171,8 @@ deduce_lock_hasher_priv
&gt; &gt;  
&gt; &gt;  prepare_x11_forwarding || x11_forwarding=
&gt; &gt;  
&gt; &gt; +[ -z &quot;${share_network-}&quot; ] || export share_network
&gt; &gt; +
&gt; &gt;  [ -z &quot;$run_script&quot; ] ||
&gt; 
&gt; Он не плох, но есть два вопроса:
&gt; - share_network - это не единственная переменная с таким свойством,
&gt;   hasher-priv ещё поддерживает share_ipc и share_uts;
&gt; - hsh-run - это не единственный скрипт, который запускает процессы в чруте,
&gt;   может быть, им тоже надо форвардить эти переменные.
&gt; 
&gt; Сейчас hsh-sh-functions явно поддерживает те переменные hasher-priv,
&gt; которыми управляет,
&gt; см. комментарий &quot;variables used by hasher-priv&quot; в коде.
&gt; Кажется, что если форвардить share_* системно, то это тоже лучше делать в
&gt; hsh-sh-functions.

Учитывая, что пользователей этого функционала ровно один, обойдемся просто документированием этого поведения в bugzilla )</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>