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

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

    <bug>
          <bug_id>47620</bug_id>
          
          <creation_ts>2023-09-16 18:18:33 +0300</creation_ts>
          <short_desc>/root/.bash_logout: Отказано в доступе при запуске через сервис пакета</short_desc>
          <delta_ts>2024-04-27 18:23:12 +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>gitlab-runner</component>
          <version>unstable</version>
          <rep_platform>x86_64</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</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="Evgeny Shesteperov">alimektor</reporter>
          <assigned_to name="bne@altlinux.org">bne</assigned_to>
          <cc>andy</cc>
    
    <cc>bne</cc>
    
    <cc>lav</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>233346</commentid>
    <comment_count>0</comment_count>
    <who name="Evgeny Shesteperov">alimektor</who>
    <bug_when>2023-09-16 18:18:33 +0300</bug_when>
    <thetext>Версия

-   gitlab-runner-16.1.1-alt2

Шаги воспроизведения

1.  Добавить Runner с тип Executor как shell для CI/CD:

    # gitlab-runner register --url &lt;URL&gt; --token &lt;TOKEN&gt;

При запросе

    **Enter an executor: kubernetes, parallels, ssh, docker+machine, shell, virtualbox, docker-autoscaler, instance, custom, docker, docker-windows**

    ввести `shell`

2.  Скопировать созданный конфиг на конфигурацию, которую используем
    systemd-сервис:

        # cp /etc/gitlab-runner/config.toml /etc/gitlab-runner.d/config.toml

3.  Запустить сервис:

        # systemctl enable --now gitlab-runner &amp;&amp; sleep 5; systemctl status gitlab-runner --no-pager -l

4.  Запустить ci, например:

    $ cat .gitlab-ci.yml 
    build-job:
      stage: build
      script:
        - echo &quot;Hello, $GITLAB_USER_LOGIN!&quot;

    test-job1:
      stage: test
      script:
        - echo &quot;This job tests something. Current project dir is $CI_PROJECT_DIR&quot;

    test-job2:
      stage: test
      script:
        - echo &quot;This job tests something, but takes more time than test-job1.&quot;
        - echo &quot;After the echo commands complete, it runs the sleep command for 20 seconds&quot;
        - echo &quot;which simulates a test that runs 20 seconds longer than test-job1&quot;
        - sleep 20

    deploy-prod:
      stage: deploy
      script:
        - echo &quot;This job deploys something from the $CI_COMMIT_BRANCH branch.&quot;
      environment: production

Ожидаемый результат: Pipeline Jobs выполнен успешно.

Фактический результат: Pipeline Jobs выполнен с ошибками:

    Running with gitlab-runner development version (HEAD)
      on test-runner csSeinuKA, system ID: s_bbb741e10f56
    Preparing the &quot;shell&quot; executor 00:00
    Using Shell (bash) executor...
    Preparing environment 00:00
    bash: /root/.bash_profile: Отказано в доступе
    Running on server-10-1-x86-64-minimal-20230916.localdomain...
    bash: строка 6: /root/.bash_logout: Отказано в доступе
    ERROR: Job failed: prepare environment: exit status 1. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information

Причина в том, что сервис GitLab Runner запущен от пользователя
gitlab-runner:

    3221 /usr/bin/gitlab-runner run -c /etc/gitlab-runner.d/config.toml -u gitlab-runner -d /var/lib/gitlab-runner --syslog

Если поменять -u gitlab-runner на -u root, то всё начинает работать,
однако это не совсем правильный подход, ванильный runner использует
именно пользователя gitlab-runner и всё должно работать относительно
данного пользователя.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>243329</commentid>
    <comment_count>1</comment_count>
    <who name="Repository Robot">repository-robot</who>
    <bug_when>2024-03-21 23:00:04 +0300</bug_when>
    <thetext>gitlab-runner-16.9.1-alt1 -&gt; sisyphus:

 Wed Mar 20 2024 Nikolay Burykin &lt;bne@altlinux&gt; 16.9.1-alt1
 - New version 16.9.1
 - Fix:
   + &quot;/root/.bash_profile: Permission denied&quot; when use shell as an executor (ALT #47620)
   + failure prepare environment step, when use Docker as an executor (ALT #47621)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>245581</commentid>
    <comment_count>2</comment_count>
    <who name="Vitaly Lipatov">lav</who>
    <bug_when>2024-04-27 18:23:12 +0300</bug_when>
    <thetext>(Ответ для Repository Robot на комментарий #1)
&gt; gitlab-runner-16.9.1-alt1 -&gt; sisyphus:
&gt; 
&gt;  Wed Mar 20 2024 Nikolay Burykin &lt;bne@altlinux&gt; 16.9.1-alt1
&gt;  - New version 16.9.1
&gt;  - Fix:
&gt;    + &quot;/root/.bash_profile: Permission denied&quot; when use shell as an executor
&gt; (ALT #47620)
Добавлю, что проблема решена так:

- script.Arguments = []string{&quot;-s&quot;, &quot;/bin/&quot; + b.Shell, info.User, &quot;-c&quot;, script.CmdLine}
+ script.Arguments = []string{&quot;-&quot;, &quot;-s&quot;, &quot;/bin/&quot; + b.Shell, info.User, &quot;-c&quot;, script.CmdLine}

то есть в апстриме использовался su без -, что желательно исправить там, а здесь это приводит нас к https://bugzilla.altlinux.org/23700</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>