Man page incorrectly states that '-' must be last

Bug #1100775 reported by maf
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
shadow (Ubuntu)
Confirmed
Low
Unassigned

Bug Description

The manual page for su (shadow version 1:4.1.4.2+svn3283-3ubuntu7) states:

       -, -l, --login
           Provide an environment similar to what the user would expect had
           the user logged in directly.

           When - is used, it must be specified as the last su option. The
           other forms (-l and --login) do not have this restriction.

The last paragraph here is wrong. The option '-' can be used anywhere on the command line, as long as it comes before the name of the user you want to su to. So the only place it certainly doe snot work at is the last position.

This can be tested fairly easily. On my system the user 'nobody' does not have a home directory, so su gives an error message when trying to create a login shell for nobody (running as root):
  # su nobody -c true
  # su nobody -c true -l
  No directory, logging in with HOME=/

Using this we can eperiment where '-' works:
  # su - nobody -c true
  No directory, logging in with HOME=/
  # su nobody - -c true
  # su nobody -c true -
  # su -c true - nobody
  No directory, logging in with HOME=/

Which gives that '-' only works when it comes before the username. This is also obvious when one looks at the source. Let me know if I need to elaborate on this.

Tags: manpage
Changed in shadow (Ubuntu):
status: New → Confirmed
Mathew Hodson (mhodson)
Changed in shadow (Ubuntu):
importance: Undecided → Low
tags: added: manpage
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.