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

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

    <bug>
          <bug_id>14078</bug_id>
          
          <creation_ts>2008-01-18 15:35:15 +0300</creation_ts>
          <short_desc>Document -l (or bring su in line with D****n)</short_desc>
          <delta_ts>2026-09-10 08:06:52 +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>su</component>
          <version>unstable</version>
          <rep_platform>all</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>23700</dependson>
          <blocked>77</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Andrey Rahmatullin">wrar</reporter>
          <assigned_to name="placeholder@altlinux.org">placeholder</assigned_to>
          <cc>dottedmag</cc>
    
    <cc>glebfm</cc>
    
    <cc>kharpost</cc>
    
    <cc>ldv</cc>
    
    <cc>led</cc>
    
    <cc>mike</cc>
    
    <cc>placeholder</cc>
    
    <cc>vvk</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>61363</commentid>
    <comment_count>0</comment_count>
    <who name="Andrey Rahmatullin">wrar</who>
    <bug_when>2008-01-18 15:35:15 +0300</bug_when>
    <thetext>ALT Linux su(1) keeps running user&apos;s $PATH (maybe other variables) when invoked 
without -l. This behavior is different from e.g. Debian and is confusing. 
Moreover, this behavior (neither default nor with -l) is not documented in any 
way:

       By default the user&apos;s shell is invoked directly, however, giving the 
argument flag -, su is  instructed  to  invoke
       the  shell  as  a login shell. This means that the current working 
directory will be changed to the home of the new
       user and the shell&apos;s first argument will be prefixed with a -.
[...]
       -, -l, --login
              Invoke the shell as a login shell.


Compare with Debian su(1):

       The optional argument - may be used to provide an environment similar to 
what the user
       would expect had the user logged in directly.
[...]
       The current environment is passed to the new shell. The value of $PATH 
is reset to /bin:/usr/bin for normal users,
       or /sbin:/bin:/usr/sbin:/usr/bin for the superuser. This may be changed 
with the ENV_PATH and ENV_SUPATH
       definitions in /etc/login.defs.
[...]
       -, -l, --login
           Provide an environment similar to what the user would expect had the 
user logged in directly.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61412</commentid>
    <comment_count>1</comment_count>
    <who name="Dmitry V. Levin">ldv</who>
    <bug_when>2008-01-19 00:53:59 +0300</bug_when>
    <thetext>Yes, ALT Linux su(1) and Debian su(1) differ.
So, what do you suggest?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61413</commentid>
    <comment_count>2</comment_count>
    <who name="Mikhail Gusarov">dottedmag</who>
    <bug_when>2008-01-19 00:55:27 +0300</bug_when>
    <thetext>Документировать, что происходит с окружением с - и без него.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61672</commentid>
    <comment_count>3</comment_count>
    <who name="Sir Raorn">raorn</who>
    <bug_when>2008-01-21 20:43:59 +0300</bug_when>
    <thetext>Т.е. толпы румяных линуксоидов не понимают что такое &quot;login shell&quot; и чем он
отличается от обычного интерактивного?  И при чём тут вообще su в таком случае?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61673</commentid>
    <comment_count>4</comment_count>
    <who name="Andrey Rahmatullin">wrar</who>
    <bug_when>2008-01-21 20:49:22 +0300</bug_when>
    <thetext>(In reply to comment #3)
&gt; Т.е. толпы румяных линуксоидов не понимают что такое &quot;login shell&quot; и чем он
&gt; отличается от обычного интерактивного?
Да. Я, например.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>61674</commentid>
    <comment_count>5</comment_count>
    <who name="Sir Raorn">raorn</who>
    <bug_when>2008-01-21 20:53:20 +0300</bug_when>
    <thetext>(In reply to comment #4)
&gt; Да. Я, например.

man `basename $SHELL`, раздел INVOCATION или что-то в этом роде.  Что при этом
будет происходить с окружением зависит от шелла и его стартовых скриптов, а не
от su...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>110547</commentid>
    <comment_count>6</comment_count>
    <who name="Michael Shigorin">mike</who>
    <bug_when>2010-07-12 22:49:26 +0400</bug_when>
    <thetext>(In reply to comment #3)
&gt; Т.е. толпы румяных линуксоидов не понимают что такое &quot;login shell&quot; и чем он
&gt; отличается от обычного интерактивного?  И при чём тут вообще su в таком случае?
При том, что всю документацию не перечитаешь и возможность полагаться на привычки помогает примерно как кэш L1.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>131504</commentid>
    <comment_count>7</comment_count>
    <who name="Michael Shigorin">mike</who>
    <bug_when>2012-05-28 19:34:24 +0400</bug_when>
    <thetext>Ну или хоть Url: починить, нынешний 404... подсказывают про http://www.linux-pam.org/pre/applications/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>297756</commentid>
    <comment_count>8</comment_count>
    <who name="Anton Farygin">rider</who>
    <bug_when>2026-09-10 08:06:52 +0300</bug_when>
    <thetext>Актуально: в su(1) из SimplePAMApps 0.60-alt37 по-прежнему нет ни слова о том, что происходит с окружением, — только «-, -l, --login: Invoke the shell as a login shell».

Что происходит на самом деле (проверено на su 0.60-alt37):

- без «-»: окружение вызывающего передаётся целиком, включая PATH и HOME (то есть HOME остаётся домашним каталогом того, кто вызвал su), рабочий каталог не меняется;
- с «-»: переносятся только TERM, LANG, LC_*, TZ, DISPLAY (pamapps/lib/make_env.c, posix_env[]), а HOME, LOGNAME и PATH выставляются для целевого пользователя (pamapps/lib/setcred.c: /bin:/usr/bin:/usr/local/bin для обычного пользователя и /sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin для root; login-шелл затем обычно переопределяет PATH из /etc/profile), рабочий каталог меняется на домашний каталог целевого пользователя.

Патч ниже добавляет в su.1 раздел ENVIRONMENT с этим описанием и упоминанием отличия от su(1) из shadow (Debian и прочие), который сбрасывает PATH по /etc/login.defs и без «-». Рендеринг groff проверен.

--- a/pamapps/su/su.1
+++ b/pamapps/su/su.1
@@ -129,6 +129,46 @@
 .BR su
 configurations similar.
 
+.SH ENVIRONMENT
+Unless the
+.BR - &quot; (&quot; -l &quot;, &quot; --login )
+flag is given,
+.BR su
+passes the whole environment of the invoking user to the new shell
+unchanged.  In particular
+.BR PATH &quot; and &quot; HOME
+keep the values they had before, so the assumed user&apos;s shell runs with
+the invoking user&apos;s search path and home directory, and the current
+working directory is not changed either.
+.sp
+With
+.BR - &quot;, &quot;
+only
+.BR TERM &quot;, &quot; LANG &quot;, &quot; LC_* &quot;, &quot; TZ &quot; and &quot; DISPLAY
+are carried over from the invoking user; the rest of the environment is
+built for the assumed user:
+.BR HOME &quot; and &quot; LOGNAME
+are taken from the password database and
+.BR PATH
+is set to
+.I /bin:/usr/bin:/usr/local/bin
+for an ordinary user and to
+.I /sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin
+for the superuser (a login shell usually overrides
+.BR PATH
+again from
+.IR /etc/profile ).
+The working directory is changed to the assumed user&apos;s home directory.
+.sp
+Note that this differs from
+.BR su (1)
+of the shadow suite (Debian and others), which resets
+.BR PATH
+from
+.I /etc/login.defs
+even without
+.BR - &quot;.&quot;
+
 .SH &quot;EXIT CODE&quot;
 
 On successful completion of its task,</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>